/// <summary>Initializes a new instance of the <see cref="ListViewChangedEventArgs" /> class.</summary>
 /// <param name="listViewChangedType">The list View Changed Type.</param>
 /// <param name="column">The column.</param>
 /// <param name="item">The item.</param>
 /// <param name="subItem">The sub Item.</param>
 public ListViewChangedEventArgs(ListViewChangedTypes listViewChangedType, VisualListViewColumn column, VisualListViewItem item, VisualListViewSubItem subItem)
 {
     _listViewChangedType = listViewChangedType;
     _column  = column;
     _item    = item;
     _subItem = subItem;
 }
        /// <summary>
        ///     Adds a subitem to the collection with the specified text, foreground color, background color, and font
        ///     settings.
        /// </summary>
        /// <param name="text">The text to display for the subitem.</param>
        /// <param name="foreColor">A <see cref="Color" /> that represents the foreground color of the subitem.</param>
        /// <param name="backColor">A <see cref="Color" /> that represents the background color of the subitem.</param>
        /// <param name="font">A <see cref="Font" /> that represents the typeface to display the subitem's text in.</param>
        /// <returns>The <see cref="VisualListViewSubItem" /> that was added to the collection.</returns>
        public VisualListViewSubItem Add(string text, Color foreColor, Color backColor, Font font)
        {
            VisualListViewSubItem _item = new VisualListViewSubItem(_owner, text, foreColor, backColor, font);

            Add(_item);
            return(_item);
        }
Exemplo n.º 3
0
        /// <summary>Generate the <see cref="VisualListViewItem" /> for this test.</summary>
        /// <returns>The <see cref="VisualListViewItem" />.</returns>
        private static VisualListViewItem GenerateItem()
        {
            Random _imageIndexRandomize = new Random();
            int    _randomImageIndex    = _imageIndexRandomize.Next(2);

            VisualListViewItem _item = new VisualListViewItem(@"Item-" + new Random().Next(0, 1000))
            {
                CheckBox   = true,
                ImageIndex = _randomImageIndex
            };

            VisualListViewSubItem _content = new VisualListViewSubItem(@"Content:" + new Random().Next(0, 1000));
            VisualListViewSubItem _date    = new VisualListViewSubItem(DateTime.Now.ToLongDateString());

            VisualProgressBar _progressBar = new VisualProgressBar
            {
                Value = new Random().Next(0, 100)
            };

            VisualListViewSubItem _progress = new VisualListViewSubItem
            {
                EmbeddedControl = _progressBar
            };

            _item.SubItems.Add(_content);
            _item.SubItems.Add(_date);
            _item.SubItems.Add(_progress);

            return(_item);
        }
        /// <summary>Adds a subitem to the collection with the specified text.</summary>
        /// <param name="text">The text to display.</param>
        /// <returns>The <see cref="VisualListViewSubItem" /> that was added to the collection.</returns>
        public VisualListViewSubItem Add(string text)
        {
            VisualListViewSubItem _item = new VisualListViewSubItem(_owner, text);

            Add(_item);
            return(_item);
        }
        /// <summary>Creates a new item and inserts it into the collection at the specified index.</summary>
        /// <param name="index">The zero-based index location where the item is inserted.</param>
        /// <param name="text">The text to display for the item.</param>
        /// <returns>The <see cref="VisualListViewSubItem" />.</returns>
        public VisualListViewSubItem Insert(int index, string text)
        {
            VisualListViewSubItem _item = new VisualListViewSubItem {
                Text = text
            };

            return(Insert(index, _item));
        }
