Home‎ > ‎My Notebook‎ > ‎UI/UA Design‎ > ‎

DNB Forms

I love DotNetBar WinForms. A great product http://www.devcomponents.com/dotnetbar/
As a UI designer I've just got so much scope to quickly create eye catching forms.

I'm especially delighted at the ability to theme all controls & forms, and even color tint everything (using just a few lines of code).







Some C# code to give you some clues about what to call to change your applications theme.
 
       public static bool m_ColorSelected = false;

        private void buttonStyleCustom_ColorPreview(object sender, ColorPreviewEventArgs e)  //Hover over color swatch
        {
            RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(this, AppColorScheme.m_BaseColorScheme, e.Color);
        }

        private void buttonStyleCustom_ExpandChange(object sender, EventArgs e)  //Color panel expanded / contract
        {
            if (buttonStyleCustom.Expanded)
            {
                m_ColorSelected = false;
            }
            else
            {
                if (!m_ColorSelected)
                    RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(this, AppColorScheme.m_BaseColorScheme, AppColorScheme.m_colorTint);
            }
        }

        private void buttonStyleCustom_SelectedColorChanged(object sender, EventArgs e)  //Color swatch clicked
        {
            m_ColorSelected = true; // Indicate that color was selected for buttonStyleCustom_ExpandChange method
            AppColorScheme.m_colorTint = buttonStyleCustom.SelectedColor;
            RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(this, AppColorScheme.m_BaseColorScheme, AppColorScheme.m_colorTint);
        }

        private void AppCommandTheme_Executed(object sender, EventArgs e)   //Theme menu command event
        {
            ICommandSource source = sender as ICommandSource;
            if (source != null && source.CommandParameter is string)  
            {
                AppColorScheme.m_BaseColorScheme = (eOffice2007ColorScheme)Enum.Parse(typeof(eOffice2007ColorScheme), source.CommandParameter.ToString());
                // This is all that is needed to change the color table for all controls on the form
                ribbonControl1.Office2007ColorTable = AppColorScheme.m_BaseColorScheme;
                AppColorScheme.m_colorTint = Color.Transparent;  //Reset the tint
                m_ColorSelected = true;
            }
            this.Invalidate();
        }


        //== Color Theme ribbon menu ==

        private void Theme_MouseEnter(object sender, EventArgs e)
        {
            if (sender is ButtonItem)
            {
                m_ColorSelected = false;
                ButtonItem btn = sender as ButtonItem;
                ribbonControl1.Office2007ColorTable = (eOffice2007ColorScheme)Enum.Parse(typeof(eOffice2007ColorScheme), btn.CommandParameter.ToString());
            }
        }

        private void Theme_MouseLeave(object sender, EventArgs e)
        {
            if (!m_ColorSelected)
            {
                //Restore original theme and scheme
                ribbonControl1.Office2007ColorTable = AppColorScheme.m_BaseColorScheme;   //Restore from preview mode
                if (AppColorScheme.m_colorTint != Color.Transparent)
                    RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(this, AppColorScheme.m_BaseColorScheme, AppColorScheme.m_colorTint);
            }
        }



Comments