コード例 #1
0
ファイル: TreeListViewItem.cs プロジェクト: utobe/QuickMon
        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();
        }
コード例 #2
0
ファイル: TreeListViewItem.cs プロジェクト: windygu/WMS-4
 internal void DrawFocusCues()
 {
     if (IsInATreeListView && !TreeListView._Updating && (!TreeListView.HideSelection || TreeListView.Focused))
     {
         Graphics graphics = Graphics.FromHwnd(TreeListView.Handle);
         if (Visible)
         {
             Rectangle bounds = GetBounds(ItemBoundsPortion.Entire);
             if ((float)bounds.Bottom > (float)bounds.Height * 1.5f)
             {
                 Rectangle bounds2 = GetBounds(ItemBoundsPortion.Label);
                 Rectangle bounds3 = GetBounds(ItemBoundsPortion.ItemOnly);
                 Rectangle rect    = new Rectangle(bounds2.Left, bounds2.Top, TreeListView.FullRowSelect ? (bounds.Width - bounds2.Left - 1) : (bounds3.Width - SystemInformation.SmallIconSize.Width - 1), bounds2.Height - 1);
                 Pen       pen     = new Pen((TreeListView.Focused && base.Selected) ? Color.Blue : ColorUtil.CalculateColor(System.Drawing.SystemColors.Highlight, System.Drawing.SystemColors.Window, 130));
                 for (int i = 1; i < TreeListView.Columns.Count; i++)
                 {
                     Rectangle subItemRect = TreeListView.GetSubItemRect(base.Index, i);
                     if (subItemRect.X < rect.X)
                     {
                         rect = new Rectangle(subItemRect.X, rect.Y, rect.Width + (rect.X - subItemRect.X), rect.Height);
                     }
                 }
                 graphics.DrawRectangle(new Pen(ColorUtil.VSNetSelectionColor), rect);
                 if (!TreeListView.FullRowSelect)
                 {
                     graphics.FillRectangle(new SolidBrush(base.BackColor), bounds3.Right - 1, bounds3.Top, bounds2.Width - bounds3.Width + SystemInformation.SmallIconSize.Width + 1, rect.Height + 1);
                 }
                 bool flag = true;
                 if (PrevVisibleItem != null && PrevVisibleItem.Selected)
                 {
                     flag = false;
                 }
                 if (flag)
                 {
                     graphics.DrawLine(pen, rect.Left, rect.Top, rect.Right, rect.Top);
                 }
                 graphics.DrawLine(pen, rect.Left, rect.Top, rect.Left, rect.Bottom);
                 flag = true;
                 if (NextVisibleItem != null && NextVisibleItem.Selected)
                 {
                     flag = false;
                 }
                 if (flag)
                 {
                     graphics.DrawLine(pen, rect.Left, rect.Bottom, rect.Right, rect.Bottom);
                 }
                 graphics.DrawLine(pen, rect.Right, rect.Top, rect.Right, rect.Bottom);
                 if (!TreeListView.FullRowSelect && NextVisibleItem != null && NextVisibleItem.Selected)
                 {
                     int width = NextVisibleItem.GetBounds(TreeListViewItemBoundsPortion.ItemOnly).Width;
                     if (width != bounds3.Width)
                     {
                         graphics.DrawLine(pen, rect.Right, rect.Bottom, rect.Right - (bounds3.Width - width), rect.Bottom);
                     }
                 }
                 pen.Dispose();
             }
         }
         graphics.Dispose();
     }
 }