Exemplo n.º 1
0
 protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
 {
     base.OnDrawColumnHeader(e);
     if (e.ColumnIndex == 0)
     {
         var headerCheckBox = new CheckBox {Text = "", Visible = true};
         SuspendLayout();
         e.DrawBackground();
         headerCheckBox.BackColor = Color.Transparent;
         headerCheckBox.UseVisualStyleBackColor = true;
         headerCheckBox.BackgroundImage = Resources.ListViewHeaderCheckboxBackgroud;
         headerCheckBox.SetBounds(e.Bounds.X, e.Bounds.Y,
                                  headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).
                                      Width,
                                  headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).
                                      Height);
         headerCheckBox.Size =
             new Size(headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width - 1, e.Bounds.Height)).Width + 1,
                      e.Bounds.Height);
         headerCheckBox.Location = new Point(4, 0);
         Controls.Add(headerCheckBox);
         headerCheckBox.Show();
         headerCheckBox.BringToFront();
         e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
         headerCheckBox.CheckedChanged += OnHeaderCheckboxCheckedChanged;
         ResumeLayout(true);
     }
     else
     {
         e.DrawDefault = true;
     }
 }
Exemplo n.º 2
0
        private void chkSameOutputFolder_CheckedChanged(object sender, System.EventArgs e)
        {
            if (chkSameOutputFolder.Checked == true)
            {
                chkSameOutputFolder.Text  = "Katalog wyjœciowy taki sam jak wejsciowy";
                chkSameOutputFolder.Width = 306;
                chkSameOutputFolder.SendToBack();

                txtOutputFolder.Text    = txtWorkingFolder.Text;
                txtOutputFolder.Enabled = false;
                cmdBrowse3.Enabled      = false;
                txtSuffix.Visible       = true;
                lblSuffix1.Visible      = true;
                lblSuffix2.Visible      = true;
            }
            else
            {
                chkSameOutputFolder.Text  = "U¿yj katalogu wyjœciowego i zachowaj tê sam¹ nazwê pliku(ów)";
                chkSameOutputFolder.Width = cmdMake.Width;
                chkSameOutputFolder.BringToFront();

                txtOutputFolder.Text    = regOutputFolder;
                txtOutputFolder.Enabled = true;
                cmdBrowse3.Enabled      = true;
                txtSuffix.Visible       = false;
                lblSuffix1.Visible      = false;
                lblSuffix2.Visible      = false;
            }
        }
 /// ////////////////////////////////////////////////////
 protected override void InitChamps()
 {
     base.InitChamps();
     m_panelFiltre.InitSansVariables((CFiltreDynamique)ActionCreerListe.Filtre.Clone());
     m_chkCompterUniquement.Checked = ActionCreerListe.CompterUniquement;
     m_chkCompterUniquement.BringToFront();
     m_chkFiltreDefaut.Checked = ActionCreerListe.AppliquerFiltreParDefaut;
     m_chkFiltreDefaut.BringToFront();
 }
Exemplo n.º 4
0
 private static void DrawCkBox(System.Windows.Forms.DataGridView dgv)
 {
     System.Windows.Forms.CheckBox ckBox = new System.Windows.Forms.CheckBox();
     System.Drawing.Point          p     = dgv.GetCellDisplayRectangle(0, -1, true).Location;
     ckBox.Size = new System.Drawing.Size(18, 18);
     p.Offset(((dgv.Columns[0].Width - ckBox.Width) / 2) + 4, 2);
     ckBox.Location = p;
     ckBox.Visible  = true;
     ckBox.BringToFront();
     ckBox.BackColor       = System.Drawing.Color.White;
     ckBox.ThreeState      = false;
     ckBox.Checked         = false;
     ckBox.CheckedChanged += new EventHandler(ckBox_CheckedChanged);
     dgv.Controls.Add(ckBox);
 }
        /// ////////////////////////////////////////////////////
        protected override void InitChamps()
        {
            base.InitChamps();
            m_panelFiltre.InitSansVariables((CFiltreDynamique)ActionVisualiser.Filtre.Clone());
            m_chkFiltreDefaut.Checked = ActionVisualiser.AppliquerFiltreParDefaut;
            m_chkFiltreDefaut.BringToFront();

            m_wndAideFormule.FournisseurProprietes = ActionVisualiser.Process;
            m_wndAideFormule.ObjetInterroge        = typeof(CProcess);

            m_txtFormuleTitre.Init(m_wndAideFormule.FournisseurProprietes, m_wndAideFormule.ObjetInterroge);
            m_txtFormuleContexteUtilisation.Init(m_wndAideFormule.FournisseurProprietes, m_wndAideFormule.ObjetInterroge);

            m_txtFormuleTitre.Formule = ActionVisualiser.ExpressionTitreFenetre;
            m_txtFormuleContexteUtilisation.Formule = ActionVisualiser.ExpressionContexteFenetre;

            OnEnterTextFormule(m_txtFormuleTitre);
        }
