Beispiel #1
0
#pragma warning restore 67

    #endregion

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

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

        case MouseButtons.Right:
            var m = new AMenu();
            m["Close\tM-click"] = o => Program.Model.CloseFile(f, true);
            using (m.Submenu("Multiple")) {
                m["Close all other"] = o => Program.Model.CloseEtc(FilesModel.ECloseCmd.CloseAll, dontClose: f);
                m["Close all"]       = o => Program.Model.CloseEtc(FilesModel.ECloseCmd.CloseAll);
            }
            m.Show(_c);
            break;

        case MouseButtons.Middle:
            Program.Model.CloseFile(f, true);
            break;
        }
    }
Beispiel #2
0
            internal void ShowContextMenu(Point p)
            {
                var m = new AMenu();

                using (m.Submenu("Width")) {
                    for (int i = 1, k = this.SplitterWidth; i <= 10; i++)
                    {
                        m.Add(i.ToString(), o => {
                            this.SplitterWidth = o.Item.Text.ToInt();
                            _manager._UpdateLayout(true);                             //not this.UpdateLayout() because may need to apply minimal layouts
                        }).Checked = k == 0;
                    }
                }

                m.Show(_manager, p.X, p.Y);
            }
Beispiel #3
0
    void MouseTriggers()
    {
        //examples of mouse triggers

        Triggers.Mouse[TMClick.Right, "Ctrl+Shift", TMFlags.ButtonModUp] = o => AOutput.Write(o.Trigger); //Ctrl+Shift+RightClick
        Triggers.Mouse[TMEdge.RightInCenter50] = o => {                                                   //the right edge of the primary screen, center 50%
            var m = new AMenu("example");
            m["A"] = o => {  };
            m["B"] = o => {  };
            using (m.Submenu("C")) {
                m["D"] = o => {  };
                m["E"] = o => {  };
            }
            m.Show();

            //To create menus can be used snippet menuSnippet. Start typing "menu" and you will see snippets in the completion list.
        };
        Triggers.Mouse[TMMove.LeftRightInCenter50, screen : TMScreen.Any] = o => AWnd.SwitchActiveWindow(); //move the mouse quickly to the left and back in center 50% of any screen
        Triggers.Mouse[TMMove.RightLeftInCenter50, screen : TMScreen.Any] = o => AKeys.Key("Ctrl+Tab");     //to the right and back. Ctrl+Tab should switch the active document.

        Triggers.FuncOf.NextTrigger     = o => AKeys.IsScrollLock;                                          //example of a custom scope (aka context, condition)
        Triggers.Mouse[TMWheel.Forward] = o => AOutput.Write($"{o.Trigger} while ScrollLock is on");
    }
Beispiel #4
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);
            }
Beispiel #5
0
    //void TestMenu2()
    //{
    //	var m = new AMenu();
    //	m["One"] = o => AOutput.Write(o);
    //	m["Two"] = o => AOutput.Write(o);
    //	m.LazySubmenu("Submenu 1").Fill = _ => {
    //		AOutput.Write("adding items of " + m.CurrentAddMenu.OwnerItem);
    //		m["Three"] = o => AOutput.Write(o);
    //		m["Four"] = o => AOutput.Write(o);
    //		m.LazySubmenu("Submenu 2", _ => {
    //			AOutput.Write("adding items of " + m.CurrentAddMenu.OwnerItem);
    //			m["Five"] = o => AOutput.Write(o);
    //			m["Six"] = o => AOutput.Write(o);
    //		});
    //		m["Seven"] = o => AOutput.Write(o);
    //	};
    //	m["Eight"] = o => AOutput.Write(o);
    //	m.Show();

    //}

    //void TestMenu2()
    //{
    //	var m = new AMenu();
    //	m["One"] = o => AOutput.Write(o);
    //	m["Two"] = o => AOutput.Write(o);
    //	m.LazySubmenu("Submenu 1");
    //	m.LazyFill = _ => {
    //		AOutput.Write("adding items of " + m.CurrentAddMenu.OwnerItem);
    //		m["Three"] = o => AOutput.Write(o);
    //		m["Four"] = o => AOutput.Write(o);
    //		m.LazySubmenu("Submenu 2", _ => {
    //			AOutput.Write("adding items of " + m.CurrentAddMenu.OwnerItem);
    //			m["Five"] = o => AOutput.Write(o);
    //			m["Six"] = o => AOutput.Write(o);
    //		});
    //		m["Seven"] = o => AOutput.Write(o);
    //	};
    //	m["Eight"] = o => AOutput.Write(o);
    //	m.Show();

    //}

