Exemplo n.º 1
0
        internal void DrawIntermediateState(Graphics g)
        {
            if (!IsInATreeListView)
            {
                return;
            }
            if (TreeListView._updating)
            {
                return;
            }
            Debug.Assert(!TreeListView.InvokeRequired);

            if (TreeListView.CheckBoxes != CheckBoxesTypes.Recursive || TreeListView.Columns.Count == 0)
            {
                return;
            }
            if (CheckStatus == CheckState.Indeterminate)
            {
                Rectangle rect = GetBounds(ItemBoundsPortion.Icon);
                Rectangle r    = TreeListView._comctl32Version >= 6 ?
                                 new Rectangle(rect.Left - 14, rect.Top + 5, rect.Height - 10, rect.Height - 10) :
                                 new Rectangle(rect.Left - 11, rect.Top + 5, rect.Height - 10, rect.Height - 10);
                Brush brush = new Drawing.Drawing2D.LinearGradientBrush(r, Color.Gray, Color.LightBlue, 45, false);
                if (TreeListView.Columns[0].Width > (Level + (TreeListView.ShowPlusMinus ? 2 : 1)) * SystemInformation.SmallIconSize.Width)
                {
                    g.FillRectangle(brush, r);
                }
                brush.Dispose();
            }
            Console.WriteLine($"Draw intermediat state for  {Text} - {Index}");
            for (int i = 0; i < SubItems.Count; ++i)
            {
                var asControlWrapper = SubItems[i] as IControlWrappedItem;
                if (asControlWrapper == null)
                {
                    continue;
                }

                if (asControlWrapper.Control.Visible)
                {
                    asControlWrapper.Control.Bounds = TreeListView.GetSubItemRect(Index, i);

                    Console.WriteLine($"item {Text} - {Index},{i}, { asControlWrapper.Control.Bounds} { asControlWrapper.Control}");
                }
            }
        }
Exemplo n.º 2
0
        public void ShowEditControl()
        {
            if (_treelistview.FocusedItem == null)
            {
                return;
            }
            ListViewItem item = (ListViewItem)_treelistview.EditedItem.Item;
            Rectangle    rec  = _treelistview.EditedItem.ColumnIndex > 0 ?
                                _treelistview.GetSubItemRect(item.Index, _treelistview.EditedItem.ColumnIndex) :
                                _treelistview.GetItemRect(item.Index, ItemBoundsPortion.Label);

            _editor.Size     = rec.Size;
            _editor.Location = rec.Location;
            _editor.Top--;
            _editor.Show();
            _editor.Text = item.SubItems[_treelistview.EditedItem.ColumnIndex].Text;
            _editor.Focus();
        }
Exemplo n.º 3
0
        internal void DrawFocusCues()
        {
            if (!IsInATreeListView)
            {
                return;
            }
            if (TreeListView._updating)
            {
                return;
            }
            if (TreeListView.HideSelection && !TreeListView.Focused)
            {
                return;
            }
            Graphics g = Graphics.FromHwnd(TreeListView.Handle);

            if (Visible)
            {
                Rectangle entireitemrect = GetBounds(ItemBoundsPortion.Entire);
                if (entireitemrect.Bottom > entireitemrect.Height * 1.5f)
                {
                    Rectangle labelitemrect    = GetBounds(ItemBoundsPortion.Label);
                    Rectangle itemonlyrect     = GetBounds(ItemBoundsPortion.ItemOnly);
                    Rectangle selecteditemrect = new Rectangle(
                        labelitemrect.Left,
                        labelitemrect.Top,
                        TreeListView.FullRowSelect ? entireitemrect.Width - labelitemrect.Left - 1 : itemonlyrect.Width - SystemInformation.SmallIconSize.Width - 1,
                        labelitemrect.Height - 1);
                    Pen pen = new Pen(TreeListView.Focused && Selected ? Color.Blue : ColorUtil.CalculateColor(SystemColors.Highlight, SystemColors.Window, 130));
                    for (int i = 1; i < TreeListView.Columns.Count; i++)
                    {
                        Rectangle rect = TreeListView.GetSubItemRect(Index, i);
                        if (rect.X < selecteditemrect.X)
                        {
                            selecteditemrect = new Rectangle(
                                rect.X, selecteditemrect.Y,
                                selecteditemrect.Width + (selecteditemrect.X - rect.X),
                                selecteditemrect.Height);
                        }
                    }

                    g.DrawRectangle(new Pen(ColorUtil.VSNetSelectionColor), selecteditemrect);
                    // Fill the item (in CommCtl V6, the selection area is not always the same :
                    // label only or first column). I decided to always draw the entire column...
                    if (!TreeListView.FullRowSelect)
                    {
                        g.FillRectangle(
                            new SolidBrush(BackColor),
                            itemonlyrect.Right - 1, itemonlyrect.Top,
                            labelitemrect.Width - itemonlyrect.Width + SystemInformation.SmallIconSize.Width + 1, selecteditemrect.Height + 1);
                    }
                    //bool draw = true;
                    //if (PrevVisibleItem != null)
                    //    if (PrevVisibleItem.Selected) draw = false;
                    //// Draw upper line if previous item is not selected
                    ////if (draw) g.DrawLine(pen, selecteditemrect.Left, selecteditemrect.Top, selecteditemrect.Right, selecteditemrect.Top);
                    ////g.DrawLine(pen, selecteditemrect.Left, selecteditemrect.Top, selecteditemrect.Left, selecteditemrect.Bottom);
                    //draw = true;
                    //if (NextVisibleItem != null)
                    //    if (NextVisibleItem.Selected) draw = false;
                    //// Draw lower line if net item is not selected
                    ////if (draw) g.DrawLine(pen, selecteditemrect.Left, selecteditemrect.Bottom, selecteditemrect.Right, selecteditemrect.Bottom);
                    ////g.DrawLine(pen, selecteditemrect.Right, selecteditemrect.Top, selecteditemrect.Right, selecteditemrect.Bottom);
                    //// If FullRowSelect is false and multiselect is enabled, the items don't have the same width
                    if (!TreeListView.FullRowSelect && NextVisibleItem != null)
                    {
                        if (NextVisibleItem.Selected)
                        {
                            int nextItemWidth = NextVisibleItem.GetBounds(TreeListViewItemBoundsPortion.ItemOnly).Width;
                            if (nextItemWidth != itemonlyrect.Width)
                            {
                                g.DrawLine(
                                    pen,
                                    selecteditemrect.Right,
                                    selecteditemrect.Bottom,
                                    selecteditemrect.Right - (itemonlyrect.Width - nextItemWidth),
                                    selecteditemrect.Bottom);
                            }
                        }
                    }
                    pen.Dispose();
                }
            }
            g.Dispose();
        }