public void Creator(DetailedItem item, object obj)
        {
            if (item == null || obj == null) return;
            item.panel.DoubleClick += (s, e) =>
            {
                item.panel.SendMessage(Message.Click, new MouseEventArgs());
            };
            item.panel.Click += (s, e) =>
            {
                CheckBox cb = (CheckBox)item.itemControls["checkbox"];
                cb.Checked = !cb.Checked;
            };
            CheckBox checkbox = new CheckBox(manager);
            checkbox.Init();
            checkbox.Parent = item.panel;
            checkbox.Left = 6;
            checkbox.Top = 3;
            checkbox.Checked = false;
            checkbox.Text = "";
            checkbox.Name = "checkbox";
            item.AddControl(checkbox);

            mtypes types = Utils.GetCompTypes((Type)item.obj);
            if (types == mtypes.none) return;
            bool AO = (types & mtypes.affectother) == mtypes.affectother;
            bool AS = (types & mtypes.affectself) == mtypes.affectself;
            bool D = ((types & mtypes.draw) == mtypes.draw) || (types & mtypes.minordraw) == mtypes.minordraw;
            bool Q = (types & mtypes.tracer) == mtypes.tracer;
            bool TREE = (Type)item.obj == typeof(Tree);
            //int weight = 0;
            //if (AO) weight += 10;
            //if (AS) weight += 1;
            //if (D) weight += 1;
            //if (Q) weight += 3;
            //if (TREE) weight = 50;
            int leftcounter = 135;
            //NewLabel(weight.ToString(), hc, item, "label1");
            //leftcounter += 100;
            if (AO) NewLabel(UserInterface.Checkmark, leftcounter, item, "label2"); else NewLabel(UserInterface.Cross, leftcounter, item, "label2");
            leftcounter += 20;
            if (AS) NewLabel(UserInterface.Checkmark, leftcounter, item, "label3"); else NewLabel(UserInterface.Cross, leftcounter, item, "label3");
            leftcounter += 20;
            if (D)  NewLabel(UserInterface.Checkmark, leftcounter, item, "label4"); else NewLabel(UserInterface.Cross, leftcounter, item, "label4");

            Info info = Utils.GetInfoType((Type)item.obj);
            if (info == null) Console.WriteLine("Info was null on component type " + item.obj);
            else
            {
                string summary = info.summary.wordWrap(32);
                item.panel.MouseOver += (s, e) =>
                {
                    lblCompName.Text = item.obj.ToString().LastWord('.');
                    lblDescription.Text = summary;
                };
            }
        }
 public void CreateCheckBox(string key, EventHandler ev)
 {
     CheckBox cb = new CheckBox(manager);
     cb.Init();
     cb.Parent = CheckBoxes.panel;
     cb.Text = key;
     cb.Top = HeightCounter4;
     cb.Width = 100;
     cb.Click += ev;
     HeightCounter4 += cb.Height;
 }
예제 #3
0
        public Control CreateControl(Manager manager, Control parent, PropertyInfo field, object existingData)
        {
            var radioButton = new CheckBox(manager) { Parent = parent, Name = field.Name, Text = String.Empty };
            radioButton.Init();

            if (existingData != null) {
                radioButton.Checked = (bool)existingData;
            }

            return radioButton;
        }
예제 #4
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);
		}
 public void CreateCheckBox(string key, bool isChecked, EventHandler ev)
 {
     CheckBox cb = new CheckBox(manager);
     cb.Init();
     cb.Parent = window;
     cb.Text = key;
     cb.Top = HeightCounter;
     cb.Left = LeftPadding;
     cb.Width = 180;
     cb.Click += ev;
     cb.Checked = isChecked;
     HeightCounter += cb.Height;
 }
