当前位置: 首页>>代码示例>>C#>>正文


C# DrawListViewSubItemEventArgs.DrawBackground方法代码示例

本文整理汇总了C#中System.Windows.Forms.DrawListViewSubItemEventArgs.DrawBackground方法的典型用法代码示例。如果您正苦于以下问题:C# DrawListViewSubItemEventArgs.DrawBackground方法的具体用法?C# DrawListViewSubItemEventArgs.DrawBackground怎么用?C# DrawListViewSubItemEventArgs.DrawBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DrawListViewSubItemEventArgs的用法示例。


在下文中一共展示了DrawListViewSubItemEventArgs.DrawBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: OnDrawSubItem

		protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) {
			ListViewItem item = Items[e.ItemIndex];
			if (item == null || !(item is HomuTactListViewItem)) {
				e.DrawDefault = true;
				return;
			}

			HomuTactListEntry entry = (item as HomuTactListViewItem).Entry;
			Color texCol = Color.Black;
			switch (entry.Behavior) {
				case EHomuBehavior.Attack:
				case EHomuBehavior.Attack1st:
				case EHomuBehavior.AttackLast:
				case EHomuBehavior.AttackWeak:
					texCol = Color.Maroon;
					break;
				case EHomuBehavior.React:
				case EHomuBehavior.React1st:
				case EHomuBehavior.ReactLast:
					texCol = Color.Violet;
					break;
				case EHomuBehavior.Avoid:
					texCol = Color.Gray;
					break;
				case EHomuBehavior.Coward:
					texCol = Color.Blue;
					break;
			}

			SolidBrush drawBrush = new SolidBrush(texCol);
			Point drawPoint = new Point(e.Bounds.X, e.Bounds.Y);

			e.DrawBackground();
			if (SelectedIndices.Contains(e.ItemIndex) == true)
				e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds);

			if (e.ColumnIndex == 0)
				e.Graphics.DrawString(entry.ID.ToString(), new Font(Font, FontStyle.Bold), drawBrush, drawPoint);
			else if (e.ColumnIndex == 1)
				e.Graphics.DrawString(entry.Name, Font, drawBrush, drawPoint);
			else if (e.ColumnIndex == 2)
				e.Graphics.DrawString(entry.Behavior.ToString(), Font, drawBrush, drawPoint);
			else if (e.ColumnIndex == 3 && entry.Behavior != EHomuBehavior.Avoid)
				e.Graphics.DrawString(entry.Skill.ToString(), Font, drawBrush, drawPoint);
			else if (e.ColumnIndex == 4 && entry.Behavior != EHomuBehavior.Avoid && entry.Skill != EHomuSkillUsage.NoSkill)
				e.Graphics.DrawString(entry.Priority.ToString(), Font, drawBrush, drawPoint);
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:47,代码来源:HomuTactListView.cs

示例5: listView_DrawSubItem

        private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {
                using (var ms = new MemoryStream())
                {
                    using (var sw = new StreamWriter(ms))
                    {
                        sw.Write(e.SubItem.Text);
                        sw.Flush();
                        ms.Seek(0, SeekOrigin.Begin);

                        var rtb = new RichTextBox();
                        {
                            rtb.BorderStyle = BorderStyle.None;
                            rtb.LoadFile(ms, RichTextBoxStreamType.RichText);
                            rtb.Location = e.SubItem.Bounds.Location;
                            rtb.Size = e.SubItem.Bounds.Size;
                            rtb.Parent = sender as Control;

                            var bmp = new Bitmap(128, 32);
                            rtb.DrawToBitmap(bmp, rtb.DisplayRectangle);
                            //bmp.Save("test.bmp");

                            e.Graphics.DrawImageUnscaledAndClipped(bmp, e.SubItem.Bounds);
                            //e.DrawBackground();
                            //e.Graphics.DrawString(rtb.Text, SystemFonts.DefaultFont, SystemBrushes.ControlText, e.SubItem.Bounds);
                        }
                    }
                }
            }
            else
            {
                e.DrawBackground();
                e.DrawText();
            }
        }
开发者ID:oojjrs,项目名称:Nuri4,代码行数:37,代码来源:TextForm.cs

