Exemple #1
0
        public static void AddIcon(Window wnd)
        {
            if (IsRunning)
            {
                return;
            }
            trayMenu = new System.Windows.Controls.ContextMenu();

            closeMenuItem = new System.Windows.Controls.MenuItem();
            closeMenuItem.AddHandler(System.Windows.Controls.MenuItem.ClickEvent, new RoutedEventHandler(CloseMenuItem_Click));

            showHideMenuItem = new System.Windows.Controls.MenuItem();
            showHideMenuItem.AddHandler(System.Windows.Controls.MenuItem.ClickEvent, new RoutedEventHandler(ShowHideMenuItem_Click));

            SetLocale();

            trayMenu.Items.Add(showHideMenuItem);
            trayMenu.Items.Add(closeMenuItem);

            trayIcon = new NotifyIcon();
            // FIXME: application executable name should not be hardcoded
            trayIcon.Icon              = Icon.FromHandle(NativeMethods.ExtractIcon(IntPtr.Zero, path + @"\Sidebar.exe", 0));
            trayIcon.Text              = "AvalonBar";
            trayIcon.MouseClick       += new MouseEventHandler(trayIcon_MouseClick);
            trayIcon.MouseDoubleClick += new MouseEventHandler(trayIcon_MouseDoubleClick);
            trayIcon.Visible           = true;
            window = wnd;
        }
Exemple #2
0
            public static void AddIcon(Window wnd)
            {
                if (isRunning)
                {
                    return;
                }
                trayMenu = new System.Windows.Controls.ContextMenu();

                closeMenuItem = new System.Windows.Controls.MenuItem();
                closeMenuItem.AddHandler(System.Windows.Controls.MenuItem.ClickEvent, new RoutedEventHandler(CloseMenuItem_Click));

                showHideMenuItem = new System.Windows.Controls.MenuItem();
                showHideMenuItem.AddHandler(System.Windows.Controls.MenuItem.ClickEvent, new RoutedEventHandler(ShowHideMenuItem_Click));

                SetLocale();

                trayMenu.Items.Add(showHideMenuItem);
                trayMenu.Items.Add(closeMenuItem);

                trayIcon                   = new NotifyIcon();
                trayIcon.Icon              = Icon.FromHandle(ExtractIcon(IntPtr.Zero, path + @"\LongBar.exe", 0));
                trayIcon.Text              = "LongBar 2.0";
                trayIcon.MouseClick       += new MouseEventHandler(trayIcon_MouseClick);
                trayIcon.MouseDoubleClick += new MouseEventHandler(trayIcon_MouseDoubleClick);
                trayIcon.Visible           = true;
                window = wnd;
            }
        public SMenuItem Render()
        {
            var result = new SMenuItem {
                Header = Title
            };

            result.AddHandler(SMenuItem.ClickEvent, new RoutedEventHandler(ClickHandler));
            if (Items != null)
            {
                foreach (var child in Items.Cast <PythonDictionary>())
                {
                    result.Items.Add(Parse(child.ToList()).Cast <MenuItem>().Render());
                }
            }
            return(result);
        }