Пример #1
0
    void ToolbarExample_Notepad(TriggerArgs ta = null)
    {
        var t = new toolbar();

        if (t.FirstTime)
        {
            //Here you can set some initial properties of the toolbar. Later users can change them: move/resize the toolbar, use the right-click menu.
        }

        t["A"]         = o => { };
        t["B|Tooltip"] = o => { };
        t["|Tooltip", image : "*Modern.TreeLeaf #73BF00"] = o => { };
        t.Menu("C", m => {         //drop-down menu
            m["X"] = o => { };
            m["Y"] = o => { };
        });
        t.Separator();
        t["Script"] = o => script.run("Script example1.cs");

        ////auto-hide. Above is the auto-hide part. Below is the visible part.
        //t = t.AutoHide();
        //if(t.FirstTime) {

        //}

        t.Show(ta);
    }
Пример #2
0
    //Examples of toolbars. Each toolbar is in a separate function.

    void ToolbarExample_Startup1()
    {
        var t = new toolbar();

        //settings
        if (t.FirstTime)
        {
            //Here you can set some initial properties of the toolbar. Later users can change them: move/resize the toolbar, use the right-click menu.
        }
        t.BorderColor = System.Drawing.Color.BlueViolet;

        //buttons
        t["A"]         = o => { };
        t["B|Tooltip"] = o => { };
        t["|Tooltip", image : "*WeatherIcons.RainMix #2F33D0"] = o => { };
        t.Menu("C", m => {         //drop-down menu
            m["X"] = o => { };
            m["Y"] = o => { };
        });
        t.Group("Examples");         //horizontal separator, optionally with text
        t.DisplayText    = false;
        t["Run program"] = o => run.it(folders.System + @"notepad.exe");
        t["Script"]      = o => script.run("Script example1.cs");
        t["Copy-paste"]  = o => {
            string s = clipboard.copy();             //note: to test it, at first select some text somewhere, else it will fail
            s = s.Upper();
            clipboard.paste(s);
        };
        //	t["Close", ""] = o => { t.Close(); };

        t.Show();
    }
Пример #3
0
    void ToolbarExample_ScreenEdge(MouseTriggerArgs ta)
    {
        var t = new toolbar();

        t[""] = o => { };
        t[""] = o => { };
        t.Separator();
        t[""] = o => { };
        t[""] = o => { };
        t.Group();
        t.Menu("", m => {
            m[""] = o => { };
            m[""] = o => { };
        });
        t[""] = o => { };
        t[""] = o => { };

        //auto-hide at the screen edge of the mouse trigger. Above is the auto-hide part. Below is the always-visible part.
        t             = t.AutoHideScreenEdge(ta, 5, ^ 5, 2);
        t.BorderColor = System.Drawing.Color.Orange;

        t.Show();
        ta.DisableTriggerUntilClosed(t);         //single instance
    }
Пример #4
0
    //class _Settings
    //{
    //	public string OneTwo { get; set; }
    //	public int ThreeFour { get; set; }
    //	public int Five { get; set; }
    //	public bool Six { get; set; }
    //	public string Seven { get; set; }
    //	public string Eight { get; set; } = "def";
    //}

    //void TestJson()
    //{
    //	var file = @"Q:\test\sett.json";
    //	var file2 = @"Q:\test\sett.xml";

    //	var v = new _Settings { OneTwo = "text ąčę", ThreeFour = 100 };

    //	for(int i = 0; i < 5; i++) {
    //		//100.ms();
    //		//perf.first();
    //		//var k1 = new JsonSerializerOptions { IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, WriteIndented = true };
    //		//var b1 = JsonSerializer.SerializeToUtf8Bytes(v, k1);
    //		//perf.next();
    //		//File.WriteAllBytes(file, b1);
    //		//perf.nw();

    //		100.ms();
    //		perf.first();
    //		var b2 = File.ReadAllBytes(file);
    //		perf.next();
    //		var k2 = new JsonSerializerOptions { IgnoreNullValues = true };
    //		perf.next();
    //		v = JsonSerializer.Deserialize<_Settings>(b2, k2);
    //		perf.nw('J');
    //	}

    //	for(int i = 0; i < 5; i++) {
    //		//100.ms();
    //		//perf.first();
    //		//var r1 = new XElement("r");
    //		//r1.Add(new XElement("OneTwo", v.OneTwo));
    //		//r1.Add(new XElement("ThreeFour", v.ThreeFour.ToString()));
    //		//perf.next();
    //		//r1.Save(file2);
    //		//perf.nw();

    //		100.ms();
    //		perf.first();
    //		var r2 = XElement.Load(file2);
    //		perf.next();
    //		v = new _Settings();
    //		v.OneTwo = r2.Element("OneTwo").Value;
    //		var s2 = r2.Element("ThreeFour").Value;
    //		perf.nw('X');
    //		v.ThreeFour = s2.ToInt();
    //	}

    //	print.it(v.OneTwo, v.ThreeFour, v.Five, v.Six, v.Seven, v.Eight);

    //	//JsonDocument d; d.RootElement.
    //}

    //[DllImport("CppE")]
    //static extern int Cpp_Install(int step, string dir);

    //[DllImport("CppE")]
    //static extern int Cpp_Uninstall();


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

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

            //t.ExtractIconPathFromCode = true;
            //t["Auto icon"] = o => print.it("notepad.exe");
            //t["Failed icon", @"Q:\app\-.ico"] = o => print.it(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 => print.it(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 += (_, _) => {
                var m = new popupMenu(dd);
                m["one"] = o => print.it(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => print.it(o);
                }
            };
            var sb = new ToolStripSplitButton("SB");
            t.Add(sb, @"Q:\app\copy.ico", o => print.it(o));
