Exemplo n.º 1
0
        public CheckedTextControl()
        {
            checkbox = new SizeableCheckbox();

            title    = new Label();
            checkbox = new SizeableCheckbox();

            BackColor = ColorUnselected;
            Size      = new Size(200, 52);

            Controls.Add(checkbox);
            Controls.Add(title);

            DPIManager.Register(this);
        }
Exemplo n.º 2
0
        public override void Initialize(UserGameInfo game, GameProfile profile)
        {
            base.Initialize(game, profile);

            this.Controls.Clear();

            int wid = 200;

            list      = new ControlListBox();
            list.Size = this.Size;

            List <GameOption>           options = game.Game.Options;
            Dictionary <string, object> vals    = profile.Options;

            for (int j = 0; j < options.Count; j++)
            {
                GameOption opt = options[j];
                if (opt.Hidden)
                {
                    continue;
                }

                object val;
                if (!vals.TryGetValue(opt.Key, out val))
                {
                    continue;
                }

                CoolListControl cool = new CoolListControl(false);
                cool.Title       = opt.Name;
                cool.Details     = opt.Description;
                cool.Width       = list.Width;
                cool.TitleFont   = nameFont;
                cool.DetailsFont = detailsFont;

                list.Controls.Add(cool);

                // Check the value type and add a control for it
                if (opt.Value is Enum || opt.List != null)
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    object value;
                    object defaultValue;
                    IList  values;
                    if (opt.Value is Enum)
                    {
                        value        = (Enum)val;
                        values       = Enum.GetValues(value.GetType());
                        defaultValue = opt.DefaultValue;
                    }
                    else
                    {
                        value        = opt.List[0];
                        values       = opt.List;
                        defaultValue = opt.DefaultValue;
                    }

                    for (int i = 0; i < values.Count; i++)
                    {
                        box.Items.Add(values[i]);
                    }

                    if (defaultValue != null)
                    {
                        box.SelectedIndex = box.Items.IndexOf(defaultValue);
                        if (box.SelectedIndex == -1)
                        {
                            box.SelectedIndex = box.Items.IndexOf(value);
                        }
                    }
                    else
                    {
                        box.SelectedIndex = box.Items.IndexOf(value);
                    }

                    box.Width         = wid;
                    box.Height        = 40;
                    box.Left          = cool.Width - box.Width - border;
                    box.Top           = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor        = AnchorStyles.Right;
                    box.DropDownStyle = ComboBoxStyle.DropDownList;
                    cool.Controls.Add(box);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                    ChangeOption(box.Tag, box.SelectedItem);
                }
                else if (opt.Value is bool)
                {
                    SizeableCheckbox box = new SizeableCheckbox();
                    int border           = 10;

                    box.Checked = (bool)val;
                    box.Width   = 40;
                    box.Height  = 40;
                    box.Left    = cool.Width - box.Width - border;
                    box.Top     = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor  = AnchorStyles.Right;
                    cool.Controls.Add(box);

                    box.Tag             = opt;
                    box.CheckedChanged += box_CheckedChanged;
                    ChangeOption(box.Tag, box.Checked);
                }
                else if (opt.Value is int || opt.Value is double)
                {
                    NumericUpDown num    = new NumericUpDown();
                    int           border = 10;

                    int value = (int)(double)val;
                    if (value < num.Minimum)
                    {
                        num.Minimum = value;
                    }

                    num.Value = value;

                    num.Width  = wid;
                    num.Height = 40;
                    num.Left   = cool.Width - num.Width - border;
                    num.Top    = (cool.Height / 2) - (num.Height / 2);
                    num.Anchor = AnchorStyles.Right;
                    cool.Controls.Add(num);

                    num.Tag           = opt;
                    num.ValueChanged += num_ValueChanged;
                    ChangeOption(num.Tag, num.Value);
                }
                else if (opt.Value is GameOptionValue)
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    GameOptionValue value = (GameOptionValue)val;
                    PropertyInfo[]  props = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.Static);

                    for (int i = 0; i < props.Length; i++)
                    {
                        PropertyInfo prop = props[i];
                        box.Items.Add(prop.GetValue(null, null));
                    }
                    box.SelectedIndex = box.Items.IndexOf(value);

                    box.Width  = wid;
                    box.Height = 40;
                    box.Left   = cool.Width - box.Width - border;
                    box.Top    = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor = AnchorStyles.Right;
                    //box.DropDownStyle = ComboBoxStyle.DropDownList;
                    cool.Controls.Add(box);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                    ChangeOption(box.Tag, box.SelectedItem);
                }
            }

            this.Controls.Add(list);
            list.UpdateSizes();
            CanPlayUpdated(true, false);
        }
