Browse by Tags
All Tags »
Winforms (RSS)
The .Net framework introduced the GDI+ "framework" for graphics. However, in .Net framework 2.0 Microsoft added a wrapper class to the original GDI called TextRenderer , which is claimed to be a lot faster than GDI+ , specifically using the TextRenderer.DrawText method instead of Graphics.DrawString . In a first reading it may also appear articles published in MSDN magazine advocate to use it as a faster alternative. After doing some testing I found out there is a pitfall to this approach...
The application I'm working on is a C4I, GIS based application, originally written in framework 1.1. Recently we did several tests to prove the improvements derived from upgrading to framework 2.0 (or 3.0) without doing major changes in the base code. The performance improvement focus was on switching to Generics for collections containing value types. Possible pitfalls - mostly the usage of Hashtable and other 1.1 collections, which tend to return NULL when the key is not found. Unlike them...
I have written before a short comparison between "old" and newer technologies, but at the beginning of that post I state that part of the choice of a new technology is the market trend towards that technology. After reading Justin's post showing that moving to ASP.NET is beneficiary because it's becoming a prominent technology I decided to implement his research methods (using Google) on different technologies. I began by searching for file types However, this reflects only on files...
We all know about the "cool new kids in town", meaning new technologies all developers want to use. Offer a developer two positions: Programming with C# 1.1 Programming with WPF and C# 3.5 What do you think most developers will choose? However, there is the question of an existing project, written in an "uncool" technology. In my experience developers tend to push towards using newer technologies, but how do you convince the people in charge? Here are my thoughts on the subject...
Guest post from Eyal Ron: After much testing this is the correct formula for a truly transparent user control: Derive from Panel rather then UserControl . Override the OnPaintBackground function: protected override void OnPaintBackground(PaintEventArgs pevent) { //do nothing } Override the OnMove function: protected override void OnMove(EventArgs e) { RecreateHandle(); } Override the CreateParams property: protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp...
As a rule, I never want to see an unhandled exception crashing my application with the .Net error dialog and without logging the error. Therefor I always hook both the AppDomain.UnhandledException and the Application.ThreadException events to catch those exceptions, log them, and close the application gracefully. Turns out I overlooked one small detail - the ThreadAbort exception, raised by a call to the Thread.Abort method. It's not a best practice to use it (you should let the thread shut down...
The NumericUpDown control has a built-in validation: Values smaller than the minimum are replaced by the minimum Values larger than the maximum are replaced by the maximum This may lead to a situation in which the user entered an invalid value and pressed the form's "OK" button, leading to saving of a value completely different than the one entered with no notification. To prevent this, enter your own validation code into the validating event (using the "Text" property instead...
I needed rounded-corners panels for the application I'm working on. Some search showed there is no built-in solution, and the way to go is using GDI+, and drawing the control's border manually, meaning you need to draw 4 arcs and 4 lines: GraphicsPath gp=new GraphicsPath(); gp.AddLine(X + radius, Y, X + width - (radius*2), Y); gp.AddArc(X + width - (radius*2), Y, radius*2, radius*2, 270, 90); gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius*2)); gp.AddArc(X + width - (radius...
I am using a ComboBoxAdv control from Syncfusion , and in version 3.2 I have noticed that the control doesn't allow you to change the height beyond a minimum value (depending on the font). There is a PreventHeightChange property, but it doesn't seem to work. The solution - override the DetermineHeightsBasedOnFont method with a blank method.
I previously wrote about a problem with a custom form's property. Since then I found problems with additional properties, including the form's default location. As it turns out the cause was a missing call to the InitializeComponent method in the initializer of a parent class.
I have had a problem recently with some of the form in my application, which were descendants of a custom form class (not the classic Windows.Forms.Form class). The form would look fine in design mode, but during run time it appeared to have shrunk, with all the controls in it being affected similarly. It took a lot of digging to find out what was wrong, but after noticing that setting the AutoScale property to "false" seemed to solve the problem the culprit was found - While in a "normal" form the...
I'm working on a C4I application using GIS maps. The map is refreshed (redrawn) by calling the Control.Invalidate() method. What got my attention was seeing few thousands of page faults on each refresh, resulting in CPU usage of 3-6%. After some research, this is the response I got from Hans Passant in the MSDN forums: " GDI+ bitmaps use memory mapped files. The bitmap data gets loaded into memory through page faults . " Now if I only could figure out why in older versions of the application there...