예제 #6
0
        public override void Initialize()
        {
            ContentSystem sys = (ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0];
            Viewport viewport = sys.GetViewport();

            toolbarWindow = new Window(manager);
            toolbarWindow.Init();
            toolbarWindow.Text = "Toolbar";
            toolbarWindow.Width = 160;
            toolbarWindow.Height = 360;
            toolbarWindow.Top = 0;
            toolbarWindow.IconVisible = false;
            toolbarWindow.Left = viewport.Width - toolbarWindow.Width;
            toolbarWindow.Resizable = false;
            toolbarWindow.AutoScroll = false;
            toolbarWindow.CloseButtonVisible = false;
            toolbarWindow.BorderVisible = true;
            toolbarWindow.Click += new TomShane.Neoforce.Controls.EventHandler(OnWindowClickBehavior);
            toolbarWindow.Movable = true;
            manager.Add(toolbarWindow);

            int toolHeight = 50;
            int clientW = toolbarWindow.ClientWidth;
            int toolWidth = toolHeight;
            int toolMargin = 5;

            roadTool = new ImageBasedButton(manager);
            roadTool.Init();
            roadTool.Parent = toolbarWindow;
            roadTool.Width = toolWidth;
            roadTool.Height = toolHeight;
            roadTool.Left = clientW / 2 - toolWidth / 2;
            roadTool.Top = toolMargin;
            roadTool.Text = "";
            roadTool.image = sys.LoadTexture("RoadIcon");
            roadTool.Click += new TomShane.Neoforce.Controls.EventHandler(RoadToolBehavior);
            roadTool.Pushed = true;
            roadTool.Mode = ButtonMode.PushButton;

            eraserTool = new ImageBasedButton(manager);
            eraserTool.Init();
            eraserTool.Parent = toolbarWindow;
            eraserTool.Width = toolWidth;
            eraserTool.Height = toolHeight;
            eraserTool.Left = clientW / 2 - toolWidth/2;
            eraserTool.Top = toolHeight + toolMargin*2;
            eraserTool.Text = "";
            eraserTool.image = sys.LoadTexture("EraserIcon");
            eraserTool.Click += new TomShane.Neoforce.Controls.EventHandler(EraseToolBehavior);

            paintTool = new ImageBasedButton(manager);
            paintTool.Init();
            paintTool.Parent = toolbarWindow;
            paintTool.Width = toolWidth;
            paintTool.Height = toolHeight;
            paintTool.Left = clientW / 2 - toolWidth / 2;
            paintTool.Top = (toolHeight*2 + toolMargin * 3);
            paintTool.Text = "";
            paintTool.image = sys.LoadTexture("PaintingIcon");
            paintTool.Click += new TomShane.Neoforce.Controls.EventHandler(PaintToolBehavior);

            //
            int top = (toolHeight * 3 + toolMargin * 4) +10;
            pathsValid = new CheckBox(manager);
            pathsValid.Init();
            pathsValid.Parent = toolbarWindow;
            pathsValid.Text = "";
            pathsValid.Left = clientW/2 - 15/2 - 16;
            pathsValid.Top = top;
            pathsValid.Width = 15;
            pathsValid.Enabled = false;
            pathsValid.TextColor = Color.Red;
            pathsValid.ToolTip = new CustomToolTip(manager);
            pathsValid.ToolTip.Parent = pathsValid;
            pathsValid.ToolTip.Init();
            pathsValid.ToolTip.Text = "0";
            pathsValid.ToolTip.TextColor = Color.White;
            pathsValid.ToolTip.Visible = false;
            pathsValid.ToolTip.Color = Color.Red;

            playerValid = new CheckBox(manager);
            playerValid.Init();
            playerValid.Parent = toolbarWindow;
            playerValid.Text = "";
            playerValid.Left = clientW / 2 - 15/2;
            playerValid.Top = top;
            playerValid.Width = 15;
            playerValid.Enabled = false;
            playerValid.TextColor = Color.Red;
            playerValid.ToolTip = new CustomToolTip(manager);
            playerValid.ToolTip.Parent = playerValid;
            playerValid.ToolTip.Init();
            playerValid.ToolTip.Text = "1";
            playerValid.ToolTip.TextColor = Color.White;
            playerValid.ToolTip.Visible = false;
            playerValid.ToolTip.Color = Color.Red;

            switchesValid = new CheckBox(manager);
            switchesValid.Init();
            switchesValid.Parent = toolbarWindow;
            switchesValid.Text = "";
            switchesValid.Left = clientW/2 - 15/2 +16;
            switchesValid.Top = top;
            switchesValid.Width = 15;
            switchesValid.Enabled = false;
            switchesValid.TextColor = Color.Red;
            switchesValid.ToolTip = new CustomToolTip(manager);
            switchesValid.ToolTip.Parent = switchesValid;
            switchesValid.ToolTip.Init();
            switchesValid.ToolTip.Text = "2";
            switchesValid.ToolTip.TextColor = Color.White;
            switchesValid.ToolTip.Visible = false;
            switchesValid.ToolTip.Color = Color.Red;
            //

            int btnW = (int)(toolbarWindow.ClientWidth * 0.8f);
            exportMap = new Button(manager);
            exportMap.Init();
            exportMap.Parent = toolbarWindow;
            exportMap.Text = "Export Map";
            exportMap.Width = btnW;
            exportMap.Height = 24;
            exportMap.Left = clientW / 2 - btnW / 2;
            exportMap.Top = toolbarWindow.ClientHeight - 26 * 5;
            exportMap.Click += new TomShane.Neoforce.Controls.EventHandler(ExportMapBehavior);

            saveMap = new Button(manager);
            saveMap.Init();
            saveMap.Parent = toolbarWindow;
            saveMap.Text = "Save Map";
            saveMap.Width = btnW;
            saveMap.Height = 24;
            saveMap.Left = clientW / 2 - btnW / 2;
            saveMap.Top = toolbarWindow.ClientHeight - 26 * 4;
            saveMap.Click += new TomShane.Neoforce.Controls.EventHandler(SaveMapBehavior);

            newMap = new Button(manager);
            newMap.Init();
            newMap.Parent = toolbarWindow;
            newMap.Text = "New Map";
            newMap.Width = btnW;
            newMap.Height = 24;
            newMap.Left = clientW / 2 - btnW / 2;
            newMap.Top = toolbarWindow.ClientHeight - 26 * 3;
            newMap.Click += new TomShane.Neoforce.Controls.EventHandler(NewMapBehavior);

            backToStartScreen = new Button(manager);
            backToStartScreen.Init();
            backToStartScreen.Parent = toolbarWindow;
            backToStartScreen.Text = "To Start Screen";
            backToStartScreen.Width = btnW;
            backToStartScreen.Height = 24;
            backToStartScreen.Left = clientW / 2 - btnW / 2;
            backToStartScreen.Top = toolbarWindow.ClientHeight - 26 * 2;
            backToStartScreen.Click += new TomShane.Neoforce.Controls.EventHandler(BackToStartScreenBehavior);

            exitButton = new Button(manager);
            exitButton.Init();
            exitButton.Parent = toolbarWindow;
            exitButton.Text = "Exit";
            exitButton.Width = btnW;
            exitButton.Height = 24;
            exitButton.Left = clientW / 2 - btnW/2;
            exitButton.Top = toolbarWindow.ClientHeight - 26;
            exitButton.Click += new TomShane.Neoforce.Controls.EventHandler(ExitBehavior);

            newMapConfirmationWindow = new Window(manager);
            newMapConfirmationWindow.Init();
            newMapConfirmationWindow.Text = "Start a new map?";
            newMapConfirmationWindow.Width = 248;
            newMapConfirmationWindow.Height = 48;
            newMapConfirmationWindow.Center();
            newMapConfirmationWindow.CloseButtonVisible = false;
            newMapConfirmationWindow.IconVisible = false;
            newMapConfirmationWindow.Visible = false;
            newMapConfirmationWindow.Resizable = false;
            manager.Add(newMapConfirmationWindow);

            accept = new Button(manager);
            accept.Init();
            accept.Parent = newMapConfirmationWindow;
            accept.Width = 100;
            accept.Height = 24;
            accept.Click += new TomShane.Neoforce.Controls.EventHandler(ConfirmedNewMapBehavior);
            accept.Left = 12;
            accept.Top = 8;
            accept.Text = "Yes";

            cancel = new Button(manager);
            cancel.Init();
            cancel.Parent = newMapConfirmationWindow;
            cancel.Width = 100;
            cancel.Height = 24;
            cancel.Click += new TomShane.Neoforce.Controls.EventHandler(CancelNewMapBehavior);
            cancel.Left = 124;
            cancel.Top = 8;
            cancel.Text = "No thanks";
        }
