public TextPad(ControlBase parent) : base(parent) { StartPosition = StartPosition.CenterParent; Size = new Size(400, 300); Padding = new Padding(1, 0, 1, 1); Title = "TextPad"; DockLayout layout = new DockLayout(this); layout.Dock = Dock.Fill; Control.MenuStrip menuStrip = new MenuStrip(layout); menuStrip.Dock = Dock.Top; Control.MenuItem fileMenu = menuStrip.AddItem("File"); fileMenu.Menu.AddItem("Open...", String.Empty, "Ctrl+O").SetAction((s, a) => OnOpen(s, a)); fileMenu.Menu.AddItem("Save", String.Empty, "Ctrl+S").SetAction((s, a) => OnSave(s, a)); fileMenu.Menu.AddItem("Save As...").SetAction((s, a) => OnSaveAs(s, a)); fileMenu.Menu.AddItem("Quit", String.Empty, "Ctrl+Q").SetAction((s, a) => Close()); m_Font = Skin.DefaultFont.Copy(); m_Font.FaceName = "Courier New"; Control.StatusBar statusBar = new Gwen.Control.StatusBar(layout); statusBar.Dock = Dock.Bottom; Control.Label length = new Control.Label(statusBar); length.Margin = new Margin(5, 0, 5, 0); Control.Label label = new Control.Label(statusBar); label.Margin = new Margin(5, 0, 5, 0); label.Text = "Length:"; Control.Label lines = new Control.Label(statusBar); lines.Margin = new Margin(5, 0, 5, 0); label = new Control.Label(statusBar); label.Margin = new Margin(5, 0, 5, 0); label.Text = "Lines:"; m_TextBox = new Control.MultilineTextBox(layout); m_TextBox.Dock = Dock.Fill; m_TextBox.ShouldDrawBackground = false; m_TextBox.Font = m_Font; m_TextBox.TextChanged += (sender, arguments) => { lines.Text = m_TextBox.TotalLines.ToString(); length.Text = m_TextBox.Text.Length.ToString(); }; m_TextBox.Text = ""; m_Path = null; }
private void OpenWindowWithMenuAndStatusBar(ControlBase control, EventArgs args) { Control.Window window = new Control.Window(this); window.Title = String.Format("Window ({0})", ++m_WindowCount); window.Size = new Size(m_Rand.Next(200, 400), m_Rand.Next(200, 400)); window.Left = m_Rand.Next(700); window.Top = m_Rand.Next(400); window.Padding = new Padding(1, 0, 1, 1); Control.Layout.DockLayout layout = new Control.Layout.DockLayout(window); Control.MenuStrip menuStrip = new Control.MenuStrip(layout); menuStrip.Dock = Dock.Top; /* File */ { Control.MenuItem root = menuStrip.AddItem("File"); root.Menu.AddItem("Load", "test16.png", "Ctrl+L"); root.Menu.AddItem("Save", String.Empty, "Ctrl+S"); root.Menu.AddItem("Save As..", String.Empty, "Ctrl+A"); root.Menu.AddItem("Quit", String.Empty, "Ctrl+Q").SetAction((c, a) => window.Close()); } /* Resizing */ { Control.MenuItem root = menuStrip.AddItem("Resizing"); root.Menu.AddItem("Disabled").SetAction((c, a) => window.Resizing = Resizing.None); root.Menu.AddItem("Width").SetAction((c, a) => window.Resizing = Resizing.Width); root.Menu.AddItem("Height").SetAction((c, a) => window.Resizing = Resizing.Height); root.Menu.AddItem("Both").SetAction((c, a) => window.Resizing = Resizing.Both); } Control.StatusBar statusBar = new Control.StatusBar(layout); statusBar.Dock = Dock.Bottom; statusBar.Text = "Status bar"; { Control.Button br = new Control.Button(statusBar); br.Text = "Right button"; statusBar.AddControl(br, true); } }
public Menu(ControlBase parent) : base(parent) { /* Menu Strip */ { Control.MenuStrip menu = new Control.MenuStrip(this); menu.Dock = Dock.Top; /* File */ { Control.MenuItem root = menu.AddItem("File"); root.Menu.AddItem("Load", "test16.png", "Ctrl+L").SetAction(MenuItemSelect); root.Menu.AddItem("Save", String.Empty, "Ctrl+S").SetAction(MenuItemSelect); root.Menu.AddItem("Save As..", String.Empty, "Ctrl+A").SetAction(MenuItemSelect); root.Menu.AddItem("Quit", String.Empty, "Ctrl+Q").SetAction(MenuItemSelect); } /* Russian */ { Control.MenuItem pRoot = menu.AddItem("\u043F\u0438\u0440\u0430\u0442\u0441\u0442\u0432\u043E"); pRoot.Menu.AddItem("\u5355\u5143\u6D4B\u8BD5").SetAction(MenuItemSelect); pRoot.Menu.AddItem("\u0111\u01A1n v\u1ECB th\u1EED nghi\u1EC7m", "test16.png").SetAction(MenuItemSelect); } { Control.MenuItem sRoot = menu.AddItemPath("File/s/d/s/s/d/f"); } /* Embdedded Menu Items */ { Control.MenuItem pRoot = menu.AddItem("Submenu"); Control.MenuItem pCheckable = pRoot.Menu.AddItem("Checkable"); pCheckable.IsCheckable = true; pCheckable.IsCheckable = true; { Control.MenuItem pRootB = pRoot.Menu.AddItem("Two"); pRootB.Menu.AddItem("Two.One"); pRootB.Menu.AddItem("Two.Two"); pRootB.Menu.AddItem("Two.Three"); pRootB.Menu.AddItem("Two.Four"); pRootB.Menu.AddItem("Two.Five"); pRootB.Menu.AddItem("Two.Six"); pRootB.Menu.AddItem("Two.Seven"); pRootB.Menu.AddItem("Two.Eight"); pRootB.Menu.AddItem("Two.Nine", "test16.png"); } pRoot.Menu.AddItem("Three"); pRoot.Menu.AddItem("Four"); pRoot.Menu.AddItem("Five"); { Control.MenuItem pRootB = pRoot.Menu.AddItem("Six"); pRootB.Menu.AddItem("Six.One"); pRootB.Menu.AddItem("Six.Two"); pRootB.Menu.AddItem("Six.Three"); pRootB.Menu.AddItem("Six.Four"); pRootB.Menu.AddItem("Six.Five", "test16.png"); { Control.MenuItem pRootC = pRootB.Menu.AddItem("Six.Six"); pRootC.Menu.AddItem("Sheep"); pRootC.Menu.AddItem("Goose"); { Control.MenuItem pRootD = pRootC.Menu.AddItem("Camel"); pRootD.Menu.AddItem("Eyes"); pRootD.Menu.AddItem("Nose"); { Control.MenuItem pRootE = pRootD.Menu.AddItem("Hair"); pRootE.Menu.AddItem("Blonde"); pRootE.Menu.AddItem("Black"); { Control.MenuItem pRootF = pRootE.Menu.AddItem("Red"); pRootF.Menu.AddItem("Light"); pRootF.Menu.AddItem("Medium"); pRootF.Menu.AddItem("Dark"); } pRootE.Menu.AddItem("Brown"); } pRootD.Menu.AddItem("Ears"); } pRootC.Menu.AddItem("Duck"); } pRootB.Menu.AddItem("Six.Seven"); pRootB.Menu.AddItem("Six.Eight"); pRootB.Menu.AddItem("Six.Nine"); } pRoot.Menu.AddItem("Seven"); } } /* Context Menu Strip */ { Control.Label lblClickMe = new Control.Label(this); lblClickMe.Dock = Dock.Fill; lblClickMe.VerticalAlignment = VerticalAlignment.Center; lblClickMe.Text = "Right Click Me"; m_ContextMenu = new Control.Menu(this); m_ContextMenu.AddItem("Test"); m_ContextMenu.AddItem("Clickable").Clicked += (sender2, args2) => { UnitPrint("Clickable item was clicked"); }; lblClickMe.RightClicked += (sender, args) => { m_ContextMenu.Position = this.CanvasPosToLocal(new Point(args.X, args.Y)); m_ContextMenu.Show(); }; } }
public Menu(Base parent) : base(parent) { /* Context Menu Strip */ { Control.Label lblClickMe = new Control.Label(this) { Text = "Right Click Me" }; lblClickMe.SetPosition(10, 30); lblClickMe.RightClicked += delegate(Control.Base sender, ClickedEventArgs args) { Control.Menu menu = new Control.Menu(this); Point Local = CanvasPosToLocal(new Point(args.X, args.Y)); menu.SetPosition(Local.X, Local.Y); menu.AddItem("Test"); menu.AddItem("Clickable").Clicked += delegate(Control.Base sender2, ClickedEventArgs args2) { UnitPrint("Clickable item was clicked"); }; menu.Show(); }; } /* Menu Strip */ { Control.MenuStrip menu = new Control.MenuStrip(this); /* File */ { Control.MenuItem root = menu.AddItem("File"); root.Menu.AddItem("Load", "test16.png", "Ctrl+L").SetAction(MenuItemSelect); root.Menu.AddItem("Save", String.Empty, "Ctrl+S").SetAction(MenuItemSelect); root.Menu.AddItem("Save As..", String.Empty, "Ctrl+A").SetAction(MenuItemSelect); root.Menu.AddItem("Quit", String.Empty, "Ctrl+Q").SetAction(MenuItemSelect); } /* Russian */ { Control.MenuItem pRoot = menu.AddItem("\u043F\u0438\u0440\u0430\u0442\u0441\u0442\u0432\u043E"); pRoot.Menu.AddItem("\u5355\u5143\u6D4B\u8BD5").SetAction(MenuItemSelect); pRoot.Menu.AddItem("\u0111\u01A1n v\u1ECB th\u1EED nghi\u1EC7m", "test16.png").SetAction(MenuItemSelect); } /* Embdedded Menu Items */ { Control.MenuItem pRoot = menu.AddItem("Submenu"); Control.MenuItem pCheckable = pRoot.Menu.AddItem("Checkable"); pCheckable.IsCheckable = true; pCheckable.IsCheckable = true; { Control.MenuItem pRootB = pRoot.Menu.AddItem("Two"); pRootB.Menu.AddItem("Two.One"); pRootB.Menu.AddItem("Two.Two"); pRootB.Menu.AddItem("Two.Three"); pRootB.Menu.AddItem("Two.Four"); pRootB.Menu.AddItem("Two.Five"); pRootB.Menu.AddItem("Two.Six"); pRootB.Menu.AddItem("Two.Seven"); pRootB.Menu.AddItem("Two.Eight"); pRootB.Menu.AddItem("Two.Nine", "test16.png"); } pRoot.Menu.AddItem("Three"); pRoot.Menu.AddItem("Four"); pRoot.Menu.AddItem("Five"); { Control.MenuItem pRootB = pRoot.Menu.AddItem("Six"); pRootB.Menu.AddItem("Six.One"); pRootB.Menu.AddItem("Six.Two"); pRootB.Menu.AddItem("Six.Three"); pRootB.Menu.AddItem("Six.Four"); pRootB.Menu.AddItem("Six.Five", "test16.png"); { Control.MenuItem pRootC = pRootB.Menu.AddItem("Six.Six"); pRootC.Menu.AddItem("Sheep"); pRootC.Menu.AddItem("Goose"); { Control.MenuItem pRootD = pRootC.Menu.AddItem("Camel"); pRootD.Menu.AddItem("Eyes"); pRootD.Menu.AddItem("Nose"); { Control.MenuItem pRootE = pRootD.Menu.AddItem("Hair"); pRootE.Menu.AddItem("Blonde"); pRootE.Menu.AddItem("Black"); { Control.MenuItem pRootF = pRootE.Menu.AddItem("Red"); pRootF.Menu.AddItem("Light"); pRootF.Menu.AddItem("Medium"); pRootF.Menu.AddItem("Dark"); } pRootE.Menu.AddItem("Brown"); } pRootD.Menu.AddItem("Ears"); } pRootC.Menu.AddItem("Duck"); } pRootB.Menu.AddItem("Six.Seven"); pRootB.Menu.AddItem("Six.Eight"); pRootB.Menu.AddItem("Six.Nine"); } pRoot.Menu.AddItem("Seven"); } } }
public MenuStrip(ControlBase parent) : base(parent) { Control.MenuStrip menu = new Control.MenuStrip(this); { Control.MenuItem root = menu.AddItem("File"); root.Menu.AddItem("New", "test16.png", "Ctrl+N").SetAction(MenuItemSelect); root.Menu.AddItem("Load", "test16.png", "Ctrl+L").SetAction(MenuItemSelect); root.Menu.AddItem("Save", String.Empty, "Ctrl+S").SetAction(MenuItemSelect); root.Menu.AddItem("Save As..", String.Empty, "Ctrl+A").SetAction(MenuItemSelect); root.Menu.AddItem("Quit", String.Empty, "Ctrl+Q").SetAction(MenuItemSelect); } { Control.MenuItem pRoot = menu.AddItem("\u043F\u0438\u0440\u0430\u0442\u0441\u0442\u0432\u043E"); pRoot.Menu.AddItem("\u5355\u5143\u6D4B\u8BD5").SetAction(MenuItemSelect); pRoot.Menu.AddItem("\u0111\u01A1n v\u1ECB th\u1EED nghi\u1EC7m", "test16.png").SetAction(MenuItemSelect); } { Control.MenuItem pRoot = menu.AddItem("Submenu"); Control.MenuItem pCheckable = pRoot.Menu.AddItem("Checkable"); pCheckable.IsCheckable = true; pCheckable.IsCheckable = true; { Control.MenuItem pRootB = pRoot.Menu.AddItem("Two"); pRootB.Menu.AddItem("Two.One"); pRootB.Menu.AddItem("Two.Two"); pRootB.Menu.AddItem("Two.Three"); pRootB.Menu.AddItem("Two.Four"); pRootB.Menu.AddItem("Two.Five"); pRootB.Menu.AddItem("Two.Six"); pRootB.Menu.AddItem("Two.Seven"); pRootB.Menu.AddItem("Two.Eight"); pRootB.Menu.AddItem("Two.Nine", "test16.png"); } pRoot.Menu.AddItem("Three"); pRoot.Menu.AddItem("Four"); pRoot.Menu.AddItem("Five"); { Control.MenuItem pRootB = pRoot.Menu.AddItem("Six"); pRootB.Menu.AddItem("Six.One"); pRootB.Menu.AddItem("Six.Two"); pRootB.Menu.AddItem("Six.Three"); pRootB.Menu.AddItem("Six.Four"); pRootB.Menu.AddItem("Six.Five", "test16.png"); { Control.MenuItem pRootC = pRootB.Menu.AddItem("Six.Six"); pRootC.Menu.AddItem("Sheep"); pRootC.Menu.AddItem("Goose"); { Control.MenuItem pRootD = pRootC.Menu.AddItem("Camel"); pRootD.Menu.AddItem("Eyes"); pRootD.Menu.AddItem("Nose"); { Control.MenuItem pRootE = pRootD.Menu.AddItem("Hair"); pRootE.Menu.AddItem("Blonde"); pRootE.Menu.AddItem("Black"); { Control.MenuItem pRootF = pRootE.Menu.AddItem("Red"); pRootF.Menu.AddItem("Light"); pRootF.Menu.AddItem("Medium"); pRootF.Menu.AddItem("Dark"); } pRootE.Menu.AddItem("Brown"); } pRootD.Menu.AddItem("Ears"); } pRootC.Menu.AddItem("Duck"); } pRootB.Menu.AddItem("Six.Seven"); pRootB.Menu.AddItem("Six.Eight"); pRootB.Menu.AddItem("Six.Nine"); } pRoot.Menu.AddItem("Seven"); } }