Exemplo n.º 1
0
        private void InitializeComponent()
        {
            CheckBoxProperties properties = new CheckBoxProperties();

            this.cmbFilter = new CheckBoxComboBox();
            this.txtSearch = new TextBox();
            base.SuspendLayout();
            this.cmbFilter.BackColor               = SystemColors.InfoText;
            properties.ForeColor                   = SystemColors.ControlText;
            this.cmbFilter.CheckBoxProperties      = properties;
            this.cmbFilter.DisplayMemberSingleItem = "";
            this.cmbFilter.DropDownStyle           = ComboBoxStyle.DropDownList;
            this.cmbFilter.Font = new Font("Microsoft Sans Serif", 7f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.cmbFilter.FormattingEnabled = true;
            this.cmbFilter.Location          = new Point(0, 0);
            this.cmbFilter.Margin            = new Padding(0);
            this.cmbFilter.Name        = "cmbFilter";
            this.cmbFilter.Size        = new Size(0x89, 20);
            this.cmbFilter.TabIndex    = 0;
            this.txtSearch.BorderStyle = BorderStyle.FixedSingle;
            this.txtSearch.Location    = new Point(0, 0);
            this.txtSearch.Margin      = new Padding(0);
            this.txtSearch.Name        = "txtSearch";
            this.txtSearch.Size        = new Size(120, 20);
            this.txtSearch.TabIndex    = 1;
            base.AutoScaleDimensions   = new SizeF(6f, 13f);
            base.AutoScaleMode         = AutoScaleMode.Font;
            base.Controls.Add(this.txtSearch);
            base.Controls.Add(this.cmbFilter);
            base.Name = "SearchControl";
            base.Size = new Size(140, 0x15);
            base.ResumeLayout(false);
            base.PerformLayout();
        }
        public void TestFlags()
        {
            var box = new CheckBoxComboBox();

            box.Items.Add("A");
            box.Items.Add("Area");
            box.Items.Add("Use Custom Tags");
            Assert.Equal(0, OutboundRulePage.GetFilter(box));
            box.CheckBoxItems[0].Checked = true;
            Assert.Equal(1, OutboundRulePage.GetFilter(box));
            box.CheckBoxItems[1].Checked = true;
            Assert.Equal(3, OutboundRulePage.GetFilter(box));
            box.CheckBoxItems[2].Checked = true;
            Assert.Equal(32771, OutboundRulePage.GetFilter(box));

            OutboundRulePage.SetFilter(32771, box);
            Assert.True(box.CheckBoxItems[2].Checked);
            Assert.True(box.CheckBoxItems[1].Checked);
            Assert.True(box.CheckBoxItems[0].Checked);
            OutboundRulePage.SetFilter(3, box);
            Assert.False(box.CheckBoxItems[2].Checked);
            Assert.True(box.CheckBoxItems[1].Checked);
            Assert.True(box.CheckBoxItems[0].Checked);
            OutboundRulePage.SetFilter(1, box);
            Assert.False(box.CheckBoxItems[2].Checked);
            Assert.False(box.CheckBoxItems[1].Checked);
            Assert.True(box.CheckBoxItems[0].Checked);
            OutboundRulePage.SetFilter(0, box);
            Assert.False(box.CheckBoxItems[2].Checked);
            Assert.False(box.CheckBoxItems[1].Checked);
            Assert.False(box.CheckBoxItems[0].Checked);
        }
Exemplo n.º 3
0
 public static void SetFilter(long filter, CheckBoxComboBox box)
 {
     box.CheckBoxItems[box.CheckBoxItems.Count - 1].Checked = (filter & 32768) != 0;
     for (int index = 0; index < box.CheckBoxItems.Count - 1; index++)
     {
         box.CheckBoxItems[index].Checked = (filter & 1 << index) != 0;
     }
 }
Exemplo n.º 4
0
        public static void SetItems <T>(this CheckBoxComboBox combo) where T : Enum
        {
            var items = typeof(T).GetEnumNames()
                        .Select(item => typeof(T).GetMember(item)[0])
                        .Select(item => item.GetMemberDisplayText());

            combo.Items.Clear();
            combo.Items.AddRange(items.ToArray());
            combo.AutoSize();
        }
Exemplo n.º 5
0
        internal CheckBoxComboBox CreateComboBoxForFilter(int pointY, string Text)
        {
            CheckBoxComboBox combo = new CheckBoxComboBox();

            combo.Location       = new Point(pointY, 70);
            combo.Name           = Text;
            combo.DropDownStyle  = ComboBoxStyle.DropDownList;
            combo.DropDownHeight = 500;

            return(combo);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 通过字符串构建CheckBoxComboBox
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        static public CheckBoxComboBox createCheckBoxComboBox(string str)
        {
            CheckBoxComboBox checkBoxComboBox = new CheckBoxComboBox();

            string[] s = str.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            for (int idx = 0; idx < s.Length; idx++)
            {
                checkBoxComboBox.Items.Add(s[idx]);
            }
            return(checkBoxComboBox);
        }
Exemplo n.º 7
0
 /// <summary>
 /// 勾选指定项
 /// </summary>
 /// <param name="checkBoxComboBox"></param>
 /// <param name="str"></param>
 /// <returns></returns>
 static public CheckBoxComboBox checkItem(CheckBoxComboBox checkBoxComboBox, string str)
 {
     string[] s = str.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
     for (int idx = 0; idx < checkBoxComboBox.Items.Count; idx++) /* 先取消所有勾选 */
     {
         checkBoxComboBox.CheckBoxItems[idx].Checked = false;;
     }
     for (int idx = 0; idx < s.Length; idx++)                     /* 然后勾选指定项 */
     {
         checkBoxComboBox.CheckBoxItems[s[idx]].Checked = true;;
     }
     return(checkBoxComboBox);
 }
Exemplo n.º 8
0
        public static long GetFilter(CheckBoxComboBox box)
        {
            long result = 0L;

            for (int index = 0; index < box.CheckBoxItems.Count - 1; index++)
            {
                if (box.CheckBoxItems[index].Checked)
                {
                    result |= 1 << index;
                }
            }

            return(box.CheckBoxItems[box.CheckBoxItems.Count - 1].Checked ? result | 32768 : result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 删除用户
        /// </summary>
        public void Delete_User(object sender, EventArgs e)
        {
            Button           button   = (Button)sender;
            CheckBoxComboBox cbcb     = panel2.Controls["panel_" + button.Name].Controls["cbcb0"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb1    = panel2.Controls["panel_" + button.Name].Controls["cbcb1"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb2    = panel2.Controls["panel_" + button.Name].Controls["cbcb2"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb3    = panel2.Controls["panel_" + button.Name].Controls["cbcb3"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb4    = panel2.Controls["panel_" + button.Name].Controls["cbcb4"] as CheckBoxComboBox;
            Panel            p_delete = panel2.Controls["panel_" + button.Name] as Panel;
            Point            pp       = p_delete.Location;

            this.Controls.Remove(p_delete);
            p_delete.Dispose();
            User_BLL.Delete_UserByCondition(button.Name);
            //LoadSource();
        }
Exemplo n.º 10
0
        /// <summary>
        /// 查看权限
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Check_Power(object sender, EventArgs e)
        {
            Button           button = (Button)sender;
            CheckBoxComboBox cbcb   = panel2.Controls["panel_" + button.Name].Controls["cbcb0"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb1  = panel2.Controls["panel_" + button.Name].Controls["cbcb1"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb2  = panel2.Controls["panel_" + button.Name].Controls["cbcb2"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb3  = panel2.Controls["panel_" + button.Name].Controls["cbcb3"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb4  = panel2.Controls["panel_" + button.Name].Controls["cbcb4"] as CheckBoxComboBox;

            string str0 = cbcb.Text.Trim();
            string str1 = cbcb1.Text.Trim();
            string str2 = cbcb2.Text.Trim();
            string str3 = cbcb3.Text.Trim();
            string str4 = cbcb4.Text.Trim();

            string str_power = "拥有权限:(1)基础配置:" + str0 + ";" + "(2)计划管理:" + str1 + ";" + "(3)配方管理权限包含:" + str2 + ";" + "(4)报表管理权限包含:" + str3 + ";" + "(5)工具权限包含" + str4;

            rtb_power.Text = "";
            rtb_power.AppendText("用户");
            rtb_power.SelectionColor = Color.Gold;
            rtb_power.AppendText(button.Name);
            rtb_power.SelectionColor = Color.Black;
            rtb_power.AppendText("拥有权限:(1)");
            rtb_power.SelectionColor = Color.Orchid;
            rtb_power.AppendText("基础配置");
            rtb_power.SelectionColor = Color.Black;
            rtb_power.AppendText(":" + str0 + ";(2)");
            rtb_power.SelectionColor = Color.Orchid;
            rtb_power.AppendText("计划管理");
            rtb_power.SelectionColor = Color.Black;
            rtb_power.AppendText(":" + str1 + ";(3)");
            rtb_power.SelectionColor = Color.Orchid;
            rtb_power.AppendText("配方管理");
            rtb_power.SelectionColor = Color.Black;
            rtb_power.AppendText(":" + str2 + ";(4)");
            rtb_power.SelectionColor = Color.Orchid;
            rtb_power.AppendText("报表管理");
            rtb_power.SelectionColor = Color.Black;
            rtb_power.AppendText(":" + str3 + ";(5)");
            rtb_power.SelectionColor = Color.Orchid;
            rtb_power.AppendText("工具");
            rtb_power.SelectionColor = Color.Black;
            rtb_power.AppendText(":" + str4);
        }
Exemplo n.º 11
0
        private void CreateLabelAndComboBox(string text)
        {
            ControlsFactory controlsFactory = new ControlsFactory();

            int pointY = getLocationY();

            Label            label = controlsFactory.CreateLabelForFilter(pointY, text);
            CheckBoxComboBox combo = controlsFactory.CreateComboBoxForFilter(pointY, text);

            if (tryFillComboBox(text, combo))
            {
                int width = getComboBoxWith(combo, label.Text);
                combo.Width = width + 50;
                label.Width = width;

                _mainForm.Controls.Add(combo);
                comboList.Add(combo);

                _mainForm.Controls.Add(label);
                labelList.Add(label);
            }
        }
Exemplo n.º 12
0
 public static T[] GetSelectedItems <T>(this CheckBoxComboBox combo) where T : Enum
 {
     T[] values = typeof(T).GetEnumValues() as T[];
     try {
         List <T> ret = new List <T>();
         // skip first item which is empty.
         for (int i = 1; i < combo.CheckBoxItems.Count; ++i)
         {
             if (combo.CheckBoxItems[i].Checked)
             {
                 ret.Add(values[i - 1]);
             }
         }
         return(ret.ToArray());
     } catch (Exception ex) {
         var items = combo.CheckBoxItems.Select(item => item.Text).ToArray();
         Log.Exception(ex,
                       $"items={string.Join(", ", items)}  " +
                       $"values={string.Join(", ", values)} " +
                       $"names={string.Join(", ", typeof(T).GetEnumNames())}");
         throw ex;
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// 填充页面
        /// </summary>
        public void LoadSource()
        {
            panel2.VerticalScroll.Visible = true;//主面板

            DataTable dt = User_BLL.GetAllUserX();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string user_name = dt.Rows[i]["h_UserName"].ToString();
                Panel  p_row     = new Panel();//分面板
                p_row.Name      = "panel_" + user_name;
                p_row.Size      = new Size(1331, 34);
                p_row.BackColor = Color.CornflowerBlue;
                #region  label
                Label l_name = new Label();
                l_name.Name     = "lb_" + user_name;
                l_name.Text     = user_name;
                l_name.Font     = new Font(l_name.Font.FontFamily, 15, l_name.Font.Style);
                l_name.Location = new System.Drawing.Point(2, 5);
                p_row.Controls.Add(l_name);
                #endregion

                #region CheckBoxComboBox
                CheckBoxComboBox cbcb;
                Size             s = new Size();
                s.Width = 181;
                Dictionary <int, ListSelectionWrapper <Status> > dicX = SaveMessage();
                for (int j = 0; j < dicX.Count; j++)
                {
                    string str_power = EncryPtForMy.Class1.DecryptDES(dt.Rows[i]["Power"].ToString());
                    Dictionary <int, List <int> > dic_POWER = Split_Power(str_power);
                    cbcb            = new CheckBoxComboBox();
                    cbcb.Name       = "cbcb" + j;
                    cbcb.DataSource = dicX[j];
                    cbcb.DisplayMemberSingleItem = "Name";
                    cbcb.DisplayMember           = "NameConcatenated";
                    cbcb.ValueMember             = "Selected";
                    if (dic_POWER.Count > 0)    //为了判断
                    {
                        if (dic_POWER[j].ToList() != null)
                        {
                            List <int> list = dic_POWER[j].ToList();
                            for (int K = 0; K < list.Count; K++)
                            {
                                dicX[j][list[K]].Selected = true;
                            }
                        }
                    }
                    //dicX[j].FindObjectWithItem(sDD).Selected = true;
                    cbcb.Size      = s;
                    cbcb.Font      = new Font(cbcb.Font.FontFamily, 13, cbcb.Font.Style);
                    cbcb.BackColor = Color.Azure;
                    cbcb.Enabled   = false;
                    cbcb.Location  = new System.Drawing.Point(142 + j * 195, 5);
                    p_row.Controls.Add(cbcb);
                }
                #endregion
                #region button
                Button bt_alter = new Button();
                bt_alter.Text      = "修改";
                bt_alter.Name      = user_name;
                bt_alter.Click    += new EventHandler(Alter_Power);
                bt_alter.FlatStyle = FlatStyle.Popup;
                bt_alter.Size      = new Size(50, 30);
                bt_alter.Tag       = 9999;
                bt_alter.Location  = new System.Drawing.Point(142 + 5 * 195, 2);

                Button btX_save = new Button();
                btX_save.Text      = "保存";
                btX_save.Name      = user_name;
                btX_save.Click    += new EventHandler(Save_Power);
                btX_save.FlatStyle = FlatStyle.Popup;
                btX_save.Tag       = 9999;
                btX_save.Size      = new Size(50, 30);
                btX_save.Location  = new System.Drawing.Point(141 + 5 * 195 + 55, 2);

                Button bt_see = new Button();
                bt_see.Text      = "查看";
                bt_see.Name      = user_name;
                bt_see.Click    += new EventHandler(Check_Power);
                bt_see.FlatStyle = FlatStyle.Popup;
                bt_see.Tag       = 9999;
                bt_see.Size      = new Size(50, 30);
                bt_see.Location  = new System.Drawing.Point(143 + 5 * 195 + 106, 2);

                Button bt_delete = new Button();
                bt_delete.Text      = "删除";
                bt_delete.Name      = user_name;
                bt_delete.Click    += new EventHandler(Delete_User);
                bt_delete.FlatStyle = FlatStyle.Popup;
                bt_delete.Tag       = 9999;
                bt_delete.Size      = new Size(50, 30);
                bt_delete.Location  = new System.Drawing.Point(142 + 5 * 195 + 163, 2);

                p_row.Controls.Add(bt_alter);
                p_row.Controls.Add(btX_save);
                p_row.Controls.Add(bt_see);
                p_row.Controls.Add(bt_delete);
                #endregion
                p_row.Location = new System.Drawing.Point(5, 45 * (i + 1) + 10 * i);
                panel2.Controls.Add(p_row);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 保存按钮监听
        /// </summary>
        public void Save_Power(object sender, EventArgs e)
        {
            bool             set_admin = false; //标识当前保存用户是否为管理员
            string           ListText  = "";
            Button           button    = (Button)sender;
            CheckBoxComboBox cbcb      = panel2.Controls["panel_" + button.Name].Controls["cbcb0"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb1     = panel2.Controls["panel_" + button.Name].Controls["cbcb1"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb2     = panel2.Controls["panel_" + button.Name].Controls["cbcb2"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb3     = panel2.Controls["panel_" + button.Name].Controls["cbcb3"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb4     = panel2.Controls["panel_" + button.Name].Controls["cbcb4"] as CheckBoxComboBox;

            #region   保存
            string     str0       = cbcb.Text.Trim();
            string[]   strX0      = str0.Split('&');
            List <int> a0         = Split_string_Save(strX0, "basis");
            string     str_power0 = "basis:";
            for (int i = 0; i < a0.Count; i++)
            {
                if (a0.Count - 1 == i)
                {
                    str_power0 += a0[i];
                }
                else
                {
                    str_power0 += a0[i] + ",";
                    //if (a0[i] == 0)//设置为管理员  并在数据库赋值标识
                    //{
                    //    User_BLL.SetUserAdmin(button.Name);
                    //    set_admin = true;
                    //}
                }
            }
            //if (set_admin == false)
            //     User_BLL.SetUserNormal(button.Name);

            str_power0 = str_power0 + ";";

            string     str1       = cbcb1.Text.Trim();
            string[]   strX1      = str1.Split('&');
            List <int> a1         = Split_string_Save(strX1, "plan");
            string     str_power1 = "plan:";
            for (int i = 0; i < a1.Count; i++)
            {
                if (a1.Count - 1 == i)
                {
                    str_power1 += a1[i];
                }
                else
                {
                    str_power1 += a1[i] + ",";
                }
            }
            str_power1 = str_power1 + ";";

            string     str2       = cbcb2.Text.Trim();
            string[]   strX2      = str2.Split('&');
            List <int> a2         = Split_string_Save(strX2, "formula");
            string     str_power2 = "formula:";
            for (int i = 0; i < a2.Count; i++)
            {
                if (a2.Count - 1 == i)
                {
                    str_power2 += a2[i];
                }
                else
                {
                    str_power2 += a2[i] + ",";
                }
            }
            str_power2 = str_power2 + ";";

            string     str3       = cbcb3.Text.Trim();
            string[]   strX3      = str3.Split('&');
            List <int> a3         = Split_string_Save(strX3, "table");
            string     str_power3 = "table:";
            for (int i = 0; i < a3.Count; i++)
            {
                if (a3.Count - 1 == i)
                {
                    str_power3 += a3[i];
                }
                else
                {
                    str_power3 += a3[i] + ",";
                }
            }
            str_power3 = str_power3 + ";";

            string     str4       = cbcb4.Text.Trim();
            string[]   strX4      = str4.Split('&');
            List <int> a4         = Split_string_Save(strX4, "tool");
            string     str_power4 = "tool:";
            for (int i = 0; i < a4.Count; i++)
            {
                if (a4.Count - 1 == i)
                {
                    str_power4 += a4[i];
                }
                else
                {
                    str_power4 += a4[i] + ",";
                }
            }
            str_power4 = str_power4 + ";";
            string str_power = str_power0 + str_power1 + str_power2 + str_power3 + str_power4;
            string Power     = EncryPtForMy.Class1.EncryptDES(str_power.Substring(0, str_power.Length - 1));
            User_BLL.Save_Power(button.Name, Power);

            #endregion

            cbcb.Enabled  = false;
            cbcb1.Enabled = false;
            cbcb2.Enabled = false;
            cbcb3.Enabled = false;
            cbcb4.Enabled = false;
        }
Exemplo n.º 15
0
 public CheckBoxComboBoxCheckBoxes(CheckBoxComboBox owner)
 {
     _owner = owner;
 }
Exemplo n.º 16
0
        private bool IsFilterEmpty(int comboIndex)
        {
            CheckBoxComboBox chbCombo = comboList[comboIndex];

            return(chbCombo.Text.Equals(string.Empty));
        }