예제 #7
0
        public GeneralDialog(Manager manager)
        {
            _manager = manager;

            _window = new Window(_manager);
            _window.Init();
            _window.Text = "General";
            _window.Width = 200;
            _window.Height = 200;
            _window.Left = 809;
            _window.Top = 15;
            _window.Visible = true;
            _window.Movable = false;
            _window.CloseButtonVisible = false;

            _wireframe = new CheckBox(_manager);
            _wireframe.Init();
            _wireframe.Text = "Wireframe";
            _wireframe.Width = 100;
            _wireframe.Height = 24;
            _wireframe.Anchor = Anchors.Bottom;
            _wireframe.Left = 15;
            _wireframe.Top = 15;
            _wireframe.Visible = true;
            _wireframe.Parent = _window;

            _terrain = new CheckBox(_manager);
            _terrain.Init();
            _terrain.Text = "Terrain";
            _terrain.Width = 100;
            _terrain.Height = 24;
            _terrain.Anchor = Anchors.Bottom;
            _terrain.Left = 15;
            _terrain.Top = 45;
            _terrain.Visible = true;
            _terrain.Parent = _window;

            _doodad = new CheckBox(_manager);
            _doodad.Init();
            _doodad.Text = "Doodads";
            _doodad.Width = 100;
            _doodad.Height = 24;
            _doodad.Anchor = Anchors.Bottom;
            _doodad.Left = 15;
            _doodad.Top = 75;
            _doodad.Visible = true;
            _doodad.Parent = _window;

            _wmo = new CheckBox(_manager);
            _wmo.Init();
            _wmo.Text = "WMOs";
            _wmo.Width = 100;
            _wmo.Height = 24;
            _wmo.Anchor = Anchors.Bottom;
            _wmo.Left = 15;
            _wmo.Top = 105;
            _wmo.Visible = true;
            _wmo.Parent = _window;

            _water = new CheckBox(_manager);
            _water.Init();
            _water.Text = "Water";
            _water.Width = 100;
            _water.Height = 24;
            _water.Anchor = Anchors.Bottom;
            _water.Left = 15;
            _water.Top = 135;
            _water.Visible = true;
            _water.Parent = _window;

            _console = new Console(_manager);
            _console.Init();
            _console.Left = 15;
            _console.Top = 15;
            _console.Width = 779;
            _console.Height = 200;
            _console.Visible = true;
            _console.Text = "meshDisplay Console";
            _console.Visible = true;
            _console.Movable = false;
            _console.Channels.Add(new ConsoleChannel(1, "Default", Color.White));
            _console.MessageSent += HandleMessage;

            _manager.Add(_console);
            _manager.Add(_window);
        }
        public LinkGeneratorWindow(Manager manager, Sidebar sidebar)
        {
            OrbIt game = OrbIt.game;
            UserInterface.GameInputDisabled = true;

            this.manager = manager;
            this.sidebar = sidebar;
            window = new Window(manager);
            window.Init();
            window.Left = OrbIt.ui.sidebar.master.Left;
            window.Width = OrbIt.ui.sidebar.master.Width;
            window.Top = 200;
            window.Height = 200;
            window.Text = "Link Generator";
            window.Closed += delegate { UserInterface.GameInputDisabled = false; };
            window.ShowModal();
            manager.Add(window);

            //LinkGenerator.ExpandedHeight += 30;
            HeightCounter3 = 0;
            int left = 0;
            int middle = 100;

            lblGenerateLink = new Label(manager);
            lblGenerateLink.Init();
            lblGenerateLink.Left = left + middle / 2;
            lblGenerateLink.Top = HeightCounter3; HeightCounter3 += lblGenerateLink.Height;
            lblGenerateLink.Text = "Generate Link";
            lblGenerateLink.Width += 40;
            lblGenerateLink.Parent = window;

            lblLinkType = new Label(manager);
            lblLinkType.Init();
            lblLinkType.Left = left;
            lblLinkType.Text = "Link Type";
            lblLinkType.Parent = window;
            lblLinkType.Top = HeightCounter3; HeightCounter3 += lblLinkType.Height;

            cbLinkType = new ComboBox(manager);
            cbLinkType.Init();
            cbLinkType.Left = left;
            cbLinkType.Width += 100;
            cbLinkType.Parent = window;
            cbLinkType.MaxItems = 15;
            cbLinkType.Top = HeightCounter3; HeightCounter3 += cbLinkType.Height;
            //cbLinkType.Items.AddRange(new List<object>() { });
            Link.GetILinkableEnumVals(cbLinkType.Items);

            /*
            foreach (comp key in Enum.GetValues(typeof(comp)))
            {
                Type compType = Game1.compTypes[key];

                if (!typeof(ILinkable).IsAssignableFrom(compType)) continue;

                cbLinkType.Items.Add(key);

                /*
                MethodInfo mInfo = compType.GetMethod("AffectOther");
                if (mInfo != null
                    && mInfo.DeclaringType == compType)
                {
                    cbLinkType.Items.Add(key);
                }
                //
            }
            */

            lblLinkFormation = new Label(manager);
            lblLinkFormation.Init();
            lblLinkFormation.Left = left;
            lblLinkFormation.Text = "Formation";
            lblLinkFormation.Parent = window;
            lblLinkFormation.Top = HeightCounter3; HeightCounter3 += lblLinkFormation.Height;

            cbLinkFormation = new ComboBox(manager);
            cbLinkFormation.Init();
            cbLinkFormation.Left = left;
            cbLinkFormation.Width += 20;
            cbLinkFormation.Parent = window;
            cbLinkFormation.Top = HeightCounter3; HeightCounter3 += cbLinkFormation.Height;

            foreach (formationtype f in Enum.GetValues(typeof(formationtype)))
            {
                cbLinkFormation.Items.Add(f);
            }
            cbLinkFormation.ItemIndex = 0;

            chkEntangled = new CheckBox(manager);
            chkEntangled.Init();
            chkEntangled.Left = left;
            chkEntangled.Width += 20;
            chkEntangled.Text = "Entangled";
            chkEntangled.Parent = window;
            chkEntangled.Top = HeightCounter3; HeightCounter3 += chkEntangled.Height;

            HeightCounter3 = lblGenerateLink.Height;

            lblLinkPresets = new Label(manager);
            lblLinkPresets.Init();
            lblLinkPresets.Left = left + middle;
            lblLinkPresets.Text = "Preset";
            lblLinkPresets.Parent = window;
            lblLinkPresets.Top = lblLinkFormation.Top;

            cbLinkPresets = new ComboBox(manager);
            cbLinkPresets.Init();
            cbLinkPresets.Left = left + middle;
            //cbLinkPresets.Width += 20;
            cbLinkPresets.Parent = window;
            cbLinkPresets.Top = cbLinkFormation.Top;

            cbLinkPresets.Items.Add("Default");
            cbLinkPresets.ItemIndex = 0;

            btnAddToPalette = new Button(manager);
            btnAddToPalette.Init();
            btnAddToPalette.Left = left + middle;
            btnAddToPalette.Width = middle - 20;
            btnAddToPalette.Text = "Add to\nPalette";
            btnAddToPalette.Height = btnAddToPalette.Height * 2 - 10;
            btnAddToPalette.Parent = window;
            btnAddToPalette.Top = chkEntangled.Top + chkEntangled.Height;
            btnAddToPalette.Click += btnAddToPalette_Click;
        }
        public void UpdatePanel(InspectorInfo inspectorItem)
        {
            //if (activeInspectorItem == inspectorItem) return;
            if (inspectorItem.membertype == member_type.previouslevel) return;

            if (panelControls.Keys.Count > 0) DisableControls();

            grouppanel.Visible = true;
            grouppanel.Refresh();

            activeInspectorItem = inspectorItem;

            //grouppanel.Text = activeInspectorItem.ToString(); //.Name();
            grouppanel.Text = activeInspectorItem.Name();

            if (!activeInspectorItem.HasPanelElements()) return;

            editType = activeInspectorItem.obj.GetType();
            object value = activeInspectorItem.GetValue();
            if (value == null) return;

            if (editType == typeof(int) || editType == typeof(Single) || editType == typeof(string) || editType == typeof(byte))
            {
                //System.Console.WriteLine("It's an int or float.");
                TextBox txtbox = new TextBox(grouppanel.Manager);
                txtbox.Init();
                txtbox.Parent = grouppanel;
                txtbox.Left = LeftPadding;
                txtbox.Top = 10;
                txtbox.Width = 80;
                txtbox.Height = txtbox.Height + 3;
                txtbox.KeyUp += delegate (object sender, KeyEventArgs e) {
                    if (!txtbox.Text.Equals("") && e.Key == Microsoft.Xna.Framework.Input.Keys.Enter)
                    {
                        btnModify_Click(sender, e);
                    }
                };

                //txtbox.BackColor = Color.Green;

                //txtbox.DrawBorders = true;
                //txtbox.Text = activeInspectorItem.obj.ToString();

                txtbox.Text = value.ToString();

                Button btnModify = new Button(grouppanel.Manager);
                btnModify.Init();
                btnModify.Parent = grouppanel;
                btnModify.Left = LeftPadding * 2 + txtbox.Width;
                btnModify.Top = 10;
                btnModify.Width = 80;
                btnModify.Text = "Modify";
                btnModify.Click += btnModify_Click;

                panelControls.Add("txtbox", txtbox);
                panelControls.Add("btnModify", btnModify);

                if (editType == typeof(int) || editType == typeof(Single) || editType == typeof(byte))
                {
                    Slider trkMain = new Slider(grouppanel.Manager);
                    trkMain.Init();
                    trkMain.Parent = grouppanel;
                    trkMain.Left = LeftPadding;
                    trkMain.Top = 20 + btnModify.Height;
                    trkMain.Width = txtbox.Width + btnModify.Width + LeftPadding;
                    trkMain.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
                    int val = Convert.ToInt32(value);

                    //int range = Math.Max(100, val * 2);
                    trkMain.Range = Math.Max(100, val * 2);

                    trkMain.Value = val;
                    //trkMain.
                    trkMain.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(trkMain_ValueChanged);
                    trkMain.Click += delegate(object sender, TomShane.Neoforce.Controls.EventArgs e)
                    {
                        MouseEventArgs me = (MouseEventArgs)e;
                        if (me.Button != MouseButton.Right) return;
                        int relpos = me.Position.X - 810; //MAGIC NUMBER HACK OMG
                        int sliderpos = (int)(((float)trkMain.Value / (float)trkMain.Range) * trkMain.Width);
                        if (relpos < sliderpos) trkMain.Range = trkMain.Range / 2;
                        else trkMain.Range = trkMain.Range * 2;
                    };
                    //trkMain.
                    trkMain.btnSlider.MouseUp += trkMain_MouseUp;
                    //trkMain.btnSlider.MouseUp += new TomShane.Neoforce.Controls.MouseEventHandler(trkMain_MouseUp);
                    panelControls.Add("trkMain", trkMain);
                }

            }
            else if (editType == typeof(bool))
            {
                //System.Console.WriteLine("It's a boolean.");
                CheckBox chkbox = new CheckBox(grouppanel.Manager);
                chkbox.Init();
                chkbox.Parent = grouppanel;
                chkbox.Left = LeftPadding;
                chkbox.Top = 10;
                chkbox.Width = 120;
                chkbox.Checked = (bool)value;
                chkbox.Text = activeInspectorItem.Name() + " (" + value + ")";
                chkbox.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(chkbox_CheckedChanged);
                panelControls.Add("chkbox", chkbox);

            }
            else if (editType.IsSubclassOf(typeof(Enum)))
            {
                //System.Console.WriteLine("ENUM!");
                ComboBox cb = new ComboBox(grouppanel.Manager);
                cb.Init();
                cb.Parent = grouppanel;
                cb.MaxItems = 20;
                cb.Left = LeftPadding;
                cb.Top = 10;
                cb.Width = 120;
                foreach (string enumname in Enum.GetNames(editType))
                {
                    cb.Items.Add(enumname);
                }
                cb.ItemIndex = (int)value;
                cb.ItemIndexChanged += cb_ItemIndexChanged;
                panelControls.Add("cb", cb);
            }

            grouppanel.Refresh();
        }
