コード例 #1
0
		////////////////////////////////////////////////////////////////////////////   


		////////////////////////////////////////////////////////////////////////////
		private void InitRes()
		{
			pnlRes = new SideBarPanel(Manager);
			pnlRes.Init();
			pnlRes.Passive = true;
			pnlRes.Parent = sidebar;
			pnlRes.Left = 16;
			pnlRes.Top = 16;
			pnlRes.Width = sidebar.Width - pnlRes.Left;
			pnlRes.Height = 86;
			pnlRes.CanFocus = false;

			rdbRes1024 = new RadioButton(Manager);
			rdbRes1024.Init();
			rdbRes1024.Parent = pnlRes;
			rdbRes1024.Left = 8;
			rdbRes1024.Width = pnlRes.Width - rdbRes1024.Left * 2;
			rdbRes1024.Height = 16;
			rdbRes1024.Text = "Resolution 1024x768";
			rdbRes1024.Top = 8;
			rdbRes1024.Checked = true;

			rdbRes1280 = new RadioButton(Manager);
			rdbRes1280.Init();
			rdbRes1280.Parent = pnlRes;
			rdbRes1280.Left = rdbRes1024.Left;
			rdbRes1280.Width = rdbRes1024.Width;
			rdbRes1280.Height = rdbRes1024.Height;
			rdbRes1280.Text = "Resolution 1280x1024";
			rdbRes1280.Top = 24;

			rdbRes1680 = new RadioButton(Manager);
			rdbRes1680.Init();
			rdbRes1680.Parent = pnlRes;
			rdbRes1680.Left = rdbRes1024.Left;
			rdbRes1680.Width = rdbRes1024.Width;
			rdbRes1680.Height = rdbRes1024.Height;
			rdbRes1680.Text = "Resolution 1680x1050";
			rdbRes1680.Top = 40;

			chkResFull = new CheckBox(Manager);
			chkResFull.Parent = pnlRes;
			chkResFull.Init();
			chkResFull.Left = rdbRes1024.Left;
			chkResFull.Width = rdbRes1024.Width;
			chkResFull.Height = rdbRes1024.Height;
			chkResFull.Text = "Fullscreen Mode";
			chkResFull.Top = 64;

			btnApply = new Button(Manager);
			btnApply.Init();
			btnApply.Width = 80;
			btnApply.Parent = sidebar;
			btnApply.Left = pnlRes.Left;
			btnApply.Top = pnlRes.Top + pnlRes.Height + 8;
			btnApply.Text = "Apply";
			btnApply.Click += new Controls.EventHandler(btnApply_Click);

			btnExit = new Button(Manager);
			btnExit.Init();
			btnExit.Width = 80;
			btnExit.Parent = sidebar;
			btnExit.Left = btnApply.Left + btnApply.Width + 8;
			btnExit.Top = pnlRes.Top + pnlRes.Height + 8;
			btnExit.Text = "Exit";
			btnExit.Click += new Controls.EventHandler(btnExit_Click);
		}
コード例 #2
0
		////////////////////////////////////////////////////////////////////////////

		////////////////////////////////////////////////////////////////////////////    
		private void InitSkins()
		{
			pnlSkin = new SideBarPanel(Manager);
			pnlSkin.Init();
			pnlSkin.Passive = true;
			pnlSkin.Parent = sidebar;
			pnlSkin.Left = 16;
			pnlSkin.Width = sidebar.Width - pnlRes.Left;
			pnlSkin.Height = 44;
			pnlSkin.Top = ClientHeight - 16 - pnlStats.Height - pnlSkin.Height - 16;
			pnlSkin.Anchor = Anchors.Left | Anchors.Bottom;
			pnlSkin.CanFocus = false;

			rdbDefault = new RadioButton(Manager);
			rdbDefault.Init();
			rdbDefault.Parent = pnlSkin;
			rdbDefault.Left = 8;
			rdbDefault.Width = pnlSkin.Width - rdbDefault.Left * 2;
			rdbDefault.Height = 16;
			rdbDefault.Text = "Default Skin";
			rdbDefault.Top = 8;
			rdbDefault.Checked = Manager.Skin.Name == "Default";
			rdbDefault.Click += new Controls.EventHandler(rdbDefault_Click);

			rdbGreen = new RadioButton(Manager);
			rdbGreen.Init();
			rdbGreen.Parent = pnlSkin;
			rdbGreen.Left = 8;
			rdbGreen.Width = pnlSkin.Width - rdbGreen.Left * 2;
			rdbGreen.Height = 16;
			rdbGreen.Text = "Green Skin";
			rdbGreen.Top = 24;
			rdbGreen.Checked = Manager.Skin.Name == "Green";
			rdbGreen.Click += new Controls.EventHandler(rdbGreen_Click);
			rdbGreen.Enabled = true;
		}
