Custom look for C# windows applications - c#

I'm making C# windows application ("Windows Forms Application") with default components, but I need to change default look of the form and all items on it (buttons, etc.) from classic windows style, to custom. How can I achieve it?
For example make buttons round, add transparency to some objects, make other objects with different shape, and so on.
It doesn't have to be customizable, but I just need to change it from default to something else. Maybe there's some components or something else that I can use? Or maybe there's additional GUI library that I can download and add to the project?

You didn't provide us with many details on how you want to customize the form.
You can change colors used on the form by setting the BackColor and ForeColor properties.
You can also apply background image to the form and use the TransparencyKey property in order to create a form with an irregular shape. More information about this method can be found here: http://msdn.microsoft.com/en-us/library/6k15y9et.aspx

Doing this manually and trying to have something looking nice takes waaay too much time. For start, look at this thread:
Best Free Controls for .NET

Related

C# Winform: Remove the border from a standard button?

Is it possible to remove the border of a standard C# Button ? I know that I could set the FlatStyle property to Flat and customize the FlatAppearance property to hide the border but I would prefer to use the Standard property to ensure that the control appears under all operating systems like a default Button. Did you have any suggestions how I can solve this issue? I am working with a Windows Forms Application.
You could use an image and make it clickable, that is one way to avoid the borders, but there are several options. Good luck!
If you are using windows forms and trying to implement Flat UI, Material UI, Metro-Looking controls, you're in hell. It is has limited properties for customizations unless you know how to work with Graphics and Animation. You'll have to use imagebox or picture box and dynamically change its image on different events.
I'll suggest WPF or Windows Presentation Foundation for a more customizable User Interface.

Own controls similar to TextBox in C# Windows application

Create own TextBox, Button etc control as own control using User control in C# Windows application, is this good idea?
I wanted make consistency for through out the application. Suppose if I want to change the Textbox border color then all forms textbox updated with this changes. It's just an example.
Please suggest me.
I don't recommend using UserControl just for consistency. If application skinning is what you are after, look into WPF. It makes it relatively simple to skin an application (or even a window, or smaller groups)
Here is an article on skinning with WPF: http://www.codeproject.com/Articles/19782/Creating-a-Skinned-User-Interface-in-WPF
Another alternative, staying within Windows Forms, is creating a class that inherits from TextBox, and using that class throughout the application. The Factory pattern would work well here. You could even adapt it to multiple skins.
It's not a bad idea to provide custom controls that match your "User Experience" (UX). It really just depends on what you are trying to accomplish with your program.

visual styles independent drawing

Using C# winforms, i want to create custom controls that looks like the real ones.
There are a lot of classes that can be used to draw controls that looks like the real ones: ControlPaint, VisualStyleRenderer, ButtonRenderer, CheckBoxRenderer, ComboBoxRenderer, GroupBoxRenderer, ProgressBarRenderer, RadioButtonRenderer, ScrollBarRenderer, TabRenderer, TextBoxRenderer, TextRenderer, ToolStripProfessionalRenderer, ToolStripRenderer, ToolStripSystemRenderer, TrackBarRenderer.
The problems coming when considering visual styles: I want to be visual styles independent. Meaning: I dont care if user allowing visual-styles or not, i want it to work. if user enabled visual-styles, i want to draw it using visual-styles, otherwise i want to draw it without visual-styles.
By the MSDN documentation, the only classes that are visual-styles independent are ButtonRenderer, CheckBoxRenderer, GroupBoxRenderer, RadioButtonRenderer. That means that for all other cases i need to check myself if visual-styles enabled and use different code to draw the parts.
Suppose i want to draw a Tab control parts myself. TabRenderer class has all needed functionality for that, but it works only if user enabled visual styles. otherwise I need to use ControlPaint class to draw, but it uses completely different model, there is no ControlPaint.DrawTab() method or something like that, and i need to figure out what rectangle types i need to draw so it will look like a real tab. that`s annoying.
The built-in controls, including the Tab control, already have this functionality of drawing themselves with or without visual styles. Why doesn`t microsoft exposing this functionality for the custom control creators? Why are custom control creators should suffer?
It's a pain unfortunately, but that is the cost for writing custom controls. The way I have seen Microsoft do this in many of the WinForm controls, is to check Application.RenderWithVisualStyes, and Control.UseVisualStyleBackColor. Depending on those values they will paint the control accordingly.
A common pattern they use is to create internal classes called MyControlRenderer.cs. Inside this renderer is where the magic actually happens. If you look at the NET REF code, you will see that they also use VisualStyleRenderer class from System.Windows.Forms.VisualStyles namespace, and there is some actual paint code as well.
You will need to utilize a mix of these various classes and tools, and a mix of also doing your own work. Testing your control on a machine with, and without visual styles.
When I hope home from work I will post a bit more.

c# how can i make sure that my application will look the same on other systems?

how do i make sure that the application iam developing will look the same on other windows-systems?
iam developing now on a windows7, with .net 3.5 framework .. (VS 2008)
as an example, i have a toolbar, that i changed its rendermode to system, it looks ok on my windows7, but when i run the application on windows xp, it is different, even the onmouseover backcolor is different. ..
is there a way to make the application looks like on every windows system (talking abt xp, vista and windows 7 only), lets say like exporting the settings of all the controls with the application !? or any trick to make sure it will be always the same ?
thankss in advance
Unless you render the window yourself you're going to always have slight differences between OS'es, they all have different ways of rendering your primitive controls like text boxes, panels, etc.
Also under windows the background color of a window/control is actually (by default) tied into the theme set in windows.
So allowing people to use their own themes is a plus. You really shouldn't force a style on people unless you're theming your own application.
You would have to you get a grab on all of the colours, fonts, transperancy, etc. and use them to override every controls' Paint event/method so that they may use your values.
The only way I see fit would be by writing yourself custom controls while handling these controls appearance throught the Paint() method so that the control may use what you give it. The pain!...
As SLaks commented, you shouldn't care about such details and let the defaut user preferences take over on the native OS, because some surprises may be encountered over time as if Windows doesn't find the font, for instance, it will replace it with its default, which could lead to horrible results. That is just one example. Need others?

How to skin UI using Forms?

I'd like to know if is there a way to "skin" a Form and every widget used inside it. Images should be on background and other elements shall be setup accordingly.
In short, a way to implement a way to display the same Form in different flavors (i.e.: theme and eyecandy UI).
DevExpress makes a WinForms control suite with an excellent selection of skins.
Telerik also provides WinForms components with theme support. I've used their library and it works fine.

Categories