예제 #1
0
#pragma warning restore 67

    #endregion

    private void _c_NodeMouseClick(object sender, TreeNodeAdvMouseEventArgs e)
    {
        if (e.ModifierKeys != 0)
        {
            return;
        }
        var t = e.Node.Tag as RunningTask;
        var f = t.f;

        switch (e.Button)
        {
        case MouseButtons.Left:
            Program.Model.SetCurrentFile(f);
            break;

        case MouseButtons.Right:
            var name = f.DisplayName;
            var m    = new AMenu();
            m["End task  " + name] = o => Program.Tasks.EndTask(t);
            m["End all  " + name]  = o => Program.Tasks.EndTasksOf(f);
            m.Separator();
            m["Close\tM-click"] = o => Program.Model.CloseFile(f, true);
            if (null == Panels.Editor.ZGetOpenDocOf(f))
            {
                m.LastMenuItem.Enabled = false;
            }
            m.Show(_c);
            break;

        case MouseButtons.Middle:
            Program.Model.CloseFile(f, true);
            break;
        }
    }
예제 #2
0
파일: TrayIcon.cs 프로젝트: alexfordc/Au
    public static void Add()
    {
        _trayIcon             = new NotifyIcon();
        _trayIcon.MouseClick += _trayIcon_MouseClick;
        _trayIcon.Icon        = EdStock.IconTrayNormal;
        _trayIcon.Text        = Program.AppName;
        _trayIcon.Visible     = true;

        var m = new AMenu {
            MultiShow = true, ActivateMenuWindow = true
        };

        m["End green task\tSleep"]     = o => Program.Tasks.EndTask();
        m["Disable triggers\tM-click"] = o => Run.DisableTriggers(null); var dt = m.LastMenuItem;
        m.Control.Opening += (unu, sed) => { dt.Checked = _disabled; };
        m.Separator();
        m["Exit"] = o => Strips.Cmd.File_Exit();
        _trayIcon.ContextMenuStrip = m.Control;
    }
예제 #3
0
            internal void ShowContextMenu(Point p)
            {
                var  gp    = this as _Panel;
                bool isTab = this is _Tab gt;
                var  state = this.DockState;
                var  m     = new AMenu();

                m.Control.Text = "Menu";

                //dock state
                m.Add("Float\tD-click, drag", o => this.SetDockState(_DockState.Floating)).Enabled      = state != _DockState.Floating;
                m.Add("Dock    \tD-click, Alt+drag", o => this.SetDockState(_DockState.Docked)).Enabled = state != _DockState.Docked;
                //menu.Add("Auto Hide", o => this.SetDockState(_DockState.AutoHide)).Enabled = state != _DockState.AutoHide && !isTab; //not implemented
                m["Hide\tM-click"] = o => this.SetDockState(_DockState.Hidden);

                m.Separator();
                using (m.Submenu("Show Panel")) _manager.ZAddShowPanelsToMenu(m.LastMenuItem.DropDown, false);
                using (m.Submenu("Show Toolbar")) _manager.ZAddShowPanelsToMenu(m.LastMenuItem.DropDown, true);

                m.Separator();
                var k = (!this.IsTabbedPanel || this.IsFloating) ? this : gp.ParentTab;

                //caption edge
                using (m.Submenu("Caption At")) {
                    m["Top"] = o => k._SetCaptionEdge(CaptionEdge.Top); if (k.CaptionAt == CaptionEdge.Top)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                    m["Bottom"] = o => k._SetCaptionEdge(CaptionEdge.Bottom); if (k.CaptionAt == CaptionEdge.Bottom)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                    m["Left"] = o => k._SetCaptionEdge(CaptionEdge.Left); if (k.CaptionAt == CaptionEdge.Left)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                    m["Right"] = o => k._SetCaptionEdge(CaptionEdge.Right); if (k.CaptionAt == CaptionEdge.Right)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                }
                //fixed width/height
                if (this.IsDockedOn(_manager))
                {
                    _AddFixedSize(k.ParentSplit, k);
                    void _AddFixedSize(_Split gs, _Node gn)
                    {
                        if (gs.IsSplitterVisible)
                        {
                            bool fixedSize = gs.IsChildFixedSize(gn);
                            m.Add(gs.IsVerticalSplit ? "Fixed Width" : "Fixed Height", o => gs.SetChildFixedSize(gn, !fixedSize)).Checked = fixedSize;
                        }
                        var gs2 = gs.ParentSplit;

                        if (gs2 != null)
                        {
                            using (m.Submenu("Container")) {
                                m.LastMenuItem.DropDown.Opened += (unu, sed) => {
                                    var osd = new AOsdRect {
                                        Rect = _manager.RectangleToScreen(gs.Bounds), Color = 0x00c000
                                    };
                                    osd.Show();
                                    ATimer.After(1000, _ => osd.Dispose());
                                };
                                _AddFixedSize(gs2, gs);
                            }
                        }
                    }
                }

                //test
                //m.Separator();
                //m["test"] = o =>
                //{
                //};

                //custom
                _manager.ZPanelContextMenu?.Invoke(new ZContextMenuEventArgs(gp, m));

                m.Show(this.ParentControl, p.X, p.Y);
            }