#elif true
            //t.Control.Font = new Font("Courier New", 16);
            //t.Control.RightToLeft = RightToLeft.Yes;
            t.MenuButton("DD", m => {
                print.it("dd");
                //m.MultiShow = false;
                m["one"] = o => print.it(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => print.it(o);
                }
            }, @"Q:\app\find.ico", "MenuButton");
            t.SplitButton("SB", m => {
                m["one"] = o => print.it(o);
                //var sb = m.Control.OwnerItem as ToolStripSplitButton;
                //print.it(sb);
                //sb.DefaultItem = m.LastItem;
                using (m.Submenu("Sub")) {
                    m["si"] = o => print.it(o);
                }
            }, @"Q:\app\copy.ico", "SplitButton", o => print.it(o));
            t.Separator("");
            t[true, "DD2", @"Q:\app\delete.ico"] = m => {
                print.it("create menu");
                //m.MultiShow = false;
                m["one"] = o => print.it(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => print.it(o);
                }
            };
            //t.SplitButton("SB", o => {
            //	print.it(o);
            //}, m => {
            //	m["one"] = o => print.it(o);
            //	using(m.Submenu("Sub")) {
            //		m["si"] = o => print.it(o);
            //	}
            //}, @"Q:\app\copy.ico", "SplitButton");
            //Action<popupMenu> menu1 = m => {
            //	m["one"] = o => print.it(o);
            //	using(m.Submenu("Sub")) {
            //		m["si"] = o => print.it(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 => print.it(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => print.it(o);
                }
            };
#else
            t.MenuButton("DD", @"Q:\app\find.ico").Menu = m => {
                print.it("dd");
                //m.MultiShow = false;
                m["one"] = o => print.it(o);
                using (m.Submenu("Sub")) {
                    m["two"] = o => print.it(o);
                }
            };
            t.SplitButton("SB", o => print.it(o), @"Q:\app\copy.ico").Menu = m => {
                print.it("dd");
                m["one"] = o => print.it(o);
                using (m.Submenu("Sub")) {
                    m["two"] = o => print.it(o);
                }
            };
#endif
            //t.Separator("");
            ////t["GC"] = o => GC.Collect();

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

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

            //void _B(TBBorder b){
            //	t.Border = b;
            //	//print.it(WndUtil.BorderWidth((wnd)t.Control));
            //}

            //t.Bounds = new Rectangle(i * 300 + 700, 200, 200, 200);
            t.Show();
            //t.Window.ActivateL();
            wait.doEvents(200);

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

            //wait.doEvents(1000);
            //t.Border = TBBorder.FixedWithCaption;
            //wait.doEvents(3000);
            //t.Border = TBBorder.SizableWithCaption;

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

            //}
            //m.Show()
        }

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

        //timer.after(500, _ => {
        //	var w = (wnd)t.Control;
        //	//w.SetStyle(WS.DLGFRAME, SetAddRemove.Add);
        //});

        dialog.options.topmostIfNoOwnerWindow = true;
        dialog.show();

        //timer.after(10000, _ => Application.Exit());
        //Application.Run();
    }
Пример #5
0
 public SIZE GetPrevSize(toolbar tb) => tb._followClientArea ? _prevClientSize : _prevSize;
Пример #6
0
 public RECT GetCachedRect(toolbar tb) => tb._followClientArea ? _clientRect : _rect;
Пример #7
0
 public void AddTB(toolbar tb)
 {
     a.Add(tb);
     tb._ow = this;
 }