Is there any easy way to convert VB.NET code to C#?
If you add a BMP file to your solution using the File|Add Existing Item… Menu Item, then change the Build Action property of this BMP file to Embedded Resource, you can then access this resource with code similar to: // WindowsApplication6 corresponds to Default Namespace in your project settings. // subfolders should be the folder names if any, inside which the bmp is added. If the bmp was added to the top level, you don’t have to specify anything here. string bmpName = ‘WindowsApplication6.subfolders.sync.bmp’; System.IO.Stream strm = null; try { strm = this.GetType().Assembly.GetManifestResourceStream(bmpName); pictureBox1.Image = new Bitmap(strm); // Do the same for Icons // Icon icon1 = new Icon(strm); } catch(Exception e) { MessageBox.Show(e.Message); } finally { if(strm != null) strm.Close(); }
How to draw a faded image?
The trick is to use an alpha component while drawing the image. // transparency should be in the range 0 to 1 protected void DrawScrollImage(Graphics g, Rectangle rect, Image image, float transparency) { ImageAttributes ia = new ImageAttributes(); ColorMatrix cm = new ColorMatrix(); cm.Matrix00 = 1; cm.Matrix11 = 1; cm.Matrix22 = 1; cm.Matrix33 = transparency; ia.SetColorMatrix(cm); g.DrawImage(image, rect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, ia); }
How does .NET support licensing
LicFileLicenseProvider is the only license provider shipped with .NET. A good discussion of licensing techniques along with sample code can be found in an article by Mike Harsh at gotnetdot.com.
How do I set the debugger to Break on Exception
1) In VS.NET go to the Debug Menu >> ‘Exceptions…’ >> ‘Common Language Runtime Exceptions’ >> ‘System’ and select ‘System.NullReferenceException’ 2) In the bottom of that dialog there is a ‘When the exception is thrown:’ group box, select ‘Break into the debugger’ 3) Run your scenario. When the exception is thrown, the debugger will stop and notify you with a dialog that says something like: ‘An exception of type ‘System.NullReferenceException’ has been thrown. [Break] [Continue]’ Hit [Break]. This will put you on the line of code that’s causing the problem. (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
In Visual Studio, all my docking windows are out of whack. How can I reset them so things will be docked properly
You can use the menu item Tools|Options, and then select Reset Window Layout. A second alternative is to close Visual Studio, and then delete the suo file in your project folder. (suo=Studio User Options)