當前位置: 首頁>>代碼示例>>C#>>正文


C# Forms.DrawListViewSubItemEventArgs類代碼示例

本文整理匯總了C#中System.Windows.Forms.DrawListViewSubItemEventArgs的典型用法代碼示例。如果您正苦於以下問題:C# DrawListViewSubItemEventArgs類的具體用法?C# DrawListViewSubItemEventArgs怎麽用?C# DrawListViewSubItemEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DrawListViewSubItemEventArgs類屬於System.Windows.Forms命名空間,在下文中一共展示了DrawListViewSubItemEventArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: listView_DrawSubItem

        private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            Rectangle bounds = e.SubItem.Bounds;

            if (e.ColumnIndex == 0)
            {
                bounds.Width = bounds.X + e.Item.SubItems[1].Bounds.X;
            }

            //toggle colors if the item is highlighted
            if (e.Item.Selected && e.Item.ListView.Focused)
            {
                e.SubItem.BackColor = SystemColors.Highlight;
                e.SubItem.ForeColor = e.Item.ListView.BackColor;
            }
            else if (e.Item.Selected && !e.Item.ListView.Focused)
            {
                e.SubItem.BackColor = SystemColors.Control;
                e.SubItem.ForeColor = e.Item.ListView.ForeColor;
            }
            else
            {
                e.SubItem.BackColor = e.Item.ListView.BackColor;
                e.SubItem.ForeColor = e.Item.ListView.ForeColor;
            }

            // Draw the standard header background.
            e.DrawBackground();

            int xOffset = 0;

            if (e.ColumnIndex == 0)
            {
                Point glyphPoint = new Point(4, e.Item.Position.Y + 2);

                MyTask task = e.Item.Tag as MyTask;

                if (string.IsNullOrEmpty(task.TaskGroupName))
                {
                    CheckBoxState state = e.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
                    CheckBoxRenderer.DrawCheckBox(e.Graphics, glyphPoint, state);
                    xOffset = CheckBoxRenderer.GetGlyphSize(e.Graphics, state).Width + 4;
                }
                else
                {
                    RadioButtonState state = e.Item.Checked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal;
                    RadioButtonRenderer.DrawRadioButton(e.Graphics, glyphPoint, state);
                    xOffset = RadioButtonRenderer.GetGlyphSize(e.Graphics, state).Width + 4;
                }
            }

            //add a 2 pixel buffer the match default behavior
            Rectangle rec = new Rectangle(e.Bounds.X + 2 + xOffset, e.Bounds.Y + 2, e.Bounds.Width - 4, e.Bounds.Height - 4);

            //TODO  Confirm combination of TextFormatFlags.EndEllipsis and TextFormatFlags.ExpandTabs works on all systems.  MSDN claims they're exclusive but on Win7-64 they work.
            TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine;

            //If a different tabstop than the default is needed, will have to p/invoke DrawTextEx from win32.
            TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.Item.ListView.Font, rec, e.SubItem.ForeColor, flags);
        }
開發者ID:J-F-B-M,項目名稱:BrainSimulator,代碼行數:60,代碼來源:TaskForm.cs

示例2: lvObjects_DrawSubItem

        private void lvObjects_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            this.columnName.Width = lvObjects.Width - 16*3 - 4;

            if (e.SubItem.Tag != null)
            {
                if (e.Header == this.columnNetwork)
                {
                    e.DrawBackground();
                    var imageRect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height);
                    Image imgToDraw = e.SubItem.Tag.Equals(true) ? Resources.networkIconOn : Resources.networkIconOff;
                    e.Graphics.DrawImage(imgToDraw, imageRect);
                    e.Header.Width = 16;
                }
                else if (e.Header == this.columnPlayer)
                {
                    e.DrawBackground();
                    var imageRect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height);
                    Image imgToDraw = e.SubItem.Tag.Equals(true) ? Resources.playerIconOn : Resources.playerIconOff;
                    e.Graphics.DrawImage(imgToDraw, imageRect);
                    e.Header.Width = 16;
                }
            }

            else
            {
                e.DrawDefault = true;
                return;
            }
        }
開發者ID:SnoUweR,項目名稱:iTunesSVKS-2,代碼行數:30,代碼來源:SettingsForm.cs