#if false
    void TestToolbar()
    {
        for (int i = 0; i < 1; i++)
        {
            var t = new AToolbar("123");
            //t.NoText = true;
            //t.Border= TBBorder.Sizable3;t.Control.Text = "Toolbar";
            //t.Border = TBBorder.SizableWithCaptionX;

            //t["Find", @"Q:\app\find.ico"] = o => AOutput.Write(o);
            //t["Copy", @"Q:\app\copy.ico"] = o => AOutput.Write(o);
            //t.Separator("Tpi group");
            //t["Delete", @"Q:\app\delete.ico"] = o => AOutput.Write(o);
            //t["No image"] = o => AOutput.Write(o);
            //t["TT", tooltip: "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW "] = o => AOutput.Write(o);
            ////t.LastButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            ////t.LastButton.AutoToolTip = false;
            ////t.LastButton.ToolTipText = "ggg";
            //t.Separator();
            //t["Run", @"Q:\app\run.ico"] = o => AOutput.Write(o);
            //t.Separator("");
            //t["Paste text", @"Q:\app\paste.ico"] = o => AOutput.Write(o);
            //t.LastButton.ToolTipText = "Toooooltip";

            //t.ExtractIconPathFromCode = true;
            //t["Auto icon"] = o => AOutput.Write("notepad.exe");
            //t["Failed icon", @"Q:\app\-.ico"] = o => AOutput.Write(o);
            ////t.LastButton.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
            ////t.Separator("");
            ////t.Add(new ToolStripTextBox { ToolTipText= "ToolStripTextBox", AutoSize=false, Width=50 });
            ////t.Add(new ToolStripComboBox { ToolTipText= "ToolStripComboBox", AutoSize=false, Width=50 });
            ////t.Add(new ToolStripTextBox());
            ////t.Add(new ToolStripTextBox());
            ////t.Add(new ToolStripTextBox());
            ////t.Add(new ToolStripButton("aaa"));
            ////t.Add(new ToolStripButton("bbb"));
            ////t["Multi\r\nline"] = o => AOutput.Write(o);

            //t["None"] = o => _B(TBBorder.None);
            //t["SWC"] = o => _B(TBBorder.SizableWithCaption);
            //t["Sizable1"] = o => _B(TBBorder.Sizable1);
            //t["Sizable2"] = o => _B(TBBorder.Sizable2);
            //t["Sizable3"] = o => _B(TBBorder.Sizable3);
            //t["Sizable3D"] = o => _B(TBBorder.Sizable3D);
            //t["Sizable"] = o => _B(TBBorder.Sizable);
            //t["FixedWithCaption"] = o => _B(TBBorder.FixedWithCaption);
            //t["SizableWithCaption"] = o => _B(TBBorder.SizableWithCaption);
            //t["Close"] = o => t.Close();

#if false
            var dd = new ToolStripDropDownButton("DD");
            t.Add(dd, @"Q:\app\find.ico");
            dd.DropDownOpening += (unu, sed) => {
                var m = new AMenu(dd);
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            };
            var sb = new ToolStripSplitButton("SB");
            t.Add(sb, @"Q:\app\copy.ico", o => AOutput.Write(o));
#elif true
            //t.Control.Font = new Font("Courier New", 16);
            //t.Control.RightToLeft = RightToLeft.Yes;
            t.MenuButton("DD", m => {
                AOutput.Write("dd");
                //m.MultiShow = false;
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            }, @"Q:\app\find.ico", "MenuButton");
            t.SplitButton("SB", m => {
                m["one"] = o => AOutput.Write(o);
                //var sb = m.Control.OwnerItem as ToolStripSplitButton;
                //AOutput.Write(sb);
                //sb.DefaultItem = m.LastItem;
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            }, @"Q:\app\copy.ico", "SplitButton", o => AOutput.Write(o));
            t.Separator("");
            t[true, "DD2", @"Q:\app\delete.ico"] = m => {
                AOutput.Write("create menu");
                //m.MultiShow = false;
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            };
            //t.SplitButton("SB", o => {
            //	AOutput.Write(o);
            //}, m => {
            //	m["one"] = o => AOutput.Write(o);
            //	using(m.Submenu("Sub")) {
            //		m["si"] = o => AOutput.Write(o);
            //	}
            //}, @"Q:\app\copy.ico", "SplitButton");
            //Action<AMenu> menu1 = m => {
            //	m["one"] = o => AOutput.Write(o);
            //	using(m.Submenu("Sub")) {
            //		m["si"] = o => AOutput.Write(o);
            //	}
            //};
            //t.MenuButton("DD", menu1, @"Q:\app\find.ico", "MenuButton");
#elif false
            t.MenuButton("DD", @"Q:\app\find.ico");
            t.Menu = m => {
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            };
#else
            t.MenuButton("DD", @"Q:\app\find.ico").Menu = m => {
                AOutput.Write("dd");
                //m.MultiShow = false;
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["two"] = o => AOutput.Write(o);
                }
            };
            t.SplitButton("SB", o => AOutput.Write(o), @"Q:\app\copy.ico").Menu = m => {
                AOutput.Write("dd");
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["two"] = o => AOutput.Write(o);
                }
            };
