Example #1
0
        private void InitializeUpgradeButtons()
        {
            Remove(UpgradeBox);
            UpgradeBox = new GroupBox(Manager);
            Add(UpgradeBox);

            UpgradeBox.Init();
            UpgradeBox.Left      = 2;
            UpgradeBox.Top       = infoBox.Top + infoBox.Height + 2;
            UpgradeBox.Width     = UpgradeBox.Parent.Width - 4;
            UpgradeBox.Height    = UpgradeBox.Parent.Height - UpgradeBox.Top - 2;
            UpgradeBox.Text      = "Upgrades";
            UpgradeBox.TextColor = Microsoft.Xna.Framework.Color.LightGray;

            UpgradeBox.AutoScroll = false;
            foreach (Button button in Buttons)
            {
                UpgradeBox.Remove(button);
                Remove(button);
                button.Visible = false;
                button.Invalidate();
            }
            Buttons.Clear();
            lastWidth = 0;

            SpriteFont cFont = Skin.Layers[0].Text.Font.Resource;

            UpgradeBox.Enabled = Tower.PossibleUpgrades.Count > 0;
            foreach (var upgrade in Tower.PossibleUpgrades)
            {
                var button = new Button(Manager);
                button.Init();
                UpgradeBox.Add(button);
                Buttons.Add(button);
                button.Text    = upgrade.Value.Name;
                button.Width   = (int)cFont.MeasureString(button.Text).X + 15;
                button.Left    = 6 + lastWidth;
                button.Top     = 14;
                button.Tag     = upgrade.Value.Key;
                button.Enabled = GamePlayScreen.MoneyManager.Money >= upgrade.Value.Price;
                button.Click  += button_Click;
                button.ToolTip = new ToolTip(Manager)
                {
                    Text = string.Format("Neuer Wert: {0}\nPreis: {1}", upgrade.Value.Value,
                                         upgrade.Value.Price)
                };
                if (upgrade.Value.Description.Length > 0)
                {
                    button.ToolTip.Text += string.Format("\nBeschreibung: {0}", upgrade.Value.Description);
                }

                lastWidth = button.Left + button.Width;
            }

            UpgradeBox.AutoScroll = true;
            UpgradeBox.Refresh();
        }
Example #2
0
        private void refreshTree(bool increase)
        {
            int points = Int32.Parse(_gb.Text.Substring(_gb.Text.IndexOf('(') + 1,
                                                        _gb.Text.IndexOf(')') - 1 - _gb.Text.IndexOf('(')));
            string treeName = Talent.Tree;

            points   = (increase ? points + 1 : points - 1);
            _gb.Text = treeName + " (" + points.ToString() + ")";
            _gb.Refresh();
        }
        public static void UpdateGroupBoxText(GroupBox control, string msg)
        {
            if (control.InvokeRequired)
            {
                MethodInvoker delcall = () => { UpdateGroupBoxText(control, msg); };

                try
                { control.BeginInvoke(delcall); }

                catch (Exception ex)
                { ex.ToDummy(); }
            }

            else
            {
                control.Text = msg;
                control.Refresh();
            }
        }