示例3: dataSelectionList_DrawSubItem

        private void dataSelectionList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            Color color;
            switch (e.ColumnIndex)
            {
                case 2:
                    color = Color.FromArgb(int.Parse(e.SubItem.Text));

                    Rectangle rect = e.Bounds;
                    rect.Inflate(-4, -2);

                    using (SolidBrush brush = new SolidBrush(color))
                    {
                        e.Graphics.FillRectangle(brush, rect);
                        e.Graphics.DrawRectangle(Pens.Black, rect);
                    }
                    break;
                case 3:
                    float x1 = e.SubItem.Bounds.X;
                    float x2 = e.SubItem.Bounds.X + e.SubItem.Bounds.Width;
                    float y = e.SubItem.Bounds.Y + e.SubItem.Bounds.Height / 2;

                    color = Color.FromArgb(int.Parse(e.Item.SubItems[2].Text));
                    float thickness = float.Parse(e.Item.SubItems[1].Text);

                    using (Pen pen = new Pen(color, thickness))
                    {
                        e.Graphics.DrawLine(pen, x1, y, x2, y);
                    }
                    break;
                default:
                    e.DrawDefault = true;
                    break;
            }
        }
開發者ID:dadelcarbo,項目名稱:StockAnalyzer,代碼行數:35,代碼來源:StockIndicatorSelectorDialog.cs

示例4: Draw

        public override void Draw(DrawListViewSubItemEventArgs e)
        {
            if (this.hot != Rectangle.Empty)
            {
                if (this.hot != e.Bounds)
                {
                    this.ListView.Invalidate(this.hot);
                    this.hot = Rectangle.Empty;
                }
            }

            if ((!this.DrawIfEmpty) && (string.IsNullOrEmpty(e.SubItem.Text)))
                return;

            Point mouse = e.Item.ListView.PointToClient(Control.MousePosition);

            if ((this.ListView.GetItemAt(mouse.X, mouse.Y) == e.Item) && (e.Item.GetSubItemAt(mouse.X, mouse.Y) == e.SubItem))
            {
                ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, true, PushButtonState.Hot);
                this.hot = e.Bounds;
            }
            else
            {
                ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, false, PushButtonState.Default);
            }
        }
開發者ID:feg-giessen,項目名稱:videocommander,代碼行數:26,代碼來源:ListViewExtender.cs

示例5: nodeListView_DrawSubItem

        private void nodeListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex > 0)
            {
                Rectangle bounds = e.SubItem.Bounds;

                if (e.Item.Selected)
                {
                    e.Graphics.FillRectangle(HL_BRUSH, bounds);
                    e.SubItem.ForeColor = SystemColors.HighlightText;
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), bounds);
                    e.SubItem.ForeColor = e.Item.ForeColor;
                }

                e.DrawText(TextFormatFlags.VerticalCenter);
                e.Graphics.DrawLine(LINE_PEN, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
開發者ID:J-F-B-M,項目名稱:BrainSimulator,代碼行數:25,代碼來源:NodeSelectionForm.cs

示例6: OnDrawSubItem

        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            e.DrawDefault = true;
            base.OnDrawSubItem(e);
            double d;

            if (e.Item.BackColor != Color.MediumPurple)
            {
                if (e.Item.Index % 2 == 0) //theSubItemIndex����ָ��Ҫ�ػ����
                {
                    //e.Item.BackColor = Color.FromArgb(247, 247, 247);

                    e.Item.BackColor = Color.Azure;
                    int count = e.Item.SubItems.Count - 1;
                    while (count >= 1)
                    {
                        e.Item.SubItems[count].BackColor = Color.Azure;
                        count--;
                    }
                    //e.Item.SubItems[2].BackColor = Color.FromArgb(247, 247, 247);
                }
                else
                {
                    //e.Item.ForeColor = Color.;
                }
            }
        }
開發者ID:harryho,項目名稱:demo-fx-trading-platform-prototype,代碼行數:27,代碼來源:ManagedTreeView.cs

示例7: this_DrawSubItem

 void this_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     if (e.SubItem is IOwnerDrawLVSubItem)
         //描畫をカスタマイズするサブアイテムの場合は描畫を呼ぶ
         ((IOwnerDrawLVSubItem)e.SubItem).DrawSubItem(e);
     else
         //そうでなければシステムに描畫を任せる
         e.DrawDefault = true;
 }