예제 #10
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);
        }
예제 #11
0
        public void Init(Control parent, Manager manager)
        {
            switch (Type)
            {
                case "Container":
                    Container container = new Container(manager);
                    container.Init();

                    SetProperties(container, parent, manager);

                    container.AutoScroll = true;
                    break;
                case "ImageBox":
                    ImageBox box = new ImageBox(manager);
                    box.Init();

                    SetProperties(box, parent, manager);

                    box.SizeMode = ImageMode;

                    if (!string.IsNullOrEmpty(ImageAsset))
                        box.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            box.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            box.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    if (!string.IsNullOrEmpty(Draw))
                        box.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };
                    break;
                case "Label":
                    Label label = new Label(manager);
                    label.Init();

                    SetProperties(label, parent, manager);

                    label.Text = Text.StartsWith("TXT_KEY_") ? Provider.Instance.Translate(Text) : Text;

                    break;
                case "GameMapBox":
                    GameMapBox mapBox = new GameMapBox(manager);
                    mapBox.Init();

                    SetProperties(mapBox, parent, manager);

                    break;
                case "SideBar":
                    SideBar sideBar = new SideBar(manager);
                    sideBar.Init();

                    SetProperties(sideBar, parent, manager);

                    if (!string.IsNullOrEmpty(Draw))
                        sideBar.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };

                    break;
                case "ContextMenu":
                    ContextMenu contextMenu = new ContextMenu(manager);
                    contextMenu.Init();

                    contextMenu.Name = Name;
                    contextMenu.Tag = this;
                    contextMenu.Passive = Passive;
                    contextMenu.Enabled = Enabled;

                    foreach (MenuItemEntry entry in Items)
                    {
                        MenuItem menuItem = new MenuItem(entry.Title);
                        menuItem.Enabled = entry.Enabled;

                        contextMenu.Items.Add(menuItem);
                    }

                    if (!string.IsNullOrEmpty(Parent))
                        contextMenu.Parent = parent.GetControl(Parent);
                    else
                        parent.Add(contextMenu);

                    break;

                case "ImageListBox":
                    ImageListBox listBox = new ImageListBox(manager);
                    listBox.Init();

                    SetProperties(listBox, parent, manager);

                    listBox.HideSelection = HideSelection;

                    if (!string.IsNullOrEmpty(ContextMenu))
                        listBox.ContextMenu = parent.GetControl(ContextMenu) as ContextMenu;

                    break;

                case "TechInfoButton":
                    TechInfoButton techInfo = new TechInfoButton(manager);
                    techInfo.Init();

                    SetProperties(techInfo, parent, manager);

                    if (!string.IsNullOrEmpty(TechName))
                        techInfo.Tech = Provider.GetTech(TechName);

                    break;
                case "PolicyButton":
                    PolicyButton policyButton = new PolicyButton(manager);
                    policyButton.Init();

                    SetProperties(policyButton, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyName))
                        policyButton.Policy = Provider.GetPolicy(PolicyName);

                    break;
                case "PolicyTypeBox":
                    PolicyTypeBox policyTypeBox = new PolicyTypeBox(manager);
                    policyTypeBox.Init();

                    SetProperties(policyTypeBox, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyTypeName))
                        policyTypeBox.PolicyType = Provider.GetPolicyType(PolicyTypeName);

                    if (!string.IsNullOrEmpty(ImageAsset))
                        policyTypeBox.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            policyTypeBox.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            policyTypeBox.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    break;
                case "ImageButton":
                    ImageButton button = new ImageButton(manager);
                    button.Init();

                    ApplyStyle(button, manager);
                    SetProperties(button, parent, manager);
                    SetAnimation(button, manager);

                    button.Text = Text;
                    break;
                case "ProgressBar":
                    ProgressBar progress = new ProgressBar(manager);
                    progress.Init();

                    SetProperties(progress, parent, manager);
                    break;
                case "CheckBox":
                    CheckBox check = new CheckBox(manager);
                    check.Init();

                    SetProperties(check, parent, manager);

                    check.Text = Text;
                    break;
                case "Graph":
                    Graph graph = new Graph(manager);
                    graph.Init();

                    SetProperties(graph, parent, manager);

                    break;
                case "RankingRow":
                    RankingRow rank = new RankingRow(manager);
                    rank.Init();

                    SetProperties(rank, parent, manager);
                    break;
                case "Include":
                    List<ControlItem> children = manager.Content.Load<List<ControlItem>>(Import);

                    foreach (ControlItem item in children)
                        item.Init(parent, manager);
                    break;
                default:
                    throw new Exception("No handling for " + Type);
            }
        }
        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];
        }
        private void ConfigMenu()
        {            
            
            NeoforceGui guiManager = this.Gui as NeoforceGui;
            System.Diagnostics.Debug.Assert(guiManager != null);

            // Create and setup Window control.
            Window window = new Window(guiManager.Manager);
            window.Init();
            window.Text = "PloobsEngine Config";
            window.Width = 350;
            window.Height = 300;
            window.Center();
            window.Visible = true;


            Label lab1 = new Label(guiManager.Manager);
            lab1.Text = "Resolução";
            lab1.Top = 20;
            lab1.Left = 20;
            lab1.Parent = window;

            List<string> colors = new List<string>();

            foreach (var item in GraphicInfo.GraphicsAdapter.SupportedDisplayModes)
            {
                if (item.Format == Microsoft.Xna.Framework.Graphics.SurfaceFormat.Color)
                {
                    colors.Add(item.Width + "x" + item.Height);
                }
            }

            lb1 = new ComboBox(guiManager.Manager);
            lb1.Init();
            lb1.Parent = window;
            lb1.Left = lab1.Left;
            lb1.Top = lab1.Top + lab1.Height;
            lb1.Width = 200;
            lb1.ItemIndex = 0;
            lb1.Height = 20;

            
            lb1.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(lb1_ItemIndexChanged);
            lb1.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
            lb1.Items.AddRange(colors);

            lb1.Text = "800x600";
            lb1.SelectionStart = 0;            



            // Create Button control and set the previous window as its parent.
            Button button = new Button(guiManager.Manager);
            button.Init();
            button.Text = "Apply";
            button.Width = button.Text.Length * 10;
            button.Height = 24;
            button.Left = (window.ClientWidth / 2) - (button.Width / 2);
            button.Top = window.ClientHeight - button.Height - 8;
            button.Anchor = Anchors.Bottom;
            button.Parent = window;
            button.Click += new TomShane.Neoforce.Controls.EventHandler(button_Click);


            CheckBox ck1 = new CheckBox(guiManager.Manager);
            ck1.Text = "FullScreen";
            ck1.Checked = false;
            ck1.Click += new TomShane.Neoforce.Controls.EventHandler(ck1_Click);
            ck1.Top = lb1.Top + lb1.Height + 10;
            ck1.Parent = window;
            ck1.Left = lb1.Left;
            ck1.Width = ck1.Text.Length*10;


            CheckBox ms1 = new CheckBox(guiManager.Manager);
            ms1.Text = "MultiSampling";
            ms1.Checked = false;
            ms1.Top = ck1.Top + ck1.Height + 10;
            ms1.Parent = window;
            ms1.Click += new TomShane.Neoforce.Controls.EventHandler(ms1_Click);
            ms1.Left = lb1.Left;
            ms1.Width = ms1.Text.Length * 10;

            CheckBox vsy = new CheckBox(guiManager.Manager);
            vsy.Text = "Vertical Sincronization";
            vsy.Checked = false;
            vsy.Top = ms1.Top + ms1.Height + 10;
            vsy.Parent = window;
            vsy.Click += new TomShane.Neoforce.Controls.EventHandler(vsy_Click);
            vsy.Left = lb1.Left;
            vsy.Width = vsy.Text.Length * 10;

            CheckBox mip = new CheckBox(guiManager.Manager);
            mip.Text = "Use MipMap";
            mip.Checked = false;
            mip.Top = vsy.Top + vsy.Height + 10;
            mip.Parent = window;
            mip.Click += new TomShane.Neoforce.Controls.EventHandler(mip_Click);
            mip.Left = lb1.Left;
            mip.Width = mip.Text.Length * 10;

            CheckBox ans = new CheckBox(guiManager.Manager);
            ans.Text = "Use Anisotropic Filtering";
            ans.Checked = false;
            ans.Top = mip.Top + mip.Height + 10;
            ans.Parent = window;
            ans.Click += new TomShane.Neoforce.Controls.EventHandler(ans_Click); 
            ans.Left = lb1.Left;
            ans.Width = ans.Text.Length * 10;           


            // Add the window control to the manager processing queue.
            guiManager.Manager.Add(window);
        
        }
예제 #14
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);
        }