/// <summary> /// Converts the given object to the type of this converter, using the specified context and culture information. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param> /// <param name="value">The <see cref="T:System.Object" /> to convert.</param> /// <returns>An <see cref="T:System.Object" /> that represents the converted value.</returns> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string stringVal && ColorConverter != null) { var color = (Color)ColorConverter.ConvertFrom(stringVal); return(ColorScheme.CreateSimpleColorScheme(color)); } return(base.ConvertFrom(context, culture, value)); }
public Form1() { InitializeComponent(); this.ColorScheme = ColorScheme.CreateSimpleColorScheme(ColorTranslator.FromHtml("#2D2D30")); var btn2 = new ModernTitlebarButton { Text = "2" }; btn2.Click += (s, e) => MessageBox.Show("2"); TitlebarButtons.Add(btn2); var btn1 = new ModernTitlebarButton { Text = "1" }; btn1.Click += (s, e) => MessageBox.Show("1"); TitlebarButtons.Add(btn1); var item11 = new SidebarTextItem("Text 1"); item11.Click += (s, e) => { MessageBox.Show(this, "3"); }; }