Exemplo n.º 1
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;
        }
 /// <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 an existing <see cref="VisualListViewColumn" /> to the collection.</summary>
        /// <param name="column">The <see cref="VisualListViewColumn" /> to add to the collection.</param>
        public virtual void Add(VisualListViewColumn column)
        {
            column.ListView      = _listView;
            column.ChangedEvent += Column_Changed;

            List.Add(column);
            ChangedEvent?.Invoke(this, new ListViewChangedEventArgs(ListViewChangedTypes.ColumnCollectionChanged, column, null, null));
        }
        /// <summary>Determines whether the specified column header is located in the collection.</summary>
        /// <param name="value">A <see cref="VisualListViewColumn" /> representing the column header to locate in the collection.</param>
        /// <returns>The <see cref="bool" />.</returns>
        public bool Contains(VisualListViewColumn value)
        {
            if (value == null)
            {
                return(false);
            }

            return(List.Contains(value));
        }
Exemplo n.º 5
0
        /// <summary>Generate the column.</summary>
        /// <param name="text">The text to display.</param>
        /// <param name="imageIndex">The image index.</param>
        /// <param name="width">The width.</param>
        /// <returns>The <see cref="VisualListViewColumn" />.</returns>
        private VisualListViewColumn GenerateColumn(string text, int imageIndex, int width)
        {
            VisualListViewColumn _column = new VisualListViewColumn(text)
            {
                TextAlignment = ContentAlignment.MiddleCenter, ImageIndex = imageIndex, Width = width
            };

            return(_column);
        }
        /// <summary>Determines the index for a column with the specified key.</summary>
        /// <param name="key">The name of the column to retrieve the index for.</param>
        /// <returns>The <see cref="int" />.</returns>
        public virtual int IndexOfKey(string key)
        {
            for (var index = 0; index < List.Count; index++)
            {
                VisualListViewColumn _column = (VisualListViewColumn)List[index];
                if (key == _column.Name)
                {
                    return(index);
                }
            }

            return(-1);
        }
        /// <summary>
        ///     Creates a new column header with the specified text and initial width, and inserts the header into the
        ///     collection at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index location where the column header is inserted.</param>
        /// <param name="text">The text to display in the column header.</param>
        /// <param name="width">The initial width of the <see cref="VisualListViewColumn" />.</param>
        public void Insert(int index, string text, int width)
        {
            VisualListViewColumn _column = new VisualListViewColumn
            {
                Name          = nameof(VisualListViewColumn) + List.GetNextID(),
                Text          = text,
                Width         = width,
                State         = ColumnStates.None,
                TextAlignment = ContentAlignment.MiddleLeft,
                ListView      = _listView
            };

            Insert(index, _column);
        }
        /// <summary>
        ///     Creates a new column header with the specified text and key, and inserts the header into the collection at the
        ///     specified index.
        /// </summary>
        /// <param name="index">The zero-based index location where the column header is inserted.</param>
        /// <param name="key">The name of the column header.</param>
        /// <param name="text">The text to display in the column header.</param>
        public void Insert(int index, string key, string text)
        {
            VisualListViewColumn _column = new VisualListViewColumn
            {
                Name          = key,
                Text          = text,
                Width         = Settings.DefaultValue.ColumnWidth,
                State         = ColumnStates.None,
                TextAlignment = ContentAlignment.MiddleLeft,
                ListView      = _listView
            };

            Insert(index, _column);
        }
