Example #1
0
        protected virtual void CheckAll(bool bCheckAll)
        {
            _bCheckAll             = true;
            _bCheckAllorUncheckAll = bCheckAll;
            if (bCheckAll)
            {
                string allNames = string.Empty;
                string allText  = string.Empty;

                foreach (RadItem ri in base.Items)
                {
                    RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                    if (chk != null)
                    {
                        allNames += chk.Name + _seperator;
                        allText  += chk.Text + _seperator;
                    }
                }

                SetChecked(allNames.Trim(new char[] { _seperator, ' ' }));
                _checkedNames = allNames.Trim(new char[] { _seperator, ' ' });
                this.Text     = allText.Trim(new char[] { _seperator, ' ' });
            }
            else
            {
                SetChecked(string.Empty);
                _checkedNames = string.Empty;
                this.Text     = "";
            }
            _bCheckAll = false;
        }
Example #2
0
        private void afterSelected()
        {
            string ret = "";

            foreach (RadItem ri in this.Items)
            {
                RadCheckComboBoxItem chkcbx = ri as RadCheckComboBoxItem;
                if (chkcbx == null)
                {
                    return;
                }

                FillPrimitive fp = ri.Children[0] as FillPrimitive;
                TextPrimitive tp = ri.Children[2].Children[1].Children[0] as TextPrimitive;

                ret += chkcbx.Text
                       //+ ",Active=" + chkcbx.Active
                       //+ ",IsMouseOver=" + chkcbx.IsMouseOver
                       //+ ",BackColor=" + chkcbx.BackColor.ToString()
                       + ",FillPrimitive.BackColor=" + fp.BackColor.ToString()
                       + ",FillPrimitive.Visibility=" + fp.Visibility.ToString()
                       + ",FillPrimitive.Bounds=" + fp.Bounds.ToString()
                       //+ ",FillPrimitive.ForeColor=" + fp.ForeColor.ToString()
                       //+ ",TextPrimitive.BackColor=" + tp.BackColor.ToString()
                       + ",TextPrimitive.ForeColor=" + tp.ForeColor.ToString()
                       + ";\r\n";
            }

            System.Diagnostics.Debug.WriteLine(ret);
        }
Example #3
0
        private void chk_MouseUp(object sender, MouseEventArgs e)
        {
            _listItemClicked = true;
            if (e.Button == MouseButtons.Right)
            {
                bool bNotChecked = true;
                foreach (RadItem ri in base.Items)
                {
                    RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                    if (chk != null)
                    {
                        if (chk.IsChecked == true)
                        {
                            bNotChecked = false;
                            break;
                        }
                    }
                }

                CheckAll(bNotChecked);
                if (OnCheckedChanged != null)
                {
                    OnCheckedChanged(this);
                }
                isChkRightClicked = true;
            }
            else if (e.Button == MouseButtons.Left && sender is RadCheckComboBoxItem)
            {
                (sender as RadCheckComboBoxItem).IsChecked = !(sender as RadCheckComboBoxItem).IsChecked;
            }
            _listItemClicked = false;
            _dtLastClicked   = System.DateTime.Now;
        }
Example #4
0
        private void chk_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                bool bNotChecked = true;
                foreach (RadItem ri in base.Items)
                {
                    RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                    if (chk != null)
                    {
                        if (chk.IsChecked)
                        {
                            bNotChecked = false;
                            break;
                        }
                    }
                }

                CheckAll(bNotChecked);

                isChkRightClicked = true;
            }

            _dtLastClicked = System.DateTime.Now;
        }
Example #5
0
        private void CSCheckComboBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!_bFindByPY)
            {
                return;
            }

            if (DateTime.Now > _tmKeyPress.AddSeconds(inputTime))
            {
                _strInputCode = _strPrevInput = string.Empty;
            }

            _strInputCode += e.KeyChar.ToString().ToUpper();

            _tmKeyPress = DateTime.Now;

            if (e.KeyChar == (char)Keys.Space && this.SelectedIndex > -1 && this.IsDroppedDown)
            {
                _bKeyBoardSelected = true;
                RadCheckComboBoxItem currentItem = this.Items[this.SelectedIndex] as RadCheckComboBoxItem;
                currentItem.IsChecked = !currentItem.IsChecked;
                this.ComboBoxElement.ListBoxElement.SelectedItem = currentItem;//need select it again
            }
            e.Handled = true;
        }
