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"); }; appBar1.ToolTip = new ModernToolTip(); AppAction action1 = new AppAction(); action1.Cursor = Cursors.Hand; action1.Image = Resources.Speaker; action1.Click += Action1_Click; action1.ToolTip = "click me!"; this.appBar1.Actions.Add(action1); AppAction action2 = new AppAction(); action2.Cursor = Cursors.Help; action2.Click += Action1_Click; action2.Image = Resources.Speaker; action2.ToolTip = "ALICE was beginning to get very tired of sitting by her sister on the bank and of having nothing to do: \n" + "once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, \n" + "\"and what is the use of a book,\" thought Alice, \"without pictures or conversations?'\n\n"; this.appBar1.Actions.Add(action2); }
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"); }; }
public MainForm() { instance = this; InitializeComponent(); panel1.Freeze(); DevicesTitlebarButton item = new DevicesTitlebarButton(this); TitlebarButtons.Add(item); if (Program.Silent) { //Right now, we use the window redraw for device discovery purposes. //We need to simulate that with a timer. Timer t = new Timer { //We should run it every 2 seconds and half. Interval = 2500 }; t.Tick += (s, e) => { //The discovery works by reading the Text from the button item.RefreshCurrentDevices(); }; void handler(object s, EventArgs e) { Hide(); Shown -= handler; } Shown += handler; t.Start(); NotifyIcon icon = new NotifyIcon { Icon = Icon, Text = Text }; icon.DoubleClick += (sender, e) => { Show(); }; ContextMenuStrip menu = new ContextMenuStrip(); menu.Items.Add("Open application").Click += (s, e) => { Show(); }; menu.Items.Add("-"); menu.Items.Add("Exit application").Click += (s, e) => { Application.Exit(); }; FormClosing += (s, e) => { if (e.CloseReason == CloseReason.UserClosing) { Hide(); e.Cancel = true; } else if (e.CloseReason == CloseReason.ApplicationExitCall) { icon.Visible = false; icon.Dispose(); } }; menu.Opening += (s, e) => { menu.Items[0].Select(); }; icon.ContextMenuStrip = menu; icon.Visible = true; } ColorSchemeCentral.ThemeChanged += (s, e) => ApplySidebarTheme(shadedPanel1); }