예제 #4
0
        /// <summary>
        /// Toolbar button MouseUp handler. Implements context menu that allows to customize.
        /// </summary>
        private void _OnMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }
            var  item        = sender as ToolStripItem;
            var  ts          = item.Owner;
            var  dd          = ts as ToolStripDropDownMenu;
            bool isMenu      = dd != null;
            bool isCustom    = ts == _tsCustom1 || ts == _tsCustom2;
            bool isSeparator = item is ToolStripSeparator;
            bool isHidden    = item.Overflow == ToolStripItemOverflow.Always;
            var  x           = item.Tag as XElement;

            var m = new AMenu();

            m["Properties..."] = o => {
                using (var f = new FSMProperties(this, item.Tag as XElement, isMenu)) {
                    if (f.ShowDialog(_form) == DialogResult.OK)
                    {
                        _Strips_Customize(6, item, null, f);
                    }
                }
            };
            if (!isMenu)
            {
                if (!isSeparator)
                {
                    m["Hide"] = o => _Strips_Customize(5, item); if (isHidden)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                }
                if (isCustom || isSeparator)
                {
                    m["Remove"] = o => _Strips_Customize(3, item);
                }
                if (!isHidden)
                {
                    m["Add separator"] = o => _Strips_Customize(4, item, ts);
                }
            }
            if (isCustom)
            {
                if (_tsCustom1 != null && _tsCustom2 != null)
                {
                    if (ts == _tsCustom1)
                    {
                        m["Move to toolbar Custom2"] = o => _Strips_Customize(2, item, _tsCustom2);
                    }
                    else
                    {
                        m["Move to toolbar Custom1"] = o => _Strips_Customize(2, item, _tsCustom1);
                    }
                }
            }
            else
            {
                if (_tsCustom1 != null)
                {
                    m["Copy to toolbar Custom1"] = o => _Strips_Customize(1, item, _tsCustom1);
                }
                if (_tsCustom2 != null)
                {
                    m["Copy to toolbar Custom2"] = o => _Strips_Customize(1, item, _tsCustom2);
                }
            }
            if (!isMenu)
            {
                m.Separator();
                m["How to customize..."] = o => ADialog.ShowInfo("Customizing toolbars and menus",
                                                                 @"There are several standard toolbars and two custom toolbars (initially empty). Standard toolbar buttons cannot be added and removed, but can be hidden and reordered. Menu items cannot be added, removed, hidden and reordered.

You can find most customization options in two context menus. Right-clicking a button or menu item shows its context menu. Right-clicking before the first button shows toolbar's context menu. You can Alt+drag toolbar buttons to reorder them on the same toolbar. You can Alt+drag toolbars to dock them somewhere else. Use splitters to resize. Right click a splitter to change its thickness."
                                                                 );
                string folder = APath.GetDirectoryPath(_xmlFileCustom), link = $"<a href=\"{folder}\">{folder}</a>";
                m["How to backup, restore, reset..."] = o => {
                    ADialog.Show("How to backup, restore or reset customizations",
                                 $@"All customizations are saved in XML files in folder
{link}

To backup:  copy the file.
To restore:  exit this application and replace the file with the backup file.
To reset:  exit this application and delete the file."
                                 , icon: DIcon.Info, onLinkClick: h => { AExec.Run(h.LinkHref); });
                };
            }

            m.Show(ts);
        }