コード例 #1
0
 /// <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;
 }
コード例 #2
0
        private void VisualListViewTest_Load(object sender, EventArgs e)
        {
            VisualListViewColumn _title = GenerateColumn("Title", 0, 150);

            _title.CheckBox   = true;
            _title.CheckBoxes = true;

            VisualListViewColumn _content = GenerateColumn("Content", 1, 150);

            _content.EmbeddedType = LVActivatedEmbeddedTypes.TextBox;

            VisualListViewColumn _date = GenerateColumn("Date", 2, 100);

            _date.EmbeddedType = LVActivatedEmbeddedTypes.DateTimePicker;

            VisualListViewColumn _progress = GenerateColumn("Progress", 3, 100);

            visualListView.Columns.Add(_title);
            visualListView.Columns.Add(_content);
            visualListView.Columns.Add(_date);
            visualListView.Columns.Add(_progress);

            for (var i = 0; i < 15; i++)
            {
                VisualListViewItem _listViewItem = GenerateItem();
                visualListView.Items.Add(_listViewItem);
            }

            visualListView.Items[0].Selected = true;
        }
コード例 #3
0
        /// <summary>Creates an item with the specified text and image and adds it to the collection.</summary>
        /// <param name="text">The text of the item.</param>
        /// <param name="imageIndex">The index of the image to display for the item.</param>
        /// <returns>The <see cref="VisualListViewItem" />.</returns>
        public virtual VisualListViewItem Add(string text, int imageIndex)
        {
            VisualListViewItem _item = new VisualListViewItem(text, imageIndex);

            Add(_item);
            return(_item);
        }
コード例 #4
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);
        }
コード例 #5
0
        /// <summary>Searches for items whose name matches the specified key, optionally searching subitems.</summary>
        /// <param name="key">The item name to search for.</param>
        /// <param name="searchAllSubItems">To search subitem.</param>
        /// <returns>
        ///     An array of <see cref="VisualListViewItem" /> objects containing the matching items, or an empty array if no
        ///     items matched.
        /// </returns>
        public VisualListViewItem[] Find(string key, bool searchAllSubItems)
        {
            ArrayList _foundItems = FindInternal(key, searchAllSubItems, this, new ArrayList());
            var       _stronglyTypedFoundItems = new VisualListViewItem[_foundItems.Count];

            _foundItems.CopyTo(_stronglyTypedFoundItems, 0);
            return(_stronglyTypedFoundItems);
        }
コード例 #6
0
ファイル: ClipboardTest.cs プロジェクト: yzwbrian/VisualPlus
        /// <summary>Generates an event item.</summary>
        /// <param name="text">The text.</param>
        private void GenerateEventItem(string text)
        {
            VisualListViewItem item = new VisualListViewItem(DateTime.Now.ToLongTimeString());

            item.SubItems.Add(text);

            listViewEvents.Items.Add(item);
        }
コード例 #7
0
        /// <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>
        /// <param name="imageIndex">The index of the image to display for the item.</param>
        /// <returns>The <see cref="VisualListViewItem" />.</returns>
        public VisualListViewItem Insert(int index, string text, int imageIndex)
        {
            VisualListViewItem _item = new VisualListViewItem {
                Text = text, ImageIndex = imageIndex
            };

            return(Insert(index, _item));
        }
コード例 #8
0
        /// <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="VisualListViewItem" />.</returns>
        public VisualListViewItem Insert(int index, string text)
        {
            VisualListViewItem _item = new VisualListViewItem {
                Text = text
            };

            return(Insert(index, _item));
        }
コード例 #9
0
        /// <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="key">The name of the item.</param>
        /// <param name="text">The text to display for the item.</param>
        /// <param name="imageIndex">The index of the image to display for the item.</param>
        /// <returns>The <see cref="VisualListViewItem" />.</returns>
        public virtual VisualListViewItem Insert(int index, string key, string text, int imageIndex)
        {
            VisualListViewItem _item = new VisualListViewItem {
                Name = key, Text = text, ImageIndex = imageIndex
            };

            return(Insert(index, _item));
        }
コード例 #10
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider isp, object value)
        {
            VisualListViewItem originalControl = (VisualListViewItem)context.Instance;

            object returnObject = base.EditValue(context, isp, value);

            originalControl.ListView.Refresh();
            return(returnObject);
        }