コード例 #3
0
ファイル: Options.cs プロジェクト: AlanFoster/Game-of-Life
        public override void Initialize()
        {
            base.Initialize();
            ScreenResolutions = new List<RadioButton>();
            var top = 50;
            var exit = new Button(ControlManager.Manager)
                           {Text = "Back to previous screen", Left = 50, Top = top, Width = 200, Height = 50};
            exit.Init();
            ControlManager.Add(exit);
            exit.Click += (sender, args) => ScreenManager.SwapScreens(this, Constants.ScreenNames.MainMenu);

            var panel = new Panel(ControlManager.Manager) {Width = 856, Height = 467, Left = 300, Top = 50 };
            panel.Init();
            ControlManager.Add(panel);

            var resLabel = new Label(ControlManager.Manager) {Text = "Screen Resolution:", Top = top, Left = 20, Width = 250};
            resLabel.Init();
            panel.Add(resLabel);

            top += 50;

            resolutionPanel = new Panel(ControlManager.Manager)
                                      {Color = Color.Gray, Width = 300, Height = 150, Top = 70, Left = 50, Parent = panel, AutoScroll = true};
            resolutionPanel.Init();
            var resTop = 10;

            DisplayMode current = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Where(i => i.Format == SurfaceFormat.Color && i.Width >= 1224))
            {
                if (mode.Width > current.Width)
                    FullScreenResolution = mode;

                var option = new RadioButton(ControlManager.Manager) { Text = String.Format("{0}x{1}", mode.Width, mode.Height), Width = 200, Left = 50, Top = resTop, Parent = resolutionPanel};
                option.Checked = mode.Width == GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width && mode.Height == GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                int x = mode.Width;
                int y = mode.Height;
                option.Click += (sender, args) => ApplyResolution(x, y);
                resTop += 30;
                option.Init();
                current = mode;
                ScreenResolutions.Add(option);
            }

            top += resolutionPanel.Height;

            var fullScreenModeLabel = new Label(ControlManager.Manager) { Text = "Full Screen Mode:", Top = top, Left = resLabel.Left, Parent = panel, Width = 200 };
            fullScreenModeLabel.Init();

            top += fullScreenModeLabel.Height;

            var fullScreenPanel = new Panel(ControlManager.Manager) { Color = Color.Gray, Width = resolutionPanel.Width, Height = 50, Top = top, Left = resolutionPanel.Left, Parent = panel };
            fullScreenPanel.Init();

            top += fullScreenModeLabel.Height;

            String OnOff = Application.Graphics.IsFullScreen ? "On" : "Off";
            var fullScreenIndicator = new RadioButton(ControlManager.Manager) { Top = top, Left = 100, Width = 200, Parent = panel, Text = "Full Screen: " + OnOff, Checked = Application.Graphics.IsFullScreen };
            fullScreenIndicator.Click += (sender, args) => FullScreenMode(fullScreenIndicator);
            fullScreenIndicator.Init();

            top += fullScreenPanel.Height;

            var backgroundSoundLabel = new Label(ControlManager.Manager) { Text = "Background Volume:", Top = top, Left = 20, Width = 250 };
            backgroundSoundLabel.Init();
            panel.Add(backgroundSoundLabel);
            top += backgroundSoundLabel.Height;

            var backgroundVolumePercentage = new Label(ControlManager.Manager) { Text = "50%", Top = top, Left = 480, Width = 250 };
            backgroundVolumePercentage.Init();
            panel.Add(backgroundVolumePercentage);

            var backgroundVolume = new TrackBar(ControlManager.Manager) {Width = 400, Top = top, Left = 50};
            backgroundVolume.Init();
            panel.Add(backgroundVolume);
            backgroundVolume.Value = 50;
            backgroundVolume.ValueChanged += (sender, args) => ChangeBackgroundVolume(backgroundVolumePercentage, backgroundVolume.Value);
            top += 20;

            var soundEffectsLabel = new Label(ControlManager.Manager) { Text = "Effects Volume:", Top = top, Left = 20, Width = 250 };
            soundEffectsLabel.Init();
            panel.Add(soundEffectsLabel);
            top += 20;

            var effectsVolumePercentage = new Label(ControlManager.Manager) { Text = "50%", Top = top, Left = 480, Width = 250 };
            backgroundVolumePercentage.Init();
            panel.Add(effectsVolumePercentage);

            var effectsVolume = new TrackBar(ControlManager.Manager) {Width = 400, Top = top, Left = 50 };
            effectsVolume.Init();
            panel.Add(effectsVolume);
            effectsVolume.Value = 50;
            effectsVolume.ValueChanged += (sender, args) => ChangeEffectsVolume(effectsVolumePercentage, effectsVolume.Value);
        }
