Example #1
0
 protected override void DrawItem(Graphics gr, VisibleItemInfo info)
 {
     if (PaintItem != null)
     {
         PaintItem(this, new PaintItemContentEventArgs {
             Graphics = gr, Info = info
         });
     }
     else
     {
         base.DrawItem(gr, info);
     }
 }
Example #2
0
 protected override void DrawItem(Graphics gr, VisibleItemInfo info)
 {
     if (PaintNode != null)
     {
         PaintNode(this, new PaintNodeContentEventArgs {
             Graphics = gr, Info = info, Node = nodes[info.ItemIndex]
         });
     }
     else
     {
         base.DrawItem(gr, info);
     }
 }
Example #3
0
 protected virtual void DrawItem(Graphics gr, VisibleItemInfo info)
 {
     DrawItemWhole(gr, info);
 }
Example #4
0
        protected virtual void DrawItemHotTracking(Graphics gr, VisibleItemInfo info)
        {
            var c1 = HotTrackingColor;
            var rect = info.TextAndIconRect;

            if (FullItemSelect)
            {
                var cr = ClientRectMinusPaddings;
                rect = new Rectangle(cr.Left, rect.Top, cr.Width - 1, rect.Height);
            }

            if (rect.Width > 0 && rect.Height > 0)
                using (var pen = new Pen(c1))
                    gr.DrawRectangle(pen, rect);
        }
Example #5
0
        public virtual void DrawSelection(Graphics gr, VisibleItemInfo info)
        {
            var c1 = Color.FromArgb(SelectionColor.A == 255 ? SelectionColorOpaque : SelectionColor.A, SelectionColor);
            var c2 = Color.FromArgb(c1.A / 2, SelectionColor);
            var rect = info.TextAndIconRect;

            if (FullItemSelect)
            {
                var cr = ClientRectMinusPaddings;
                rect = new Rectangle(cr.Left, rect.Top, cr.Width - 1, rect.Height);
            }

            if (rect.Width > 0 && rect.Height > 0)
                using (var brush = new LinearGradientBrush(rect, c2, c1, LinearGradientMode.Vertical))
                using (var pen = new Pen(c1))
                {
                    gr.FillRectangle(brush, Rectangle.FromLTRB(rect.Left, rect.Top, rect.Right + 1, rect.Bottom + 1));
                    gr.DrawRectangle(pen, rect);
                }
        }
Example #6
0
 protected virtual VisibleItemInfo CalcVisibleItemInfo(Graphics gr, int itemIndex)
 {
     var result = new VisibleItemInfo();
     result.Calc(this, itemIndex, gr);
     return result;
 }
Example #7
0
        /// <summary>
        /// Draws Expand box, Check box and Icon of the Item
        /// </summary>
        public virtual void DrawItemIcons(Graphics gr, VisibleItemInfo info)
        {
            if (info.ExpandBoxType > 0)
            {
                var img = (Bitmap)(info.ExpandBoxType == 2 ? ImageEmptyExpand : (info.Expanded ? ImageCollapse : ImageExpand));
                img.SetResolution(gr.DpiX, gr.DpiY);
                gr.DrawImage(img, info.X_ExpandBox, info.Y + 1);
            }

            if (info.CheckBoxVisible)
            {
                var img = (Bitmap)(GetItemChecked(info.ItemIndex) ? ImageCheckBoxOn : ImageCheckBoxOff);
                img.SetResolution(gr.DpiX, gr.DpiY);
                gr.DrawImage(img, info.X_CheckBox, info.Y + 1);
            }

            if (ShowIcons && info.Icon != null)
            {
                var img = (Bitmap)info.Icon;
                img.SetResolution(gr.DpiX, gr.DpiY);
                gr.DrawImage(img, info.X_Icon, info.Y + 1);
            }
        }
Example #8
0
        public void DrawItemWhole(Graphics gr, VisibleItemInfo info)
        {
            DrawItemBackgound(gr, info);

            if (lastDragAndDropEffect == null) //do not draw selection when drag&drop over the control
                if (SelectedItemIndexes.Contains(info.ItemIndex))
                    DrawSelection(gr, info);

            if (HotTracking && info.ItemIndex == currentHotTrackingIndex)
                DrawItemHotTracking(gr, info);

            DrawItemIcons(gr, info);
            DrawItemContent(gr, info);
        }
Example #9
0
        public virtual void DrawItemBackgound(Graphics gr, VisibleItemInfo info)
        {
            var backColor = info.BackColor;

            if (backColor != Color.Empty)
                using (var brush = new SolidBrush(backColor))
                    gr.FillRectangle(brush, info.TextAndIconRect);
        }
Example #10
0
 public virtual void DrawItemContent(Graphics gr, VisibleItemInfo info)
 {
     using (var brush = new SolidBrush(info.ForeColor))
         gr.DrawString(info.Text, Font, brush, info.X_Text, info.Y + 1);
 }
Example #11
0
        protected virtual void OnMouseSelectItem(MouseEventArgs e, VisibleItemInfo item)
        {
            if (MultiSelect)
            {
                startMouseSelectArea = e.Location;
                startMouseSelectArea.Offset(HorizontalScroll.Value, VerticalScroll.Value);
                mouseCanSelectArea = item.X_EndText < e.Location.X || !AllowDragItems;

                if (Control.ModifierKeys == Keys.Control)
                {
                    if (SelectedItemIndexes.Contains(item.ItemIndex) && SelectedItemIndexes.Count > 1)
                        UnselectItem(item.ItemIndex);
                    else
                        SelectItem(item.ItemIndex, false);

                    startDiapasonSelectedItemIndex = -1;
                }
                else if (Control.ModifierKeys == Keys.Shift)
                {
                    if (SelectedItemIndexes.Count == 1)
                        startDiapasonSelectedItemIndex = SelectedItemIndexes.First();

                    if (startDiapasonSelectedItemIndex >= 0)
                        SelectItems(Math.Min(startDiapasonSelectedItemIndex, item.ItemIndex),
                                    Math.Max(startDiapasonSelectedItemIndex, item.ItemIndex));
                }
            }

            if (!MultiSelect || Control.ModifierKeys == Keys.None)
                if (!SelectedItemIndexes.Contains(item.ItemIndex) || SelectedItemIndexes.Count > 1)
                    SelectItem(item.ItemIndex, true);

            Invalidate();
        }
Example #12
0
 protected virtual void OnExpandBoxClick(VisibleItemInfo info)
 {
     if (info.Expanded)
         CollapseItem(info.ItemIndex);
     else
         ExpandItem(info.ItemIndex);
 }
Example #13
0
 protected virtual void OnCheckboxClick(VisibleItemInfo info)
 {
     if (GetItemChecked(info.ItemIndex))
         UncheckItem(info.ItemIndex);
     else
         CheckItem(info.ItemIndex);
 }
Example #14
0
        protected virtual void DrawItem(Graphics gr, VisibleItemInfo info)
        {
            DrawItemBackgound(gr, info);

            if (lastDragAndDropEffect == null)//do not draw selection when drag&drop over the control
            if (SelectedItemIndex.Contains(info.ItemIndex))
                DrawSelection(gr, info);

            DrawItemIcons(gr, info);
            DrawItemContent(gr, info);
        }
Example #15
0
 protected virtual void OnCheckboxClick(VisibleItemInfo info)
 {
     if (CheckedItemIndex.Contains(info.ItemIndex))
         UncheckItem(info.ItemIndex);
     else
         CheckItem(info.ItemIndex);
 }