Exemplo n.º 9
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if ((destinationType == typeof(InstanceDescriptor)) && value is VisualListViewColumn)
            {
                VisualListViewColumn _column          = (VisualListViewColumn)value;
                ConstructorInfo      _constructorInfo = typeof(VisualListViewColumn).GetConstructor(new Type[] { });
                if (_constructorInfo != null)
                {
                    return(new InstanceDescriptor(_constructorInfo, null, false));
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
        /// <summary>
        ///     Creates a new column header with the specified text, key, and initial width, and inserts the header into the
        ///     collection at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index location where the column header is inserted.</param>
        /// <param name="key">The name of the column header.</param>
        /// <param name="text">The text to display in the column header.</param>
        /// <param name="width">The initial width of the <see cref="VisualListViewColumn" />.</param>
        /// <param name="textAlign">One of the <see cref="HorizontalAlignment" /> values.</param>
        public void Insert(int index, string key, string text, int width, ContentAlignment textAlign)
        {
            VisualListViewColumn _column = new VisualListViewColumn
            {
                Name          = key,
                Text          = text,
                Width         = width,
                State         = ColumnStates.None,
                TextAlignment = textAlign,
                ListView      = _listView
            };

            Insert(index, _column);
        }
        /// <summary>Creates and adds a column with the specified text, key, and width to the collection.</summary>
        /// <param name="key">The key of the column header.</param>
        /// <param name="text">The text to display in the column header.</param>
        /// <param name="width">The initial width of the <see cref="VisualListViewColumn" />.</param>
        /// <returns>The <see cref="VisualListViewColumn" />.</returns>
        public virtual VisualListViewColumn Add(string key, string text, int width)
        {
            VisualListViewColumn _column = new VisualListViewColumn
            {
                Name          = key,
                Text          = text,
                Width         = width,
                State         = ColumnStates.None,
                TextAlignment = ContentAlignment.MiddleLeft,
                ListView      = _listView
            };

            Add(_column);
            return(_column);
        }
        /// <summary>Adds a column to the collection with the specified text, width, and alignment settings.</summary>
        /// <param name="text">The text to display in the column header.</param>
        /// <returns>The <see cref="VisualListViewColumn" />.</returns>
        public virtual VisualListViewColumn Add(string text)
        {
            VisualListViewColumn _column = new VisualListViewColumn
            {
                Name          = nameof(VisualListViewColumn) + List.GetNextID(),
                Text          = text,
                Width         = Settings.DefaultValue.ColumnWidth,
                State         = ColumnStates.None,
                TextAlignment = ContentAlignment.MiddleLeft,
                ListView      = _listView
            };

            Add(_column);
            return(_column);
        }
        /// <summary>Adds a column to the collection with the specified text, width, and alignment settings.</summary>
        /// <param name="text">The text to display in the column header.</param>
        /// <param name="width">The initial width of the column header.</param>
        /// <param name="textAlign">One of the <see cref="HorizontalAlignment" /> values.</param>
        /// <returns>The <see cref="VisualListViewColumn" />.</returns>
        public virtual VisualListViewColumn Add(string text, int width, ContentAlignment textAlign)
        {
            VisualListViewColumn _column = new VisualListViewColumn
            {
                Name          = nameof(VisualListViewColumn) + List.GetNextID(),
                Text          = text,
                Width         = width,
                State         = ColumnStates.None,
                TextAlignment = textAlign,
                ListView      = _listView
            };

            Add(_column);
            return(_column);
        }
        /// <summary>Inserts an existing column header into the collection at the specified index.</summary>
        /// <param name="index">The zero-based index location where the column header is inserted.</param>
        /// <param name="value">The <see cref="VisualListViewColumn" /> to insert into the collection.</param>
        public void Insert(int index, VisualListViewColumn value)
        {
            value.ListView      = _listView;
            value.ChangedEvent += Column_Changed;
            value.Name          = nameof(VisualListViewColumn) + List.GetNextID();

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

            ChangedEvent?.Invoke(this, new ListViewChangedEventArgs(ListViewChangedTypes.ColumnCollectionChanged, value, null, null));
        }
Exemplo n.º 15
0
        public ClipboardTest()
        {
            InitializeComponent();

            VisualListViewColumn timeColumn = new VisualListViewColumn("Time");

            VisualListViewColumn eventsColumn = new VisualListViewColumn("Events")
            {
                Width = 200
            };

            listViewEvents.Columns.Add(timeColumn);
            listViewEvents.Columns.Add(eventsColumn);

            textBox.ClipboardCopy  += TextBox_ClipboardCopy;
            textBox.ClipboardCut   += TextBox_ClipboardCut;
            textBox.ClipboardPaste += TextBox_ClipboardPaste;
        }
Exemplo n.º 16
0
        /// <summary>Draw the column header.</summary>
        /// <param name="graphicsColumn">The graphics column.</param>
        /// <param name="columnRectangle">The rectangle column.</param>
        /// <param name="column">The column.</param>
        /// <param name="theme">The theme.</param>
        /// <param name="listView">The list View.</param>
        public static void DrawColumnHeader(Graphics graphicsColumn, Rectangle columnRectangle, VisualListViewColumn column, IntPtr theme, VisualListView listView)
        {
            ConsoleEx.WriteDebug("ListViewRenderer::DrawColumnHeader - Text: " + column.Text);

            if (listView.ControlStyle == LVControlStyles.SuperFlat)
            {
                SolidBrush columnRectangleBrush;

                if (column.State == ColumnStates.None)
                {
                    columnRectangleBrush = new SolidBrush(listView.ColumnColorState.Enabled);
                    graphicsColumn.FillRectangle(columnRectangleBrush, columnRectangle);
                }
                else if (column.State == ColumnStates.Pressed)
                {
                    columnRectangleBrush = new SolidBrush(listView.ColumnColorState.Pressed);
                    graphicsColumn.FillRectangle(columnRectangleBrush, columnRectangle);
                }
                else if (column.State == ColumnStates.Hover)
                {
                    columnRectangleBrush = new SolidBrush(listView.ColumnColorState.Hover);
                    graphicsColumn.FillRectangle(columnRectangleBrush, columnRectangle);
                }
            }
            else if ((listView.ControlStyle == LVControlStyles.XP) && listView.ThemesAvailable)
            {
                // This is really the only thing we care about for theme right now inside the control.
                IntPtr hDC = graphicsColumn.GetHdc();

                RECT _columnRect = new RECT(columnRectangle.X, columnRectangle.Y, columnRectangle.Right, columnRectangle.Bottom);
                RECT _clipRect   = new RECT(columnRectangle.X, columnRectangle.Y, columnRectangle.Right, columnRectangle.Bottom);

                if (column.State == ColumnStates.None)
                {
                    // Normal.
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 1, ref _columnRect, ref _clipRect);
                }
                else if (column.State == ColumnStates.Pressed)
                {
                    // Pressed
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 3, ref _columnRect, ref _clipRect);
                }
                else if (column.State == ColumnStates.Hover)
                {
                    // Hover
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 2, ref _columnRect, ref _clipRect);
                }

                graphicsColumn.ReleaseHdc(hDC);
            }
            else
            {
                // Normal state.
                if (column.State != ColumnStates.Pressed)
                {
                    ControlPaint.DrawButton(graphicsColumn, columnRectangle, ButtonState.Normal);
                }
                else
                {
                    ControlPaint.DrawButton(graphicsColumn, columnRectangle, ButtonState.Pushed);
                }
            }

            // Check if we need checkboxes in this column.
            if (column.CheckBox)
            {
                columnRectangle = DrawCheckBox(graphicsColumn, columnRectangle, column.Checked, ListViewConstants.CHECKBOX_SIZE, 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 ((column.ImageIndex > -1) && (listView.ImageListColumns != null) && (column.ImageIndex < listView.ImageListColumns.Images.Count))
            {
                columnRectangle = DrawCellGraphic(graphicsColumn, columnRectangle, listView.ImageListColumns.Images[column.ImageIndex], HorizontalAlignment.Left, listView.CellPaddingSize, listView);
            }

            DrawCellText(graphicsColumn, columnRectangle, column.Text, listView.Font, column.TextAlignment, listView.ForeColor, false, listView);
        }
Exemplo n.º 17
0
        /// <summary>Draw column in header control.</summary>
        /// <param name="graphicsColumn">The graphics column.</param>
        /// <param name="rectColumn">The rectangle column.</param>
        /// <param name="column">The column.</param>
        /// <param name="theme">The _theme.</param>
        /// <param name="listView">The list View.</param>
        public static void DrawColumnHeader(Graphics graphicsColumn, Rectangle rectColumn, VisualListViewColumn column, IntPtr theme, VisualListViewEx listView)
        {
            DebugTraceManager.WriteDebug("ListViewRenderer::DrawColumnHeader - Name: " + column.Name, DebugTraceManager.DebugOutput.TraceListener);

            if (listView.ControlStyle == LVControlStyles.SuperFlat)
            {
                SolidBrush brush = new SolidBrush(listView.SuperFlatHeaderColor);
                graphicsColumn.FillRectangle(brush, rectColumn);
                brush.Dispose();
            }
            else if ((listView.ControlStyle == LVControlStyles.XP) && listView.ThemesAvailable)
            {
                // this is really the only thing we care about for themeing right now inside the control
                IntPtr hDC = graphicsColumn.GetHdc();

                RECT colrect  = new RECT(rectColumn.X, rectColumn.Y, rectColumn.Right, rectColumn.Bottom);
                RECT cliprect = new RECT(rectColumn.X, rectColumn.Y, rectColumn.Right, rectColumn.Bottom);

                if (column.State == ColumnStates.None)
                {
                    // Debug.WriteLine( "Normal" );
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 1, ref colrect, ref cliprect);
                }
                else if (column.State == ColumnStates.Pressed)
                {
                    // Debug.WriteLine( "Pressed" );
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 3, ref colrect, ref cliprect);
                }
                else if (column.State == ColumnStates.Hot)
                {
                    // Debug.WriteLine( "Hot" );
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 2, ref colrect, ref cliprect);
                }

                graphicsColumn.ReleaseHdc(hDC);
            }
            else
            {
                // normal state
                if (column.State != ColumnStates.Pressed)
                {
                    ControlPaint.DrawButton(graphicsColumn, rectColumn, ButtonState.Normal);
                }
                else
                {
                    ControlPaint.DrawButton(graphicsColumn, rectColumn, ButtonState.Pushed);
                }
            }

            // Check if we need checkboxes in this column
            if (column.CheckBox)
            {
                rectColumn = DrawCheckBox(graphicsColumn, rectColumn, column.Checked, ListViewConstants.CHECKBOX_SIZE, 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 ((column.ImageIndex > -1) && (listView.ImageListColumns != null) && (column.ImageIndex < listView.ImageListColumns.Images.Count))
            {
                rectColumn = DrawCellGraphic(graphicsColumn, rectColumn, listView.ImageListColumns.Images[column.ImageIndex], HorizontalAlignment.Left, listView.CellPaddingSize, listView);
            }

            DrawCellText(graphicsColumn, rectColumn, column.Text, listView.Font, column.TextAlignment, listView.ForeColor, false, listView);
        }
 /// <summary>Return the index, within the collection, of the specified column header.</summary>
 /// <param name="value">A <see cref="VisualListViewColumn" /> representing the column header to locate in the collection.</param>
 /// <returns>The <see cref="int" />.</returns>
 public virtual int IndexOf(VisualListViewColumn value)
 {
     return(List.IndexOf(value));
 }
 /// <summary>Removes the specified column header from the collection.</summary>
 /// <param name="column">A <see cref="VisualListViewColumn" /> representing the item to remove from the collection.</param>
 public virtual void Remove(VisualListViewColumn column)
 {
     RemoveByKey(column.Name);
 }