Exemplo n.º 3
0
        private void box_CheckedChanged(object sender, EventArgs e)
        {
            SizeableCheckbox check = (SizeableCheckbox)sender;

            ChangeOption(check.Tag, check.Checked);
        }
        public override void Initialize(UserGameInfo game, GameProfile profile)
        {
            base.Initialize(game, profile);

            this.Controls.Clear();

            int wid = 200;

            list = new ControlListBox();
            GameOption[] options             = game.Game.Options;
            Dictionary <string, object> vals = profile.Options;

            for (int j = 0; j < options.Length; j++)
            {
                GameOption opt = options[j];

                object val;
                if (!vals.TryGetValue(opt.Key, out val))
                {
                    continue;
                }

                CoolListControl cool = new CoolListControl();
                cool.Text        = opt.Name;
                cool.Description = opt.Description;
                cool.Width       = this.Width;

                list.Controls.Add(cool);

                // Check the value type and add a control for it
                if (opt.Value is bool)
                {
                    SizeableCheckbox box = new SizeableCheckbox();
                    int border           = 10;

                    box.Checked = (bool)val;
                    box.Width   = 40;
                    box.Height  = 40;
                    box.Left    = cool.Width - box.Width - border;
                    box.Top     = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor  = AnchorStyles.Right;
                    cool.AddControl(box, false);

                    box.Tag             = opt;
                    box.CheckedChanged += box_CheckedChanged;
                }
                else if (opt.Value is int || opt.Value is double)
                {
                    NumericUpDown num    = new NumericUpDown();
                    int           border = 10;

                    int value = (int)(double)val;
                    if (value < num.Minimum)
                    {
                        num.Minimum = value;
                    }

                    num.Value = value;

                    num.Width  = wid;
                    num.Height = 40;
                    num.Left   = cool.Width - num.Width - border;
                    num.Top    = (cool.Height / 2) - (num.Height / 2);
                    num.Anchor = AnchorStyles.Right;
                    cool.AddControl(num, false);

                    num.Tag           = opt;
                    num.ValueChanged += num_ValueChanged;
                }
                else if (opt.Value is Enum)
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    Enum  value  = (Enum)val;
                    Array values = Enum.GetValues(value.GetType());
                    for (int i = 0; i < values.Length; i++)
                    {
                        box.Items.Add(((IList)values)[i]);
                    }
                    box.SelectedIndex = box.Items.IndexOf(value);

                    box.Width  = wid;
                    box.Height = 40;
                    box.Left   = cool.Width - box.Width - border;
                    box.Top    = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor = AnchorStyles.Right;
                    cool.AddControl(box, false);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                }
                else if (opt.Value is GameOptionValue)
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    GameOptionValue value = (GameOptionValue)val;
                    PropertyInfo[]  props = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.Static);

                    for (int i = 0; i < props.Length; i++)
                    {
                        PropertyInfo prop = props[i];
                        box.Items.Add(prop.GetValue(null, null));
                    }
                    box.SelectedIndex = box.Items.IndexOf(value);

                    box.Width  = wid;
                    box.Height = 40;
                    box.Left   = cool.Width - box.Width - border;
                    box.Top    = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor = AnchorStyles.Right;
                    cool.AddControl(box, false);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                }
            }

            list.Size = this.Size;
            this.Controls.Add(list);

            list.UpdateSizes();
            OnCanPlayTrue(false);
        }