#endif
            //t.Separator("");
            ////t["GC"] = o => GC.Collect();

            //var dd = new ToolStripSplitButton("SB2", null, (unu,sed)=>AOutput.Write("click"));
            //t.Add(dd, @"Q:\app\delete.ico");
            //dd.DropDownOpening += (unu, sed) => {
            //	var m = new AMenu();
            //	dd.DropDown = m.Control;
            //	m["one"] = o => AOutput.Write(o);
            //};
            //dd.ButtonClick += (unu, sed) => AOutput.Write("button click");
            //dd.DoubleClickEnabled = true;
            //dd.ButtonDoubleClick += (unu, sed) => AOutput.Write("button double click");

            //ATimer.After(3000, _ => {
            //	var c = t.Control.Items[0];
            //	c.Select();
            //});

            //void _B(TBBorder b){
            //	t.Border = b;
            //	//AOutput.Write(AWnd.More.BorderWidth((AWnd)t.Control));
            //}

            //t.Bounds = new Rectangle(i * 300 + 700, 200, 200, 200);
            t.Show();
            //t.Window.ActivateLL();
            ATime.SleepDoEvents(200);

            //for(int j = 1; j <= (int)TBBorder.SizableWithCaptionX; j++) {
            //	ATime.SleepDoEvents(1000);
            //	t.Border = (TBBorder)j;
            //}

            //ATime.SleepDoEvents(1000);
            //t.Border = TBBorder.FixedWithCaption;
            //ATime.SleepDoEvents(3000);
            //t.Border = TBBorder.SizableWithCaption;

            //var m = new AMenu();
            //using(m.Submenu("Sub")) {

            //}
            //m.Show()
        }

        //var c = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(VisualStyleElement.Window.FrameLeft.Inactive).GetColor(ColorProperty.BorderColor);
        //AOutput.Write((uint)c.ToArgb());

        //ATimer.After(500, _ => {
        //	var w = (AWnd)t.Control;
        //	//w.SetStyle(WS.DLGFRAME, SetAddRemove.Add);
        //});

        ADialog.Options.TopmostIfNoOwnerWindow = true;
        ADialog.Show();

        //ATimer.After(10000, _ => Application.Exit());
        //Application.Run();
    }