Exemplo n.º 6
0
        /// <summary>
        /// dgv第一列加checkbox
        /// </summary>
        /// <param name="dgv">datagridview名称</param>
        public static void AddCheckBoxToDataGridView(ref DataGridView dgv)
        {
            DataGridViewCheckBoxColumn FirstCells = new DataGridViewCheckBoxColumn();

            FirstCells.Name             = "dgvCellsCheck";
            FirstCells.DataPropertyName = "dgvCellsCheck";
            FirstCells.HeaderText       = "";
            FirstCells.ReadOnly         = false;
            FirstCells.Width            = 60;
            dgv.Columns.Add(FirstCells);
            System.Windows.Forms.CheckBox ckBox = new System.Windows.Forms.CheckBox();
            ckBox.Text    = "全选";
            ckBox.Parent  = dgv;//设置checkbox父控件为DataGridView
            ckBox.Checked = false;
            System.Drawing.Rectangle rect = dgv.GetCellDisplayRectangle(0, -1, true);
            ckBox.Size            = new System.Drawing.Size(dgv.Columns[0].Width - 10, 18);
            ckBox.Location        = new Point(rect.Location.X + 5, rect.Location.Y + 10);
            ckBox.CheckedChanged += new EventHandler(ckBox_CheckedChanged);
            dgv.Controls.Add(ckBox);
            ckBox.BringToFront();
        }
Exemplo n.º 7
0
        public void CreateFilterButtons(int x, int y, Panel pnl, EventHandler Handler)
        {
            List<String> Items = new List<string>(Data.ItemTypes.Keys);
            Items.Sort();

            foreach (String Type in Items)
                if (Type != "NONE" && Type != "ITEM_TYPE_NONE")
                {
                    CheckBox Chk = new CheckBox();
                    pnl.Controls.Add(Chk);
                    Chk.UseVisualStyleBackColor = true;
                    Chk.Text = Type;
                    Chk.Location = new Point(x, y);
                    Chk.Name = "_chk" + Type;
                    Chk.AutoSize = true;
                    Chk.Checked = true;
                    Chk.BringToFront();
                    Chk.CheckedChanged += Handler;
                    y += 14;
                }
        }