Example #6
0
        private void _timer_Tick(object sender, EventArgs e)
        {
            if (!IsDroppedDown)
            {
                return;
            }

            if (DateTime.Now > _tmKeyPress.AddMilliseconds(500) && _strInputCode.Length > _strPrevInput.Length)
            {
                if (_nCurrentIndex < 0 || _nCurrentIndex >= this.Items.Count)
                {
                    _nCurrentIndex = 0;
                }

                string firstChar = "";

                for (int i = 0; i < this.Items.Count; i++)
                {
                    RadItem ri = this.Items[(_nCurrentIndex + i + 1) % this.Items.Count];

                    RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                    if (chk == null)
                    {
                        continue;
                    }

                    firstChar = FirstPYManager.Instance.GetPYFirstCharacter(ri.Text).ToUpper();

                    if (firstChar.StartsWith(_strInputCode))
                    {
                        _nCurrentIndex = (_nCurrentIndex + i + 1) % this.Items.Count;

                        //RadComboBoxElement element = (RadComboBoxElement)base.RootElement.Children[0];
                        this.ComboBoxElement.ListBoxElement.ClearSelected();
                        this.ComboBoxElement.ListBoxElement.ScrollElementIntoView(chk);
                        this.ComboBoxElement.ListBoxElement.SelectedItem = ri;

                        setSelectedColor(ri);

                        System.Diagnostics.Debug.WriteLine("Selected, IDX=" + i.ToString()
                                                           + ",SelectedIndex=" + this.SelectedIndex.ToString()
                                                           + ",Input=" + _strInputCode
                                                           + ",Text=" + ri.Text
                                                           + ",firstPY=" + firstChar);

                        break;
                    }
                }

                _strPrevInput = _strInputCode;
            }
        }
Example #7
0
        /// <summary>
        /// The comma is regarded as the separator keyword,
        /// so name and txt should not contain the comma.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="txt"></param>
        public void AddItem(string name, string txt)
        {
            System.Diagnostics.Debug.Assert(
                name != null && txt != null &&
                name.IndexOf(',') < 0 && txt.IndexOf(',') < 0,
                "Please do not use comma!");

            RadCheckComboBoxItem chk = new RadCheckComboBoxItem(txt);

            chk.Name                 = name;
            chk.Text                 = txt;
            chk.MouseUp             += new MouseEventHandler(chk_MouseUp);
            chk.MouseDown           += new MouseEventHandler(chk_MouseDown);
            chk.ToggleStateChanged  += new StateChangedEventHandler(chk_ToggleStateChanged);
            chk.ToggleStateChanging += new StateChangingEventHandler(chk_ToggleStateChanging);
            base.Items.Add(chk);
        }
Example #8
0
        public void InsertItem(int index, string name, string txt)
        {
            System.Diagnostics.Debug.Assert(
                name != null && txt != null &&
                name.IndexOf(_seperator) < 0 && txt.IndexOf(_seperator) < 0,
                "Please do not use " + _seperator);

            RadCheckComboBoxItem chk = new RadCheckComboBoxItem(txt);

            chk.Name = name;
            //chk.Text = txt;
            //chk.ShowBorder = false;
            //chk.ForeColor = Color.Transparent;
            chk.MouseUp             += new MouseEventHandler(chk_MouseUp);
            chk.MouseDown           += new MouseEventHandler(chk_MouseDown);
            chk.ToggleStateChanged  += new StateChangedEventHandler(chk_ToggleStateChanged);
            chk.ToggleStateChanging += new StateChangingEventHandler(chk_ToggleStateChanging);
            base.Items.Insert(index, chk);
        }
Example #9
0
        private void OnItemChecked()
        {
            _checkedNames = string.Empty;
            string txt = string.Empty;

            foreach (RadItem ri in base.Items)
            {
                RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                if (chk != null &&
                    chk.IsChecked &&
                    chk.Text != null && chk.Text != string.Empty)
                {
                    _checkedNames += ri.Text + ",";
                    txt           += ri.Text + ",";
                }
            }

            _checkedNames = _checkedNames.Trim(",".ToCharArray());
            this.Text     = txt.Trim(",".ToCharArray());
        }
Example #10
0
        protected virtual void SetChecked(string checkedNames)
        {
            string[] keys = checkedNames.Split(_seperator);

            System.Collections.Specialized.StringDictionary maps = new System.Collections.Specialized.StringDictionary();

            foreach (string key in keys)
            {
                if (!maps.ContainsKey(key))
                {
                    maps.Add(key, string.Empty);
                }
            }

            _checkedNames = string.Empty;

            foreach (RadItem ri in base.Items)
            {
                RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                if (chk != null)
                {
                    // case insensitive
                    chk.IsChecked = maps.ContainsKey(chk.Name) ? true : false;
                }
            }

            _checkedNames = string.Empty;

            foreach (RadItem ri in base.Items)
            {
                RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                if (chk != null && chk.IsChecked)
                {
                    _checkedNames += chk.Name + _seperator;
                }
            }

            _checkedNames = _checkedNames.Trim(new char[] { _seperator, ' ' });
        }
Example #11
0
        private void CheckAll(bool bCheckAll)
        {
            if (bCheckAll)
            {
                string allNames = string.Empty;

                foreach (RadItem ri in base.Items)
                {
                    RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                    if (chk != null)
                    {
                        allNames += chk.Name + ",";
                    }
                }

                SetChecked(allNames.Trim(", ".ToCharArray()));
            }
            else
            {
                SetChecked(string.Empty);
            }
        }