コード例 #11
0
        /// <summary>Adds an existing <see cref="VisualListViewItem" /> to the collection.</summary>
        /// <param name="value">The <see cref="VisualListViewItem" /> to add to the collection.</param>
        /// <returns>The <see cref="VisualListViewItem" />.</returns>
        public virtual VisualListViewItem Add(VisualListViewItem value)
        {
            value.ListView      = _listView;
            value.ChangedEvent += Item_Changed;

            List.Add(value);
            ChangedEvent?.Invoke(this, new ListViewChangedEventArgs(ListViewChangedTypes.ItemCollectionChanged, null, null, null));
            return(value);
        }
コード例 #12
0
        /// <summary>Determines whether the specified item is located in the collection.</summary>
        /// <param name="value">A <see cref="VisualListViewItem" /> representing the item to locate in the collection.</param>
        /// <returns>The <see cref="bool" />.</returns>
        public bool Contains(VisualListViewItem value)
        {
            if (value == null)
            {
                return(false);
            }

            return(List.Contains(value));
        }
コード例 #13
0
ファイル: UnitTestManager.cs プロジェクト: sadgood/VisualPlus
        /// <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);
        }
コード例 #14
0
        /// <summary>Creates an item with the specified text and adds it to the collection.</summary>
        /// <param name="text">The text to display for the item.</param>
        /// <returns>The <see cref="VisualListViewItem" />.</returns>
        public virtual VisualListViewItem Add(string text)
        {
            VisualListViewItem _item = new VisualListViewItem(text)
            {
                ListView = _listView
            };

            Add(_item);
            return(_item);
        }
コード例 #15
0
 /// <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(VisualListViewItem itemIgnore)
 {
     for (var index = 0; index < List.Count; index++)
     {
         VisualListViewItem _item = this[index];
         if (_item != itemIgnore)
         {
             _item.Selected = false;
         }
     }
 }
コード例 #16
0
        /// <summary>Find the index of a specified item.</summary>
        /// <param name="item">The item.</param>
        /// <returns>The <see cref="int" />.</returns>
        public int FindItemIndex(VisualListViewItem item)
        {
            for (var index = 0; index < Count; index++)
            {
                if (item == this[index])
                {
                    return(index);
                }
            }

            return(-1);
        }
コード例 #17
0
        /// <summary>Retrieves the index of the item with the specified key.</summary>
        /// <param name="key">The name of the item to find in the collection.</param>
        /// <returns>The <see cref="int" />.</returns>
        public virtual int IndexOfKey(string key)
        {
            for (var index = 0; index < List.Count; index++)
            {
                VisualListViewItem _item = (VisualListViewItem)List[index];
                if (key == _item.Name)
                {
                    return(index);
                }
            }

            return(-1);
        }
コード例 #18
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);
        }
コード例 #19
0
        /// <summary>Compare items using the compare direction.</summary>
        /// <param name="item1">The item 1.</param>
        /// <param name="item2">The item 2.</param>
        /// <param name="direction">The direction.</param>
        /// <returns>The <see cref="bool" />.</returns>
        private bool CompareItems(VisualListViewItem item1, VisualListViewItem item2, CompareDirection direction)
        {
            bool dir = false;

            if (direction == CompareDirection.GreaterThan)
            {
                dir = true;
            }

            if (_sortDirection == SortDirections.Ascending)
            {
                dir = !dir; // flip it
            }

            if (!_numericCompare)
            {
                if (dir)
                {
                    return(string.Compare(item1.SubItems[SortColumn].Text, item2.SubItems[SortColumn].Text, StringComparison.Ordinal) < 0);
                }
                else
                {
                    return(string.Compare(item1.SubItems[SortColumn].Text, item2.SubItems[SortColumn].Text, StringComparison.Ordinal) > 0);
                }
            }
            else
            {
                try
                {
                    double n1 = double.Parse(item1.SubItems[SortColumn].Text);
                    double n2 = double.Parse(item2.SubItems[SortColumn].Text);

                    if (dir)
                    {
                        return(n1 < n2);
                    }
                    else
                    {
                        return(n1 > n2);
                    }
                }
                catch (Exception ex)
                {
                    // no numeric value (bad bad)
                    Debug.WriteLine(ex.ToString());
                    return(false);
                }
            }
        }
コード例 #20
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
        }
コード例 #21
0
        private void VisualListViewTest_Load(object sender, EventArgs e)
        {
            for (var i = 0; i < 5; i++)
            {
                VisualListViewItem _listViewItem = GenerateItem();
                visualListViewAdvanced1.Items.Add(_listViewItem);
            }

            visualListViewAdvanced1.Items[1].Selected = true;

            visualListViewAdvanced1.Columns[0].ImageIndex = 0;
            visualListViewAdvanced1.Columns[1].ImageIndex = 1;
            visualListViewAdvanced1.Columns[2].ImageIndex = 2;
            visualListViewAdvanced1.Columns[3].ImageIndex = 3;
        }