Exemplo n.º 8
0
        public void CreateGUI()
        {
            this.MetaTab.Controls.Clear();
            int num = 0;
            int num2 = 0;
            int arg_25_0 = 0;
            checked
            {
                int num3 = [email protected] - 1;
                for (int i = arg_25_0; i <= num3; i++)
                {
                    GroupBox groupBox = new GroupBox();
                    groupBox.Text = this.@struct[i].name;
                    groupBox.Name = this.@struct[i].name + "GroupBox";
                    Point location;
                    int j;
                    if (!(this.@struct[i].name.Equals("Main")))
                    {
                        ComboBox comboBox = new ComboBox();
                        Label label = new Label();
                        label.Text = this.@struct[i].name;
                        Control arg_C2_0 = label;
                        location = new Point(2, num);
                        arg_C2_0.Location = location;
                        label.Width = this.@struct[i].name.Length * 7;
                        comboBox.Name = this.@struct[i].name + "ComboBox";
                        Control arg_11F_0 = comboBox;
                        location = new Point(label.Width + 10, num);
                        arg_11F_0.Location = location;
                        comboBox.SelectedIndexChanged += new EventHandler(this.somethingChanged);
                        comboBox.Click += new EventHandler(this.SetUserDidIt);
                        this.MetaTab.Controls.Add(label);
                        this.MetaTab.Controls.Add(comboBox);
                        int arg_188_0 = 0;
                        int num4 = this.@struct[0].values.Length - 1;
                        for (j = arg_188_0; j <= num4; j++)
                        {
                            if (this.@struct[i].name.Equals(this.@struct[0].values[j].name) & this.@struct[0].values[j].type.Equals("reflexive"))
                            {
                                int arg_212_0 = 0;
                                int num5 = this.@struct[0].values[j].count - 1;
                                for (int k = arg_212_0; k <= num5; k++)
                                {
                                    comboBox.Items.Add(k);
                                }

                            }
                        }

                        num += 25;
                    }

                    Control arg_252_0 = groupBox;
                    location = new Point(2, num);
                    arg_252_0.Location = location;
                    int x = 10;
                    int num6 = 15;
                    int arg_277_0 = 0;
                    int num7 = this.@struct[i].values.Length - 1;
                    j = arg_277_0;
                    Size size;
                    while (j <= num7)
                    {
                        string type = this.@struct[i].values[j].type;
                        if (type.Equals("float"))
                        {
                            goto IL_2E2;
                        }

                        if (type.Equals("string32"))
                        {
                            goto IL_2E2;
                        }

                        if (type.Equals("integer"))
                        {
                            goto IL_2E2;
                        }

                        if (type.Equals("short"))
                        {
                            goto IL_2E2;
                        }

                        if (type.Equals("id32") || type.Equals("id16"))
                        {
                            GroupBox groupBox2 = new GroupBox();
                            groupBox2.Tag = this.@struct[i].values[j].offset;
                            groupBox2.Name = this.@struct[i].values[j].name.Replace(" ", "") + "Group";
                            groupBox2.Text = this.@struct[i].values[j].name;
                            groupBox2.Width = this.MetaTab.Width - 20;
                            groupBox2.Height = 20 + (this.@struct[i].values[j].offset_options.Length / 2 + this.@struct[i].values[j].offset_options.Length % 2) * 16;
                            Control arg_5BD_0 = groupBox2;
                            location = new Point(x, num6);
                            arg_5BD_0.Location = location;
                            groupBox2.TabIndex = num2;
                            num2++;
                            int x2 = 10;
                            int num8 = 15;
                            int arg_5F9_0 = 0;
                            int num9 = this.@struct[i].values[j].offset_options.Length - 1;
                            for (int k = arg_5F9_0; k <= num9; k++)
                            {
                                RadioButton radioButton = new RadioButton();
                                radioButton.Name = this.@struct[i].values[j].offset_options[k].op_name.Replace(" ", "") + "RadioButton";
                                radioButton.Text = this.@struct[i].values[j].offset_options[k].op_name;
                                radioButton.Tag = this.@struct[i].values[j].offset_options[k].op_value;
                                if (Operators.ConditionalCompareObjectEqual(this.@struct[i].values[j].offset_options[k].op_value, this.@struct[i].values[j].data, false))
                                {
                                    radioButton.Checked = true;
                                }

                                else
                                {
                                    radioButton.Checked = false;
                                }

                                Control arg_71F_0 = radioButton;
                                location = new Point(x2, num8);
                                arg_71F_0.Location = location;
                                Control arg_742_0 = radioButton;
                                size = new Size(radioButton.Name.Length * 5 + 15, 15);
                                arg_742_0.Size = size;
                                radioButton.TabIndex = num2 + k;
                                radioButton.CheckedChanged += new EventHandler(this.somethingChanged);
                                groupBox2.Controls.Add(radioButton);
                                radioButton.BringToFront();
                                if (k % 2 == 1)
                                {
                                    x2 = 10;
                                    num8 += 15;
                                }

                                else
                                {
                                    x2 = (int)Math.Round((double)this.MetaTab.Width / 2.0);
                                }

                            }
                            groupBox.Controls.Add(groupBox2);
                            num6 += groupBox2.Height;
                            x = 10;
                            num2 += this.@struct[i].values[j].offset_options.Length;
                        }

                        else
                        {
                            if (type.Equals("bitmask32"))
                            {
                                GroupBox groupBox3 = new GroupBox();
                                groupBox3.Tag = this.@struct[i].values[j].offset;
                                groupBox3.Name = this.@struct[i].values[j].name.Replace(" ", "") + "Group";
                                groupBox3.Text = this.@struct[i].values[j].name;
                                groupBox3.Width = this.MetaTab.Width - 20;
                                groupBox3.Height = 20 + (this.@struct[i].values[j].offset_options.Length / 2 + this.@struct[i].values[j].offset_options.Length % 2) * 16;
                                groupBox3.TabIndex = num2;
                                Control arg_916_0 = groupBox3;
                                location = new Point(x, num6);
                                arg_916_0.Location = location;
                                int x2 = 10;
                                int num8 = 15;
                                num2++;
                                int arg_94A_0 = 0;
                                int num10 = this.@struct[i].values[j].offset_options.Length - 1;
                                for (int k = arg_94A_0; k <= num10; k++)
                                {
                                    CheckBox checkBox = new CheckBox();
                                    checkBox.Name = this.@struct[i].values[j].offset_options[k].op_name.Replace(" ", "") + "CheckBox";
                                    checkBox.Text = this.@struct[i].values[j].offset_options[k].op_name;
                                    checkBox.Tag = this.@struct[i].values[j].offset_options[k].op_value;
                                    Control arg_A0E_0 = checkBox;
                                    location = new Point(x2, num8);
                                    arg_A0E_0.Location = location;
                                    Control arg_A31_0 = checkBox;
                                    size = new Size(checkBox.Name.Length * 5 + 15, 15);
                                    arg_A31_0.Size = size;
                                    checkBox.TabIndex = num2 + k;
                                    if (this.@struct[i].values[j].data != null)
                                    {
                                        object arg_ADE_0 = this.@struct[i].values[j].data;
                                        Type arg_ADE_1 = null;
                                        string arg_ADE_2 = "BitOn";
                                        object[] array = new object[1];
                                        object[] arg_AC6_0 = array;
                                        int arg_AC6_1 = 0;
                                        XMLMain.TAG_STRUCT[] arg_A99_0 = this.@struct;
                                        int num11 = i;
                                        XMLMain.VALUE_STRUCT[] arg_AA8_0 = arg_A99_0[num11].values;
                                        int num12 = j;
                                        XMLMain.OFFSET_OPTIONS[] arg_AB7_0 = arg_AA8_0[num12].offset_options;
                                        int num13 = k;
                                        arg_AC6_0[arg_AC6_1] = arg_AB7_0[num13].op_value;
                                        object[] array2 = array;
                                        object[] arg_ADE_3 = array2;
                                        string[] arg_ADE_4 = null;
                                        Type[] arg_ADE_5 = null;
                                        bool[] array3 = new bool[]
                                        {
                                            true
                                        };
                                        object arg_B35_0 = NewLateBinding.LateGet(arg_ADE_0, arg_ADE_1, arg_ADE_2, arg_ADE_3, arg_ADE_4, arg_ADE_5, array3);
                                        if (array3[0])
                                        {
                                            this.@struct[num11].values[num12].offset_options[num13].op_value = (int)Conversions.ChangeType(RuntimeHelpers.GetObjectValue(array2[0]), typeof(int));
                                        }

                                        if (Conversions.ToBoolean(arg_B35_0))
                                        {
                                            checkBox.Checked = true;
                                        }

                                    }
                                    checkBox.CheckedChanged += new EventHandler(this.somethingChanged);
                                    groupBox3.Controls.Add(checkBox);
                                    checkBox.BringToFront();
                                    if (k % 2 == 1)
                                    {
                                        x2 = 10;
                                        num8 += 15;
                                    }

                                    else
                                    {
                                        x2 = (int)Math.Round((double)this.MetaTab.Width / 2.0);
                                    }

                                }
                                groupBox.Controls.Add(groupBox3);
                                num6 += groupBox3.Height;
                                num2 += this.@struct[i].values[j].offset_options.Length;
                                x = 10;
                            }

                        }
                    IL_BE9:
                        j++;
                        continue;
                    IL_2E2:
                        TextBox textBox = new TextBox();
                        Label label2 = new Label();
                        textBox.Name = this.@struct[i].values[j].name + "TextBox";
                        textBox.Tag = this.@struct[i].values[j].offset;
                        if (this.@struct[i].values[j].data != null)
                        {
                            textBox.Text = Conversions.ToString(this.@struct[i].values[j].data);
                        }

                        label2.Name = this.@struct[i].values[j].name + "Label";
                        label2.Text = this.@struct[i].values[j].name;
                        label2.TabIndex = num2;
                        textBox.TabIndex = num2 + 1;
                        label2.AutoSize = true;
                        Control arg_404_0 = label2;
                        location = new Point(x, num6);
                        arg_404_0.Location = location;
                        x = (int)Math.Round((double)this.MetaTab.Width / 2.0);
                        Control arg_436_0 = textBox;
                        size = new Size(75, 20);
                        arg_436_0.Size = size;
                        Control arg_44A_0 = textBox;
                        location = new Point(x, num6);
                        arg_44A_0.Location = location;
                        textBox.TextChanged += new EventHandler(this.somethingChanged);
                        groupBox.Controls.Add(label2);
                        groupBox.Controls.Add(textBox);
                        textBox.BringToFront();
                        num6 += 20;
                        x = 10;
                        num2 += 2;
                        goto IL_BE9;
                    }

                    Control arg_C12_0 = groupBox;
                    size = new Size(this.MetaTab.Width - 24, num6 + 5);
                    arg_C12_0.Size = size;
                    num += groupBox.Height;
                    this.MetaTab.Controls.Add(groupBox);
                }

            }
        }