示例6: DrawSubItem

 private void DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     TextFormatFlags flag = e.ColumnIndex > 0 ? TextFormatFlags.HorizontalCenter : TextFormatFlags.Left;
     e.DrawBackground();
     e.DrawText(flag);
 }
开发者ID:khoavnguyen,项目名称:cs333,代码行数:6,代码来源:DisplayForm.cs

示例7: ListViewDrawSubItem

        private void ListViewDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ItemIndex < 0)
                return;
            try {
                //文字を描画する色の選択
                var b = new SolidBrush(Color.DodgerBlue);
                if (e.Item.SubItems[0].Text == "Recv")
                    b = new SolidBrush(Color.Red);

                if (e.Item.Selected) {// 選択行
                    e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                    if (e.Item.SubItems[0].Text != "Recv")
                        b = new SolidBrush(Color.White);
                } else {
                    e.DrawBackground();
                }

                //Ver5.1.4
                //e.Graphics.DrawString(e.Item.SubItems[e.ColumnIndex].Text, listView.Font, b, e.Bounds);//文字列の描画
                e.Graphics.SetClip(e.Bounds);
                e.Graphics.DrawString(e.Item.SubItems[e.ColumnIndex].Text, listViewTrace.Font, b, e.Bounds.X + 2, e.Bounds.Y + 2);//文字列の描画
                b.Dispose();

            } catch {
            }
        }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:27,代码来源:TraceDlg.cs

示例8: this_DrawSubItem

        private void this_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            e.DrawBackground();
            if (e.ColumnIndex == _sortcol)
            {
                e.Graphics.FillRectangle(_sortcolbrush, e.Bounds);
            }
            if ((e.ItemState & ListViewItemStates.Selected) != 0)
            {
                e.Graphics.FillRectangle(_highlightbrush, e.Bounds);
            }

            int fonty = e.Bounds.Y + ((int)(e.Bounds.Height / 2)) - ((int)(e.SubItem.Font.Height / 2));
            int x = e.Bounds.X + 2;

            if (e.ColumnIndex == 0)
            {
                EXListViewItem item = (EXListViewItem)e.Item;
                e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), x, fonty);
                return;
            }

            EXListViewSubItemAB subitem = e.SubItem as EXListViewSubItemAB;
            if (subitem == null)
            {
                e.DrawDefault = true;
            }
            else
            {
                x = subitem.DoDraw(e, x, this.Columns[e.ColumnIndex] as EXColumnHeader);
                e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), x, fonty);
            }
        }
开发者ID:opianHealth,项目名称:ForLAB,代码行数:33,代码来源:SiteListView.cs

示例9: OnDrawSubItem

		/// <summary>
		/// Raises the <see cref="ListView.DrawSubItem"/> event.
		/// </summary>
		/// <remarks>
		/// This is where the owner draws the specific sub item. We handle this.
		/// </remarks>
		/// <param name="e">A <see cref="DrawListViewSubItemEventArgs"/> describing the event arguments.</param>
		protected void OnDrawSubItem(DrawListViewSubItemEventArgs e)
		{
			if (e.Item.ListView == null)
				return;
			
			e.DrawBackground();

			Int32 intBoundsX = e.Bounds.X;
			Int32 intBoundsY = e.Bounds.Y;
			Int32 intBoundsWidth = e.Bounds.Width;
			Int32 intFontX = e.Bounds.X + 3;
			Int32 intFontWidth = e.Bounds.Width - 3;
			if (e.Item.SubItems[0] == e.SubItem)
			{
				intBoundsX += 4;
				intBoundsWidth -= 4;
							
				m_intFocusBoundsX = intBoundsX;
			}

			Color clrForeColor = e.SubItem.ForeColor;
			if (e.Item.Selected)
			{
				clrForeColor = e.Item.ListView.Focused ? SystemColors.HighlightText : clrForeColor;
				Color clrBackColor = e.Item.ListView.Focused ? SystemColors.Highlight : SystemColors.Control;
				e.Graphics.FillRectangle(new SolidBrush(clrBackColor), new Rectangle(intBoundsX, intBoundsY, intBoundsWidth, e.Bounds.Height));
			}

			if ((Messages.ContainsKey(e.SubItem)) && (e.ColumnIndex == 4) && (e.SubItem.Text != ""))
			{
				Image imgIcon = Messages[e.SubItem].Value;
				Rectangle rctIconBounds = GetMessageIconBounds(e.Bounds, imgIcon, String.IsNullOrEmpty(e.SubItem.Text) ? true : false);
				Rectangle rctPaint = new Rectangle(new Point(rctIconBounds.X, intBoundsY + rctIconBounds.Y), rctIconBounds.Size);
				e.Graphics.DrawImage(imgIcon, rctPaint);
				intFontWidth -= rctIconBounds.Width;
			}

			Rectangle rctTextBounds = new Rectangle(intFontX, intBoundsY + 2, intFontWidth, e.Bounds.Height - 4);
			TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font, rctTextBounds, clrForeColor, TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter);

			if (e.Item.Focused)
			{
				Pen penFocusRectangle = new Pen(Brushes.Black);
				penFocusRectangle.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
				e.Graphics.DrawRectangle(penFocusRectangle, new Rectangle(m_intFocusBoundsX, intBoundsY, e.Item.Bounds.Width - m_intFocusBoundsX - 1, e.Item.Bounds.Height - 1));
			}
		}