コード例 #4
0
ファイル: Forms.cs プロジェクト: Eamnon/Emergence
        public void GuiInitialize(Manager manager, GraphicsDeviceManager graphics)
        {
            // Create and setup Window control.
            BottomBar = new Window(manager);
            BottomBar.Init();
            BottomBar.Width = graphics.PreferredBackBufferWidth;
            BottomBar.Height = 100;
            BottomBar.Top = graphics.PreferredBackBufferHeight - BottomBar.Height;
            BottomBar.Left = 0;
            BottomBar.BorderVisible = false;
            BottomBar.Movable = false;
            BottomBar.Resizable = false;
            BottomBar.Visible = true;

            // Create Alert Text
            textbox = new TextBox(manager);
            textbox.Init();
            textbox.Text = "In philosophy and science, emergence is the way complex systems and patterns arise out of a multiplicity of relatively simple interactions.";
            textbox.Width = 830;
            textbox.Height = 20;
            textbox.ReadOnly = true;
            textbox.Passive = true;
            textbox.Left = (1024 / 2) - (textbox.Width / 2);
            textbox.Top = 0;
            textbox.Parent = BottomBar;

            #region BottomBar
            // Create Tool Select.
            radStimulant = new RadioButton(manager);
            radStimulant.Init();
            radStimulant.Parent = BottomBar;
            radStimulant.Left = (1024 / 2) - (textbox.Width / 2);
            radStimulant.Top = 30;
            radStimulant.Width = 100;
            radStimulant.Height = 16;
            radStimulant.Text = "Stimulant";
            radStimulant.Checked = false;
            radStimulant.Click += new MouseEventHandler(Tool_Click);

            radPoison = new RadioButton(manager);
            radPoison.Init();
            radPoison.Parent = BottomBar;
            radPoison.Left = (1024 / 2) - (textbox.Width / 2) + 110;
            radPoison.Top = 30;
            radPoison.Width = 100;
            radPoison.Height = 16;
            radPoison.Text = "Poison";
            radPoison.Checked = false;
            radPoison.Click += new MouseEventHandler(Tool_Click);

            radMutigen = new RadioButton(manager);
            radMutigen.Init();
            radMutigen.Parent = BottomBar;
            radMutigen.Left = (1024 / 2) - (textbox.Width / 2) + 220;
            radMutigen.Top = 30;
            radMutigen.Width = 100;
            radMutigen.Height = 16;
            radMutigen.Text = "Mutigen";
            radMutigen.Checked = false;
            radMutigen.Click += new MouseEventHandler(Tool_Click);

            radGrab = new RadioButton(manager);
            radGrab.Init();
            radGrab.Parent = BottomBar;
            radGrab.Left = (1024 / 2) - (textbox.Width / 2) + 330;
            radGrab.Top = 30;
            radGrab.Width = 100;
            radGrab.Height = 16;
            radGrab.Text = "Grab";
            radGrab.Checked = true;
            radGrab.Click += new MouseEventHandler(Tool_Click);

            // Create Settings button.
            btnSettings = new Button(manager);
            btnSettings.Init();
            btnSettings.Text = "Settings";
            btnSettings.Width = 72;
            btnSettings.Height = 24;
            btnSettings.Left = 10;
            btnSettings.Top = 10;
            btnSettings.Anchor = Anchors.Bottom;
            btnSettings.Parent = BottomBar;
            btnSettings.Click += new MouseEventHandler(btnSettings_Click);

            // Create Sample button.
            btnSample = new Button(manager);
            btnSample.Init();
            btnSample.Text = "Sample";
            btnSample.Width = 72;
            btnSample.Height = 24;
            btnSample.Left = 10;
            btnSample.Top = 44;
            btnSample.Anchor = Anchors.Bottom;
            btnSample.Parent = BottomBar;
            btnSample.Click += new MouseEventHandler(btnSample_Click);

            // Create Edit button.
            btnEdit = new Button(manager);
            btnEdit.Init();
            btnEdit.Text = "Edit";
            btnEdit.Width = 72;
            btnEdit.Height = 24;
            btnEdit.Left = textbox.Left + textbox.Width - btnEdit.Width;
            btnEdit.Top = textbox.Top + textbox.Height + 10;
            btnEdit.Anchor = Anchors.Bottom;
            btnEdit.Parent = BottomBar;
            btnEdit.Click += new MouseEventHandler(btnEdit_Click);

            // Create Save Button.
            btnSave = new Button(manager);
            btnSave.Init();
            btnSave.Text = "Save";
            btnSave.Width = 72;
            btnSave.Height = 24;
            btnSave.Left = 1024 - btnSave.Width - 10;
            btnSave.Top = 10;
            btnSave.Anchor = Anchors.Bottom;
            btnSave.Parent = BottomBar;

            // Create Load Button.
            btnLoad = new Button(manager);
            btnLoad.Init();
            btnLoad.Text = "Load";
            btnLoad.Width = 72;
            btnLoad.Height = 24;
            btnLoad.Left = 1024 - btnLoad.Width - 10;
            btnLoad.Top = 44;
            btnLoad.Anchor = Anchors.Bottom;
            btnLoad.Parent = BottomBar;
            #endregion

            #region SettingsPane
            //Create Settings Pane
            wndSettings = new Window(manager);
            wndSettings.Init();
            wndSettings.Text = "Settings";
            wndSettings.Width = 400;
            wndSettings.Height = 300;
            wndSettings.Top = 20;
            wndSettings.Left = 20;
            wndSettings.Resizable = false;
            wndSettings.Visible = false;

            //Create Environment settings

            lblMutRate = new Label(manager);
            lblMutRate.Init();
            lblMutRate.Parent = wndSettings;
            lblMutRate.Left = 10;
            lblMutRate.Top = 10;
            lblMutRate.Text = "Mutation rate:";
            lblMutRate.Width = 130;
            lblMutRate.Height = 20;

            spnMutRate = new SpinBox(manager, SpinBoxMode.Range);
            spnMutRate.Init();
            spnMutRate.ReadOnly = true;
            spnMutRate.Width = 60;
            spnMutRate.Height = 20;
            spnMutRate.Top = 30;
            spnMutRate.Left = 10;
            spnMutRate.Maximum = 10;
            spnMutRate.Minimum = 0;
            spnMutRate.Rounding = 0;
            spnMutRate.Value = Game1.Globals.MutationRate;
            spnMutRate.Step = 1;
            spnMutRate.Passive = true;
            spnMutRate.Text = Convert.ToString(spnMutRate.Value);
            spnMutRate.Parent = wndSettings;

            lblSolar = new Label(manager);
            lblSolar.Init();
            lblSolar.Parent = wndSettings;
            lblSolar.Left = 10;
            lblSolar.Top = 60;
            lblSolar.Text = "Solar Radiation:";
            lblSolar.Width = 130;
            lblSolar.Height = 20;

            spnSolar = new SpinBox(manager, SpinBoxMode.Range);
            spnSolar.Init();
            spnSolar.ReadOnly = true;
            spnSolar.Width = 60;
            spnSolar.Height = 20;
            spnSolar.Top = 80;
            spnSolar.Left = 10;
            spnSolar.Maximum = 10;
            spnSolar.Minimum = 0;
            spnSolar.Rounding = 0;
            spnSolar.Step = 1;
            spnSolar.Value = Game1.Globals.SolarIntensity;
            spnSolar.Passive = true;
            spnSolar.Text = Convert.ToString(spnSolar.Value);
            spnSolar.Parent = wndSettings;

            lblLifeSpan = new Label(manager);
            lblLifeSpan.Init();
            lblLifeSpan.Parent = wndSettings;
            lblLifeSpan.Left = 10;
            lblLifeSpan.Top = 110;
            lblLifeSpan.Text = "Life in Mins:";
            lblLifeSpan.Width = 130;
            lblLifeSpan.Height = 20;

            spnLifeSpan = new SpinBox(manager, SpinBoxMode.Range);
            spnLifeSpan.Init();
            spnLifeSpan.ReadOnly = true;
            spnLifeSpan.Width = 60;
            spnLifeSpan.Height = 20;
            spnLifeSpan.Top = 130;
            spnLifeSpan.Left = 10;
            spnLifeSpan.Maximum = 30;
            spnLifeSpan.Minimum = 0;
            spnLifeSpan.Rounding = 0;
            spnLifeSpan.Step = 1;
            spnLifeSpan.Value = Game1.Globals.SymetLifespan;
            spnLifeSpan.Passive = true;
            spnLifeSpan.Text = Convert.ToString(spnLifeSpan.Value);
            spnLifeSpan.Parent = wndSettings;

            lblSpeed = new Label(manager);
            lblSpeed.Init();
            lblSpeed.Parent = wndSettings;
            lblSpeed.Left = 10;
            lblSpeed.Top = 160;
            lblSpeed.Text = "Game Speed:";
            lblSpeed.Width = 130;
            lblSpeed.Height = 20;

            spnSpeed = new SpinBox(manager, SpinBoxMode.Range);
            spnSpeed.Init();
            spnSpeed.ReadOnly = true;
            spnSpeed.Width = 60;
            spnSpeed.Height = 20;
            spnSpeed.Top = 180;
            spnSpeed.Left = 10;
            spnSpeed.Maximum = 10;
            spnSpeed.Minimum = 0;
            spnSpeed.Rounding = 0;
            spnSpeed.Step = 1;
            spnSpeed.Value = Game1.Globals.SymetSpeed;
            spnSpeed.Text = Convert.ToString(spnSpeed.Value);
            spnSpeed.Passive = true;
            spnSpeed.Parent = wndSettings;

            // Create Done Button.
            btnSettingsClose = new Button(manager);
            btnSettingsClose.Init();
            btnSettingsClose.Text = "Done";
            btnSettingsClose.Width = 72;
            btnSettingsClose.Height = 24;
            btnSettingsClose.Left = 400 - 92;
            btnSettingsClose.Top = 300 - 64;
            btnSettingsClose.Anchor = Anchors.Bottom;
            btnSettingsClose.Parent = wndSettings;
            btnSettingsClose.Click += new MouseEventHandler(btnDone_Click);
            #endregion

            // Add the window controls to the manager processing queue.
            manager.Add(BottomBar);
            manager.Add(wndSettings);
        }