Exemplo n.º 6
0
        /// <summary>Creates a data entry.</summary>
        /// <param name="name">The name.</param>
        /// <param name="category">The category</param>
        /// <returns>The <see cref="VisualListViewItem" />.</returns>
        private static VisualListViewItem DataEntry(string name, string category)
        {
            VisualListViewItem    dataEntry = new VisualListViewItem(name);
            VisualListViewSubItem subEntry  = new VisualListViewSubItem(category);

            dataEntry.SubItems.Add(subEntry);

            return(dataEntry);
        }
        /// <summary>Determines whether the specified item is located in the collection.</summary>
        /// <param name="value">A <see cref="VisualListViewSubItem" /> representing the item to locate in the collection.</param>
        /// <returns>The <see cref="bool" />.</returns>
        public bool Contains(VisualListViewSubItem value)
        {
            if (value == null)
            {
                return(false);
            }

            return(List.Contains(value));
        }
 /// <summary>Clears all selection bits in the item structure.</summary>
 /// <param name="itemIgnore">This overload is an optimization to stop a redraw on a re-selection.</param>
 public void ClearSelection(VisualListViewSubItem itemIgnore)
 {
     for (var index = 0; index < List.Count; index++)
     {
         VisualListViewSubItem _item = this[index];
         if (_item != itemIgnore)
         {
             _item.Selected = false;
         }
     }
 }
        /// <summary>Return the index within the collection of the specified item.</summary>
        /// <param name="subItem">A <see cref="VisualListViewSubItem" /> representing the item to locate in the collection.</param>
        /// <returns>
        ///     The zero-based index of the subitem's location in the collection. if the subitems is not located in the
        ///     collection, the return value is negative one(-1).
        /// </returns>
        public int IndexOf(VisualListViewSubItem subItem)
        {
            for (var index = 0; index < Count; index++)
            {
                if (List[index] == subItem)
                {
                    return(index);
                }
            }

            return(-1);
        }
Exemplo n.º 10
0
        public bool LVEmbeddedControlLoad(VisualListViewItem item, VisualListViewSubItem subItem, VisualListView listView)
        {
            _item    = item;
            _subItem = subItem;
            _owner   = listView;

            Text = _subItem.Text;

            Items.Add("Item1");
            Items.Add("Item2");
            Items.Add("Item3");

            return(true);
        }
Exemplo n.º 11
0
        public bool LVEmbeddedControlLoad(VisualListViewItem item, VisualListViewSubItem subItem, VisualListView listView)
        {
            // populate this control however you wish with item
            // set the styles you want for this
            // this.BorderStyle = BorderStyle.None;
            AutoSize = false;

            _item    = item;
            _subItem = subItem;
            _owner   = listView;

            Text = subItem.Text;

            return(true); // we don't do any heavy processing in this ctrl so we just return true
        }
        /// <summary>Inserts a subitem into the collection at the specified index.</summary>
        /// <param name="index">The zero-based index location where the item is inserted.</param>
        /// <param name="item">A <see cref="VisualListViewSubItem" /> representing the subitem to insert into the collection.</param>
        /// <returns>The <see cref="VisualListViewSubItem" />.</returns>
        public VisualListViewSubItem Insert(int index, VisualListViewSubItem item)
        {
            item.ListView      = _listView;
            item.ChangedEvent += SubItem_Changed;

            if (index < 0)
            {
                List.Add(item);
            }
            else
            {
                List.Insert(index, item);
            }

            ChangedEvent?.Invoke(this, new ListViewChangedEventArgs(ListViewChangedTypes.SubItemCollectionChanged, null, null, item));
            return(item);
        }
Exemplo n.º 13
0
        public bool LVEmbeddedControlLoad(VisualListViewItem item, VisualListViewSubItem subItem, VisualListView listView)
        {
            Format = DateTimePickerFormat.Long;

            try
            {
                _item    = item;
                _subItem = subItem;
                _owner   = listView;

                Text = subItem.Text;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                Text = DateTime.Now.ToString(CultureInfo.CurrentCulture);
            }

            return(true);
        }
        /// <summary>Gets or sets the subitem at the specified index within the collection.</summary>
        /// <param name="index">The index of the item in the collection to retrieve.</param>
        /// <returns>
        ///     A <see cref="VisualListViewSubItem" /> representing the subitem located at the specified index within the
        ///     collection.
        /// </returns>
        public VisualListViewSubItem this[int index]
        {
            get
            {
                int bailOut = 0;

                while (List.Count <= index)
                {
                    VisualListViewSubItem newItem = new VisualListViewSubItem();
                    newItem.ChangedEvent += SubItem_Changed;
                    newItem.ListView      = _listView;

                    // If the index doesn't yet exist, fill in the subitems till it does.
                    List.Add(newItem);

                    if (bailOut++ > 25)
                    {
                        break;
                    }
                }

                return((VisualListViewSubItem)List[index]);
            }
        }