开发者ID:etinquis,项目名称:nexusmodmanager,代码行数:54,代码来源:ActivateModsMonitorControl.cs

示例10: _tailListView_DrawSubItem

        private void _tailListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex != 1)
                return;

            Color? textColor = null;;
            Color? backColor = null;

            // Bookmark coloring has higher priority, than keyword highlight
            if (MatchesBookmark(e.ItemIndex))
            {
                backColor = _bookmarkBackColor;
                textColor = _bookmarkTextColor;
            }
            else
            {
                TailKeywordConfig keyword = MatchesKeyword(e.Item.Text, false, true);
                if (keyword != null)
                {
                    if (keyword.FormBackColor.HasValue && keyword.FormTextColor.HasValue)
                    {
                        backColor = keyword.FormBackColor.Value;
                        textColor = keyword.FormTextColor.Value;
                    }
                }
            }

            //toggle colors if the item is highlighted
            if (e.Item.Selected)
            {
                if (backColor.HasValue || textColor.HasValue)
                {
                    e.SubItem.BackColor = SystemColors.Highlight;
                    e.SubItem.ForeColor = Color.FromArgb(SystemColors.Highlight.A, (SystemColors.Highlight.R + 128) % 256, (SystemColors.Highlight.G + 128) % 256, (SystemColors.Highlight.B + 128) % 256);
                }
                else
                {
                    e.SubItem.BackColor = SystemColors.Highlight;
                    e.SubItem.ForeColor = SystemColors.HighlightText;
                }
            }
            else
            {
                if (backColor.HasValue)
                    e.SubItem.BackColor = backColor.Value;
                else
                    e.SubItem.BackColor = e.Item.ListView.BackColor;
                if (textColor.HasValue)
                    e.SubItem.ForeColor = textColor.Value;
                else
                    e.SubItem.ForeColor = e.Item.ListView.ForeColor;
            }

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

            TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine | TextFormatFlags.NoPrefix;
            if (e.Item.Text.Length > 1000)
                TextRenderer.DrawText(e.Graphics, e.Item.Text.Substring(0, 1000), e.Item.ListView.Font, e.Bounds, e.SubItem.ForeColor, flags);
            else
                TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Item.ListView.Font, e.Bounds, e.SubItem.ForeColor, flags);
        }
开发者ID:modulexcite,项目名称:snaketail-net,代码行数:63,代码来源:TailForm.cs

示例11: lstvList_DrawSubItem

 //-------------------------------------------------------------------------------
 //
 private void lstvList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     if (e.ColumnIndex > 0) { e.DrawDefault = true; return; }
     e.DrawBackground();
     List<UserProfile> profileList = (sender == lstvCommonFollower) ? _profile_followers : _profile_friends;
     Image img = _imageListWrapper.GetImage(profileList[e.ItemIndex].IconURL);
     if (img != null) {
         e.Graphics.DrawImage(img, e.Bounds.Location);
     }
     else if (_imageAnimation != null) {
         e.Graphics.DrawImage(_imageAnimation.Image, e.Bounds.Location);
     }
 }