コード例 #5
0
ファイル: Options.cs プロジェクト: AlanFoster/Game-of-Life
        private void FullScreenMode(RadioButton fullScreenIndicator)
        {
            Application.Graphics.PreferredBackBufferWidth =
                    Application.Graphics.IsFullScreen ? 1225 : GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            Application.Graphics.PreferredBackBufferHeight =
                Application.Graphics.IsFullScreen ? 550 : GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;

            Application.Graphics.ToggleFullScreen();

            Application.Graphics.ApplyChanges();

            RecalculatePosition();

            resolutionPanel.Enabled = Application.Graphics.IsFullScreen;

            foreach (var screenResolution in ScreenResolutions.Where(i => i.Text == FullScreenResolution.Width + "x" +
                                           FullScreenResolution.Height && Application.Graphics.IsFullScreen).ToArray())
                screenResolution.Checked = true;

            fullScreenIndicator.Checked = Application.Graphics.IsFullScreen;
            fullScreenIndicator.Text = Application.Graphics.IsFullScreen ? "Full Screen: On" : "Full Screen: Off";
        }
コード例 #6
0
        ////////////////////////////////////////////////////////////////////////////   
        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);
        }
コード例 #7
0
        public void InitializeSecondPage()
        {
            stackview = new StackView();
            TabPage second = tbcMain.TabPages[1];
            second.Text = "Links";

            backPanel = new Panel(manager);
            backPanel.Height = second.Height;
            backPanel.Width = second.Width;
            //backPanel.Width = second.Width + 20;
            backPanel.AutoScroll = true;
            backPanel.Init();
            //backPanel.Color = master.BackColor;
            second.Add(backPanel);

            HeightCounter3 = 0;
            VertPadding3 = 0;

            SourceTarget = new CollapsePanel(manager, backPanel, "Source      |   Target"); stackview.AddPanel(SourceTarget);
            LinkPalette = new CollapsePanel(manager, backPanel, "Link Palette"); stackview.AddPanel(LinkPalette);
            //c3 = new CollapsePanel(manager, backPanel, "third", extended: false); stackview.AddPanel(c3);
            //c4 = new CollapsePanel(manager, backPanel, "fourth", extended: false); stackview.AddPanel(c4);
            //c5 = new CollapsePanel(manager, backPanel, "fifth", extended: false); stackview.AddPanel(c5);
            //c6 = new CollapsePanel(manager, backPanel, "sixth", extended: false); stackview.AddPanel(c6);
            //c7 = new CollapsePanel(manager, backPanel, "seventh", extended: false); stackview.AddPanel(c7);
            //c8 = new CollapsePanel(manager, backPanel, "eighth", extended: false); stackview.AddPanel(c8);

            backPanel.Color = UserInterface.TomDark;

            tbcMain.SelectedPage = tbcMain.TabPages[1];

            #region /// Source | Target ///

            int left = backPanel.Left;
            int middle = backPanel.Left + backPanel.Width / 2 - 15;
            int right = backPanel.Width - 15;

            SourceTarget.ExpandedHeight += 60;

            #region /// Source Side ///

            lblSource = new Label(manager);
            lblSource.Init();
            lblSource.Left = left;
            lblSource.Top = HeightCounter3; HeightCounter3 += lblSource.Height + VertPadding3;
            lblSource.Text = "   Source";
            lblSource.Parent = SourceTarget.panel;

            lblGroupS = new Label(manager);
            lblGroupS.Init();
            lblGroupS.Left = left;
            lblGroupS.Top = HeightCounter3; HeightCounter3 += lblGroupS.Height + VertPadding3;
            lblGroupS.Text = "Group";
            lblGroupS.Parent = SourceTarget.panel;

            cbGroupS = new ComboBox(manager);
            cbGroupS.Init();
            cbGroupS.Left = left;
            cbGroupS.Top = HeightCounter3; HeightCounter3 += cbGroupS.Height + VertPadding3;
            cbGroupS.Width = middle;
            cbGroupS.Parent = SourceTarget.panel;
            cbGroupS.ItemIndexChanged += cbGroupS_ItemIndexChanged;
            cbGroupS.MaxItems = 100;

            lblNodeS = new Label(manager);
            lblNodeS.Init();
            lblNodeS.Left = left;
            lblNodeS.Top = HeightCounter3; HeightCounter3 += lblNodeS.Height + VertPadding3;
            lblNodeS.Text = "Node";
            lblNodeS.Parent = SourceTarget.panel;

            cbNodeS = new ComboBox(manager);
            cbNodeS.Init();
            cbNodeS.Left = left;
            cbNodeS.Top = HeightCounter3; HeightCounter3 += cbNodeS.Height + VertPadding3;
            cbNodeS.Width = middle;
            cbNodeS.Parent = SourceTarget.panel;

            GroupBox radioBoxSource = new GroupBox(manager);
            radioBoxSource.Init();
            radioBoxSource.Left = left;
            radioBoxSource.Top = HeightCounter3 - 7;
            radioBoxSource.Width = middle;
            radioBoxSource.Height = 75;
            radioBoxSource.Text = "";
            radioBoxSource.Parent = SourceTarget.panel;

            HeightCounter3 = 5;

            rdGroupS = new RadioButton(manager);
            rdGroupS.Init();
            rdGroupS.Left = left;
            rdGroupS.Top = HeightCounter3; HeightCounter3 += rdGroupS.Height + VertPadding3;
            rdGroupS.Width = middle;
            rdGroupS.Text = "Group";
            rdGroupS.Parent = radioBoxSource;
            rdGroupS.Click += rdGroupS_Click;

            rdNodeS = new RadioButton(manager);
            rdNodeS.Init();
            rdNodeS.Left = left;
            rdNodeS.Top = HeightCounter3; HeightCounter3 += rdNodeS.Height + VertPadding3;
            rdNodeS.Width = middle;
            rdNodeS.Text = "Node";
            rdNodeS.Parent = radioBoxSource;
            rdNodeS.Click += rdNodeS_Click;

            chSelectionS = new CheckBox(manager);
            chSelectionS.Init();
            chSelectionS.Left = left;
            chSelectionS.Top = HeightCounter3; HeightCounter3 += chSelectionS.Height + VertPadding3;
            chSelectionS.Width = middle;
            chSelectionS.Text = "Selection";
            chSelectionS.Parent = radioBoxSource;
            chSelectionS.Click += chSelectionS_Click;

            #endregion

            #region /// Target Side ///

            HeightCounter3 = 0;

            lblTarget = new Label(manager);
            lblTarget.Init();
            lblTarget.Left = middle;
            lblTarget.Top = HeightCounter3; HeightCounter3 += lblTarget.Height + VertPadding3;
            lblTarget.Text = "|   Target";
            lblTarget.Parent = SourceTarget.panel;

            lblGroupT = new Label(manager);
            lblGroupT.Init();
            lblGroupT.Left = middle;
            lblGroupT.Top = HeightCounter3; HeightCounter3 += lblGroupT.Height + VertPadding3;
            lblGroupT.Text = "Group";
            lblGroupT.Parent = SourceTarget.panel;

            cbGroupT = new ComboBox(manager);
            cbGroupT.Init();
            cbGroupT.Left = middle;
            cbGroupT.Top = HeightCounter3; HeightCounter3 += cbGroupT.Height + VertPadding3;
            cbGroupT.Width = middle;
            cbGroupT.Parent = SourceTarget.panel;
            cbGroupT.ItemIndexChanged += cbGroupT_ItemIndexChanged;
            cbGroupT.MaxItems = 100;

            lblNodeT = new Label(manager);
            lblNodeT.Init();
            lblNodeT.Left = middle;
            lblNodeT.Top = HeightCounter3; HeightCounter3 += lblNodeT.Height + VertPadding3;
            lblNodeT.Text = "Node";
            lblNodeT.Parent = SourceTarget.panel;

            cbNodeT = new ComboBox(manager);
            cbNodeT.Init();
            cbNodeT.Left = middle;
            cbNodeT.Top = HeightCounter3; HeightCounter3 += cbNodeT.Height + VertPadding3;
            cbNodeT.Width = middle;
            cbNodeT.Parent = SourceTarget.panel;

            GroupBox radioBoxTarget = new GroupBox(manager);
            radioBoxTarget.Init();
            radioBoxTarget.Left = middle;
            radioBoxTarget.Top = HeightCounter3 - 7;
            radioBoxTarget.Width = middle;
            radioBoxTarget.Height = 75;
            radioBoxTarget.Text = "";
            radioBoxTarget.Parent = SourceTarget.panel;

            HeightCounter3 = 5;

            rdGroupT = new RadioButton(manager);
            rdGroupT.Init();
            rdGroupT.Left = left;
            rdGroupT.Top = HeightCounter3; HeightCounter3 += rdGroupT.Height + VertPadding3;
            rdGroupT.Width = middle;
            rdGroupT.Text = "Group";
            rdGroupT.Parent = radioBoxTarget;
            rdGroupT.Click += rdGroupT_Click;

            rdNodeT = new RadioButton(manager);
            rdNodeT.Init();
            rdNodeT.Left = left;
            rdNodeT.Top = HeightCounter3; HeightCounter3 += rdNodeT.Height + VertPadding3;
            rdNodeT.Width = middle;
            rdNodeT.Text = "Node";
            rdNodeT.Parent = radioBoxTarget;
            rdNodeT.Click += rdNodeT_Click;

            chSelectionT = new CheckBox(manager);
            chSelectionT.Init();
            chSelectionT.Left = left;
            chSelectionT.Top = HeightCounter3; HeightCounter3 += chSelectionT.Height + VertPadding3;
            chSelectionT.Width = middle;
            chSelectionT.Text = "Selection";
            chSelectionT.Parent = radioBoxTarget;
            chSelectionT.Click += chSelectionT_Click;

            #endregion

            #endregion

            #region /// Link Palette ///

            LinkPalette.ExpandedHeight += 130;
            HeightCounter3 = 5;
            GroupPanel parent3 = LinkPalette.panel;

            cbLinkList = new ComboBox(manager);
            cbLinkList.Init();
            cbLinkList.Top = HeightCounter3; HeightCounter3 += cbLinkList.Height;
            cbLinkList.Left = 0;
            cbLinkList.Width = 150;
            cbLinkList.Parent = parent3;
            cbLinkList.Items.AddRange(new List<object>() { "Palette Links", "Source's Links", "Target's Links", "All Active Links" });
            cbLinkList.ItemIndexChanged += cbLinkList_ItemIndexChanged;

            btnCreateLink = new Button(manager);
            btnCreateLink.Init();
            btnCreateLink.Top = HeightCounter3; //HeightCounter3 += btnCreateLink.Height;
            btnCreateLink.Left = 0;
            btnCreateLink.Width = (parent3.Width - 10) / 2;
            btnCreateLink.Text = "Create Link";
            btnCreateLink.Parent = parent3;
            btnCreateLink.Click += btnCreateLink_Click;

            btnOpenGenerator = new Button(manager);
            btnOpenGenerator.Init();
            btnOpenGenerator.Top = HeightCounter3; HeightCounter3 += btnOpenGenerator.Height;
            btnOpenGenerator.Left = btnCreateLink.Width;
            btnOpenGenerator.Width = btnCreateLink.Width;
            btnOpenGenerator.Text = "Generator";
            btnOpenGenerator.Parent = parent3;
            btnOpenGenerator.Click += btnOpenGenerator_Click;

            insArea2 = new InspectorArea(this, parent3, 0, HeightCounter3);
            //insArea2.backPanel.AutoScroll = true;
            LinkPalette.ExpandedHeight = HeightCounter3 + insArea2.Height + 20;

            cbLinkList.ItemIndex = 0;

            rdGroupS.Checked = true;
            rdGroupT.Checked = true;
            rdGroupS_Click(null, null);
            rdGroupT_Click(null, null);

            #endregion

            backPanel.Refresh();
            tbcMain.SelectedPage = tbcMain.TabPages[0];
        }
