コード例 #1
0
 private void InitializeComponent()
 {
     this.tree = new DarkUI.Controls.DarkTreeView();
     this.suggestedGameVersionComboBox = new DarkUI.Controls.DarkComboBox();
     this.darkLabel1 = new DarkUI.Controls.DarkLabel();
     this.SuspendLayout();
     //
     // tree
     //
     this.tree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                               | System.Windows.Forms.AnchorStyles.Left)
                                                              | System.Windows.Forms.AnchorStyles.Right)));
     this.tree.Enabled       = false;
     this.tree.Location      = new System.Drawing.Point(0, 30);
     this.tree.MaxDragChange = 20;
     this.tree.MultiSelect   = true;
     this.tree.Name          = "tree";
     this.tree.Size          = new System.Drawing.Size(150, 120);
     this.tree.TabIndex      = 1;
     this.tree.Click        += new System.EventHandler(this.tree_Click);
     this.tree.DoubleClick  += new System.EventHandler(this.tree_DoubleClick);
     this.tree.KeyDown      += new System.Windows.Forms.KeyEventHandler(this.Tree_KeyDown);
     this.tree.KeyPress     += new System.Windows.Forms.KeyPressEventHandler(this.Tree_KeyPress);
     this.tree.KeyUp        += new System.Windows.Forms.KeyEventHandler(this.Tree_KeyUp);
     this.tree.MouseDown    += new System.Windows.Forms.MouseEventHandler(this.tree_MouseDown);
     //
     // suggestedGameVersionComboBox
     //
     this.suggestedGameVersionComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                                                                                      | System.Windows.Forms.AnchorStyles.Right)));
     this.suggestedGameVersionComboBox.Enabled           = false;
     this.suggestedGameVersionComboBox.FormattingEnabled = true;
     this.suggestedGameVersionComboBox.Location          = new System.Drawing.Point(103, 3);
     this.suggestedGameVersionComboBox.Name                  = "suggestedGameVersionComboBox";
     this.suggestedGameVersionComboBox.Size                  = new System.Drawing.Size(47, 21);
     this.suggestedGameVersionComboBox.TabIndex              = 0;
     this.suggestedGameVersionComboBox.SelectedIndexChanged += new System.EventHandler(this.suggestedGameVersionComboBox_SelectedIndexChanged);
     //
     // darkLabel1
     //
     this.darkLabel1.AutoSize  = true;
     this.darkLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
     this.darkLabel1.Location  = new System.Drawing.Point(3, 6);
     this.darkLabel1.Name      = "darkLabel1";
     this.darkLabel1.Size      = new System.Drawing.Size(91, 13);
     this.darkLabel1.TabIndex  = 3;
     this.darkLabel1.Text      = "Game slot names:";
     //
     // WadTreeView
     //
     this.Controls.Add(this.darkLabel1);
     this.Controls.Add(this.suggestedGameVersionComboBox);
     this.Controls.Add(this.tree);
     this.Name   = "WadTreeView";
     this.Click += new System.EventHandler(this.WadTreeView_Click);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
コード例 #2
0
        public static void InitializeComboBox(this DarkComboBox cb, Type type, object value, bool addNull = false)
        {
            cb.BeginUpdate();
            cb.Items.Clear();
            var items = ObjectCache.GetObjectTypeList(type);

            if (addNull)
            {
                cb.Items.Add(new DarkUI.Controls.DarkListItem(null, o => "<None>"));
            }

            cb.Items.AddRange(items.OfType <MBObjectBase>()
                              .Select(x => new DarkUI.Controls.DarkListItem(x, o => ((MBObjectBase)o).GetName()?.ToString()))
                              .OrderBy(x => x.Text, StringComparer.InvariantCultureIgnoreCase)
                              .OfType <object>()
                              .ToArray());
            cb.EndUpdate();
            cb.SelectedItem = cb.Items.OfType <DarkUI.Controls.DarkListItem>().FirstOrDefault(x => x.Tag == value);
        }
