Archive

Archive for the ‘C#’ Category

A simple bubble sort

May 15th, 2013 No comments

A simple bubble sort which arranges the provided array of numbers from smallest to largest.

static void BubbleSort(ref int[] arr)
{
bool change = true;
int temp;

while (change)
{
change = false;
for (int i = 0; i < arr.GetLength(0) - 1; i++)
{
if (arr[i + 1] < arr[i])
{
change = true;
temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
break;
}
}
}
}
Categories: C# Tags:

.Net Balloon window

October 17th, 2012 No comments

Have you ever been frustated by the ToolTip component’s lack of functionality,  i.e. you’t can add a close button like the NotifyIcon control, lack of handleable events? Be frustated no more, as a solution is at hand.

The Balloon Window for .Net will is a handy addon that offers all the functionality of the NotifyIcon control AND the ToolTip in a handy package.

Categories: C#, Code Tags:

A perplexing problem with FCKEditor solved….

June 20th, 2009 No comments

A perplexing problem I encountered with FCKEditor 2.6.3 was solved with the help of the internet. Well fancy that! Rather than recount my own problems, I’ll use the words of others who encountered the same problem and paste, slightly reformat and present them, verbatim, below.

i have sucessfully implemented the editor into my .net application (vb.net) the editor works fine and configured how i wanted it, only isusse is when you go and click on the image uploader and then go to the upload tab, select the file and then click the “send it to server” button it comes up with the status bar and just hangs and does nothing. it does not upload the file all it does is show the status bar and does not move of it.

Any Sugguestions, i have altered the config.ascx file and also the fckconfig file and i belive i have pointed it to the correct file location see bellow for config.ascx and fckconfig.

Quoted from this post, where much tooing and froing occurred until a kind gentleman (or woman) posted a fix to the problem, which I reproduce for your pleasure here:

For those who have the issue where the image upload dialog uploads the image BUT the dialog hangs or stays open…here is what I did to fix it.

This is for the .net assembly 2_6_3. I based it on the help file http://dev.fckeditor.net/attachment/tic … 2115.patch

Steps:

Open the FredCK.FCKeditorV2.vs2005.csproj in Visual Studio 2005

Open the file FileBrowser > FileWorkerBase.cs

Go to line 119 and replace:

Response.Write( @"(function(){var d=document.domain;while (true){try{var A=<span style="font-weight: bold;">window.top.opener.document.domain</span>;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();" );

with:

Response.Write(@"(function(){var d=document.domain;while (true){try{var A=<span style="font-weight: bold;">window.parent.OnUploadCompleted</span>;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();")

Compile the project and then reference the new dll file in your project.

This worked for me and I hope it helps you. The upload dialog now works on my dev XP and on the Windows Server 2003 website.

The above text was taken from here.

Categories: C# Tags:

C#: Convert .BMP to .ICO

February 22nd, 2009 No comments

Some handy code:

public void BitmapToIcon(string sourceFileName, string destFileName)
{
// Create a Bitmap object from an image file.
Bitmap bmp = new Bitmap(sourceFileName);
// Get an Hicon for myBitmap.
IntPtr Hicon = bmp.GetHicon();
// Create a new icon from the handle.
Icon newIcon = Icon.FromHandle(Hicon);
//Write Icon to File Stream
FileStream fs = new FileStream(destFileName, FileMode.OpenOrCreate);
newIcon.Save(fs);
fs.Close();
}
Categories: C# Tags:

C# Express

May 14th, 2007 No comments

C# Express is a freely available programming language from Microsoft. I’ll be occasionally adding stuff to this section as and when the mood takes me.

Get it here.

Categories: C# Tags: