Example #1
0
        public static void runDownload(App[] a, CheckedListBox c)
        {
            //count checked apps
            int appsChecked = 0;

            for (int i = (c.Items.Count - 1); i >= 0; i--)
            {
                if (c.GetItemCheckState(i) == CheckState.Checked)
                {
                    appsChecked++;
                }
            }

            //start task window
            Form2 form = new Form2();

            //run apps
            int currentAppNum = 1;

            for (int i = 0; i < (a.Length); i++)
            {
                if (c.GetItemCheckState(i) == CheckState.Checked)
                {
                    form.taskName.Text   = "Downloading: " + a[i].name;
                    form.taskNumber.Text = currentAppNum.ToString() + " / " + appsChecked.ToString();
                    download(a[i]);
                    form.progressBar.Value = (int)((double)currentAppNum / (double)appsChecked * 100.0);
                    currentAppNum++;
                }
                ;
            }
            ;
            form.progressBar.Value = 100;
            form.Close();
        }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //tạo ra messagebox xác nhận thanh toán
            string            message = "Do you confirm buy there amenities?";
            string            title   = "Save and confirm";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result  = MessageBox.Show(message, title, buttons);

            if (result == DialogResult.Yes)
            {
                for (int i = 0; i < listAmentities.Rows.Count; i++)
                {
                    BussinessLayer objBLL     = new BussinessLayer();
                    string         tick_id    = cbxTicket.SelectedValue.ToString();
                    string         amenity_id = listAmentities.Rows[i]["ID"].ToString();
                    //trường hợp mua thêm
                    if (clbx.GetItemCheckState(i) == CheckState.Checked && String.IsNullOrEmpty(listAmentities.Rows[i]["Price_bought"].ToString()))
                    {
                        int price = int.Parse(listAmentities.Rows[i]["Price"].ToString());
                        objBLL.ChangeAmenTick(tick_id, amenity_id, "ADD", price);
                    }
                    //trường hợp xóa sản phẩm đã mua
                    else if (clbx.GetItemCheckState(i) == CheckState.Unchecked && !String.IsNullOrEmpty(listAmentities.Rows[i]["Price_bought"].ToString()))
                    {
                        objBLL.ChangeAmenTick(tick_id, amenity_id, "DEL", 0);
                    }
                }
                MessageBox.Show("Change buying amenities successfully");
                Reset_Form();
            }
        }
 private void button12_Click(object sender, EventArgs e)
 {
     for (int i = 0; i <= (CheckedListBox1.Items.Count - 1); i++)
     {
         if (CheckedListBox1.GetItemCheckState(i) == CheckState.Checked)
         {
             CheckedListBox1.SetItemCheckState(i, CheckState.Indeterminate);
         }
         else if (CheckedListBox1.GetItemCheckState(i) == CheckState.Indeterminate)
         {
             CheckedListBox1.SetItemCheckState(i, CheckState.Checked);
         }
     }
 }
Example #4
0
        public void CheckedListBox_SetItemCheckState_Invoke_GetReturnsExpected(CheckState value)
        {
            using var control = new CheckedListBox();
            control.Items.Add(new CheckBox(), false);

            control.SetItemCheckState(0, value);
            Assert.Equal(value, control.GetItemCheckState(0));
            Assert.False(control.IsHandleCreated);

            // Set same.
            control.SetItemCheckState(0, value);
            Assert.Equal(value, control.GetItemCheckState(0));
            Assert.False(control.IsHandleCreated);
        }
Example #5
0
        private FontStyle clbtoFS(CheckedListBox clb)
        {
            FontStyle fs = FontStyle.Regular;

            if (clb.GetItemCheckState(0) == CheckState.Checked)
            {
                fs |= FontStyle.Bold;
            }
            if (clb.GetItemCheckState(1) == CheckState.Checked)
            {
                fs |= FontStyle.Italic;
            }
            return(fs);
        }
        private void cmbStudenti_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            broj           = 0;
            lblPoruka.Text = "";
            cmbStudenti.ResetText();
            svi_predmeti_studenta.Items.Clear();

            //checklistbox kreiranje
            svi_predmeti_studenta.Size     = new Size(400, 200);
            svi_predmeti_studenta.Location = new Point(50, 150);
            Controls.Add(svi_predmeti_studenta);


            Studenti student = (Studenti)cmbStudenti.SelectedItem;


            //dodavanje predmeta u checklistbox ako su sa smera ili u chombobox ako nisu sa istog smera
            foreach (Predmet p in predmeti)
            {
                if (p.Smer.ToString().Equals(student.Smer.ToString()))
                {
                    string unos = p.Naziv_predmeta + ",  " + p.Smer + ",  " + p.Semestar;
                    svi_predmeti_studenta.Items.Add(unos, (p.Obavezan) ?CheckState.Checked:CheckState.Unchecked);

                    if (p.Obavezan)
                    {
                        svi_predmeti_studenta.SetItemCheckState(svi_predmeti_studenta.Items.Count - 1, CheckState.Indeterminate);
                    }
                }
                else
                {
                    cmbPredmeti.Items.Insert(cmbPredmeti.Items.Count, p);
                }
            }


            btnDodaj.Enabled = true;

            //Trenutni ESPB bodovi
            broj = 0;
            for (int i = 0; i < svi_predmeti_studenta.Items.Count; i++)
            {
                if (svi_predmeti_studenta.GetItemCheckState(i) == CheckState.Checked || svi_predmeti_studenta.GetItemCheckState(i) == CheckState.Indeterminate)
                {
                    broj += 6;
                }
            }
            lblESPB.Text = "ESPB: " + broj;
        }
Example #7
0
        private void UpdateNumerics()
        {
            if (lstEnchants.SelectedItem == null)
            {
                return;
            }

            if (lstEnchants.GetItemCheckState(lstEnchants.SelectedIndex) == CheckState.Checked)
            {
                numSpellLevel.Enabled = true;
                numDuration.Enabled   = true;
                if (lstEnchants.Text == "SHIELD")
                {
                    numShieldHP.Enabled = true;
                }
                else
                {
                    numShieldHP.Enabled = false;
                }
            }
            else
            {
                numSpellLevel.Enabled = false;
                numDuration.Enabled   = false;
                numShieldHP.Enabled   = false;
            }
        }
Example #8
0
        public override MeasuredIon[] GetChosen(ItemCheckEventArgs e)
        {
            if (CheckedListBox == null)
            {
                return(new MeasuredIon[0]);
            }

            var listChosen = new List <MeasuredIon>();

            for (int i = 0; i < CheckedListBox.Items.Count; i++)
            {
                MeasuredIon ion;
                bool        checkItem = CheckedListBox.GetItemChecked(i);

                // If event refers to this item, then use the check state in the event.
                if (e != null && e.Index == i)
                {
                    checkItem = (e.NewValue == CheckState.Checked || e.NewValue == CheckState.Indeterminate);
                }

                if (checkItem && List.TryGetValue(CheckedListBox.Items[i].ToString(), out ion))
                {
                    bool isOptional = IsOptional(CheckedListBox.GetItemCheckState(i));
                    if (ion.IsCustom && ion.IsOptional != isOptional)
                    {
                        ion = ion.ChangeIsOptional(isOptional);
                    }
                    listChosen.Add(ion);
                }
            }
            return(listChosen.ToArray());
        }
Example #9
0
        //因为checkedListBox1仅有选中前发生事件(ItemCheck)没有选中后发生事件,所以要针对当前选中的Item进行反向处理
        private List <SortInfo> GetLstSortInfo(CheckedListBox checkedListBox1, int curIndex)
        {
            List <SortInfo> lstSortCategory = new List <SortInfo>();

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                CheckState cs = checkedListBox1.GetItemCheckState(i);
                //如果是
                if (i == curIndex)
                {
                    cs = cs == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked;
                }

                if (cs != CheckState.Checked)
                {
                    continue;
                }
                CheckedListBoxItem clbi = checkedListBox1.Items[i] as CheckedListBoxItem;
                if (clbi == null)
                {
                    continue;
                }
                SortInfo sort = new SortInfo();
                sort.Type      = clbi.Type;
                sort.Ascending = true;

                lstSortCategory.Add(sort);
            }

            return(lstSortCategory);
        }
Example #10
0
        //因为checkedListBox1仅有选中前发生事件(ItemCheck)没有选中后发生事件,所以要针对当前选中的Item进行反向处理
        private List <SortType> GetLstSortInfo(CheckedListBox checkedListBox1, int curIndex)
        {
            List <SortType> lstSortCategory = new List <SortType>();

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                CheckState cs = checkedListBox1.GetItemCheckState(i);
                //如果是
                if (i == curIndex)
                {
                    cs = cs == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked;
                }

                if (cs != CheckState.Checked)
                {
                    continue;
                }
                SortInfo clbi = checkedListBox1.Items[i] as SortInfo;
                if (clbi == null)
                {
                    continue;
                }

                lstSortCategory.Add(clbi.Type);
            }

            return(lstSortCategory);
        }
Example #11
0
 private void GetPermission(ref string Permission, Control tabPage)
 {
     foreach (Control item in tabPage.Controls)
     {
         if (item.Controls.Count > 0)
         {
             GetPermission(ref Permission, item);
         }
         else if (item.GetType() == typeof(CheckedListBox))
         {
             CheckedListBox CheckList = (CheckedListBox)item;
             for (int i = 0; i < CheckList.Items.Count; i++)
             {
                 if (CheckList.GetItemCheckState(i) == CheckState.Unchecked)
                 {
                     if (string.IsNullOrEmpty(Permission) == false)
                     {
                         Permission += "$";
                     }
                     Permission += ((HPS.BLL.PermissionBLL.BLLPermission_T)CheckList.Items[i]).PermissionID_bint.ToString();
                 }
             }
         }
     }
 }
        public string GetChecked(int ignore = 0)
        {
            string ret = "";

            int total = 0;

            for (int i = ignore; i < clb.Items.Count; i++)
            {
                if (clb.GetItemCheckState(i) == CheckState.Checked)
                {
                    ret += clb.Items[i] + ";";
                    total++;
                }
            }

            if (total == clb.Items.Count - ignore)
            {
                ret = "All";
            }
            if (ret.Length == 0)
            {
                ret = "None";
            }

            return(ret);
        }
Example #13
0
        public string GetChecked(int ignore = 0, bool allornone = true)            // semicolon list of options with trailing ;, or All, or None if selected
        {
            string ret = "";

            int total = 0;

            for (int i = ignore; i < clb.Items.Count; i++)
            {
                if (clb.GetItemCheckState(i) == CheckState.Checked)
                {
                    ret += clb.Items[i] + ";";
                    total++;
                }
            }

            if (allornone)
            {
                if (total == clb.Items.Count - ignore)
                {
                    ret = "All";
                }
                if (ret.Length == 0)
                {
                    ret = "None";
                }
            }

            return(ret);
        }
Example #14
0
 // Выбор значений CheckLB
 private void CheckLB_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     if (e.Index == 0)
     {
         if (checkMark)
         {
             if (e.NewValue == CheckState.Checked)
             {
                 for (int i = 1; i < CheckLB.Items.Count; i++)
                 {
                     CheckLB.SetItemChecked(i, true);
                 }
             }
             else
             {
                 for (int i = 1; i < CheckLB.Items.Count; i++)
                 {
                     CheckLB.SetItemChecked(i, false);
                 }
             }
         }
     }
     else
     if (e.NewValue == CheckState.Unchecked)
     {
         checkMark = false;
         CheckLB.SetItemChecked(0, false);
         checkMark = true;
     }
     else
     {
         int checkCount = 0;
         for (int i = 0; i < CheckLB.Items.Count; i++)
         {
             if (CheckLB.GetItemCheckState(i) == CheckState.Checked)
             {
                 checkCount++;
             }
         }
         if (checkCount == CheckLB.Items.Count - 2)
         {
             checkMark = false;
             CheckLB.SetItemChecked(0, true);
             checkMark = true;
         }
     }
 }
Example #15
0
        public void CheckedListBox_GetItemCheckStateOutOfRange(int index)
        {
            var box = new CheckedListBox();

            var ex = Assert.Throws <ArgumentOutOfRangeException>(() => box.GetItemCheckState(index));

            Assert.Equal("index", ex.ParamName);
        }
Example #16
0
        void checkedListBox_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
        {
            if (inEventProcess)
            {
                return;
            }

            inEventProcess = true;

            // 'Select All'
            if (e.Index == 0)
            {
                if (CheckedListBox.GetItemCheckState(0) != e.NewValue)
                {
                    for (int i = 1; i < CheckedListBox.Items.Count; i++)
                    {
                        CheckedListBox.SetItemChecked(i, e.NewValue == System.Windows.Forms.CheckState.Checked);
                        SelectedCount = CheckedListBox.Items.Count - 1;
                    }

                    if (e.NewValue == System.Windows.Forms.CheckState.Checked)
                    {
                        SelectedCount = CheckedListBox.Items.Count - 1;
                    }
                    else
                    {
                        SelectedCount = 0;
                    }
                }
            }
            // others else 'Select All'
            else if (e.NewValue != CheckedListBox.GetItemCheckState(0))
            {
                CheckedListBox.SetItemCheckState(0, System.Windows.Forms.CheckState.Indeterminate);

                if (e.NewValue != System.Windows.Forms.CheckState.Checked)
                {
                    SelectedCount--;

                    if (SelectedCount <= 0)
                    {
                        CheckedListBox.SetItemChecked(0, false);
                        SelectedCount = 0;
                    }
                }
                else
                {
                    SelectedCount++;

                    if (SelectedCount >= CheckedListBox.Items.Count - 1)
                    {
                        CheckedListBox.SetItemChecked(0, true);
                    }
                }
            }

            inEventProcess = false;
        }
Example #17
0
        public void CheckedListBoxPropertyTest()
        {
            Form myform = new Form();

            myform.ShowInTaskbar = false;
            myform.Visible       = true;
            CheckedListBox mychklistbox  = new CheckedListBox();
            ArrayList      checked_items = new ArrayList(2);
            ArrayList      checked_pos   = new ArrayList(2);

            mychklistbox.Items.Add("test1", true);
            checked_items.Add("test1");
            checked_pos.Add(0);
            mychklistbox.Items.Add("test2");
            mychklistbox.Items.Add("test3", true);
            checked_items.Add("test3");
            checked_pos.Add(2);
            mychklistbox.Visible = true;
            myform.Controls.Add(mychklistbox);
            Assert.AreEqual(checked_items.Count, mychklistbox.CheckedIndices.Count, "#1");
            Assert.AreEqual(checked_items.Count, mychklistbox.CheckedItems.Count, "#2");
            foreach (object o in mychklistbox.CheckedItems)
            {
                Assert.IsTrue(checked_items.Contains(o), "#3");
                checked_items.Remove(o);
            }

            Assert.AreEqual(0, checked_items.Count);
            for (int i = 0; i < mychklistbox.Items.Count; ++i)
            {
                if (checked_pos.Contains(i))
                {
                    Assert.AreEqual(CheckState.Checked, mychklistbox.GetItemCheckState(i), "#4");
                }
                else
                {
                    Assert.IsFalse(CheckState.Checked == mychklistbox.GetItemCheckState(i), "#5");
                }
            }
            Assert.AreEqual(false, mychklistbox.CheckOnClick, "#6");
            Assert.AreEqual(3, mychklistbox.Items.Count, "#7");
            Assert.AreEqual(SelectionMode.One, mychklistbox.SelectionMode, "#8");
            Assert.AreEqual(false, mychklistbox.ThreeDCheckBoxes, "#9");
            myform.Dispose();
        }