Exemplo n.º 15
0
        /// <summary>Gets or sets the subitem at the specified index within the collection.</summary>
        /// <param name="index">The index of the item in the collection to retrieve.</param>
        /// <returns>
        ///     A <see cref="VisualListViewSubItem" /> representing the subitem located at the specified index within the
        ///     collection.
        /// </returns>
        public VisualListViewSubItem this[int index]
        {
            get
            {
                int bailOut = 0;

                while (List.Count <= index)
                {
                    VisualListViewSubItem newitem = new VisualListViewSubItem();
                    newitem.ChangedEvent += SubItem_Changed;
                    newitem.ListView      = ListView;

                    // newitem.Control = Parent.Columns[ nItemIndex ]
                    List.Add(newitem); // if the index doesn't yet exist, fill in the subitems till it does

                    if (bailOut++ > 25)
                    {
                        break;
                    }
                }

                return((VisualListViewSubItem)List[index]);
            }
        }
 /// <summary>Removes the specified item from the collection.</summary>
 /// <param name="item">The <see cref="VisualListViewSubItem" /> representing the item to remove from the collection.</param>
 public virtual void Remove(VisualListViewSubItem item)
 {
     RemoveByKey(item.Name);
 }
Exemplo n.º 17
0
        /// <summary>Draw Sub Item (Cell) at location specified.</summary>
        /// <param name="graphicsSubItem">The graphics sub item.</param>
        /// <param name="rectSubItem">The rectangle sub item.</param>
        /// <param name="item">The item.</param>
        /// <param name="subItem">The sub item.</param>
        /// <param name="column">The column.</param>
        /// <param name="font">The font.</param>
        /// <param name="listView">The list View.</param>
        /// <param name="_newLiveControls">The _new Live Controls.</param>
        /// <param name="_liveControls">The _live Controls.</param>
        /// <param name="cellPaddingSize">The cell Padding Size.</param>
        /// <param name="checkBoxSize">The check Box Size.</param>
        public static void DrawSubItem(Graphics graphicsSubItem, Rectangle rectSubItem, VisualListViewItem item, VisualListViewSubItem subItem, int column, Font font, VisualListView listView, ArrayList _newLiveControls, ArrayList _liveControls, int cellPaddingSize, int checkBoxSize)
        {
            ConsoleEx.WriteDebug("ListViewRenderer::DrawSubItem Name: " + subItem.Name);

            Rectangle _controlRectangle = new Rectangle(rectSubItem.X, rectSubItem.Y, rectSubItem.Width, rectSubItem.Height);

            if ((subItem.EmbeddedControl != null) && !subItem.ForceText)
            {
                Control _control = subItem.EmbeddedControl;

                if (_control.Parent != listView)
                {
                    _control.Parent = listView;
                }

                // Update the control BackColor to the current list view BackColorState.
                if (_control is VisualControlBase visualControlBase)
                {
                    visualControlBase.BackColor = ColorState.BackColorState(listView.BackColorState, listView.Enabled, listView.MouseState);
                }

                Rectangle _subItemRectangle = new Rectangle(_controlRectangle.X, _controlRectangle.Y + 1, _controlRectangle.Width, _controlRectangle.Height - 1);

                // Type _type = _control.GetType();
                PropertyInfo _propertyInfo = _control.GetType().GetProperty("PreferredHeight");
                if (_propertyInfo != null)
                {
                    var _preferredHeight = (int)_propertyInfo.GetValue(_control, null);

                    if ((_preferredHeight + (listView.CellPaddingSize * 2) > listView.ItemHeight) && listView.AutoHeight)
                    {
                        listView.ItemHeight = _preferredHeight + (listView.CellPaddingSize * 2);
                    }

                    _subItemRectangle.Y = _controlRectangle.Y + ((_controlRectangle.Height - _preferredHeight) / 2);
                }

                _newLiveControls.Add(_control);
                if (_liveControls.Contains(_control))
                {
                    _liveControls.Remove(_control);
                }

                if (_control.Bounds.ToString() != _subItemRectangle.ToString())
                {
                    // Forces to invalidate.
                    _control.Bounds = _subItemRectangle;
                }

                if (_control.Visible != true)
                {
                    _control.Visible = true;
                }
            }
            else
            {
                // If the sub item color is not the same as the back color fo the control, AND the item is not selected, then color this sub item background.
                if ((subItem.BackColor.ToArgb() != listView.BackColor.ToArgb()) && !item.Selected && (subItem.BackColor != Color.White))
                {
                    using (SolidBrush _backColorBrush = new SolidBrush(subItem.BackColor))
                    {
                        graphicsSubItem.FillRectangle(_backColorBrush, rectSubItem);
                    }
                }

                // Check if we need checkboxes in this column.
                if (listView.Columns[column].CheckBoxes && subItem.CheckBox)
                {
                    rectSubItem = DrawCheckBox(graphicsSubItem, rectSubItem, subItem.Checked, checkBoxSize, listView);
                }

                // If there is an image, this routine will RETURN with exactly the space left for everything else after the image is drawn (or not drawn due to lack of space).
                if ((subItem.ImageIndex > -1) && (listView.ImageListItems != null) && (subItem.ImageIndex < listView.ImageListItems.Images.Count))
                {
                    rectSubItem = DrawCellGraphic(graphicsSubItem, rectSubItem, listView.ImageListItems.Images[subItem.ImageIndex], subItem.ImageAlignment, cellPaddingSize, listView);
                }

                // Deal with text color in a box on whether it is selected or not.
                Color textColor;
                if (item.Selected && listView.Selectable)
                {
                    textColor = listView.ItemSelectedTextColor;
                }
                else
                {
                    textColor = listView.ForeColor;
                    if (item.ForeColor.ToArgb() != listView.ForeColor.ToArgb())
                    {
                        textColor = item.ForeColor;
                    }
                    else if (subItem.ForeColor.ToArgb() != listView.ForeColor.ToArgb())
                    {
                        textColor = subItem.ForeColor;
                    }
                }

                DrawCellText(graphicsSubItem, rectSubItem, subItem.Text, font, listView.Columns[column].TextAlignment, textColor, item.Selected, listView);
                subItem.LastCellRectangle = rectSubItem; // important to ONLY catch the area where the text is drawn
            }
        }