コード例 #22
0
        /// <summary>The sort.</summary>
        /// <param name="items">The items.</param>
        /// <param name="low_0">The low.</param>
        /// <param name="high_0">The high.</param>
        public void Sort(VisualListViewItemCollection items, int low_0, int high_0)
        {
            int lo = low_0;
            int hi = high_0;

            if (lo >= hi)
            {
                return;
            }

            int mid = (lo + hi) / 2;

            Sort(items, lo, mid);
            Sort(items, mid + 1, hi);

            int end_lo   = mid;
            int start_hi = mid + 1;

            while ((lo <= end_lo) && (start_hi <= hi))
            {
                if (StopRequested)
                {
                    return;
                }

                if (CompareItems(items[lo], items[start_hi], CompareDirection.LessThan))
                {
                    lo++;
                }
                else
                {
                    VisualListViewItem visualListViewItem = items[start_hi];
                    for (int k = start_hi - 1; k >= lo; k--)
                    {
                        items[k + 1] = items[k];
                    }

                    items[lo] = visualListViewItem;
                    lo++;
                    end_lo++;
                    start_hi++;
                }
            }
        }
コード例 #23
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);
        }
コード例 #24
0
        /// <summary>Inserts an existing <see cref="VisualListViewItem" /> 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">The <see cref="VisualListViewItem" /> that represents the item to insert.</param>
        /// <returns>The <see cref="VisualListViewItem" />.</returns>
        public VisualListViewItem Insert(int index, VisualListViewItem item)
        {
            if ((index < 0) || (index > Count))
            {
                throw new ArgumentOutOfRangeException("index=" + index);
            }

            item.ListView      = _listView;
            item.ChangedEvent += Item_Changed;

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

            ChangedEvent?.Invoke(this, new ListViewChangedEventArgs(ListViewChangedTypes.ItemCollectionChanged, null, null, null));
            return(item);
        }
コード例 #25
0
        public bool ContainsItem(VisualListViewItem value)
        {
            foreach (VisualListViewItem _item in List)
            {
                var _subItemFlag = true;
                for (var i = 0; i < _item.SubItems.Count; i++)
                {
                    string _subItem1 = _item.SubItems[i].Text;
                    string _subItem2 = value.SubItems[i].Text;

                    if (_subItem1 != _subItem2)
                    {
                        _subItemFlag = false;
                    }
                }

                if (_subItemFlag)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #26
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();
        }
コード例 #27
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
            }
        }