Example #18
0
        public void CheckedListBox_SetItemChecked(bool send, CheckState expected)
        {
            using var box = new CheckedListBox();
            box.Items.Add(new CheckBox(), false);

            box.SetItemChecked(0, send);

            Assert.Equal(expected, box.GetItemCheckState(0));
        }
 private void changeItemCheckedStatus(CheckedListBox i_CheckedListBox)
 {
     if (i_CheckedListBox.SelectedItem != null)
     {
         i_CheckedListBox.SetItemCheckState(
             i_CheckedListBox.SelectedIndex,
             i_CheckedListBox.GetItemCheckState(i_CheckedListBox.SelectedIndex) == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked);
     }
 }
Example #20
0
        public void SetItemCheckedTest()
        {
            Form myform = new Form();

            myform.ShowInTaskbar = false;
            myform.Visible       = true;
            CheckedListBox mychklistbox = new CheckedListBox();

            mychklistbox.Items.Add("test1");
            mychklistbox.Items.Add("test2");
            mychklistbox.Visible = true;
            myform.Controls.Add(mychklistbox);
            mychklistbox.SetItemChecked(0, true);
            mychklistbox.SetItemChecked(1, false);
            Assert.AreEqual(CheckState.Checked, mychklistbox.GetItemCheckState(0), "#17");
            Assert.AreEqual(CheckState.Unchecked, mychklistbox.GetItemCheckState(1), "#18");
            myform.Dispose();
        }
Example #21
0
        public void GetItemCheckStateTest()
        {
            Form f = new Form();

            f.ShowInTaskbar = false;
            f.Visible       = true;
            CheckedListBox mychklistbox = new CheckedListBox();

            mychklistbox.Items.Add("test1", true);
            mychklistbox.Items.Add("test2", CheckState.Indeterminate);
            mychklistbox.Items.Add("test3");
            mychklistbox.Visible = true;
            f.Controls.Add(mychklistbox);
            Assert.AreEqual(CheckState.Checked, mychklistbox.GetItemCheckState(0), "#14");
            Assert.AreEqual(CheckState.Indeterminate, mychklistbox.GetItemCheckState(1), "#15");
            Assert.AreEqual(CheckState.Unchecked, mychklistbox.GetItemCheckState(2), "#16");
            f.Dispose();
        }
Example #22
0
        private static Dictionary <Guid, bool> GetCategorySettings(CheckedListBox ListBox)
        {
            Dictionary <Guid, bool> Result = new Dictionary <Guid, bool>();

            for (int Idx = 0; Idx < ListBox.Items.Count; Idx++)
            {
                Guid UniqueId = ((WorkspaceSyncCategory)ListBox.Items[Idx]).UniqueId;
                Result[UniqueId] = ListBox.GetItemCheckState(Idx) == CheckState.Checked;
            }
            return(Result);
        }
Example #23
0
        public EditDialogForm()
        {
            InitializeComponent();

            var itemListCollection = Form.ActiveForm.Controls.Find("itemListBox", searchAllChildren: false);

            _parentItemList = (CheckedListBox)itemListCollection[0];

            nameTextBox.Text        = (string)_parentItemList.SelectedItem;
            itemCheckBox.CheckState = _parentItemList.GetItemCheckState(_parentItemList.SelectedIndex);
        }
