Ejemplo n.º 1
0
        /// <summary>
        /// Invoked when the ComboBox has to render the drop-down items.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CheckComboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            // make sure the index is valid (sanity check)
            if (e.Index == -1)
            {
                return;
            }

            // test the item to see if its a CheckComboBoxItem
            if (!(Items[e.Index] is CheckComboBoxItem))
            {
                // it's not, so just render it as a default string
                e.Graphics.DrawString(
                    Items[e.Index].ToString(),
                    this.Font,
                    Brushes.Black,
                    new Point(e.Bounds.X, e.Bounds.Y));
                return;
            }

            // get the CheckComboBoxItem from the collection
            CheckComboBoxItem box = (CheckComboBoxItem)Items[e.Index];

            // render it
            CheckBoxRenderer.RenderMatchingApplicationState = true;
            CheckBoxRenderer.DrawCheckBox(
                e.Graphics,
                new Point(e.Bounds.X, e.Bounds.Y),
                e.Bounds,
                box.Text,
                this.Font,
                (e.State & DrawItemState.Focus) == 0,
                box.CheckState ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal);
        }
Ejemplo n.º 2
0
        private async void AuthorsComboBox_CheckStateChanged(object sender, EventArgs e)
        {
            if (sender is CheckComboBoxItem)
            {
                CheckComboBoxItem item = (CheckComboBoxItem)sender;
                if (item.CheckState)
                {
                    FilterAndSearchConfig.AddFilterUnsavedAuthor(item.Text);
                }
                else
                {
                    FilterAndSearchConfig.DeleteFilterUnsavedAuthor(item.Text);
                }
                string result = await Task.Factory.StartNew <string>(() => Timer(), TaskCreationOptions.LongRunning);

                ChangeAuthorsComboBox();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Invoked when the selected index is changed on the dropdown.  This sets the check state
        /// of the CheckComboBoxItem and fires the public event CheckStateChanged using the
        /// CheckComboBoxItem as the event sender.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CheckComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            TimeSpan span = DateTime.Now - LastChange;

            if (span < new TimeSpan(0, 0, 1))
            {
                return;
            }
            else
            {
                LastChange = DateTime.Now;
                CheckComboBoxItem item = (CheckComboBoxItem)SelectedItem;
                item.CheckState = !item.CheckState;
                if (CheckStateChanged != null)
                {
                    CheckStateChanged(item, e);
                }
            }
        }
Ejemplo n.º 4
0
        private async void GenresComboBox_CheckStateChanged(object sender, EventArgs e)
        {
            if (sender is CheckComboBoxItem)
            {
                CheckComboBoxItem item = (CheckComboBoxItem)sender;
                if (item.CheckState == true)
                {
                    FilterAndSearchConfig.AddUnsavedFilterGenre(item.Text);
                }
                else if (item.CheckState == false)
                {
                    FilterAndSearchConfig.DeleteUnsavedFilterGenre(item.Text);
                }
                string UNS    = FilterAndSearchConfig.UnsavedFilterGenre;
                string result = await Task.Factory.StartNew <string>(
                    () => Timer());

                ChangeGenreComboBox();
            }
        }