Exemplo n.º 9
0
 private void createCheckBoxes()
 {
     int left = 100;
     int top = 55;
     for (int k = 0; k < 4; k++)
     {
         for (int j = 1; j <= 4; j++)
         {
             for (int i = 1; i <= 20; i++)
             {
                 CheckBox ii = new CheckBox();
                 ii.AutoSize = false;
                 ii.Size = new System.Drawing.Size(17, 18);
                 ii.Name = "cbx" + i;
                 ii.Text = i.ToString();
                 ii.Location = new Point(left, top);
                 ii.Tag = ((20 * k) + i) + ":" + j; // Assuming you have your files in an array or similar
                 ii.CheckedChanged += new System.EventHandler(this.Check_CheckedChanged);
                 top += 25;
                 this.Controls.Add(ii);
                 ii.BringToFront();
             }
             top = 55;
             if (j == 2)
             {
                 left += 50;
             }
             else
             {
                 left += 20;
             }
         } left += 90;
     }
 }
Exemplo n.º 10
0
        public void Display(QuestionDescriptor question)
        {
            if (question != null)
              {
            this.question = question;

            this.textControl.Title = question.Text.Text;
            this.textControl.Description = question.Description.Text;
            this.textControl.Url = question.Url.Text;
            this.textControl.BeginInfo();
            this.textControl.InfoFont = new Font("Arial", 12);
            RecalculateLayout();

            this.optionControls = new Dictionary<InfoControl, int>();
            this.optionsPanel.Controls.Clear();

            if (question.MaxOptions == 1)
            {
              this.maxOptionLabel.Text = Resources.VotingDialogMaxOptionSingle;
              this.singleOptionControls = new Dictionary<int, RadioButton>();
              int index = 0;
              int top = Space;

              foreach (OptionDescriptor option in question.Options)
              {
            var optionInfo = AddOptionInfo(index, top, option);

            RadioButton optionControl = new RadioButton();
            optionControl.Text = string.Empty;
            optionControl.Left = Space;
            optionControl.Top = top + BoxTop;
            optionControl.Height = optionInfo.Height;
            optionControl.TextAlign = ContentAlignment.MiddleRight;
            optionControl.Width = BoxWidth;
            this.optionsPanel.Controls.Add(optionControl);
            optionControl.BringToFront();
            optionControl.CheckedChanged += new EventHandler(OptionControl_CheckedChanged);
            this.singleOptionControls.Add(index, optionControl);

            top += optionControl.Height + VerticalSpace;
            index++;
              }
            }
            else
            {
              this.maxOptionLabel.Text = string.Format(Resources.VotingDialogMaxOptionMulti, question.MaxOptions);
              this.multiOptionControls = new Dictionary<int, CheckBox>();
              int index = 0;
              int top = Space;

              foreach (OptionDescriptor option in question.Options)
              {
            if (!option.IsAbstentionSpecial)
            {
              var optionInfo = AddOptionInfo(index, top, option);

              CheckBox optionControl = new CheckBox();
              optionControl.Text = string.Empty;
              optionControl.Top = top + BoxTop;
              optionControl.Width = BoxWidth;
              optionControl.Height = optionInfo.Height;
              optionControl.TextAlign = ContentAlignment.MiddleRight;
              this.optionsPanel.Controls.Add(optionControl);
              optionControl.BringToFront();
              optionControl.CheckedChanged += new EventHandler(OptionControl_CheckedChanged);
              this.multiOptionControls.Add(index, optionControl);

              top += optionControl.Height + VerticalSpace;
            }

            index++;
              }
            }
              }
        }