Exemplo n.º 5
0
        public override void Initialize(HandlerData handlerData, UserGameInfo game, GameProfile profile)
        {
            base.Initialize(handlerData, game, profile);

            this.Controls.Clear();

            int wid = 200;

            Image     = FormGraphicsUtil.BuildCharToBitmap(new Size(40, 40), 30, Color.FromArgb(240, 240, 240), "⚙");
            list      = new ControlListBox();
            list.Size = this.Size;

            List <GameOption>           options = handlerData.Options;
            Dictionary <string, object> vals    = profile.Options;

            for (int j = 0; j < options.Count; j++)
            {
                GameOption opt = options[j];
                if (opt.Hidden)
                {
                    continue;
                }

                object val;
                if (!vals.TryGetValue(opt.Key, out val))
                {
                    continue;
                }

                CoolListControl cool = new CoolListControl(false);
                cool.Title          = opt.Name;
                cool.Details        = opt.Description;
                cool.Width          = list.Width;
                cool.TitleFont      = nameFont;
                cool.DetailsFont    = detailsFont;
                cool.EnableClicking = false;

                list.Controls.Add(cool);

                // Check the value type and add a control for it
                if (opt.Value is Enum || opt.IsCollection())
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    object value;
                    object defaultValue;
                    IList  values;
                    if (opt.Value is Enum)
                    {
                        value        = (Enum)val;
                        values       = Enum.GetValues(value.GetType());
                        defaultValue = opt.DefaultValue;
                    }
                    else
                    {
                        values       = opt.GetCollection();
                        value        = values[0];
                        defaultValue = opt.DefaultValue;
                    }

                    for (int i = 0; i < values.Count; i++)
                    {
                        box.Items.Add(values[i]);
                    }

                    if (defaultValue != null)
                    {
                        box.SelectedIndex = box.Items.IndexOf(defaultValue);
                        if (box.SelectedIndex == -1)
                        {
                            box.SelectedIndex = box.Items.IndexOf(value);
                        }
                    }
                    else
                    {
                        box.SelectedIndex = box.Items.IndexOf(value);
                    }

                    box.Width         = wid;
                    box.Height        = 40;
                    box.Left          = cool.Width - box.Width - border;
                    box.Top           = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor        = AnchorStyles.Right;
                    box.DropDownStyle = ComboBoxStyle.DropDownList;
                    cool.Controls.Add(box);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                    ChangeOption(box.Tag, box.SelectedItem);
                }
                else if (opt.Value is bool)
                {
                    SizeableCheckbox box = new SizeableCheckbox();
                    int border           = 10;

                    box.Checked = (bool)val;
                    box.Width   = 40;
                    box.Height  = 40;
                    box.Left    = cool.Width - box.Width - border;
                    box.Top     = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor  = AnchorStyles.Right;
                    cool.Controls.Add(box);

                    box.Tag             = opt;
                    box.CheckedChanged += box_CheckedChanged;
                    ChangeOption(box.Tag, box.Checked);
                }
                else if (opt.Value is int || opt.Value is double)
                {
                    NumericUpDown num    = new NumericUpDown();
                    int           border = 10;

                    int value = int.Parse(val.ToString());
                    if (value < num.Minimum)
                    {
                        num.Minimum = value;
                    }

                    num.Value = value;

                    num.Width  = wid;
                    num.Height = 40;
                    num.Left   = cool.Width - num.Width - border;
                    num.Top    = (cool.Height / 2) - (num.Height / 2);
                    num.Anchor = AnchorStyles.Right;
                    cool.Controls.Add(num);

                    num.Tag           = opt;
                    num.ValueChanged += num_ValueChanged;
                    ChangeOption(num.Tag, num.Value);
                }
                else if (opt.Value is GameOptionValue)
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    GameOptionValue value = (GameOptionValue)val;
                    PropertyInfo[]  props = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.Static);

                    for (int i = 0; i < props.Length; i++)
                    {
                        PropertyInfo prop = props[i];
                        box.Items.Add(prop.GetValue(null, null));
                    }
                    box.SelectedIndex = box.Items.IndexOf(value);

                    box.Width  = wid;
                    box.Height = 40;
                    box.Left   = cool.Width - box.Width - border;
                    box.Top    = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor = AnchorStyles.Right;
                    //box.DropDownStyle = ComboBoxStyle.DropDownList;
                    cool.Controls.Add(box);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                    ChangeOption(box.Tag, box.SelectedItem);
                }

                UserControl bottomLine = new UserControl();
                bottomLine.Width     = cool.Width;
                bottomLine.Height    = 1;
                bottomLine.Top       = cool.Height - 1;
                bottomLine.Anchor    = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
                bottomLine.BackColor = Color.FromArgb(35, 39, 42);
                cool.Controls.Add(bottomLine);
            }

            this.Controls.Add(list);
            list.UpdateSizes();
            CanPlayUpdated(true, false);
        }
Exemplo n.º 6
0
        public void Initialize(UserGameInfo game, GameProfile profile)
        {
            this.profile = profile;
            this.Controls.Clear();

            var options = game.Game.Options;
            var vals    = profile.Options;

            foreach (var opt in options)
            {
                CoolListControl cool = new CoolListControl();
                cool.Text        = opt.Value.Name;
                cool.Description = opt.Value.Description;
                cool.Width       = this.Width;

                this.Controls.Add(cool);

                // Check the value type and add a control for it
                if (opt.Value.Value is bool)
                {
                    SizeableCheckbox box = new SizeableCheckbox();
                    int border           = 10;

                    box.Checked = (bool)vals[opt.Key];
                    box.Width   = 40;
                    box.Height  = 40;
                    box.Left    = cool.Width - box.Width - border;
                    box.Top     = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor  = AnchorStyles.Right;
                    cool.AddControl(box, false);

                    box.Tag             = opt;
                    box.CheckedChanged += box_CheckedChanged;
                }
                else if (opt.Value.Value is int)
                {
                    NumericUpDown num    = new NumericUpDown();
                    int           border = 10;

                    num.Value = (int)vals[opt.Key];

                    num.Width  = 150;
                    num.Height = 40;
                    num.Left   = cool.Width - num.Width - border;
                    num.Top    = (cool.Height / 2) - (num.Height / 2);
                    num.Anchor = AnchorStyles.Right;
                    cool.AddControl(num, false);

                    num.Tag           = opt;
                    num.ValueChanged += num_ValueChanged;
                }
                else if (opt.Value.Value is Enum)
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    Enum  value  = (Enum)vals[opt.Key];
                    Array values = Enum.GetValues(value.GetType());
                    for (int i = 0; i < values.Length; i++)
                    {
                        box.Items.Add(((IList)values)[i]);
                    }
                    box.SelectedIndex = box.Items.IndexOf(value);

                    box.Width  = 150;
                    box.Height = 40;
                    box.Left   = cool.Width - box.Width - border;
                    box.Top    = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor = AnchorStyles.Right;
                    cool.AddControl(box, false);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                }
            }

            UpdateSizes();
        }