Example #24
0
        public void SetItemCheckStateTest()
        {
            Form myform = new Form();

            myform.ShowInTaskbar = false;
            myform.Visible       = true;
            CheckedListBox mychklistbox = new CheckedListBox();

            mychklistbox.Items.Add("test1");
            mychklistbox.Items.Add("test2");
            mychklistbox.Items.Add("test3");
            mychklistbox.Visible = true;
            myform.Controls.Add(mychklistbox);
            mychklistbox.SetItemCheckState(0, CheckState.Checked);
            mychklistbox.SetItemCheckState(1, CheckState.Indeterminate);
            mychklistbox.SetItemCheckState(2, CheckState.Unchecked);
            Assert.AreEqual(CheckState.Checked, mychklistbox.GetItemCheckState(0), "#19");
            Assert.AreEqual(CheckState.Indeterminate, mychklistbox.GetItemCheckState(1), "#20");
            Assert.AreEqual(CheckState.Unchecked, mychklistbox.GetItemCheckState(2), "#21");
            myform.Dispose();
        }
        public bool VerificarCheckBox(CheckedListBox e)
        {
            bool marcados = false;

            for (int i = 0; i < e.Items.Count; i++)
            {
                if (e.GetItemCheckState(i) == CheckState.Checked)
                {
                    marcados = true;
                }
            }
            return(marcados);
        }
        /// <summary>
        /// 現在チェックされているアイテムのインデックスを配列で取得します(内部)。
        /// </summary>
        /// <param name="checkedListBox">対象のチェックリストボックス。</param>
        /// <returns></returns>
        private static int[] CheckedIndicsInTarget(CheckedListBox checkedListBox)
        {
            List <int> checkedlist = new List <int>();

            for (int i = 0; i < checkedListBox.Items.Count; i++)
            {
                if (checkedListBox.GetItemCheckState(i) == CheckState.Checked)
                {
                    checkedlist.Add(i);
                }
            }
            return(checkedlist.ToArray());
        }
Example #27
0
        private void SetItemsCheckOnCarrinho(CheckedListBox list, ItemCheckEventArgs e)
        {
            try
            {
                var nome = list.Items[e.Index].ToString().Split(':')[0].Trim();
                if (list.GetItemCheckState(e.Index) == CheckState.Unchecked)
                {
                    // foi marcado agora
                    this.carrinho.Add(this.produtos.Where(prod => prod.nome == nome).ToArray()[0]);
                }

                if (list.GetItemCheckState(e.Index) == CheckState.Checked)
                {
                    // foi desmarcado agora
                    this.carrinho.Remove(this.produtos.Where(prod => prod.nome == nome).ToArray()[0]);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Svi_predmeti_studenta_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            CheckedListBox predmet = (CheckedListBox)sender;

            // racuna trenutni broj ESPB bodova
            for (int i = 0; i < svi_predmeti_studenta.Items.Count; i++)
            {
                if (svi_predmeti_studenta.Items[i].Equals(predmet.SelectedItem))
                {
                    if (svi_predmeti_studenta.GetItemCheckState(i) != CheckState.Checked)
                    {
                        broj_ESPB += 6;
                    }
                    else
                    {
                        broj_ESPB -= 6;
                    }
                    lblESPB.Text = "ESPB: " + broj_ESPB;
                }
            }

            lblPoruka.ResetText();
        }
Example #29
0
        private int ComputeTotalBytes(CheckedListBox _chklstbox)
        {
            int iTotal = 0;

            for (int i = 0; i < _chklstbox.Items.Count; i++)
            {
                if (_chklstbox.GetItemCheckState(i) == CheckState.Checked)
                {
                    iTotal += ((HelpItem)_chklstbox.Items[i]).FileSizeInBytes;
                }
            }

            return(iTotal);
        }
Example #30
0
 //when we click next data or prev data we need to clear every checked data in the list and
 //we need to check appropriate datas
 private void ClearCheckedDataFromCheckedListBox(CheckedListBox _chcLstLabels)
 {
     //item check fires everytime we check or uncheck the object so we need to stop doing it while clearing data
     //otherwise we will loose datas
     UnregisterItemCheckEvent(chcLstLabels_ItemCheck);
     for (int j = 0; j < _chcLstLabels.Items.Count; j++)
     {
         if (_chcLstLabels.GetItemCheckState(j) == CheckState.Checked)
         {
             _chcLstLabels.SetItemCheckState(j, CheckState.Unchecked);
         }
     }
     RegisterItemCheckEvent(chcLstLabels_ItemCheck);
 }