Exemplo n.º 11
0
        public SelectColumns()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            checkBoxes = new ArrayList();

            Hashtable underscored = new Hashtable();

            int numCounters = Statistics.GetNumberOfCounters();
            for(int i = 0; i < numCounters; i++)
            {
                string text = Statistics.GetCounterName(i);
                for(int j = 0; j < text.Length; j++)
                {
                    if(!Char.IsLetter(text, j))
                    {
                        continue;
                    }

                    char c = Char.ToLower(text[j]);
                    if(!underscored.ContainsKey(c))
                    {
                        underscored.Add(c, null);
                        text = text.Substring(0, j) + "&" + text.Substring(j);
                        break;
                    }
                }

                int px = (i % 2) == 1 ? Width / 2 : 16, py = 56;
                if(i > 1)
                {
                    py = ((CheckBox)checkBoxes[i - 2]).Bottom;
                }

                CheckBox box = new CheckBox();
                box.Parent = this;
                box.Visible = true;
                box.Location = new Point(px, py);
                box.Width = Width / 2 - 10;
                box.Text = text;
                box.BringToFront();

                checkBoxes.Add(box);
            }
        }
Exemplo n.º 12
0
        public void CreateFlags(GroupBox GrpBox, int x, int y, bool Chked)
        {
            int beginY = y;
            int count = 0;
            foreach(KeyValuePair<String, String> kvp in CustomFlags)
            {

                CheckBox chkBox = new CheckBox();
                chkBox.Text = kvp.Key;
                chkBox.Tag = kvp.Value;
                GrpBox.Controls.Add(chkBox);
                chkBox.Location = new System.Drawing.Point(x, y);
                chkBox.AutoSize = true;
                chkBox.Checked = Chked;
                chkBox.BringToFront();
                y += 14;
                count++;
                if (count == 19)
                {
                    x += 100;
                    y = beginY;
                }
            }
        }