Example #12
0
        /// <summary>
        /// The comma is regarded as the separator keyword,
        /// so name and txt should not contain the comma.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="txt"></param>
        public void AddItem(string name, string txt)
        {
            System.Diagnostics.Debug.Assert(
                name != null && txt != null &&
                name.IndexOf(_seperator) < 0 && txt.IndexOf(_seperator) < 0,
                "Please do not use " + _seperator);

            if (_canDelayLoadItems && base.Items.Count == _firstLoadCount && !_isLoadMoreClicked)
            {
                RadComboBoxItem loadMoreElement = new RadComboBoxItem();
                loadMoreElement.Text   = "¸ü¶à...";
                loadMoreElement.Click += new EventHandler(loadMoreElement_Click);
                this.Items.Add(loadMoreElement);
                return;
            }
            else if (_canDelayLoadItems && base.Items.Count >= _firstLoadCount + 1 && !_isLoadMoreClicked)
            {
                return;
            }

            RadCheckComboBoxItem chk = new RadCheckComboBoxItem(txt);

            chk.Name = name;
            //chk.Text = txt;
            //chk.ShowBorder = false;
            //chk.ForeColor = Color.Transparent;
            chk.MouseUp   += new MouseEventHandler(chk_MouseUp);
            chk.MouseDown += new MouseEventHandler(chk_MouseDown);
            (chk.Children[3] as RadCheckBoxElement).MouseUp   += new MouseEventHandler(chk_MouseUp);
            (chk.Children[3] as RadCheckBoxElement).MouseDown += new MouseEventHandler(chk_MouseDown);
            chk.ToggleStateChanged  += new StateChangedEventHandler(chk_ToggleStateChanged);
            chk.ToggleStateChanging += new StateChangingEventHandler(chk_ToggleStateChanging);
            chk.MouseEnter          += new EventHandler(chk_MouseEnter);
            //chk.RadPropertyChanging += new RadPropertyChangingEventHandler(chk_RadPropertyChanging);

            base.Items.Add(chk);
        }
Example #13
0
        protected virtual void OnItemChecked(object sender)
        {
            _listItemClicked = true;
            _strInputCode    = _strPrevInput = string.Empty;

            _checkedNames = string.Empty;
            string txt = string.Empty;

            foreach (RadItem ri in base.Items)
            {
                RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                if (chk != null &&
                    chk.IsChecked &&
                    chk.Text != null && chk.Text != string.Empty)
                {
                    _checkedNames += ri.Name + _seperator;
                    txt           += ri.Text + _seperator;
                }
            }

            _checkedNames    = _checkedNames.Trim(_seperator);
            this.Text        = txt.Trim(_seperator);
            _listItemClicked = false;
        }
Example #14
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                foreach (RadItem ri in base.Items)
                {
                    RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                    if (chk != null)
                    {
                        chk.MouseUp             -= new MouseEventHandler(chk_MouseUp);
                        chk.MouseDown           -= new MouseEventHandler(chk_MouseDown);
                        chk.ToggleStateChanged  -= new StateChangedEventHandler(chk_ToggleStateChanged);
                        chk.ToggleStateChanging -= new StateChangingEventHandler(chk_ToggleStateChanging);
                        (chk.Children[3] as RadCheckBoxElement).MouseUp   -= new MouseEventHandler(chk_MouseUp);
                        (chk.Children[3] as RadCheckBoxElement).MouseDown -= new MouseEventHandler(chk_MouseDown);
                        chk.MouseEnter -= new EventHandler(chk_MouseEnter);
                    }
                }
                this.ComboBoxElement.ArrowButton.MouseDown -= new MouseEventHandler(ArrowButton_MouseDown);
                this.ComboBoxElement.RadPropertyChanging   -= new RadPropertyChangingEventHandler(ComboBoxElement_RadPropertyChanging);
                this.ComboBoxElement.TextBoxElement.TextBoxItem.RadPropertyChanging -= new RadPropertyChangingEventHandler(ComboBoxElement_RadPropertyChanging);
                if (_timer != null)
                {
                    _timer.Stop();
                    _timer.Tick -= new EventHandler(_timer_Tick);
                    _timer.Dispose();
                    _timer = null;
                }
                //if (this.DataSource == null)
                //    base.Items.Clear();

                //System.Diagnostics.Debug.WriteLine("CSCheckComboBox_Dispose");
            }

            base.Dispose(disposing);
        }
Example #15
0
        private void SetChecked(string checkedNames)
        {
            string[] keys = checkedNames.Split(new char[] { ',' });

            System.Collections.Specialized.StringDictionary maps = new System.Collections.Specialized.StringDictionary();

            foreach (string key in keys)
            {
                if (!maps.ContainsKey(key))
                {
                    maps.Add(key, string.Empty);
                }
            }

            foreach (RadItem ri in base.Items)
            {
                RadCheckComboBoxItem chk = ri as RadCheckComboBoxItem;
                if (chk != null)
                {
                    // case insensitive
                    chk.IsChecked = maps.ContainsKey(chk.Name);
                }
            }
        }