コード例 #28
0
        /// <summary>Draw row at specified coordinates.</summary>
        /// <param name="graphicsRow">The graphics row.</param>
        /// <param name="rectRow">The rectangle row.</param>
        /// <param name="item">The item.</param>
        /// <param name="itemIndex">The item index.</param>
        /// <param name="listView">The list View.</param>
        /// <param name="hPanelScrollBar">The h Panel Scroll Bar.</param>
        /// <param name="_newLiveControls">The _new Live Controls.</param>
        /// <param name="_liveControls">The _live Controls.</param>
        /// <param name="checkBoxSize">The check Box Size.</param>
        public static void DrawRow(Graphics graphicsRow, Rectangle rectRow, VisualListViewItem item, int itemIndex, VisualListView listView, ManagedHScrollBar hPanelScrollBar, ArrayList _newLiveControls, ArrayList _liveControls, int checkBoxSize)
        {
            ConsoleEx.WriteDebug("ListViewRenderer::DrawRow");

            // If its selected, that trumps all, if not then see if we are using alternating colors, if not draw normal
            // this can all be overridden by the sub item background property make sure anything can even be selected before drawing selection rectangles
            if (item.Selected && listView.Selectable)
            {
                using (SolidBrush _brushBackground = new SolidBrush(Color.FromArgb(255, listView.ItemSelectedColor.R, listView.ItemSelectedColor.G, listView.ItemSelectedColor.B)))
                {
                    if (!listView.FullRowSelect)
                    {
                        // Calculate how far into the control it goes
                        int _widthDepth = -hPanelScrollBar.Value + listView.Columns.Width;
                        graphicsRow.FillRectangle(_brushBackground, listView.RowsInnerClientRect.X, rectRow.Y, _widthDepth, rectRow.Height);
                    }
                    else
                    {
                        graphicsRow.FillRectangle(_brushBackground, listView.RowsInnerClientRect.X, rectRow.Y, listView.RowsInnerClientRect.Width, rectRow.Height);
                    }
                }
            }
            else
            {
                // If the back color of the list doesn't match the back color of the item (AND) the back color isn't white, then override it
                if ((item.BackColor.ToArgb() != listView.BackColor.ToArgb()) && (item.BackColor != Color.White))
                {
                    using (SolidBrush _backgroundBrush = new SolidBrush(item.BackColor))
                    {
                        graphicsRow.FillRectangle(_backgroundBrush, listView.RowsInnerClientRect.X, rectRow.Y, listView.RowsInnerClientRect.Width, rectRow.Height);
                    }
                }
                else if (listView.AlternatingColors)
                {
                    // Check for full row alternate color alternating colors are only shown if the row isn't selected.
                    int _alternateItemIndex = listView.Items.FindItemIndex(item);
                    if (_alternateItemIndex % 2 > 0)
                    {
                        using (SolidBrush _backgroundBrush = new SolidBrush(listView.AlternateBackground))
                        {
                            if (!listView.FullRowSelect)
                            {
                                // Calculate how far into the control it goes
                                int _widthDepth = -hPanelScrollBar.Value + listView.Columns.Width;
                                graphicsRow.FillRectangle(_backgroundBrush, listView.RowsInnerClientRect.X, rectRow.Y, _widthDepth, rectRow.Height);
                            }
                            else
                            {
                                graphicsRow.FillRectangle(_backgroundBrush, listView.RowsInnerClientRect.X, rectRow.Y, listView.RowsInnerClientRect.Width, rectRow.Height);
                            }
                        }
                    }
                }
            }

            int _xCursor = -hPanelScrollBar.Value + listView.Border.Thickness;

            for (var subItemIndex = 0; subItemIndex < listView.Columns.Count; subItemIndex++)
            {
                Rectangle _subItemRectangle = new Rectangle(_xCursor, rectRow.Y, listView.Columns[subItemIndex].Width, rectRow.Height);

                // Avoid drawing items that are not in the visible region
                if ((_subItemRectangle.Right < 0) || (_subItemRectangle.Left > listView.RowsInnerClientRect.Right))
                {
                    Debug.Write(string.Empty);
                }
                else
                {
                    DrawSubItem(graphicsRow, _subItemRectangle, item, item.SubItems[subItemIndex], subItemIndex, listView.Font, listView, _newLiveControls, _liveControls, listView.CellPaddingSize, checkBoxSize);
                }

                _xCursor += listView.Columns[subItemIndex].Width;
            }

            // Post draw for focus rect and hot tracking
            if ((itemIndex == listView.HoverItemIndex) && listView.HoverItemTracking)
            {
                // handle hot tracking of items
                Color transparentColor = Color.FromArgb(75, listView.HoverTrackingColor.R, listView.HoverTrackingColor.G, listView.HoverTrackingColor.B); // 182, 189, 210 );
                using (Brush hotBrush = new SolidBrush(transparentColor))
                {
                    graphicsRow.FillRectangle(hotBrush, listView.RowsInnerClientRect.X, rectRow.Y, listView.RowsInnerClientRect.Width, rectRow.Height);
                }
            }

            // Draw row borders
            if (item.RowBorderSize > 0)
            {
                using (Pen _borderPen = new Pen(item.RowBorderColor, item.RowBorderSize)
                {
                    Alignment = PenAlignment.Inset
                })
                {
                    graphicsRow.DrawRectangle(_borderPen, rectRow);
                }
            }

            // Make sure anything can even be selected before drawing selection rects
            if (listView.Selectable)
            {
                if (listView.ShowFocusRectangle && (listView.FocusedItem == item))
                {
                    // Deal with focus rect
                    ControlPaint.DrawFocusRectangle(graphicsRow, new Rectangle(listView.RowsInnerClientRect.X + 1, rectRow.Y, listView.RowsInnerClientRect.Width - 1, rectRow.Height));
                }
            }
        }
コード例 #29
0
 /// <summary>Initializes a new instance of the <see cref="VisualListViewSubItemCollection" /> class.</summary>
 /// <param name="owner">The <see cref="VisualListViewItem" /> that owns the collection.</param>
 public VisualListViewSubItemCollection(VisualListViewItem owner) : this()
 {
     _owner = owner;
 }
コード例 #30
0
 /// <summary>Initializes a new instance of the <see cref="VisualListViewSubItemCollection" /> class.</summary>
 public VisualListViewSubItemCollection()
 {
     _lastAccessedIndex = -1;
     _listView          = null;
     _owner             = null;
 }