Exemplo n.º 13
0
        // Character Trait Controls
        //private NumericUpDown spinAlchemyLevel; // 15-100
        //private CheckBox chkPhysicianPerk; // Restore Health, Magicka, or Stamina + 25%
        //private CheckBox chkBenefactorPerk; // +25% Beneficial
        //private CheckBox chkPoisonerPerk; // +25% Harmful
        //private CheckBox chkPurityPerk; // Only Harmful or only Beneficial

        public void DrawGui()
        {            
            #region Ingredients
            _drpIng = new ComboBox[3];
            var lblIng = new Label[3];
            var lblIngId = new Label[3];
            _dgvEffects = new DataGridView[3];
            var noIngs = new List<Ingredient> { new Ingredient() { Name = "<NONE>" } };
            var allIngs = noIngs.ToList();
            allIngs.AddRange(Ingredients.Values.OrderBy(ing => ing.Name));

            for (int i = 0; i < 3; i++)
            {
                lblIng[i] = new Label
                {
                    Text = string.Format("Ingredient #{0}:", i),
                    AutoSize = true,
                    Location =
                        i == 0
                            ? new Point(5, 5)
                            : new Point(lblIng[i - 1].Location.X, _drpIng[i - 1].Location.Y + 15 + _drpIng[i - 1].Height)
                };

                lblIngId[i] = new Label
                {
                    Text = string.Empty,
                    AutoSize = true,
                    Location = new Point(i == 0 ? lblIng[i].Right - 16 : lblIngId[i - 1].Left, lblIng[i].Top)
                };

                _drpIng[i] = new ComboBox();
                _drpIng[i].Size = new Size(150, _drpIng[i].Height);
                _drpIng[i].Location = new Point(lblIng[i].Location.X, lblIng[i].Location.Y + lblIng[i].Height);
                _drpIng[i].DataSource = allIngs.ToList();
                if (i != 0) _drpIng[i].Enabled = false;
                #region _drpIng[i].SelectedIndexChanged
                switch (i)
                {
                    case 0:
                        _drpIng[i].SelectedIndexChanged += (o, e) =>
                        {
                            var ing = _drpIng.Select(drp => drp.SelectedValue as Ingredient).ToArray();
                            lblIngId[0].Text = ing[0].ID ?? string.Empty;
                            var row1 = _dgvEffects[0].Rows.Cast<DataGridViewRow>().First();
                            _drpIng[1].Enabled = ing[0].ID != null;
                            for (int j = 0; j < 4; j++)
                            {
                                ((DataGridViewTextBoxCell)row1.Cells[j]).Value = _drpIng[1].Enabled ? ing[0].Effects[j].Name : string.Empty;
                                _dgvEffects[0].Columns[j].DefaultCellStyle.BackColor = Color.White;
                            }

                            var ing2 = _drpIng[1].SelectedValue as Ingredient;
                            var newSet = FilterIngredients(ing[0].CompatibleIngredients.Where(ingr => ingr.ID != null).Select(ingr => Ingredients[ingr.ID]));
                            _drpIng[1].DataSource = noIngs.Concat(newSet).ToList();
                            if (ing2 != null && !(ing2.ID == null || !newSet.Any(ingr => ingr.ID != null && ingr.ID.Equals(ing[1].ID))))
                                _drpIng[1].SelectedItem = ing[1].Name;
                        };
                        break;
                    case 1:
                        _drpIng[i].SelectedIndexChanged += (o, e) =>
                        {
                            var ing = _drpIng.Select(drp => drp.SelectedValue as Ingredient).ToArray();
                            lblIngId[1].Text = ing[1].ID ?? string.Empty;
                            var row1 = _dgvEffects[1].Rows.Cast<DataGridViewRow>().First();
                            for (int j = 0; j < 4; j++) _dgvEffects[0].Columns[j].DefaultCellStyle.BackColor = Color.White;
                            for (int j = 0; j < 4; j++)
                            {
                                var cell = row1.Cells[j] as DataGridViewTextBoxCell;
                                if (cell != null)
                                {
                                    if (ing[1].ID != null)
                                    {
                                        var ef = ing[1].Effects[j];
                                        cell.Value = ef.Name;
                                    }
                                    else cell.Value = string.Empty;
                                }
                            }
                            SetEffectColors();

                            var results = noIngs.ToList();
                            if (ing[0].ID != null)
                            {
                                var compat1 = ing[0].CompatibleIngredients;
                                results.AddRange(compat1);
                            }
                            _drpIng[2].Enabled = ing[1].ID != null;
                            if (_drpIng[1].Enabled)
                            {
                                var compat2 = ing[1].CompatibleIngredients;
                                results.AddRange(compat2);
                            }
                            else lblPotionValue.Text = @"N/A";
                            results = results.DistinctBy(ingr => ingr.ID).Where(ingr => ingr.ID == null || !(ingr.ID.Equals(ing[0].ID) || ingr.ID.Equals(ing[1].ID)))
                                                .OrderBy(ingr => !ingr.Name.Equals("<NONE>")).ThenBy(ingr => ingr.Name).ToList();
                            results = FilterIngredients(results.Where(ingr => ingr.ID != null).Select(ingr => Ingredients[ingr.ID]));
                            _drpIng[2].DataSource = noIngs.Concat(results).ToList();
                            if (ing[2].ID != null && results.Any(ingr => ingr.ID != null && ingr.ID.Equals(ing[2].ID))) _drpIng[2].SelectedItem = ing[2].Name;
                        };
                        break;
                    case 2:
                        _drpIng[i].SelectedIndexChanged += (o, e) =>
                        {
                            var ing = _drpIng.Select(drp => drp.SelectedValue as Ingredient).ToArray();
                            lblIngId[2].Text = ing[2].ID ?? string.Empty;
                            var row1 = _dgvEffects[2].Rows.Cast<DataGridViewRow>().First();
                            for (int j = 0; j < 4; j++)
                            {
                                var cell = row1.Cells[j] as DataGridViewTextBoxCell;
                                if (cell != null)
                                {
                                    if (ing[2].ID != null)
                                    {
                                        var ef = ing[2].Effects[j];
                                        cell.Value = ef.Name;
                                    }
                                    else cell.Value = string.Empty;
                                }
                            }
                            SetEffectColors();
                            UpdateResult(o, e);
                        };
                        break;
                }
                #endregion
                pnlIngredients.Controls.Add(_drpIng[i]);
                _drpIng[i].BringToFront();

                _dgvEffects[i] = new DataGridView
                {
                    ColumnCount = 4,
                    Name = "dgvIng" + i.ToString() + "Effects",
                    Location = new Point(_drpIng[i].Right + 10, _drpIng[i].Top),
                    Size = new Size(100 + 3*TxtEffectsWidth, 22),
                    AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                    Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
                    EditMode = DataGridViewEditMode.EditProgrammatically,
                    AllowUserToAddRows = false,
                    AllowUserToDeleteRows = false,
                    AllowUserToResizeColumns = false,
                    AllowUserToResizeRows = false,
                    RowHeadersVisible = false,
                    ColumnHeadersVisible = false
                };
                switch (i)
                {
                    case 0: _dgvEffects[i].SelectionChanged += (o, e) => _dgvEffects[0].ClearSelection(); break;
                    case 1: _dgvEffects[i].SelectionChanged += (o, e) => _dgvEffects[1].ClearSelection(); break;
                    case 2: _dgvEffects[i].SelectionChanged += (o, e) => _dgvEffects[2].ClearSelection(); break;
                }
                _dgvEffects[i].Rows.Add(new DataGridViewRow());

                var row = _dgvEffects[i].Rows.Cast<DataGridViewRow>().First();
                for (int j = 0; j < 4; j++)
                {
                    var cell = row.Cells[0] as DataGridViewTextBoxCell;
                    if (cell != null)
                    {
                        cell.Value = string.Empty;
                        cell.ReadOnly = true;
                    }
                }
            }
            pnlIngredients.Controls.AddRange(lblIng);
            pnlIngredients.Controls.AddRange(lblIngId);
            pnlIngredients.Controls.AddRange(_dgvEffects);

            btnUpdateDb.Click += (o, e) => LoadDb(true);
            btnUpdateDb.Visible = Program.IsAdministrator;
            #endregion

            #region Filters
            btnApplyFilter.Click += ApplyFilter;
            pnlFilterChk.HorizontalScroll.Enabled = false;

            _chkDlc = new CheckBox[4];
            for (int i = 0; i < 4; i++)
            {
                _chkDlc[i] = new CheckBox
                {
                    Text = i == 0 ? "ALL Dlc" : ((Dlc) i).ToString(),
                    AutoSize = true,
                    Location = new Point(5, i == 0 ? 5 : _chkDlc[i - 1].Bottom - 8),
                    Checked = true
                };
                if (i > 0) _chkDlc[i].CheckedChanged += chkDlc_CheckChanged;
                else
                {
                    _chkDlc[i].ThreeState = true;
                    _chkDlc[i].Click += (o, e) =>
                    {
                        switch (_chkDlc[0].CheckState)
                        {
                            case CheckState.Checked:
                                foreach (var chk in _chkDlc.Skip(1)) chk.CheckState = CheckState.Checked;
                                break;
                            case CheckState.Unchecked:
                            case CheckState.Indeterminate:
                                foreach (var chk in _chkDlc.Skip(1)) chk.CheckState = CheckState.Unchecked;
                                break;
                        }
                    };
                }
            }
            pnlFilterChk.Controls.AddRange(_chkDlc);

            var efs = Effects.Values.OrderBy(ing => ing.Name).ToArray();
            _chkEffect = new Dictionary<string, CheckBox>();
            var chkAllEffects = new CheckBox
            {
                Text = @"ALL EFFECTS",
                AutoSize = true,
                Location = new Point(_chkDlc[0].Left, _chkDlc[3].Bottom + 20),
                Checked = true,
                ThreeState = true
            };
            chkAllEffects.Click += (o, e) =>
            {
                switch (chkAllEffects.CheckState)
                {
                    case CheckState.Checked:
                        foreach (var chk in _chkEffect.Values) chk.CheckState = CheckState.Checked;
                        _chkPosEffect.CheckState = CheckState.Checked;
                        _chkNegEffect.CheckState = CheckState.Checked;
                        break;
                    case CheckState.Unchecked:
                    case CheckState.Indeterminate:
                        foreach (var chk in _chkEffect.Values) chk.CheckState = CheckState.Unchecked;
                        _chkPosEffect.CheckState = CheckState.Unchecked;
                        _chkNegEffect.CheckState = CheckState.Unchecked;
                        break;
                }
            };
            _chkEffect[string.Empty] = chkAllEffects;
            pnlFilterChk.Controls.Add(chkAllEffects);

            _chkPosEffect = new CheckBox
            {
                Text = @"Beneficial",
                AutoSize = true,
                Location = new Point(chkAllEffects.Left, chkAllEffects.Bottom - 2),
                ThreeState = true,
                CheckState = CheckState.Checked
            };
            _chkPosEffect.Click += (o, e) =>
            {
                switch (_chkPosEffect.CheckState)
                {
                    case CheckState.Checked:
                        foreach (var efId in _chkEffect.Keys.Skip(1))
                        {
                            if (Effects[efId].IsBeneficial == 1)
                            {
                                _chkEffect[efId].CheckState = CheckState.Checked;
                            }
                        }
                        break;
                    case CheckState.Indeterminate:
                        _chkPosEffect.CheckState = CheckState.Unchecked;
                        goto case CheckState.Unchecked;
                    case CheckState.Unchecked:
                        foreach (var efId in _chkEffect.Keys.Skip(1))
                        {
                            if (Effects[efId].IsBeneficial == 1)
                            {
                                _chkEffect[efId].CheckState = CheckState.Unchecked;
                            }
                        }
                        break;
                }
            };
            pnlFilterChk.Controls.Add(_chkPosEffect);
            _chkPosEffect.BringToFront();

            _chkNegEffect = new CheckBox
            {
                Text = @"Harmful",
                AutoSize = true,
                Location = new Point(_chkPosEffect.Left, _chkPosEffect.Bottom - 2),
                ThreeState = true,
                CheckState = CheckState.Checked
            };

            _chkNegEffect.Click += (o, e) =>
            {
                switch (_chkNegEffect.CheckState)
                {
                    case CheckState.Checked:
                        foreach (var efId in _chkEffect.Keys.Skip(1))
                        {
                            if (Effects[efId].IsBeneficial == 0)
                            {
                                _chkEffect[efId].CheckState = CheckState.Checked;
                            }
                        }
                        break;
                    case CheckState.Indeterminate:
                        _chkNegEffect.CheckState = CheckState.Unchecked;
                        goto case CheckState.Unchecked;
                    case CheckState.Unchecked:
                        foreach (var efId in _chkEffect.Keys.Skip(1))
                        {
                            if (Effects[efId].IsBeneficial == 0)
                            {
                                _chkEffect[efId].CheckState = CheckState.Unchecked;
                            }
                        }
                        break;
                }
            };
            pnlFilterChk.Controls.Add(_chkNegEffect);
            _chkNegEffect.BringToFront();

            var lblSep = new Label
            {
                Text = string.Empty,
                BorderStyle = BorderStyle.Fixed3D,
                AutoSize = false,
                Height = 2,
                Width = pnlFilterChk.Width - 28,
                Location = new Point(5, _chkNegEffect.Bottom + 1)
            };
            pnlFilterChk.Controls.Add(lblSep);

            for (int i = 0; i < efs.Length; i++)
            {
                var effect = efs[i];
                var chk = new CheckBox
                {
                    Text = effect.Name,
                    Location =
                        new Point(chkAllEffects.Left,
                            i == 0 ? _chkNegEffect.Bottom + 5 : _chkEffect[efs[i - 1].ID].Bottom - 2),
                    AutoSize = true,
                    Checked = true
                };
                chk.CheckedChanged += chkEffect_CheckChanged;
                _chkEffect[effect.ID] = chk;
                pnlFilterChk.Controls.Add(chk);
                chk.BringToFront();
            }
            #endregion

            #region Character Traits
            spinAlchemyLevel.ValueChanged += UpdateResult;
            spinAlchemistPerk.ValueChanged += UpdateResult;

            var ttTemplate = new ToolTip
            {
                AutoPopDelay = 5000,
                InitialDelay = 1000,
                ReshowDelay = 500,
                ShowAlways = true
            };

            chkPhysicianPerk.CheckedChanged += UpdateResult;
            ttTemplate.SetToolTip(chkPhysicianPerk, "+25% Bonus to Restore Health, Magicka, or Stamina");
            chkBenefactorPerk.CheckedChanged += UpdateResult;
            ttTemplate.SetToolTip(chkBenefactorPerk, "+25% Bonus to beneficial Effects");
            chkPoisonerPerk.CheckedChanged += UpdateResult;
            ttTemplate.SetToolTip(chkPoisonerPerk, "+25% Bonus to harmful Effects");
            chkPurityPerk.CheckedChanged += UpdateResult;
            ttTemplate.SetToolTip(chkPurityPerk, "Potion contains only beneficial effects or only harmful effects");
            #endregion
        }