Example #4
0
        public UIDesignTableClass(Control frm, string name, bool show = true, int x = 50, int y = 50)
        {
            Location = new Point(x, y);
            Name     = name;
            _action  = new ActionClass {
                parent = frm
            };
            _action.SetAbsoluteOffset(_absoluteOffset);

            _action.action   = eAction.None;
            PForm            = frm;
            PForm.MouseMove += Form_MouseMove;
            PForm.MouseUp   += Form_MouseUp;

            InitializeComponent();
            _pnlTableBottomRight.MouseUp    += Form_MouseUp;
            _pnlTableBottomRight.MouseMove  += Table_MouseMove;
            _pnlTableBottomRight.MouseClick += PnlTableBottom_MouseClick;
            _pnlTableBottomRight.MouseDown  += PnlTableBottom_MouseDown;
            _action.hotspot   = _pnlTableBottomRight;
            _action.mainctrl  = _gbTable;
            _tsmiMinimize.Tag = eTableType.Autosize;
            _gbTable.Left     = x;
            _gbTable.Top      = y;
            _gbTable.Text     = "";
            _txtCaption.Text  = name;

            _action.last_local_position   = _gbTable.Location;
            _action.last_local_dimensions = _gbTable.Size;
            _action.DrawLastMove();

            if (show)
            {
                _action.Show();
            }
            else
            {
                _action.Hide();
            }
            _pnlTableBottom.Height = 14;
            _gbTable.Refresh();
        }
        private int PopulateUi(string name, int y, Type type, GroupBox groupbox, object defaultValue, string description = "")
        {
            const int textBoxX = 200;
            const int labelX   = 10;
            TextBox   textBox  = new TextBox();

            Label label = new Label
            {
                AutoSize  = true,
                Location  = new Point(labelX, y),
                Name      = $"{_labelCounter}_label",
                Size      = new Size(87, 13),
                TabIndex  = 67,
                Text      = name,
                TextAlign = ContentAlignment.MiddleRight
            };

            groupbox.Controls.Add(label);

            if (type.IsEnum)
            {
                ComboBox comboBox = new ComboBox
                {
                    Location       = new Point(textBoxX, y),
                    Name           = name,
                    Size           = new Size(150, 20),
                    BindingContext = new BindingContext(),
                    DataSource     = type.GetEnumValues()
                };
                workflowToolTip.SetToolTip(comboBox, description);
                if (groupbox.Tag != null)
                {
                    var propertyInfo = groupbox.Tag.GetType().GetProperty(name);
                    if (propertyInfo != null)
                    {
                        comboBox.SelectedIndex =
                            comboBox.Items.IndexOf(propertyInfo.GetValue(groupbox.Tag));
                    }
                }

                fieldValidator.RequireCustom(comboBox, () => ValidateInput(comboBox.Text, type), $"Input Parameter of { (object)comboBox.Name} is of incorrect type");
                y += 20;
                groupbox.Controls.Add(comboBox);
            }
            else if (type.GetInterface("IEnumerable") != null && type != typeof(string))
            {
                var firstOrDefault = type.GetGenericArguments().FirstOrDefault();
                if (firstOrDefault != null && firstOrDefault.IsEnum)
                {
                    ListBox listBox = new ListBox
                    {
                        Name           = name,
                        Location       = new Point(textBoxX, y),
                        Size           = new Size(150, 50),
                        BindingContext = new BindingContext(),
                        SelectionMode  = SelectionMode.MultiSimple,
                        DataSource     = type.GetGenericArguments().First().GetEnumNames()
                    };
                    workflowToolTip.SetToolTip(listBox, description);
                    if (groupbox.Tag != null)
                    {
                        listBox.ClearSelected();
                        var propertyInfo = groupbox.Tag.GetType().GetProperty(name);
                        if (propertyInfo != null)
                        {
                            var selectedItemList = propertyInfo.GetValue(groupbox.Tag) as IEnumerable;
                            if (selectedItemList != null)
                            {
                                foreach (int index in selectedItemList.Cast <object>().Select(selectedItem => listBox.Items.IndexOf(selectedItem.ToString())).Where(index => index != -1))
                                {
                                    listBox.SetSelected(index, true);
                                }
                            }
                        }
                    }

                    groupbox.Controls.Add(listBox);
                    y += 50;
                }
            }
            else if (type == typeof(bool))
            {
                CheckBox checkBox = new CheckBox
                {
                    Location = new Point(textBoxX, y),
                    Name     = name,
                    Size     = new Size(150, 20)
                };
                if (groupbox.Tag != null)
                {
                    checkBox.DataBindings.Add("Checked", groupbox.Tag, name);
                }
                workflowToolTip.SetToolTip(checkBox, description);
                if (null != defaultValue)
                {
                    checkBox.Checked = (bool)defaultValue;
                }
                groupbox.Controls.Add(checkBox);
                y += 20;
            }
            else
            {
                textBox.Name     = name;
                textBox.Size     = new Size(150, 20);
                textBox.Location = new Point(textBoxX, y);
                if (null != defaultValue)
                {
                    textBox.Text = defaultValue.ToString();
                }
                if (groupbox.Tag != null)
                {
                    textBox.DataBindings.Add("Text", groupbox.Tag, name);
                }
                workflowToolTip.SetToolTip(textBox, description);
                groupbox.Controls.Add(textBox);
                fieldValidator.RequireCustom(textBox, () => ValidateInput(textBox.Text, type), $"Input Parameter of {textBox.Name} is of incorrect type");

                y += 20;
            }
            groupbox.Refresh();
            return(y);
        }