public CollapsePanel(Manager manager, Control parent, string Name, int expandedHeight = 100, bool extended = true) { this.panel = new GroupPanel(manager); panel.Init(); panel.Height = expandedHeight; panel.Width = parent.Width - 20; panel.Resizable = true; //panel.Text = " " + Name.Trim(); Text = Name; this.collapseButton = new Button(manager); collapseButton.Init(); collapseButton.Width = 15; collapseButton.Height = 18; collapseButton.Text = "^"; collapseButton.Click += collapseButton_Click; this.ExpandedHeight = expandedHeight; this.panelControls = new Dictionary<string, Control>(); this.parent = parent; parent.Add(panel); parent.Add(collapseButton); this.IsExtended = extended; parent.Refresh(); }
//////////////////////////////////////////////////////////////////////////// #endregion #region //// Constructors ////// //////////////////////////////////////////////////////////////////////////// public TaskDialog(Manager manager) : base(manager) { //Alpha = 200; Height = 520; MinimumWidth = 254; MinimumHeight = 160; Center(); TopPanel.Height = 80; TopPanel.BevelStyle = BevelStyle.None; TopPanel.BevelBorder = BevelBorder.None; Caption.Visible = false; Description.Visible = false; Text = "Dialog Template"; imgTop = new ImageBox(manager); imgTop.Init(); imgTop.Parent = TopPanel; imgTop.Top = 0; imgTop.Left = 0; imgTop.Width = TopPanel.ClientWidth; imgTop.Height = TopPanel.ClientHeight; imgTop.Anchor = Anchors.Left | Anchors.Top | Anchors.Right | Anchors.Bottom; imgTop.SizeMode = SizeMode.Normal; imgTop.Image = Manager.Content.Load<Texture2D>("Content\\Images\\Caption"); tbcMain = new TabControl(manager); tbcMain.Init(); tbcMain.Parent = this; tbcMain.Left = 4; tbcMain.Top = TopPanel.Height + 4; tbcMain.Width = ClientArea.Width - 8; tbcMain.Height = ClientArea.Height - 8 - TopPanel.Height - BottomPanel.Height; tbcMain.Anchor = Anchors.All; tbcMain.AddPage(); tbcMain.TabPages[0].Text = "First"; tbcMain.AddPage(); tbcMain.TabPages[1].Text = "Second"; tbcMain.AddPage(); tbcMain.TabPages[2].Text = "Third"; btnFirst = new Button(manager); btnFirst.Init(); btnFirst.Parent = tbcMain.TabPages[0]; btnFirst.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; btnFirst.Top = 8; btnFirst.Left = 8; btnFirst.Width = btnFirst.Parent.ClientWidth - 16; btnFirst.Text = ">>> First Page Button <<<"; grpFirst = new GroupPanel(manager); grpFirst.Init(); grpFirst.Parent = tbcMain.TabPages[0]; grpFirst.Anchor = Anchors.All; //grpFirst.Type = GroupBoxType.Flat; grpFirst.Left = 8; grpFirst.Top = btnFirst.Top + btnFirst.Height + 4; grpFirst.Width = btnFirst.Parent.ClientWidth - 16; grpFirst.Height = btnFirst.Parent.ClientHeight - grpFirst.Top - 8; btnSecond = new Button(manager); btnSecond.Init(); btnSecond.Parent = tbcMain.TabPages[1]; btnSecond.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; btnSecond.Top = 8; btnSecond.Left = 8; btnSecond.Width = btnSecond.Parent.ClientWidth - 16; btnSecond.Text = ">>> Second Page Button <<<"; btnThird = new Button(manager); btnThird.Init(); btnThird.Parent = tbcMain.TabPages[2]; btnThird.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; btnThird.Top = 8; btnThird.Left = 8; btnThird.Width = btnThird.Parent.ClientWidth - 16; btnThird.Text = ">>> Third Page Button <<<"; btnOk = new Button(manager); btnOk.Init(); btnOk.Parent = BottomPanel; btnOk.Anchor = Anchors.Top | Anchors.Right; btnOk.Top = btnOk.Parent.ClientHeight - btnOk.Height - 8; btnOk.Left = btnOk.Parent.ClientWidth - 8 - btnOk.Width * 3 - 8; btnOk.Text = "OK"; btnOk.ModalResult = ModalResult.Ok; btnApply = new Button(manager); btnApply.Init(); btnApply.Parent = BottomPanel; btnApply.Anchor = Anchors.Top | Anchors.Right; btnApply.Top = btnOk.Parent.ClientHeight - btnOk.Height - 8; btnApply.Left = btnOk.Parent.ClientWidth - 4 - btnOk.Width * 2 - 8; btnApply.Text = "Apply"; btnClose = new Button(manager); btnClose.Init(); btnClose.Parent = BottomPanel; btnClose.Anchor = Anchors.Top | Anchors.Right; btnClose.Top = btnOk.Parent.ClientHeight - btnClose.Height - 8; btnClose.Left = btnOk.Parent.ClientWidth - btnClose.Width - 8; btnClose.Text = "Close"; btnClose.ModalResult = ModalResult.Cancel; btnFirst.Focused = true; }
public void Initialize() { HeightCounter = 0; Width = parent.Width - LeftPadding * 2; #region /// GroupBox (back panel) /// backPanel = new Panel(manager); backPanel.Init(); //backPanel.Left = Left;//change backPanel.Top = Top; backPanel.Width = Width; backPanel.Parent = parent; backPanel.Text = ""; backPanel.Color = sidebar.master.BackColor; #endregion int WidthReduction = 15; //change #region /// Inspector Address Label /// lblInspectorAddress = new Label(manager); lblInspectorAddress.Init(); //lblInspectorAddress.Visible = false; //change lblInspectorAddress.Parent = backPanel; lblInspectorAddress.Top = HeightCounter; //HeightCounter += VertPadding + lblInspectorAddress.Height + 10; lblInspectorAddress.Width = Width - WidthReduction; lblInspectorAddress.Height = lblInspectorAddress.Height * 2; //HeightCounter += lblInspectorAddress.Height; labelDoubleHeight = lblInspectorAddress.Height; //lblInspectorAddress.Left = LeftPadding; //lblInspectorAddress.Anchor = Anchors.Left; lblInspectorAddress.Text = ">No Node Selected<"; bool changed = false; lblInspectorAddress.TextChanged += delegate(object s, EventArgs e) { if (!changed) { changed = true; Label l = (Label)s; l.Text = l.Text.wordWrap(25); } changed = false; }; #endregion //btnToggleFields = new Button(manager); //btnToggleFields.Init(); //btnToggleFields.Parent = backPanel; //btnToggleFields.Left = LeftPadding + backPanel.Width - 30; //btnToggleFields.Width = 15; //btnToggleFields.Height = 20; //btnToggleFields.Top = HeightCounter + 10; //btnToggleFields.Text = "F"; //btnToggleFields.Click += delegate(object s, EventArgs e) //{ // this.GenerateFields = !this.GenerateFields; // //ResetInspectorBox(ActiveInspectorParent.obj); // ActiveInspectorParent.DoubleClickItem(this); //}; HeightCounter += lblInspectorAddress.Height; #region /// Component List /// InsBox = new ListBox(manager); InsBox.Init(); //manager.Add(InsBox); InsBox.Parent = backPanel; InsBox.Top = HeightCounter; InsBox.Left = 10; InsBox.Width = Width - WidthReduction; InsBox.Height = 140; HeightCounter += InsBox.Height; InsBox.HideSelection = false; InsBox.ItemIndexChanged += InsBox_ItemIndexChanged; InsBox.Click += InsBox_Click; InsBox.DoubleClick += InsBox_DoubleClick; InsBox.Refresh(); sidebar.ui.SetScrollableControl(InsBox, InsBox_ChangeScrollPosition); #region /// Context Menu /// contextMenuInsBox = new ContextMenu(manager); applyToAllNodesMenuItem = new MenuItem("Apply to Group"); applyToAllNodesMenuItem.Click += applyToAllNodesMenuItem_Click; toggleComponentMenuItem = new MenuItem("Toggle Component"); toggleComponentMenuItem.Click += toggleComponentMenuItem_Click; removeComponentMenuItem = new MenuItem("Remove Component"); removeComponentMenuItem.Click += removeComponentMenuItem_Click; toggleBoolMenuItem = new MenuItem("Toggle"); toggleBoolMenuItem.Click += toggleBoolMenuItem_Click; toggleLinkMenuItem = new MenuItem("Toggle link"); toggleLinkMenuItem.Click += toggleLinkMenuItem_Click; removeLinkMenuItem = new MenuItem("Delete link"); removeLinkMenuItem.Click += removeLinkMenuItem_Click; addComponentToLinkMenuItem = new MenuItem("Add Link Component"); addComponentToLinkMenuItem.Click += AddComponentToLinkMenuItem_Click; contextMenuInsBox.Items.Add(applyToAllNodesMenuItem); InsBox.ContextMenu = contextMenuInsBox; #endregion #endregion #region /// GroupPanel /// GroupPanel groupPanel = new GroupPanel(manager); groupPanel.Init(); groupPanel.Parent = backPanel; //groupPanel.Visible = false;//change groupPanel.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; groupPanel.Width = Width - WidthReduction; groupPanel.Top = HeightCounter; groupPanel.Height = 90; HeightCounter += VertPadding + groupPanel.Height; groupPanel.Left = InsBox.Left; groupPanel.Text = "Inspector Property"; #endregion #region /// PropertyEditPanel /// propertyEditPanel = new PropertyEditPanel(this, groupPanel); #endregion backPanel.Height = groupPanel.Top + groupPanel.Height; }
public LobbyWindow(Manager manager) : base(manager) { //Setup the window CaptionVisible = false; TopPanel.Visible = false; Movable = false; Resizable = false; Width = 700; Height = 500; Shadow = true; Center(); //Group panels grpLobby = new GroupPanel(Manager) { Width = ClientWidth / 2, Height = ClientHeight - BottomPanel.Height + 2, Text = "Rooms" }; grpLobby.Init(); Add(grpLobby); grpServer = new GroupPanel(Manager) { Left = (ClientWidth / 2) - 1, Width = (ClientWidth / 2) + 1, Height = ClientHeight - BottomPanel.Height + 2, Text = "Server" }; grpServer.Init(); Add(grpServer); //Top controls txtSearch = new TextBox(Manager) { Left = 8, Top = 8, Width = (ClientWidth / 4) - 16, }; txtSearch.Init(); txtSearch.Text = searchStr; txtSearch.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { RefreshRooms(); }); //Show "Search..." text, but make it dissapear on focus txtSearch.FocusGained += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { if (txtSearch.Text.Trim() == searchStr) txtSearch.Text = string.Empty; }); txtSearch.FocusLost += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { if (txtSearch.Text.Trim() == string.Empty) txtSearch.Text = searchStr; }); grpLobby.Add(txtSearch); cmbSort = new ComboBox(Manager) { Left = txtSearch.Right + 8, Top = 8, Width = (ClientWidth / 4) - 16 - 20, }; cmbSort.Init(); cmbSort.Items.AddRange(sortFilters); cmbSort.ItemIndex = 0; cmbSort.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { RefreshRooms(); }); grpLobby.Add(cmbSort); btnReload = new Button(Manager) { Left = cmbSort.Right + 8, Top = 8, Width = 20, Height = 20, Text = string.Empty, }; btnReload.Init(); btnReload.Glyph = new Glyph(ContentPack.Textures["gui\\icons\\refresh"]); btnReload.ToolTip.Text = "Refresh"; btnReload.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { Game.NetManager.Send(new RequestMessage(MessageTypes.Lobby)); }); grpLobby.Add(btnReload); //Main room list RoomListCtrl = new ControlList<LobbyDataControl>(Manager) { Left = 8, Top = txtSearch.Bottom + 8, Width = grpLobby.Width - 16, Height = grpLobby.Height - 16 - txtSearch.Bottom - 24 }; RoomListCtrl.Init(); grpLobby.Add(RoomListCtrl); //Server info labels lblName = new Label(Manager) { Text = "Loading...", Top = 8, Font = FontSize.Default20, Left = 8, Alignment = Alignment.MiddleCenter, Height = 30, Width = grpServer.ClientWidth - 16 }; lblName.Init(); grpServer.Add(lblName); lblDescription = new Label(Manager) { Text = string.Empty, Top = 8 + lblName.Bottom, Left = 8, Alignment = Alignment.MiddleCenter, Width = grpServer.ClientWidth - 16 }; lblDescription.Init(); grpServer.Add(lblDescription); lblInfo = new Label(Manager) { Text = string.Empty, Top = 8 + lblDescription.Bottom, Left = 8, Alignment = Alignment.TopLeft, Width = grpServer.ClientWidth - 16, Height = grpServer.Height }; lblInfo.Init(); grpServer.Add(lblInfo); //Bottom buttons btnCreate = new Button(Manager) { Top = 8, Text = "Create" }; btnCreate.Left = (ClientWidth / 2) - (btnCreate.Width / 2); btnCreate.Init(); btnCreate.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { CreateWorldDialog window = new CreateWorldDialog(manager, this); window.Init(); Manager.Add(window); window.Show(); }); BottomPanel.Add(btnCreate); btnJoin = new Button(Manager) { Right = btnCreate.Left - 8, Top = 8, Text = "Join" }; btnJoin.Init(); btnJoin.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { JoinRoom(RoomListCtrl.ItemIndex); }); BottomPanel.Add(btnJoin); btnDisconnect = new Button(Manager) { Left = btnCreate.Right + 8, Top = 8, Text = "Quit" }; btnDisconnect.Init(); btnDisconnect.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { Game.NetManager.Disconnect("Left Lobby"); Game.CurrentGameState = GameState.Login; Interface.MainWindow.ScreenManager.SwitchScreen(new LoginScreen()); }); BottomPanel.Add(btnDisconnect); //When finished, request server send lobby data Game.NetManager.Send(new RequestMessage(MessageTypes.Lobby)); }
public void CreateInterface(Node node) { foreach (var child in Controls.First().Controls.ToList()) Controls.First().Remove(child); _node = node; int yPos = 16; // Create the node editing section var nodeEditing = new GroupPanel(Manager) { Text = "Node Details" }; nodeEditing.Init(); // nodeEditing.Anchor = Anchors.Left | Anchors.Right | Anchors.Top; nodeEditing.Left = 16; nodeEditing.Top = yPos; nodeEditing.Width = Width - 48; nodeEditing.Parent = this; nodeEditing.Visible = true; _nodeEditor = new ObjectEditor<Node>(Manager, nodeEditing); _nodeEditor.SetInstance(node); _nodeEditor.CreateInterface(); yPos += nodeEditing.Height + 16; // Create the binded logic section var bindedLogicEditing = new GroupPanel(Manager) { Text = "Node Details" }; bindedLogicEditing.Init(); //bindedLogicEditing.Anchor = Anchors.Left | Anchors.Right | Anchors.Top; bindedLogicEditing.Left = 16; bindedLogicEditing.Top = yPos; bindedLogicEditing.Width = Width - 48; bindedLogicEditing.Parent = this; bindedLogicEditing.Visible = true; _bindedLogicEditor = new ObjectEditor<BindedLogic>(Manager, bindedLogicEditing); _bindedLogicEditor.SetInstance(node.BindedLogic); _bindedLogicEditor.CreateInterface(); yPos += bindedLogicEditing.Height + 16; // Create the pure logic section pureLogicEditing = new GroupPanel(Manager) { Text = "Node Details", AutoScroll = true, Left = 16, Top = yPos, Width = Width - 48, Parent = this, Visible = true, Height = 80 }; pureLogicEditing.Init(); CreatePureLogicEditor(pureLogicEditing); Invalidate(); Refresh(); pureLogicEditing.Invalidate(); pureLogicEditing.Refresh(); }
public override void Initialize() { ContentSystem contentSystem = ((ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]); Viewport viewport = contentSystem.GetViewport(); overlay = new HalfTransparentOverlay(manager); overlay.Init(); overlay.Width = manager.ScreenWidth; overlay.Height = manager.ScreenHeight; overlay.BackGroundTexture = contentSystem.LoadTexture("white_dot"); manager.Add(overlay); startupDialog = new Window(manager); startupDialog.Init(); startupDialog.ShowModal(); startupDialog.Width = 400; startupDialog.Height = 158; startupDialog.Center(); startupDialog.Text = "Select what you would like to do..."; startupDialog.CloseButtonVisible = false; startupDialog.Resizable = false; startupDialog.Movable = false; startupDialog.IconVisible = false; startupDialog.VisibleChanged +=new TomShane.Neoforce.Controls.EventHandler(startupDialog_VisibleChanged); startupDialog.Closing += new WindowClosingEventHandler(WindowCloseBehavior); manager.Add(startupDialog); //LEFT PANEL possibleMaps = new GroupPanel(manager); possibleMaps.Init(); possibleMaps.Parent = startupDialog; possibleMaps.Width = 189; possibleMaps.Height = 122; possibleMaps.Text = "Select a Theme?"; possibleMaps.Top = 1; int buttonSize = 80; tileMapGarden = new ImageBasedButton(manager); tileMapGarden.Init(); tileMapGarden.Parent = possibleMaps; tileMapGarden.Width = buttonSize; tileMapGarden.Height = buttonSize; tileMapGarden.Top = buttonSize * 0 + 8; tileMapGarden.Left = buttonSize * 0 + 8 * 1; tileMapGarden.tilemap = textures["tilemap_garden"]; tileMapGarden.tilemap.Name = "tilemap_garden"; tileMapGarden.Click += new TomShane.Neoforce.Controls.EventHandler(OnTilemapButtonClickBehavior); tileMapGarden.MouseOver += new MouseEventHandler(OnTilemapButtonMouseOverBehavior); tileMapGarden.FocusGained += new TomShane.Neoforce.Controls.EventHandler(OnTilemapButtonMouseOverBehavior); tileMapGarden.GenerateFirstTile(contentSystem); tileMapGarden.Focused = true; tileMapCellar = new ImageBasedButton(manager); tileMapCellar.Init(); tileMapCellar.Parent = possibleMaps; tileMapCellar.Width = buttonSize; tileMapCellar.Height = buttonSize; tileMapCellar.Top = buttonSize * 0 + 8; tileMapCellar.Left = buttonSize * 1 + 8 * 2; tileMapCellar.tilemap = textures["tilemap_winecellar"]; tileMapCellar.tilemap.Name = "tilemap_winecellar"; tileMapCellar.Click += new TomShane.Neoforce.Controls.EventHandler(OnTilemapButtonClickBehavior); tileMapCellar.MouseOver += new MouseEventHandler(OnTilemapButtonMouseOverBehavior); tileMapCellar.FocusGained += new TomShane.Neoforce.Controls.EventHandler(OnTilemapButtonMouseOverBehavior); tileMapCellar.GenerateFirstTile(contentSystem); tilemap = tileMapGarden.tilemap; //RIGHT PANEL recentMaps = new GroupPanel(manager); recentMaps.Init(); recentMaps.Parent = startupDialog; recentMaps.Width = possibleMaps.Width; recentMaps.Height = possibleMaps.Height; recentMaps.Text = "Load a recent Map?"; recentMaps.Left = possibleMaps.Width + 8; recentMaps.Top = 1; openMap = new Button(manager); openMap.Init(); openMap.Parent = recentMaps; openMap.Width = 150; openMap.Height = 24; openMap.Top = recentMaps.Height/2 - openMap.Height; openMap.Left = recentMaps.Width/2 - openMap.Width/2; openMap.Text = "Load Saved Map"; openMap.Click += new TomShane.Neoforce.Controls.EventHandler(LoadMapFromFile); }
//////////////////////////////////////////////////////////////////////////// public TaskControls(Manager manager) : base(manager) { MinimumWidth = 340; MinimumHeight = 140; Height = 480; Center(); Text = "Controls Test"; TopPanel.Visible = true; Caption.Text = "Information"; Description.Text = "Demonstration of various controls available in Neoforce Controls library."; Caption.TextColor = Description.TextColor = new Color(96, 96, 96); grpEdit = new GroupPanel(Manager); grpEdit.Init(); grpEdit.Parent = this; grpEdit.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; grpEdit.Width = ClientWidth - 200; grpEdit.Height = 160; grpEdit.Left = 8; grpEdit.Top = TopPanel.Height + 8; grpEdit.Text = "EditBox"; pnlControls = new Panel(Manager); pnlControls.Init(); pnlControls.Passive = true; pnlControls.Parent = this; pnlControls.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; pnlControls.Left = 8; pnlControls.Top = grpEdit.Top + grpEdit.Height + 8; pnlControls.Width = ClientWidth - 200; pnlControls.Height = BottomPanel.Top - 32 - pnlControls.Top; pnlControls.BevelBorder = BevelBorder.All; pnlControls.BevelMargin = 1; pnlControls.BevelStyle = BevelStyle.Etched; pnlControls.Color = Color.Transparent; lblEdit = new Label(manager); lblEdit.Init(); lblEdit.Parent = grpEdit; lblEdit.Left = 16; lblEdit.Top = 8; lblEdit.Text = "Testing field:"; lblEdit.Width = 128; lblEdit.Height = 16; txtEdit = new TextBox(manager); txtEdit.Init(); txtEdit.Parent = grpEdit; txtEdit.Left = 16; txtEdit.Top = 24; txtEdit.Width = grpEdit.ClientWidth - 32; txtEdit.Height = 20; txtEdit.Anchor = Anchors.Left | Anchors.Top | Anchors.Right | Anchors.Bottom; txtEdit.Text = "Text"; rdbNormal = new RadioButton(manager); rdbNormal.Init(); rdbNormal.Parent = grpEdit; rdbNormal.Left = 16; rdbNormal.Top = 52; rdbNormal.Width = grpEdit.ClientWidth - 32; rdbNormal.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right; rdbNormal.Checked = true; rdbNormal.Text = "Normal mode"; rdbNormal.ToolTip.Text = "Enables normal mode for TextBox control."; rdbNormal.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(ModeChanged); rdbPassword = new RadioButton(manager); rdbPassword.Init(); rdbPassword.Parent = grpEdit; rdbPassword.Left = 16; rdbPassword.Top = 68; rdbPassword.Width = grpEdit.ClientWidth - 32; rdbPassword.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right; rdbPassword.Checked = false; rdbPassword.Text = "Password mode"; rdbPassword.ToolTip.Text = "Enables password mode for TextBox control."; rdbPassword.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(ModeChanged); chkBorders = new CheckBox(manager); chkBorders.Init(); chkBorders.Parent = grpEdit; chkBorders.Left = 16; chkBorders.Top = 96; chkBorders.Width = grpEdit.ClientWidth - 32; chkBorders.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right; chkBorders.Checked = false; chkBorders.Text = "Borderless mode"; chkBorders.ToolTip.Text = "Enables or disables borderless mode for TextBox control."; chkBorders.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(chkBorders_CheckedChanged); chkReadOnly = new CheckBox(manager); chkReadOnly.Init(); chkReadOnly.Parent = grpEdit; chkReadOnly.Left = 16; chkReadOnly.Top = 110; chkReadOnly.Width = grpEdit.ClientWidth - 32; chkReadOnly.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right; chkReadOnly.Checked = false; chkReadOnly.Text = "Read only mode"; chkReadOnly.ToolTip.Text = "Enables or disables read only mode for TextBox control.\nThis mode is necessary to enable explicitly."; chkReadOnly.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(chkReadOnly_CheckedChanged); string[] colors = new string[] {"Red", "Green", "Blue", "Yellow", "Orange", "Purple", "White", "Black", "Magenta", "Cyan", "Brown", "Aqua", "Beige", "Coral", "Crimson", "Gray", "Azure", "Ivory", "Indigo", "Khaki", "Orchid", "Plum", "Salmon", "Silver", "Gold", "Pink", "Linen", "Lime", "Olive", "Slate"}; spnMain = new SpinBox(manager, SpinBoxMode.List); spnMain.Init(); spnMain.Parent = pnlControls; spnMain.Left = 16; spnMain.Top = 16; spnMain.Width = pnlControls.Width - 32; spnMain.Height = 20; spnMain.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; spnMain.Items.AddRange(colors); spnMain.Mode = SpinBoxMode.Range; spnMain.ItemIndex = 0; cmbMain = new ComboBox(manager); cmbMain.Init(); cmbMain.Parent = pnlControls; cmbMain.Left = 16; cmbMain.Top = 44; cmbMain.Width = pnlControls.Width - 32; cmbMain.Height = 20; cmbMain.ReadOnly = true; cmbMain.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; cmbMain.Items.AddRange(colors); cmbMain.ItemIndex = 0; cmbMain.MaxItems = 5; cmbMain.ToolTip.Color = Color.Yellow; cmbMain.Movable = cmbMain.Resizable = true; cmbMain.OutlineMoving = cmbMain.OutlineResizing = true; trkMain = new TrackBar(manager); trkMain.Init(); trkMain.Parent = pnlControls; trkMain.Left = 16; trkMain.Top = 72; trkMain.Width = pnlControls.Width - 32; trkMain.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; trkMain.Range = 64; trkMain.Value = 16; trkMain.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(trkMain_ValueChanged); lblTrack = new Label(manager); lblTrack.Init(); lblTrack.Parent = pnlControls; lblTrack.Left = 16; lblTrack.Top = 96; lblTrack.Width = pnlControls.Width - 32; lblTrack.Anchor = Anchors.Left | Anchors.Top | Anchors.Right; lblTrack.Alignment = Alignment.TopRight; lblTrack.TextColor = new Color(32, 32, 32); trkMain_ValueChanged(this, null); // forcing label redraw with init values mnuListBox = new ContextMenu(manager); MenuItem i1 = new MenuItem("This is very long text"); MenuItem i2 = new MenuItem("Menu", true); MenuItem i3 = new MenuItem("Item", false); //i3.Enabled = false; MenuItem i4 = new MenuItem("Separated", true); MenuItem i11 = new MenuItem(); MenuItem i12 = new MenuItem(); MenuItem i13 = new MenuItem(); MenuItem i14 = new MenuItem(); MenuItem i111 = new MenuItem(); MenuItem i112 = new MenuItem(); MenuItem i113 = new MenuItem(); mnuListBox.Items.AddRange(new MenuItem[]{i1,i2, i3, i4}); i2.Items.AddRange(new MenuItem[] { i11, i12, i13, i14 }); i13.Items.AddRange(new MenuItem[] { i111, i112, i113 }); lstMain = new ListBox(manager); lstMain.Init(); lstMain.Parent = this; lstMain.Top = TopPanel.Height + 8; lstMain.Left = grpEdit.Left + grpEdit.Width + 8; lstMain.Width = ClientWidth - lstMain.Left - 8; lstMain.Height = ClientHeight - 16 - BottomPanel.Height - TopPanel.Height; lstMain.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom; lstMain.HideSelection = false; lstMain.Items.AddRange(colors); lstMain.ContextMenu = mnuListBox; prgMain = new ProgressBar(manager); prgMain.Init(); prgMain.Parent = this.BottomPanel; prgMain.Left = lstMain.Left; prgMain.Top = 10; prgMain.Width = lstMain.Width; prgMain.Height = 16; prgMain.Anchor = Anchors.Top | Anchors.Right; prgMain.Mode = ProgressBarMode.Infinite; prgMain.Passive = false; btnDisable = new Button(manager); btnDisable.Init(); btnDisable.Parent = BottomPanel; btnDisable.Left = 8; btnDisable.Top = 8; btnDisable.Text = "Disable"; btnDisable.Click += new Controls.EventHandler(btnDisable_Click); btnDisable.TextColor = Color.FromNonPremultiplied(255, 64, 32, 200); btnProgress = new Button(manager); btnProgress.Init(); btnProgress.Parent = BottomPanel; btnProgress.Left = prgMain.Left - 16; btnProgress.Top = prgMain.Top; btnProgress.Height = 16; btnProgress.Width = 16; btnProgress.Text = "!"; btnProgress.Anchor = Anchors.Top | Anchors.Right; btnProgress.Click += new Controls.EventHandler(btnProgress_Click); mnuMain = new MainMenu(manager); mnuMain.Items.Add(i2); mnuMain.Items.Add(i13); mnuMain.Items.Add(i3); mnuMain.Items.Add(i4); MainMenu = mnuMain; ToolBarPanel tlp = new ToolBarPanel(manager); ToolBarPanel = tlp; ToolBar tlb = new ToolBar(manager); ToolBar tlbx = new ToolBar(manager); tlb.FullRow = true; tlbx.Row = 1; tlbx.FullRow = false; tlp.Add(tlb); tlp.Add(tlbx); /* tlb.Init(); tlb.Width = 256; tlb.Parent = ToolBarPanel;*/ //tlbx.Init(); /* tlbx.Width = 512; tlbx.Top = 25; tlbx.Parent = ToolBarPanel;*/ /* ToolBarButton tb1 = new ToolBarButton(manager); tb1.Init(); tb1.Parent = tlb; tb1.Left = 10; tb1.Top = 1; tb1.Glyph = new Glyph(Manager.Skin.Images["Icon.Warning"].Resource); tb1.Glyph.SizeMode = SizeMode.Stretched; */ StatusBar stb = new StatusBar(Manager); StatusBar = stb; DefaultControl = txtEdit; OutlineMoving = true; OutlineResizing = true; BottomPanel.BringToFront(); SkinChanged += new TomShane.Neoforce.Controls.EventHandler(TaskControls_SkinChanged); TaskControls_SkinChanged(null, null); }
public static void makePopup(UserInterface ui, opt[] options, String title = "Hey! Listen!", ConfirmDelegate action = null) { Manager manager = ui.game.Manager; bool confirmed = false; object[] answer = new object[options.Length]; bool[] answered = new bool[options.Length]; ConfirmDelegate emptyDelegate = delegate{ return true;}; action = action ?? emptyDelegate; Dialog window = new Dialog(manager); window.Text = title; window.Init(); window.ShowModal(); window.Caption.Text = ""; window.Description.Text = ""; window.Width = 200; window.Height = 200; window.SetPosition(20, OrbIt.ScreenHeight / 4); int heightCounter = window.Caption.Top; int i = 0; Button btnOk = new Button(manager); btnOk.Top = window.Description.Top + window.Description.Height; btnOk.Anchor = Anchors.Top; btnOk.Parent = window; btnOk.Text = "Ok"; btnOk.Left = btnOk.Left = window.Width / 2 - btnOk.Width / 2; btnOk.Init(); foreach (opt opt in options) { if (opt.type.In(OptType.info,OptType.prompt)) { Label info = new Label(manager); info.Init(); info.Parent = window; info.Left = VertPadding; info.Width = window.Width - VertPadding * 5; string message = ((string)opt.content).wordWrap(MAX_CHARS_PER_LINE); info.Text = message; info.Height = (info.Text.Count(x => x == '\n')+1) * info.Height; info.Top = heightCounter; heightCounter += info.Height + VertPadding; } if (opt.type == OptType.dropDown) { ComboBox cbBox = new ComboBox(manager); cbBox.Init(); cbBox.Parent = window; cbBox.MaxItems = 20; // TODO : ERROR? cbBox.Width = window.Width - VertPadding * 5; cbBox.Left = VertPadding; cbBox.Top = heightCounter; heightCounter += cbBox.Height + VertPadding; ObservableCollection<object> q = (ObservableCollection<object>)opt.content; foreach (object o in q) cbBox.Items.Add(o); q.CollectionChanged += delegate(object s, NotifyCollectionChangedEventArgs e) { cbBox.Items.syncToOCDelegate(e); }; int qq = i; answer[qq] = null; cbBox.ItemIndexChanged += delegate { answer[qq] = (cbBox.Items.ElementAt(cbBox.ItemIndex)); }; cbBox.ItemIndexChanged += opt.action; } if (opt.type == OptType.textBox) { TextBox tbName = new TextBox(manager); tbName.Init(); tbName.Parent = window; tbName.Width = window.Width - VertPadding * 5; tbName.Left = VertPadding; tbName.Top = heightCounter; heightCounter += tbName.Height + VertPadding; int qq = i; answer[qq] = null; tbName.TextChanged += delegate { answer[qq] = tbName.Text; }; tbName.KeyUp += delegate(object sender, KeyEventArgs e) { if (e.Key == Keys.Enter) { confirmed = true; if (action(true, answer)) window.Close(); } }; tbName.TextChanged += opt.action; } if (opt.type == OptType.radialButton) { GroupPanel gp = new GroupPanel(manager); gp.Init(); gp.Parent = window; gp.Width = window.Width - VertPadding * 5; gp.Left = VertPadding; int qq = i; answer[qq] = -1; for (int j = 0; j < ((string[])opt.content).Length; j++) { RadioButton rb = new RadioButton(manager); rb.Init(); rb.Parent = gp; rb.Text = (string)opt.content; int jj = j; rb.Click += delegate { answer[qq] = jj; }; rb.Click += opt.action; } gp.Top = heightCounter; heightCounter += gp.Height + VertPadding; } if (opt.type == OptType.checkBox) { CheckBox cb = new CheckBox(manager); cb.Init(); cb.Parent = window; cb.Width = window.Width - VertPadding * 5; cb.Left = VertPadding; cb.Top = heightCounter; heightCounter += cb.Height + VertPadding; int qq = i; answer[qq] = false; cb.Text = (string)opt.content; cb.Click += delegate { answer[qq] = cb.Checked; }; cb.Click += opt.action; } i++; } if (options.Any<opt>(x => x.type != OptType.info)) { btnOk.Left = VertPadding; Button btnCancel = new Button(manager); btnCancel.Init(); btnCancel.Parent = window; btnCancel.Top = heightCounter; btnCancel.Text = "Cancel"; btnCancel.Left = VertPadding * 2 + btnOk.Width; btnCancel.Click += delegate { window.Close(); action(false, answer); }; } btnOk.Click += delegate { confirmed = true; window.Close(ModalResult.Cancel); bool res = action(true, answer); if (!res) { window.Show(); }; }; btnOk.Top = heightCounter; window.Closing += delegate { if (confirmed == false) action(false, answer); }; window.Height = (btnOk.Top) + 70; manager.Add(window); }