1

I have already tried to find an answer in google but I am probably not using the correct words to get an useful link.

I designed a C# GUI using the toolbox in Visual Studio 2008. The thing is at the end my GUI is not good looking, but the functionality is perfect for my app. Some testers said that my GUI is not attractive or too boring.

That's why I want to improve it and I would like to know if it is possible to change for example the default layout of a button or any other form from the toolbox in visual studio?

Or does anyone knows a rich collection library for UI design compatible with C#?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Carolina M
  • 33
  • 4

3 Answers3

1

AFAIK, you can always derive from the basic controls, override some/all of the behaviour or visual properties of them.

In responce to the other part of your question, I think DevExpress presents a fairly rich collection of such controls.

tafa
  • 7,146
  • 3
  • 36
  • 40
  • Do u know how to change the visual properties of a form in vusual studio? ....I also will give a try to DevExpress, thanks! – Carolina M Jul 28 '11 at 15:40
1

You can always derive the controls and create your own.

You can use WxWidgets Toolkit which has WX.NET if you do not like WinForms or WPF look/feel.

Or, if you are using Mono, you can use GTK#.

0

Make your own and enjoy.

Create a new class file and paste this code in: http://pastebin.com/cZ8xzTXX Then make a new class in the same file:

public class ThemeBaseUI : ThemeContainer154
{
    private string _UnderInfo = "";
    public string SoftwareInfo
    {
        get { return _UnderInfo; }
        set
        {
            _UnderInfo = value;
            Invalidate();
        }
    }
    public ThemeBaseUI()
    {
        BackColor = Color.WhiteSmoke;
        Font = new Font("Segoe UI", 10);
        SetColor("Border", Color.FromArgb(0, 114, 198));
        SetColor("Text", Color.White);
        _UnderInfo = GetCopyright() + "     " + GetCompany();
    }
    Color Border;
    Brush TextBrush;
    protected override void ColorHook()
    {
        Border = GetColor("Border");
        TextBrush = GetBrush("Text");
    }
    private string GetCopyright()
    {
        Assembly asm = Assembly.GetExecutingAssembly();
        object[] obj = asm.GetCustomAttributes(false);
        foreach (object o in obj)
        {
            if (o.GetType() == typeof(System.Reflection.AssemblyCopyrightAttribute))
            {
                AssemblyCopyrightAttribute aca = (AssemblyCopyrightAttribute)o;
                return aca.Copyright;
            }
        }
        return string.Empty;
    }
    private string GetCompany()
    {
        Assembly asm = Assembly.GetExecutingAssembly();
        object[] obj = asm.GetCustomAttributes(false);
        foreach (object o in obj)
        {
            if (o.GetType() == typeof(System.Reflection.AssemblyCompanyAttribute))
            {
                AssemblyCompanyAttribute aca = (AssemblyCompanyAttribute)o;
                return aca.Company;
            }
        }
        return string.Empty;

    }
    protected override void PaintHook()
    {
        //Form

        G.Clear(Border);
        G.FillRectangle(new SolidBrush(BackColor), new Rectangle(0, 36, Width, Height - 36));
        G.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, Height - 20, Width, Height));
        G.DrawString(FindForm().Text, Font, TextBrush, new Point(35, 9));
        G.DrawIcon(FindForm().Icon, new Rectangle(10, 10, 16, 16));
        G.DrawString(_UnderInfo, Font, new SolidBrush(Color.DimGray), new Point(5, Height - 19));
        //Close

        //Minimise

        //Minimise
        //G.DrawRectangle(new Pen(Color.White, 2), new Rectangle(Width - 73, 0, 24, 24));
        WindowStateClose WSC = new WindowStateClose();
        WSC.Location = new Point(Width - 21, 0);
        WSC.Size = new Size(20, 20);
        Controls.Add(WSC);
        WindowStateMin WSMa = new WindowStateMin();
        WSMa.Location = new Point(Width - 59, 0);
        WSMa.Size = new Size(34, 23);
        Controls.Add(WSMa);
        Size SetSize = new Size(Width, Height);
        MinimumSize = SetSize;
        MaximumSize = SetSize;

    }
    private class WindowStateClose : ThemeControl154
    {
        public WindowStateClose()
        {
            //Close Button
            SetColor("Cross", Color.White);
            SetColor("Button", Color.FromArgb(0, 114, 198));
            SetColor("Border", Color.White);
        }
        Color ButtonColor;
        Pen Border, Cross;
        protected override void ColorHook()
        {
            Cross = GetPen("Cross", 2);
            Border = GetPen("Border");
            ButtonColor = GetColor("Button");
        }
        protected override void PaintHook()
        {
            G.Clear(ButtonColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;
            switch (State)
            {
                case MouseState.None:
                    G.DrawEllipse(Cross, new Rectangle(Width - 20, 4, 15, 15));
                    break;
                case MouseState.Over:
                    G.DrawEllipse(Cross, new Rectangle(Width - 20, 4, 15, 15));
                    G.FillEllipse(new SolidBrush(Color.White), new Rectangle(Width - 17, 7, 9, 9));
                    break;
                case MouseState.Down:
                    G.DrawEllipse(Cross, new Rectangle(Width - 20, 4, 15, 15));
                    G.FillEllipse(new SolidBrush(Color.White), new Rectangle(Width - 16, 8, 7, 7));
                    Environment.Exit(0);
                    break;
            }
        }

    }
    private class WindowStateMin : ThemeControl154
    {
        public WindowStateMin()
        {
            //Close Button
            SetColor("Min", Color.White);
            SetColor("Button", Color.FromArgb(0, 114, 198));
            SetColor("Border", Color.White);
        }
        Color ButtonColor;
        Pen Border, Min;
        protected override void ColorHook()
        {
            Min = GetPen("Min", 3);
            Border = GetPen("Border");
            ButtonColor = GetColor("Button");
        }
        protected override void PaintHook()
        {
            G.Clear(ButtonColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;
            switch (State)
            {
                case MouseState.None:
                    G.DrawLine(Min, new Point(Width - 44, 12), new Point(20, 12));
                    break;
                case MouseState.Over:
                    G.DrawLine(Min, new Point(Width - 44, 6), new Point(20, 6));
                    G.DrawLine(Min, new Point(Width - 44, 12), new Point(20, 12));
                    G.DrawLine(Min, new Point(Width - 44, 18), new Point(20, 18));
                    break;
                case MouseState.Down:
                    G.DrawLine(Min, new Point(Width - 44, 12), new Point(20, 12));
                    this.FindForm().WindowState = FormWindowState.Minimized;
                    break;
            }
        }

    }
}

As you study the code, you notice there are 3 main functions:

  • constructor
  • ColorHook()
  • PaintHook()

Constructor will define the variables.
ColorHook sets the variables ready to be used in PaintHook.
PaintHook is the function that draws all of your code.

I have also included close and minimize button. It is quite buggy when you move the form so I have restricted the window size in the PaintHook().

As you see in the Min/Close Classes there are MouseStates in order to change the Graphics on a MouseEvent:

switch (State)
        {
            case MouseState.None:
                //When mouse is off
                break;
            case MouseState.Over:
                //When mouse is over control
                break;
            case MouseState.Down:
                //When you click and hold
                break;
        }

A control will appear at the top of your toolbox.

K_X
  • 173
  • 9