コード例 #8
0
        public CreateGroupWindow(Sidebar sidebar)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            sidebar.CreatingGroup = true;
            //sidebar.ui.game.SwitchToTempRoom();
            //temproom = sidebar.ui.game.tempRoom;
            //tempgroup = g;// sidebar.ActiveGroup;//temproom.groups.generalGroups.childGroups.ElementAt(0).Value;

            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            int tomtom = 5;
            neoSidebar.ClientArea.BackColor = UserInterface.TomDark;
            neoSidebar.BackColor = Color.Black;
            neoSidebar.BevelBorder = BevelBorder.All;
            Margins tomtomtomtom = new Margins(tomtom, tomtom, tomtom, tomtom);
            neoSidebar.ClientMargins = tomtomtomtom;

            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = sidebar.Width;
            neoSidebar.Top = 0;
            neoSidebar.Height = OrbIt.ScreenHeight;
            //poop.Text = "Create Group";
            //poop.Closed += delegate { UserInterface.GameInputDisabled = false; sidebar.CreatingGroup = false; sidebar.ui.game.SwitchToMainRoom(); sidebar.groupsView.createGroupWindow = null; };
            //window.ShowModal();
            manager.Add(neoSidebar);

            int width = 120;
            int offset = neoSidebar.Width - width - 20;

            TitlePanel titlePanelCreateGroup = new TitlePanel(sidebar, neoSidebar, "Create Group", true);
            titlePanelCreateGroup.btnBack.Click += (s, e) => Close();

            HeightCounter += titlePanelCreateGroup.Height;

            Label lblName = new Label(manager);
            lblName.Init();
            lblName.Parent = neoSidebar;
            lblName.Left = LeftPadding;
            lblName.Top = HeightCounter;
            lblName.Width = width;
            lblName.Text = "Group Name:";

            TextBox txtName = new TextBox(manager);
            txtName.Init();
            txtName.Parent = neoSidebar;
            txtName.Top = HeightCounter;
            txtName.Width = width;
            txtName.Left = offset;
            HeightCounter += txtName.Height + LeftPadding;

            Button btnRandomName = new Button(manager);
            btnRandomName.Init();
            btnRandomName.Parent = neoSidebar;
            btnRandomName.Top = HeightCounter;
            btnRandomName.Width = txtName.Width;
            btnRandomName.Left = offset;
            btnRandomName.Text = "Random Name";
            HeightCounter += txtName.Height + LeftPadding;
            btnRandomName.Click += (s, e) =>
            {
                txtName.Text = Utils.RandomName();
            };

            RadioButton rdEmpty = new RadioButton(manager);
            rdEmpty.Init();
            rdEmpty.Parent = neoSidebar;
            rdEmpty.Top = HeightCounter;
            rdEmpty.Left = LeftPadding;
            rdEmpty.Text = "Default";
            rdEmpty.Checked = true;
            HeightCounter += rdEmpty.Height + LeftPadding;

            RadioButton rdExisting = new RadioButton(manager);
            rdExisting.Init();
            rdExisting.Parent = neoSidebar;
            rdExisting.Top = HeightCounter;
            rdExisting.Left = LeftPadding;
            rdExisting.Text = "Existing";
            rdExisting.Checked = false;
            rdExisting.Width = width;

            ComboBox cbExisting = new ComboBox(manager);
            cbExisting.Init();
            cbExisting.Parent = neoSidebar;
            cbExisting.Top = HeightCounter;
            cbExisting.Width = width;
            cbExisting.Left = offset;
            foreach(Group gg in sidebar.game.room.groups.general.childGroups.Values)
            {
                cbExisting.Items.Add(gg);
            }
            cbExisting.ItemIndex = 0;
            cbExisting.Enabled = false;
            HeightCounter += cbExisting.Height + LeftPadding;

            RadioButton rdTemplate = new RadioButton(manager);
            rdTemplate.Init();
            rdTemplate.Parent = neoSidebar;
            rdTemplate.Top = HeightCounter;
            rdTemplate.Left = LeftPadding;
            rdTemplate.Text = "Template";
            rdTemplate.Checked = false;
            rdTemplate.Width = width;

            ComboBox cbTemplate = new ComboBox(manager);
            cbTemplate.Init();
            cbTemplate.Parent = neoSidebar;
            cbTemplate.Top = HeightCounter;
            cbTemplate.Width = width;
            cbTemplate.Left = offset;
            foreach (Node n in Assets.NodePresets)
            {
                cbTemplate.Items.Add(n);
            }
            if (Assets.NodePresets.Count > 0) cbTemplate.ItemIndex = 0;
            cbTemplate.Enabled = false;
            HeightCounter += cbTemplate.Height + LeftPadding;

            componentView = new ComponentView(sidebar, neoSidebar, 0, HeightCounter, ViewType.Group);
            componentView.Height = 150;
            componentView.Width = neoSidebar.Width - LeftPadding * 4;

            neoSidebar.Width += 100;
            neoSidebar.Width -= 100;
            tempgroup = new Group(sidebar.room, sidebar.room.defaultNode.CreateClone(sidebar.room), null, "tempgroup", false);

            SetGroup(sidebar.room.defaultNode);

            rdEmpty.Click += (s, e) =>
            {
                cbExisting.Enabled = false;
                cbTemplate.Enabled = false;
                SetGroup(sidebar.room.defaultNode);
            };
            rdExisting.Click += (s, e) =>
            {
                cbExisting.Enabled = true;
                cbTemplate.Enabled = false;
                ComboUpdate(cbExisting);
            };
            cbExisting.ItemIndexChanged += (s, e) =>
            {
                ComboUpdate(cbExisting);
            };
            rdTemplate.Click += (s, e) =>
            {
                cbExisting.Enabled = false;
                cbTemplate.Enabled = true;
                ComboUpdate(cbTemplate);
            };
            cbTemplate.ItemIndexChanged += (s, e) =>
            {
                ComboUpdate(cbTemplate);
            };

            btnCreateGroup = new Button(manager);
            btnCreateGroup.Init();
            btnCreateGroup.Parent = neoSidebar;
            btnCreateGroup.Top = componentView.bottomArea.Top + componentView.bottomArea.Height + LeftPadding * 2;
            btnCreateGroup.Text = "Create Group";
            btnCreateGroup.Width = width;
            btnCreateGroup.Left = neoSidebar.Width / 2 - btnCreateGroup.Width / 2;

            btnCreateGroup.Click += (s, e) =>
            {
                if (String.IsNullOrWhiteSpace(txtName.Text))
                    PopUp.Toast("Please enter a group name.");
                else if(sidebar.game.room.groups.general.childGroups.Keys.Contains(txtName.Text))
                    PopUp.Toast("Group already exists.");
                else{

                    OrbIt.game.room = sidebar.game.room;
                    Node newNode = tempgroup.defaultNode.CreateClone(sidebar.game.room);
                    newNode.body.color = ColorChanger.randomColorHue();
                    newNode.basicdraw.UpdateColor();
                    Group newGroup = new Group(sidebar.game.room, newNode, sidebar.game.room.groups.general, txtName.Text.Trim());
                    newNode.name = txtName.Text.Trim();
                    newNode.group = newGroup;
                    sidebar.groupsView.UpdateGroups();
                    foreach(DetailedItem item in sidebar.groupsView.viewItems)
                    {
                        if (item.obj == newGroup)
                        {
                            sidebar.groupsView.SelectItem(item);
                            break;
                        }
                    }
                    Close();
                }
            };
        }
コード例 #9
0
        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);
        }