Example #1
0
        //Everything has to be sent in on the constructor since things do not auto-refresh / update this is a limitation
        public LinuxTrayIcon(string TooTip, string IconPath, Avalonia.Controls.ContextMenu _menu)
        {
            Dispatcher.UIThread.Post(() =>
            {
                var ctxMnu = new Eto.Forms.ContextMenu();
                foreach (var x in _menu.Items.Cast <Avalonia.Controls.MenuItem>())
                {
                    ButtonMenuItem bmi = new ButtonMenuItem();
                    bmi.Text           = x.Header.ToString();
                    bmi.Command        = new Command((s, e) => { Dispatcher.UIThread.Post(() =>
                        {
                            x.Command.Execute(null);
                        }); });
                    ctxMnu.Items.Add(bmi);
                }

                ClientSize = new Size(200, 200);
                _tray      = new TrayIndicator
                {
                    Image = Eto.Drawing.Icon.FromResource(IconPath.Replace("resm:", "")),
                    Menu  = ctxMnu,
                    Title = ToolTip
                };

                _tray.Show();
                _tray.Visible = true;
            });
        }
Example #2
0
 TrayIndicator GetSharedIndicator()
 {
     if (s_sharedIndicator == null)
     {
         s_sharedIndicator = new TrayIndicator
         {
             Image = Application.Instance?.MainForm?.Icon ?? sd.SystemIcons.Application.ToEto()
         };
     }
     s_sharedIndicator.Show();
     return(s_sharedIndicator);
 }
Example #3
0
        public TrayIcon(MainForm window)
        {
            var showWindow = new ButtonMenuItem
            {
                Text = "Show Window"
            };

            showWindow.Click += (sender, e) =>
            {
                window.Show();
                window.WindowState = WindowState.Normal;
                window.BringToFront();
                window.WindowStyle = WindowStyle.Default;
            };

            var restart = new ButtonMenuItem
            {
                Text = "Restart"
            };

            restart.Click += (sender, e) => Application.Instance.Restart();

            var close = new ButtonMenuItem
            {
                Text = "Close"
            };

            close.Click += (sender, e) => window.Close();

            indicator = new TrayIndicator
            {
                Title = "OpenTabletDriver",
                Image = App.Logo,
                Menu  = new ContextMenu
                {
                    Items =
                    {
                        showWindow,
                        restart,
                        close
                    }
                }
            };
            indicator.Activated += (object sender, System.EventArgs e) =>
            {
                window.Show();
                window.WindowState = WindowState.Normal;
                window.BringToFront();
                window.WindowStyle = WindowStyle.Default;
            };
            indicator.Show();
        }
Example #4
0
        public TrayIndicatorSection()
        {
            tray       = new TrayIndicator();
            tray.Image = TestIcons.TestIcon;
            tray.Title = "Eto Test App";

            var menu = new ContextMenu();

            menu.Items.Add(new Commands.About());
            menu.Items.Add(new Commands.Quit());
            tray.Menu = menu;

            tray.Activated += (o, e) => MessageBox.Show("Hello World!!!");

            tray.Show();

            Content = TableLayout.AutoSized("Tray should now be visible");
        }
Example #5
0
        public TrayIcon(MainForm window)
        {
            this.window = window;

            Indicator = new TrayIndicator
            {
                Title = "OpenTabletDriver",
                Image = App.Logo
            };

            RefreshMenuItems();

            Indicator.Activated += (object sender, System.EventArgs e) =>
            {
                window.Show();
                window.BringToFront();
            };
            Indicator.Show();
        }
Example #6
0
        public TrayIcon(MainForm window)
        {
            var showWindow = new ButtonMenuItem
            {
                Text = "Show Window"
            };

            showWindow.Click += (sender, e) =>
            {
                window.Show();
                window.BringToFront();
            };

            var close = new ButtonMenuItem
            {
                Text = "Close"
            };

            close.Click += (sender, e) => window.Close();

            indicator = new TrayIndicator
            {
                Title = "OpenTabletDriver",
                Image = App.Logo,
                Menu  = new ContextMenu
                {
                    Items =
                    {
                        showWindow,
                        close
                    }
                }
            };
            indicator.Activated += (object sender, System.EventArgs e) =>
            {
                window.Show();
                window.BringToFront();
            };
            indicator.Show();
        }