開發者ID:lscyane,項目名稱:KCBr,代碼行數:9,代碼來源:ListViewEx.cs

示例8: OnDrawSubItem

 protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
 {
     object o = ((OLVListItem) e.Item).RowObject;
     if (o is TreePathReference)
     {
         TreePathReference r = (TreePathReference) o;
         e.Item.ForeColor = ActiveGetter(r) ? ActiveForegroudColor : InactiveForegroudColor;
     }
     base.OnDrawSubItem(e);
 }
開發者ID:applejian,項目名稱:cyberduck,代碼行數:10,代碼來源:MulticolorTreeListView.cs

示例9: OnDrawSubItem

 protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
 {
     if ( !this.ContainsFocus && !_HideSelection )
     {
         ListViewItemStates status = e.Item.Selected ? ListViewItemStates.Selected : e.ItemState;
         base.OnDrawSubItem(new DrawListViewSubItemEventArgs(e.Graphics, e.Bounds, e.Item, e.SubItem, e.ItemIndex, e.ColumnIndex, e.Header, status));
     }
     else
         base.OnDrawSubItem(e);
 }
開發者ID:ischool-desktop,項目名稱:MOD_Club.General.Zizhu,代碼行數:10,代碼來源:ListViewEX.cs

示例10: HandleDrawSubItem

 private void HandleDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     if (e.ItemIndex == -1)
         return;
     e.Graphics.FillRectangle(new SolidBrush(e.ItemState.HasFlag(ListViewItemStates.Selected) ? oRAColours.Colour_Item_BG_0 : oRAColours.Colour_BG_P0), e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1);
     if (e.Item.Text == "")
         e.Graphics.DrawLine(new Pen(oRAColours.Colour_BG_P1), Columns[0].Width - 1, e.Bounds.Y, Columns[0].Width - 1, e.Bounds.Y + e.Bounds.Height);
     else
         e.Graphics.DrawLine(new Pen(oRAColours.Colour_BG_P1), e.Bounds.X - 1, e.Bounds.Y, e.Bounds.X - 1, e.Bounds.Y + e.Bounds.Height);
     e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
     e.Graphics.DrawString(e.SubItem.Text, oRAFonts.Font_SubDescription, e.ItemState.HasFlag(ListViewItemStates.Selected) ? new SolidBrush(oRAColours.Colour_Text_H) : new SolidBrush(oRAColours.Colour_Text_N), e.Bounds.Left + 22, e.Bounds.Top + e.Bounds.Height / 2 - e.Graphics.MeasureString(e.Item.Text, oRAFonts.Font_SubDescription).Height / 2);
 }
開發者ID:smoogipooo,項目名稱:osu-Replay-Analyzer,代碼行數:12,代碼來源:CustomListView.cs

示例11: OnDrawSubItem

        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            if (e.Item.Selected)
            {
                e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds);
            }
            else
            {
                e.DrawBackground();
            }

            e.Graphics.DrawString(e.SubItem.Text, Font, Brushes.Black, e.Bounds);
        }
開發者ID:HeatherTooill,項目名稱:RegExpose,代碼行數:13,代碼來源:HighlightableListView.cs

示例12: OnDrawSubItem

        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            base.OnDrawSubItem(e);
            if (e.ItemState == 0)
            {
                return;
            }
            if ((e.ItemState & ListViewItemStates.Selected) == ListViewItemStates.Selected)
                e.SubItem.BackColor = System.Drawing.Color.LightSkyBlue;
            else
            {
                ConfigData data = e.Item.Tag as ConfigData;
                if (data != null && (data.HasTaskitem || data.IsAutRun))
                {
                    e.SubItem.BackColor = System.Drawing.Color.Pink;
                }
                else if (e.ItemIndex % 2 != 0)
                    e.SubItem.BackColor = HVH_Ken_Modules.GlobalVar.Instanse.StyleColor;
                else
                    e.SubItem.BackColor = this.BackColor;
            }
            e.DrawBackground();

            using (StringFormat sf = new StringFormat())
            {
                HorizontalAlignment align = Columns[e.ColumnIndex].TextAlign;
                if (align == HorizontalAlignment.Center)
                    sf.Alignment = StringAlignment.Center;
                else if (align == HorizontalAlignment.Right)
                    sf.Alignment = StringAlignment.Far;
                e.Graphics.DrawString(e.SubItem.Text, Font, new SolidBrush(ForeColor), e.Bounds, sf);
            }

            e.DrawFocusRectangle(e.Bounds);

            if ((e.ItemState & ListViewItemStates.Focused) == ListViewItemStates.Focused)
            {
                if (this.FullRowSelect == false)
                {
                    if (e.ColumnIndex == 0)
                    {
                        e.DrawFocusRectangle(e.Bounds);
                    }
                }
                else
                    e.DrawFocusRectangle(e.Bounds);

            }
        }