Exemplo n.º 18
0
        /// <summary>Create component instance.</summary>
        private void CreateComponentInstance()
        {
            if (componentNamespace == null)
            {
                return;
            }

            string visualPlusEntryPoint = SettingConstants.ProductName;

            componentType = Type.GetType(string.Concat(componentNamespace, ", ", visualPlusEntryPoint));
            component     = (Control)Activator.CreateInstance(componentType);

            if (IsDialog)
            {
                if (component is VisualForm form)
                {
                    form.Text       = @"VisualPlus";
                    form.Size       = new Size(300, 250);
                    form.TopLevel   = false;
                    form.AutoScroll = true;
                    form.UpdateTheme(theme);
                    form.Show();
                }
            }
            else
            {
                if (component is VisualComboBox comboBox)
                {
                    // Generate a sample items
                    for (var i = 0; i <= 7; i++)
                    {
                        comboBox.Items.Add("Item #" + i);
                    }

                    comboBox.SelectedIndex = 0;
                }
                else if (component is VisualDateTimePicker)
                {
                    // Do nothing. Doesn't like un-formatted Text.
                }
                else if (component is VisualGauge gauge)
                {
                    gauge.Value = 50;
                }
                else if (component is VisualListBox listBox)
                {
                    // Generate a sample items
                    for (var i = 0; i <= 7; i++)
                    {
                        listBox.Items.Add("Item #" + i);
                    }

                    listBox.SelectedIndex = 0;
                }
                else if (component is VisualListView listView)
                {
                    listView.Size = new Size(250, 200);
                    listView.Columns.Add("1", "Column 1", 100);
                    listView.Columns.Add("2", "Column 2", 100);

                    // Generate a sample items
                    for (var i = 0; i <= 7; i++)
                    {
                        VisualListViewItem    item    = new VisualListViewItem("Item #" + i);
                        VisualListViewSubItem subItem = new VisualListViewSubItem("SubItem #" + i);
                        item.SubItems.Add(subItem);
                        listView.Items.Add(item);
                    }

                    // listView.SelectedIndex = 0;
                }
                else if (component is VisualProgressBar progressBar)
                {
                    progressBar.Value = 50;
                }
                else if (component is VisualRadialProgress radialProgress)
                {
                    radialProgress.Value = 50;
                }
                else
                {
                    component.Text = @"VisualPlus";
                }
            }

            Controls.Clear();
            Controls.Add(component);
            component.ToCenter();
        }
 /// <summary>Adds an existing <see cref="VisualListViewSubItem" /> to the collection.</summary>
 /// <param name="item">The <see cref="VisualListViewSubItem" /> to add to the collection.</param>
 /// <returns>The <see cref="VisualListViewSubItem" /> that was added to the collection.</returns>
 public VisualListViewSubItem Add(VisualListViewSubItem item)
 {
     Insert(-1, item);
     return(item);
 }