开发者ID:tomfuru,项目名称:StarlitTwit,代码行数:15,代码来源:FrmUsersRelations.cs

示例12: logListView_DrawSubItem

        private void logListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            var item = e.Item.SubItems[e.ColumnIndex];

            e.DrawBackground();
            var text = item.Text;

            Color forecolor;
            if (text.StartsWith(@"ERROR") || text.StartsWith(@"FATAL"))
            {
                forecolor = Color.DarkRed;
            }
            else if (text.StartsWith(@"WARN"))
            {
                forecolor = Color.FromArgb(181, 166, 16);
            }
            else if (text.StartsWith(@"DEBUG"))
            {
                forecolor = Color.Black;
            }
            else
            {
                forecolor = Color.DarkBlue;
            }

            TextRenderer.DrawText(e.Graphics, item.Text, this.logListView.Font, e.Bounds, forecolor, TextFormatFlags.Left);
            e.DrawFocusRectangle(e.Bounds);
        }
开发者ID:xsburg,项目名称:ssh-tunnel-manager-2,代码行数:28,代码来源:ConnectionControl.cs

示例13: m_lvMatches_DrawSubItem

		// We have to draw this ourselves to ensure the alignment works correctly when we change font sizes
		void m_lvMatches_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
		{
			FwListView lv = (FwListView)sender;

			// In the future, different image indexes may be used for affixes or other kinds of results
			//int imageIndex = 0;

			e.SubItem.BackColor = e.Item.Selected ?
				(lv.Focused ? SystemColors.Highlight : SystemColors.GrayText) : lv.BackColor;

			e.DrawBackground();

			// Per LT-4815 comments, we don't want the icon. If we reinstate it, it should be the
			// new find entry icon.
			Image image = null; //  m_ilEntries.Images[imageIndex];
			Rectangle rect = e.Bounds;
			if (image != null && e.ColumnIndex == 0)
			{
				// Create a bounds rectangle that isn't larger than the area we have to draw in
				Rectangle imageRect = new Rectangle(rect.Location, new Size(Math.Min(rect.Width, image.Width), Math.Min(rect.Height, image.Height)));
				e.Graphics.DrawImage(image, imageRect);
				rect.X += image.Width;
			}

			TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font, rect, lv.GetTextColor(e),
				TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:28,代码来源:MatchingEntries.cs

示例14: listview_DrawSubItem

        /// <summary>
        /// 任务和BUG下的列表绘制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listview_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            ListView listView = (ListView)sender;

            if (listView.Tag == null)
            {
                e.DrawDefault = true;
                return;
            }
            SearchOperate type = (SearchOperate)listView.Tag;

            //BUG的解决列和任务的完成列,绘制添加一个复选框
            if ((e.ColumnIndex == 3 && type == SearchOperate.BUG) || (type == SearchOperate.TASK && e.ColumnIndex == 6))
            {
                e.DrawBackground();

                drawCheckBox(listView, e.SubItem, e.SubItem.Tag == null ? false : (bool)e.SubItem.Tag);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
开发者ID:easysoft,项目名称:zentao_extension,代码行数:28,代码来源:IssuesForm.cs

示例15: lvViewPurchase_DrawSubItem

        private void lvViewPurchase_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            var s = e.Header;
            var colH = new ColumnHeader { Name = "Quitar", Text = "Quitar" };

            if (s.Text != colH.Text)
            {
                e.DrawDefault = true;
                return;
            }

            e.DrawBackground();
            var imageRect = new Rectangle(e.Bounds.X, e.Bounds.Y, 14, 14);
            e.Graphics.DrawImage(SystemIcons.Hand.ToBitmap(), imageRect);
        }
开发者ID:Stocolmo79,项目名称:Heroko-Rima,代码行数:15,代码来源:frmCashier.cs


注:本文中的System.Windows.Forms.DrawListViewSubItemEventArgs.DrawBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。