開發者ID:kener1985,項目名稱:MyGitHubProj,代碼行數:49,代碼來源:MyListView.cs

示例13: RssListView_DrawSubItem

        private void RssListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {

                e.Graphics.FillRectangle(new SolidBrush(Color.Blue), e.Bounds);
            }
            else
            {
                //e.Graphics.DrawString(e.SubItem.Text, Font, Brushes.Red, e.Bounds);

                e.DrawDefault = true;
                //e.Graphics.DrawString(e.SubItem.Text,Font,Brushes.Black,e.Bounds);
            }
        }
開發者ID:metaburbia,項目名稱:RssTray,代碼行數:15,代碼來源:RssListView.cs

示例14: OnDrawSubItem

        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            ImageListViewSubItem item = e.SubItem as ImageListViewSubItem;

            if (item == null)
            {
                e.DrawDefault = true;
                base.OnDrawSubItem(e);
            }
            else
            {
                using (e.Graphics)
                    item.Drawable.Draw(e.Graphics, e.Bounds);
            }
        }
開發者ID:AssassinUKG,項目名稱:monotorrent,代碼行數:15,代碼來源:ImageListView.cs

示例15: OnDrawSubItem

        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            ListViewItem.ListViewSubItem oitem = e.Item.SubItems[e.ColumnIndex];
            ProgressSubItem item = null;

            if (oitem is ProgressSubItem)
                item = (ProgressSubItem)oitem;
            if (item != null && item.ShowProgress && item.ProgressMaxValue > 0)
            {
                double percent = (double)item.ProgressValue / (double)item.ProgressMaxValue;
                if (percent > 1.0f)
                    percent = 1.0f;
                Rectangle rect = item.Bounds;
                Graphics g = e.Graphics;

                //繪製進度條
                Rectangle progressRect = new Rectangle(rect.X + 1, rect.Y + 3, rect.Width - 2, rect.Height - 5);
                g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(0x51, 0x51, 0x51)), 1), progressRect);

                //繪製進度
                int progressMaxWidth = progressRect.Width - 1;
                int width = (int)(progressMaxWidth * percent);
                if (width >= progressMaxWidth) width = progressMaxWidth;
                g.FillRectangle(new SolidBrush(Color.FromArgb(0xa4, 0xa3, 0xa3)), new Rectangle(progressRect.X + 1, progressRect.Y + 1, width, progressRect.Height - 1));

                if(item.ShowPercentOverflowProgress)
                {
                    //繪製進度百分比
                    percent *= 100;
                    string percentText = string.Format("{0}% ", percent.ToString("F2"));
                    Size size = TextRenderer.MeasureText(percentText.ToString(), Font);
                    int x = (progressRect.Width - size.Width) / 2;
                    int y = (progressRect.Height - size.Height) / 2 + 3;
                    if (x <= 0) x = 1;
                    if (y <= 0) y = 1;
                    int w = size.Width;
                    int h = size.Height;
                    if (w > progressRect.Width) w = progressRect.Width;
                    if (h > progressRect.Height) h = progressRect.Height;
                    g.DrawString(percentText, this.Font, new SolidBrush(Color.Black), new Rectangle(rect.X + x, rect.Y + y, w, h));
                }
            }
            else
            {
                e.DrawDefault = true;
                base.OnDrawSubItem(e);
            }
        }
開發者ID:cheehwasun,項目名稱:BaiduPCS_NET,代碼行數:48,代碼來源:ListViewProgress.cs


注:本文中的System.Windows.Forms.DrawListViewSubItemEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。