コード例 #3
0
 public Layer(string folderName, DarkComboBox itemList, DarkButton colorButton, ColorDialog colorD, TrackBar intBar, TrackBar aBar, PictureBox lockPic, frmGenerator form)
 {
     if (!Directory.Exists("assets"))
     {
         Directory.CreateDirectory("assets");
     }
     frmGenerator = form;
     colorDialog  = colorD;
     intensityBar = intBar;
     lockBox      = lockPic;
     alphaBar     = aBar;
     directory    = folderName;
     cmbItems     = itemList;
     colorBtn     = colorButton;
     LoadItems();
     PopulateList(true);
     cmbItems.SelectedIndexChanged += cmbItems_SelectedIndexChanged;
     colorBtn.Click        += btnColor_Click;
     intBar.ValueChanged   += intBar_ValueChanged;
     alphaBar.ValueChanged += alphaBar_ValueChanged;
     lockBox.Click         += LockBox_Click;
 }
コード例 #4
0
        internal static void DarkUI_ObjectList_CellEditStarting(object sender, CellEditEventArgs e)
        {
            var type     = e.Value.GetType();
            var typeCode = Convert.GetTypeCode(e.Value);

            if (typeCode == TypeCode.Boolean)
            {
                e.AutoDispose = true;
                var cb = new DarkComboBox
                {
                    Bounds        = e.CellBounds,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                    Sorted        = false,
                };
                cb.Items.Add(Boolean.FalseString);
                cb.Items.Add(Boolean.TrueString);
                cb.SelectedIndex = Convert.ToInt32(e.Value);
                e.Control        = cb;
            }
            else if (type.IsEnum)
            {
                e.AutoDispose = true;
                var cb = new DarkComboBox
                {
                    Bounds        = e.CellBounds,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                    Sorted        = false,
                };
                cb.Items.AddRange(Enum.GetNames(type));
                cb.SelectedIndex = cb.FindStringExact(e.Value.ToString());
                e.Control        = cb;
            }
            else if (typeCode == TypeCode.String)
            {
                e.AutoDispose = true;
                e.Control     = new DarkTextBox
                {
                    Bounds = e.CellBounds,
                    Text   = e.Value.ToString(),
                };
            }
            else if (typeCode == TypeCode.Object || typeCode == TypeCode.DBNull || typeCode == TypeCode.Empty)
            {
                e.Cancel = true;
            }
            else // numeric types
            {
                var value    = e.Value;
                var minValue = (decimal)Int32.MinValue;
                var maxValue = (decimal)Int32.MaxValue;
                var absval   = Math.Abs(Convert.ToDouble(value));
                var scale    = (absval < 0.001) ? 0 : Convert.ToInt32(Math.Log10(absval));
                var incr     = (absval < 0.001) ? 1M : Convert.ToDecimal(Math.Pow(10, Math.Min(3, Math.Max(0, scale - 2))));

                switch (typeCode)
                {
                case TypeCode.Byte:
                    minValue = (decimal)Byte.MinValue;
                    maxValue = (decimal)Byte.MaxValue;
                    break;

                case TypeCode.SByte:
                    minValue = (decimal)SByte.MinValue;
                    maxValue = (decimal)SByte.MaxValue;
                    break;

                case TypeCode.Char:
                    minValue = (decimal)Char.MinValue;
                    maxValue = (decimal)Char.MaxValue;
                    break;

                case TypeCode.Int16:
                    minValue = (decimal)Int16.MinValue;
                    maxValue = (decimal)Int16.MaxValue;
                    break;

                case TypeCode.Int32:
                    minValue = (decimal)Int32.MinValue;
                    maxValue = (decimal)Int32.MaxValue;
                    break;

                case TypeCode.Int64:
                    minValue = (decimal)Int64.MinValue;
                    maxValue = (decimal)Int64.MaxValue;
                    break;

                case TypeCode.UInt16:
                    minValue = (decimal)UInt16.MinValue;
                    maxValue = (decimal)UInt16.MaxValue;
                    break;

                case TypeCode.UInt32:
                    minValue = (decimal)UInt32.MinValue;
                    maxValue = (decimal)UInt32.MaxValue;
                    break;

                case TypeCode.UInt64:
                    minValue = (decimal)UInt64.MinValue;
                    maxValue = (decimal)UInt64.MaxValue;
                    break;

                case TypeCode.Decimal:
                case TypeCode.Double:
                case TypeCode.Single:
                    minValue = Decimal.MinValue;
                    maxValue = Decimal.MaxValue;
                    break;
                }
                e.AutoDispose = true;
                e.Control     = new DarkNumericUpDown
                {
                    Bounds              = e.CellBounds,
                    Minimum             = minValue,
                    Maximum             = maxValue,
                    Increment           = incr,
                    MouseWheelIncrement = incr,
                    Value = Convert.ToDecimal(e.Value),
                };
            }
        }