DrawBackground() публичный Метод

public DrawBackground ( ) : void
Результат void
Пример #1
0
        private void IconListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            IconListViewItem item = e.Item as IconListViewItem;
            if (item == null)
            {
                e.DrawDefault = true;
                return;
            }

            // Draw item
            e.DrawBackground();
            Pen border = SystemPens.ControlLight;
            if (e.Item.Selected)
            {
                if (this.Focused)
                    border = SystemPens.Highlight;
                else
                    border = SystemPens.ButtonFace;
            }
            int centerSpacing = (e.Bounds.Width - this.TileSize.Width - TilePadding.Horizontal) / 2 + TilePadding.Left;
            Rectangle newBounds = new Rectangle(e.Bounds.X + centerSpacing, e.Bounds.Y + TilePadding.Top, this.TileSize.Width, this.TileSize.Height);
            e.Graphics.DrawRectangle(border, newBounds);

            //e.Graphics.DrawString("Whatever", this.Font, e., 0, 0);
            int x = e.Bounds.X + (newBounds.Width - item.Icon.Width) / 2 + centerSpacing + 1;
            int y = e.Bounds.Y + (newBounds.Height - item.Icon.Height) / 2 + TilePadding.Top + 1;
            Rectangle rect = new Rectangle(x, y, item.Icon.Width, item.Icon.Height);
            Region clipReg = new Region(newBounds);
            e.Graphics.Clip = clipReg;
            e.Graphics.DrawIcon(item.Icon, rect);

            string text = string.Format("{0} x {1}", item.Icon.Width, item.Icon.Height);
            SizeF stringSize = e.Graphics.MeasureString(text, this.Font);
            int stringWidth = (int) Math.Round(stringSize.Width);
            int stringHeight = (int) Math.Round(stringSize.Height);
            x = e.Bounds.X + (e.Bounds.Width - stringWidth - TilePadding.Horizontal) / 2 + TilePadding.Left;
            y = e.Bounds.Y + this.TileSize.Height + verticalSpacing + TilePadding.Top;
            clipReg = new Region(e.Bounds);
            e.Graphics.Clip = clipReg;
            if (e.Item.Selected)
            {
                if (this.Focused)
                {
                    e.Graphics.FillRectangle(SystemBrushes.Highlight, x - 1, y - 1, stringWidth + 2, stringSize.Height + 2);
                    e.Graphics.DrawString(text, this.Font, SystemBrushes.HighlightText, x, y);
                }
                else
                {
                    e.Graphics.FillRectangle(SystemBrushes.ButtonFace, x - 1, y - 1, stringWidth + 2, stringSize.Height + 2);
                    e.Graphics.DrawString(text, this.Font, SystemBrushes.ControlText, x, y);
                }
            }
            else
                e.Graphics.DrawString(text, this.Font, SystemBrushes.ControlText, x, y);
        }
        private void HiddenWindowsListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            WindowInfo currentItem = (e.Item as WindowListViewItem).Window;
            switch (this.View)
            {
                case View.LargeIcon:
                    e.DrawDefault = false;
                    e.DrawBackground();
                    Rectangle itemBounds = new Rectangle(e.Bounds.Location, new Size(e.Bounds.Width, 65));

                    //if (e.Item.Selected)
                    //    e.Graphics.FillRectangle(SystemColors.Highlight.ToBrush(), e.Bounds);

                    Rectangle iconBounds = e.Graphics.AddImage(e.Bounds, currentItem.ApplicationIcon, null,
                        (e.Item.Selected) ? 16 : 18);
                    e.Graphics.AddImage(e.Bounds,
                        (currentItem.IsPasswordProtected)
                            ? ActionResource.lockwindow_small
                            : ActionResource.unlockwindow_small, ImageOverlayPosition.TopLeft);
                    if (currentItem.IsPinned)
                        e.Graphics.AddImage(e.Bounds, ActionResource.tack_small, ImageOverlayPosition.TopRight);

                    //e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.EndEllipsis | TextFormatFlags.HorizontalCenter);
                    Rectangle rec = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width - 4,
                        e.Bounds.Height - 4);
                    TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Item.Font, rec, e.Item.ForeColor,
                        TextFormatFlags.Bottom | TextFormatFlags.Left | TextFormatFlags.EndEllipsis
                        | TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine);

                    //e.DrawFocusRectangle();
                    break;

                default:
                    e.DrawDefault = true;
                    break;
            }
            if ((bool) e.Item.SubItems[1].Tag != currentItem.IsPasswordProtected)
            {
                e.Item.SubItems[1].Tag = currentItem.IsPasswordProtected;
                e.Item.SubItems[1].Text = currentItem.IsPasswordProtected ? "Yes" : "No";
            }
            if ((bool) e.Item.SubItems[2].Tag != currentItem.IsPinned)
            {
                e.Item.SubItems[2].Tag = currentItem.IsPinned;
                e.Item.SubItems[2].Text = currentItem.IsPinned ? "Yes" : "No";
            }
        }
Пример #3
0
        void PEListView_DrawItem(object sender, System.Windows.Forms.DrawListViewItemEventArgs e)
        {
            var item = e.Item as PEListViewItem;

            var bounds = item.Bounds;
            var g      = e.Graphics;

            e.DrawBackground();

            bool  selected  = SelectedItems.Contains(item);
            Color itemColor = BackColor;

            if (selected)
            {
                itemColor = Color.LightSkyBlue;
            }
            using (var highlightBrush = new SolidBrush(Color.FromArgb(200, itemColor)))
            {
                var drawBound = bounds;

                g.FillRectangle(highlightBrush, drawBound);
            }

            if (selected)
            {
                var drawBound = bounds;
                drawBound.Width  -= 4;
                drawBound.Height -= 4;
                drawBound.X      += 2;
                drawBound.Y      += 1;

                using (Pen p = new Pen(Color.FromArgb(100, Color.SteelBlue), 1.5f))
                {
                    g.DrawRectangle(p, drawBound);
                }
            }
            if (item.ParentItem == null)
            {
                TextRenderer.DrawText(g,
                                      item.Text,
                                      this.Font,
                                      bounds,
                                      ForeColor,
                                      TextFormatFlags.Left | TextFormatFlags.VerticalCenter |
                                      TextFormatFlags.LeftAndRightPadding | TextFormatFlags.EndEllipsis | TextFormatFlags.PreserveGraphicsClipping);
            }
        }
Пример #4
0
        private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();

            string previewStr = char.ConvertFromUtf32(LastChar);

            var sf = new StringFormat(StringFormatFlags.NoFontFallback);
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;

            var font = new Font(e.Item.Text, 72f, FontStyle.Regular, GraphicsUnit.Pixel);
            var smallFont = new Font(e.Item.Text, 12f, FontStyle.Regular, GraphicsUnit.Pixel);

            e.Graphics.DrawString(previewStr, font, SystemBrushes.WindowText, e.Bounds, sf);

            RectangleF labelRect = new RectangleF(e.Bounds.X, e.Bounds.Y + (e.Bounds.Height - 24), e.Bounds.Width, 24);
            e.Graphics.DrawString(e.Item.Text, smallFont, SystemBrushes.WindowText, labelRect, sf);
        }
Пример #5
0
		private void lvIcons_DrawItem(object sender, DrawListViewItemEventArgs e) {
			e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
			e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
			e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

			if ((e.State & ListViewItemStates.Hot) != 0 && (e.State & ListViewItemStates.Selected) == 0) {
				this._ItemHoverRenderer.DrawBackground(e.Graphics, e.Bounds);
			} else if ((e.State & ListViewItemStates.Hot) != 0 && (e.State & ListViewItemStates.Selected) != 0) {
				this._Selectedx2Renderer.DrawBackground(e.Graphics, e.Bounds);
			} else if ((e.State & ListViewItemStates.Selected) != 0) {
				this._ItemSelectedRenderer.DrawBackground(e.Graphics, e.Bounds);
			} else {
				e.DrawBackground();
			}
			var ico = _Icons[(int)e.Item.Tag].Icon;
			if (ico.Width <= 48) {
				e.Graphics.DrawIcon(_Icons[(int)e.Item.Tag].Icon,
						e.Bounds.X + (e.Bounds.Width - ico.Width) / 2, e.Bounds.Y + (e.Bounds.Height - ico.Height) / 2 - 5);
			}
			e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordEllipsis);
		}
            void C1_DrawItem(object sender, DrawListViewItemEventArgs e)
            {
                if (main == null)
                    return;
                e.DrawBackground();
                e.DrawFocusRectangle();
                RectangleF E = e.Bounds;
                SizeF Q = e.Graphics.MeasureString(e.Item.Text, F);
                Guid g = Guid.Empty;
                if (e.Item.Tag is gCInventory_PS_Wrapper.InventoryItem)
                    g = (e.Item.Tag as gCInventory_PS_Wrapper.InventoryItem).ItemGuid;
                else g = (Guid)e.Item.Tag;
                if (ResourceManager.Rects.ContainsKey(g))
                {
                    RectangleF r0 = ResourceManager.Rects[g];
                    RectangleF r1 = E;
                    r1.Height -= Q.Height;
                    float sh = (r1.Height / r0.Height);
                    float sw = (r1.Width / r0.Width);
                    if (sw > sh)//new box not heigh enough
                    {
                        float h = r0.Height * sh;
                        float w = r0.Width * sh;
                        float q0 = (r1.Width - w) / 2.0f;
                        r1.X += q0;
                        r1.Width = w;
                        r1.Height = h;
                    }
                    else
                    {

                    }
                    e.Graphics.DrawImage(main, r1, r0, GraphicsUnit.Pixel);
                }
                e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
            }
Пример #7
0
 private void lstFiles_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     e.DrawBackground();
     e.DrawDefault = true;
     e.DrawText();
     e.DrawFocusRectangle();
 }
Пример #8
0
        private void lstShow_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            ListView listView = new ListView();
            listView = (ListView)sender;

            e.DrawBackground();
            e.Graphics.DrawString(listView.Items[e.ItemIndex].Text, e.Item.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);

            for (int i = 0; i < _lstResult.Count; i++)
            {
                if (e.ItemIndex.ToString() == _lstResult[i])
                {
                    bool selected = ((e.State & ListViewItemStates.Selected) == ListViewItemStates.Selected);

                    //搜尋過後尚未選取發生的事件
                    if(!selected)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.Silver), e.Bounds);
                        e.Graphics.DrawString(listView.Items[e.ItemIndex].Text, e.Item.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
                    }
                    //搜尋過選取時發生的事件
                    else
                    {

                    }
                }
                //搜尋過後不符合的項目想發生的事件往這寫
            }

            if (((e.State & ListViewItemStates.Selected) == ListViewItemStates.Selected))
            {
                ////設定指定物件填充背景的大小
                //Rectangle r = new Rectangle(e.Bounds.Left + 4, e.Bounds.Top, TextRenderer.MeasureText(e.Item.Text, e.Item.Font).Width, e.Bounds.Height);
                ////設定填充的顏色和無間
                //e.Graphics.FillRectangle(SystemBrushes.Highlight, r);
                ////設定物件中的字體顏色
                //e.Item.ForeColor = SystemColors.HighlightText;
                //e.DrawText();

                e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                e.Graphics.DrawString(listView.Items[e.ItemIndex].Text, e.Item.Font, Brushes.White, e.Bounds, StringFormat.GenericDefault);
            }

            e.DrawFocusRectangle();
        }
Пример #9
0
        private void unitsLV_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawBackground();

            e.Graphics.DrawImage((Image)DHRC.GetImage(e.Item.ImageKey),
                                e.Bounds.X + borderWidth, e.Bounds.Y + borderWidth-1 /*+ borderWidth*/,
                                fakeImgList.ImageSize.Width - borderWidth*2, fakeImgList.ImageSize.Height - borderWidth);

            if (e.Item.Selected)
                e.Graphics.DrawRectangle(framePen,
                e.Bounds.X + 1, e.Bounds.Y + borderWidth-1,
                fakeImgList.ImageSize.Width - borderWidth, fakeImgList.ImageSize.Height - borderWidth);

            e.Graphics.DrawString(e.Item.Text, e.Item.ListView.Font, Brushes.White,
                e.Bounds.X + fakeImgList.ImageSize.Width, e.Bounds.Y + ((e.Bounds.Height-e.Item.ListView.Font.GetHeight()) / 2) -1, StringFormat.GenericDefault);
        }
Пример #10
0
		private void listViewShowItems_Highlight(object sender, DrawListViewItemEventArgs e)
		{
			// If this item is the selected item
			if (e.Item != null)
			{
				if (e.Item.Selected)
				{
					// If the selected item has focus Set the colors to the normal colors for a selected item
					e.Item.ForeColor = SystemColors.HighlightText;
					e.Item.BackColor = SystemColors.Highlight;
				}
				else
				{
					// Set the normal colors for items that are not selected
					e.Item.ForeColor = listViewShowItems.ForeColor;
					e.Item.BackColor = listViewShowItems.BackColor;
				}
				e.DrawBackground();
				e.DrawText();
			}
		}
Пример #11
0
        private void FileStatusListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (e.Bounds.Height <= 0 || e.Bounds.Width <= 0 || e.ItemIndex < 0)
                return;

            e.DrawBackground();
            if (e.Item.Selected)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                e.Item.ForeColor = SystemColors.HighlightText;
            }
            else
                e.Item.ForeColor = SystemColors.WindowText;
            e.DrawFocusRectangle();

            e.Graphics.FillRectangle(Brushes.White, e.Bounds.Left, e.Bounds.Top, ImageSize, e.Bounds.Height);

            int centeredImageTop = e.Bounds.Top;
            if ((e.Bounds.Height - ImageSize) > 1)
                centeredImageTop = e.Bounds.Top + ((e.Bounds.Height - ImageSize) / 2);

            if (e.Item.ImageIndex != -1)
            {
                var image = e.Item.ImageList.Images[e.Item.ImageIndex];
                e.Graphics.DrawImage(image, e.Bounds.Left, centeredImageTop, ImageSize, ImageSize);
            }

            GitItemStatus gitItemStatus = (GitItemStatus)e.Item.Tag;

            string text = GetItemText(e.Graphics, gitItemStatus);

            using (var solidBrush = new SolidBrush(e.Item.ForeColor))
            {
                e.Graphics.DrawString(text, e.Item.ListView.Font,
                                      solidBrush, e.Bounds.Left + ImageSize, e.Bounds.Top);
            }
        }
Пример #12
0
        private void lvMasterDesField_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawText();
            e.DrawFocusRectangle();
            ListViewItem.ListViewSubItem LVSI = e.Item.SubItems[3];

            if (LVSI != null)
            {
                Rectangle cellBounds = LVSI.Bounds;
                Rectangle rect = cellBounds;
                Point buttonLocation = new Point();
                buttonLocation.Y = cellBounds.Y + 1;
                buttonLocation.X = cellBounds.X + 1;
                Rectangle ButtonBounds = new Rectangle();

                ButtonBounds.X = cellBounds.X + 1;
                ButtonBounds.Y = cellBounds.Y + 1;
                ButtonBounds.Width = cellBounds.Width - 2;
                ButtonBounds.Height = cellBounds.Height - 3;

                Pen pen1 = new Pen(Brushes.White, 1);
                Pen pen2 = new Pen(Brushes.Black, 1);
                Pen pen3 = new Pen(Brushes.DimGray, 1);

                SolidBrush myBrush = new SolidBrush(SystemColors.Control);

                e.Graphics.FillRectangle(myBrush, ButtonBounds.X, ButtonBounds.Y, ButtonBounds.Width, ButtonBounds.Height);
                e.Graphics.DrawLine(pen2, ButtonBounds.X, ButtonBounds.Y + ButtonBounds.Height, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y + ButtonBounds.Height);
                e.Graphics.DrawLine(pen2, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y + ButtonBounds.Height);

                StringFormat sf1 = new StringFormat();
                sf1.Alignment = StringAlignment.Center;
                sf1.LineAlignment = StringAlignment.Center;
                e.Graphics.DrawString("...", new Font("SimSun", 5), Brushes.Black, ButtonBounds.X + 10, ButtonBounds.Y + 5, sf1);
            }
        }
Пример #13
0
        private void lvwRadar_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            ////e.DrawBackground();

            ////if (e.ItemIndex < 0) return;

            ////ListViewItem itemToDraw = lvwRadar.Items[e.ItemIndex];

            ////if ((e.State & ListViewItemStates.Selected) != 0)
            ////{
            ////    // Draw the background and focus rectangle for a selected item.
            ////    e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds);
            ////    e.DrawFocusRectangle();
            ////}
            ////else
            ////{
            ////    // Draw the background for an unselected item.
            ////    using (LinearGradientBrush brush =
            ////        new LinearGradientBrush(e.Bounds, Color.Orange,
            ////        Color.Maroon, LinearGradientMode.Horizontal))
            ////    {
            ////        e.Graphics.FillRectangle(brush, e.Bounds);
            ////    }
            ////}

            ////// Draw the item text for views other than the Details view.
            ////if (lvwRadar.View != View.Details)
            ////{
            ////    e.DrawText();
            ////}

            e.DrawBackground();

            ////TextFormatFlags flags = TextFormatFlags.Left;

            //ListViewItem itemToDraw = lvwRadar.Items[e.ItemIndex];

            ////Brush textBrush = null;
            ////Brush dBrush = null;
            ////Brush rBrush = null;
            ////Font boldFont = new Font("Arial", 8, FontStyle.Bold);
            ////Font regularFont = new Font("Arial", 8, FontStyle.Regular);
            ////Font italicFont = new Font("Arial", 7, FontStyle.Italic);

            //if ((e.State & ListViewItemStates.Selected) != 0)
            //{
            //    //textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.HighlightText));
            //    //dBrush = new SolidBrush(Color.Yellow);
            //    e.Graphics.FillRectangle(Brushes.White, e.Bounds);
            //    e.DrawFocusRectangle();
            //}
            //else
            //{
            //    //textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.ControlText));
            //    //dBrush = new SolidBrush(Color.RoyalBlue);
            //    e.Graphics.FillRectangle(Brushes.RoyalBlue, e.Bounds);
            //}

            ////float nameX = e.Bounds.Location.X;
            ////float nameY = e.Bounds.Location.Y;

            //string name = string.Empty;
            ////string description = string.Empty;
            ////string distance = string.Empty;

            //name = itemToDraw.Name;

            //if (avtyping.Contains(name))
            //{
            //    //rBrush = new SolidBrush(Color.Red);
            //    //e.Graphics.DrawString(name, regularFont, rBrush, nameX, nameY);
            //}
            //else if (client.Self.AgentID == (UUID)itemToDraw.Tag)
            //{
            //    //e.Graphics.DrawString(name, boldFont, textBrush, nameX, nameY);
            //    e.Graphics.DrawImage(Properties.Resources.green_orb, e.Bounds.Location);
            //}
            //else
            //{
            //    //e.Graphics.DrawString(name, regularFont, textBrush, nameX, nameY);
            //}

            ////e.Graphics.DrawLine(new Pen(Color.FromArgb(200, 200, 200)), new Point(e.Bounds.Left, e.Bounds.Bottom - 1), new Point(e.Bounds.Right, e.Bounds.Bottom - 1));
            //////e.DrawFocusRectangle();

            ////boldFont.Dispose();
            ////regularFont.Dispose();
            ////textBrush.Dispose();
            ////boldFont = null;
            ////regularFont = null;
            ////textBrush = null;
            ////dBrush = null;
            ////rBrush = null;

            ////e.DrawText(flags);

            //// Draw the item text for views other than the Details view.
            //if (lvwRadar.View != View.Details)
            //{
                e.DrawText();
            //}
        }
Пример #14
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        protected override void OnDrawItem(DrawListViewItemEventArgs e)
        {
            if (e.Item.Selected)
                e.Graphics.FillRectangle(_SelectedItemBrush, e.Bounds);
            else
                e.DrawBackground();

            TermListItem item = GetItemAt(e.ItemIndex);

            Color tbcolor = Color.Empty;
            if (TermBaseSet != null)
            {
                if (item != null)
                    tbcolor = TermBaseSet.GetDisplayColor(item.TermBaseID);
            }

            if (tbcolor != Color.Empty)
            {
                SolidBrush brush = new SolidBrush(tbcolor);
                Rectangle rcBar = e.Bounds;
                rcBar.Width = 4;
                e.Graphics.FillRectangle(brush, rcBar);
            }

            Rectangle rect = e.Bounds;
            rect.X += 4;
            rect.Y += 2;

            if (item != null && item.Status == TermStatus.prohibited)
            {
                e.Graphics.DrawImage(Resources.Prohibited_sm, rect.Left, rect.Top);
                rect.X += 12;
            }

            e.Graphics.DrawString(e.Item.Text, Font, _TextBrush, rect.X, rect.Y);

            e.DrawFocusRectangle();
        }
Пример #15
0
        private void listView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (e.Item.Tag != null)
            {
                e.Item.Checked = (bool)e.Item.Tag;
            }

            e.DrawBackground();
            e.DrawText();
        }
Пример #16
0
        private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawBackground();

            Rectangle itemRect = new Rectangle(e.Bounds.Left+2 ,
               e.Bounds.Top+1,
               e.Bounds.Width - 4-1,
               e.Bounds.Height - 2);

            //画线
            e.Graphics.DrawLine(new Pen(new SolidBrush(Color.FromArgb(240, 240, 240))),
                                new Point(itemRect.X, itemRect.Y + itemRect.Height),
                                new Point(itemRect.X + itemRect.Width - 4, itemRect.Y + itemRect.Height));

            //if (listView1.SelectedIndices.Count > 1)
            //{
            //    itemRect = new Rectangle(e.Bounds.Left + 3,
            //                            e.Bounds.Top,
            //                            e.Bounds.Width - 4,
            //                            e.Bounds.Height);
            //}

            //draw mouse move item back
            if (listViewItem1 != null &&
                e.Item == listViewItem1 && NativeInterop.IsWinVista)
            {
                e.Graphics.FillRectangle(brush3, itemRect);
                e.Graphics.DrawRectangle(pen3, itemRect);
                //listView1.Refresh();
            }

            //focusd item
            if ((e.State & ListViewItemStates.Focused) != 0)
            {
                e.Graphics.DrawRectangle(pen1, itemRect);
                focusedListViewItem1 = e.Item;

            }

            //draw selected item
            if (e.Item.Selected)
            {
                if (listView1.Focused)
                {
                    e.Graphics.FillRectangle(brush1, itemRect);
                    e.Graphics.DrawRectangle(pen1, itemRect);
                }
                else
                {
                    e.Graphics.FillRectangle(brush2, itemRect);
                    e.Graphics.DrawRectangle(pen2, itemRect);
                }
            }

            Size size = TextRenderer.MeasureText(e.Item.Text, listView1.Font);

            //text
            Rectangle textRect = new Rectangle(e.Item.Bounds.Left + 16 + 8,
                                               e.Item.Bounds.Top + size.Height/2 -2 ,
                                               e.Item.Bounds.Width - 50,
                                               20);

            //e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Red)), textRect);

            e.Graphics.DrawString(e.Item.Text, listView1.Font, new SolidBrush(listView1.ForeColor), textRect);

            //HTML Icon
            Rectangle imgRect = new Rectangle(4,
                                              e.Item.Bounds.Top + 8,
                                              16,
                                              16);

            e.Graphics.DrawImage(pictureBox1.Image, imgRect);

            //e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Blue)), imgRect);

            //ATTACH IMG
            //string filename = path + "\\" + e.Item.Text + fileExt;
            //listView1.Items[Index].SubItems[1].Text = filename;
            string attachdir = DirectoryCore.Get_AttachmentsDirectory(e.Item.SubItems[1].Text);
            if (Directory.Exists(attachdir))
            {

                Rectangle attachRect = new Rectangle(e.Bounds.Right - 22,
                                                     e.Item.Bounds.Top + 8,
                                                     16,
                                                     16);

                e.Graphics.DrawImage(pictureBox2.Image, attachRect);
                //e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), attachRect);
            }
        }
Пример #17
0
        private void lvwIcons_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            IconListViewItem item = e.Item as IconListViewItem;
            if (item == null)
            {
                e.DrawDefault = true;
                return;
            }

            // Draw item
            e.DrawBackground();
            e.Graphics.DrawRectangle(SystemPens.ControlLight, e.Bounds);

            int x = e.Bounds.X + (e.Bounds.Width - item.Icon.Width) / 2;
            int y = e.Bounds.Y + (e.Bounds.Height - item.Icon.Height) / 2;
            Rectangle rect = new Rectangle(x, y, item.Icon.Width, item.Icon.Height);
            Region clipReg = new Region(e.Bounds);
            e.Graphics.Clip = clipReg;
            e.Graphics.DrawIcon(item.Icon, rect);
        }
Пример #18
0
 void lstFunctions_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     var tag = e.Item.Tag;
     if (tag == null || tag.GetType() != typeof(Function))
     {
         e.DrawDefault = true;
     }
     else
     {
         e.DrawBackground();
     }
 }
Пример #19
0
        void FeedListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (this.View == View.Tile)
            {
                Feed feed = (Feed) e.Item.Tag;

                // draw the background and focus rectangle for selected and non-selected states
                e.DrawBackground();
                if (e.Item.Selected)
                {
                    e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
                }

                // draw icon
                int newX = e.Bounds.Left;
                /*
                System.Drawing.Image img = this.imageList.Images[e.Item.ImageKey];
                if (img != null)
                {
                    int x = e.Bounds.Left;
                    int y = e.Bounds.Top;
                    e.Graphics.DrawImage(img, x, y);
                    newX = e.Bounds.Left + img.Width + this.Margin.Right;
                    img.Dispose();
                }
                 * */

                // draw main text
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);
                System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
                sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
                sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;
                System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(e.Item.ForeColor);
                using (foreBrush)
                {
                    e.Graphics.DrawString(feed.Name,
                        e.Item.Font,
                        foreBrush,
                        rect,
                        sf);
                }

                // draw subitems
                System.Drawing.Color subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());
                System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);
                using (subBrush)
                {
                    for (int i = 1; i < this.Columns.Count; i++)
                    {
                        if (i < e.Item.SubItems.Count)
                        {
                            rect.Offset(0, e.Item.Font.Height);
                            e.Graphics.DrawString(e.Item.SubItems[i].Text,
                                e.Item.Font,
                                subBrush,
                                rect,
                                sf);
                        }
                    }
                }
            }
            else
            {
                e.DrawDefault = true;
            }
        }
Пример #20
0
 private void listObjects_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     e.DrawDefault = false;
     e.DrawBackground();
     e.DrawText();
 }
Пример #21
0
        private void lsvMods_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawDefault = true;
            if (e.Item.Index != -1)
            {
                if (lsvMods.Enabled)
                    e.DrawBackground();

                if ((e.State & ListViewItemStates.Selected) > 0)
                {
                    Color c = Color.FromKnownColor(KnownColor.Highlight);
                    Brush brush = new LinearGradientBrush(e.Bounds, c, c, LinearGradientMode.Horizontal);
                    e.Graphics.FillRectangle(brush, e.Bounds);
                }
            }
        }
		private void ArgumentsList_DrawItem(object sender, DrawListViewItemEventArgs e)
		{
			e.DrawBackground();
			if(e.ItemIndex < ArgumentsList.Items.Count - 1)
			{
				CheckBoxState State = e.Item.Checked? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
				Size CheckSize = CheckBoxRenderer.GetGlyphSize(e.Graphics, State);
				CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(e.Bounds.Left + 4, e.Bounds.Top + (e.Bounds.Height - CheckSize.Height) / 2), State);
				DrawItemLabel(e.Graphics, SystemColors.WindowText, e.Item);
			}
			else
			{
				DrawItemLabel(e.Graphics, SystemColors.GrayText, e.Item);
			}
		}
Пример #23
0
        private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawBackground();

            Rectangle itemRect = new Rectangle(e.Bounds.Left + 2,
                                               e.Bounds.Top + 1,
                                               e.Bounds.Width - 4 - 1,
                                               e.Bounds.Height - 2);

            //画线
            e.Graphics.DrawLine(new Pen(new SolidBrush(Color.FromArgb(240, 240, 240))),
                                new Point(itemRect.X, itemRect.Y + itemRect.Height),
                                new Point(itemRect.X + itemRect.Width - 4, itemRect.Y + itemRect.Height));

            //if (listView1.SelectedIndices.Count > 1)
            //{
            //    itemRect = new Rectangle(e.Bounds.Left + 3,
            //                            e.Bounds.Top,
            //                            e.Bounds.Width - 4,
            //                            e.Bounds.Height);
            //}

            //draw mouse move item back
            if (listViewItem1 != null &&
                e.Item == listViewItem1 && NativeInterop.IsWinVista)
            {
                e.Graphics.FillRectangle(brush3, itemRect);
                e.Graphics.DrawRectangle(pen3, itemRect);
                //listView1.Refresh();
            }

            //focusd item
            if ((e.State & ListViewItemStates.Focused) != 0)
            {
                e.Graphics.DrawRectangle(pen1, itemRect);
                focusedListViewItem1 = e.Item;
            }

            //draw selected item
            if (e.Item.Selected)
            {
                if (listView1.Focused)
                {
                    e.Graphics.FillRectangle(brush1, itemRect);
                    e.Graphics.DrawRectangle(pen1, itemRect);
                }
                else
                {
                    e.Graphics.FillRectangle(brush2, itemRect);
                    e.Graphics.DrawRectangle(pen2, itemRect);
                }
            }

            Size size = TextRenderer.MeasureText(e.Item.Text, listView1.Font);


            //text
            Rectangle textRect = new Rectangle(e.Item.Bounds.Left + 16 + 8,
                                               e.Item.Bounds.Top + size.Height / 2 - 2,
                                               e.Item.Bounds.Width - 50,
                                               20);

            //e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Red)), textRect);



            e.Graphics.DrawString(e.Item.Text, listView1.Font, new SolidBrush(listView1.ForeColor), textRect);

            //HTML Icon
            Rectangle imgRect = new Rectangle(4,
                                              e.Item.Bounds.Top + 8,
                                              16,
                                              16);

            e.Graphics.DrawImage(pictureBox1.Image, imgRect);

            //e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Blue)), imgRect);


            //ATTACH IMG
            //string filename = path + "\\" + e.Item.Text + fileExt;
            //listView1.Items[Index].SubItems[1].Text = filename;
            string attachdir = DirectoryCore.Get_AttachmentsDirectory(e.Item.SubItems[1].Text);

            if (Directory.Exists(attachdir))
            {
                Rectangle attachRect = new Rectangle(e.Bounds.Right - 22,
                                                     e.Item.Bounds.Top + 8,
                                                     16,
                                                     16);

                e.Graphics.DrawImage(pictureBox2.Image, attachRect);
                //e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), attachRect);
            }
        }
Пример #24
0
        private void FileStatusListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (e.Bounds.Height <= 0 || e.Bounds.Width <= 0 || e.ItemIndex < 0)
                return;

            e.DrawBackground();
            Color color;
            if (e.Item.Selected)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                color = SystemColors.HighlightText;
            }
            else
                color = SystemColors.WindowText;
            e.DrawFocusRectangle();

            e.Graphics.FillRectangle(Brushes.White, e.Bounds.Left, e.Bounds.Top, ImageSize, e.Bounds.Height);

            int centeredImageTop = e.Bounds.Top;
            if ((e.Bounds.Height - ImageSize) > 1)
                centeredImageTop = e.Bounds.Top + ((e.Bounds.Height - ImageSize) / 2);

            var image = e.Item.ImageList.Images[e.Item.ImageIndex];

            if (image != null)
                e.Graphics.DrawImage(image, e.Bounds.Left, centeredImageTop, ImageSize, ImageSize);

            GitItemStatus gitItemStatus = (GitItemStatus)e.Item.Tag;

            string text = GetItemText(e.Graphics, gitItemStatus);

            if (gitItemStatus.IsSubmodule && gitItemStatus.SubmoduleStatus != null && gitItemStatus.SubmoduleStatus.IsCompleted)
                text += " " + gitItemStatus.SubmoduleStatus.Result.AddedAndRemovedString();

            e.Graphics.DrawString(text, e.Item.ListView.Font,
                                  new SolidBrush(color), e.Bounds.Left + ImageSize, e.Bounds.Top);
        }
        void ForwardListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (this.View == View.Tile)
            {
                int checkBoxAreaWidth = CHECKBOX_PADDING + CHECKBOX_SIZE + CHECKBOX_PADDING;
                System.Drawing.Rectangle bounds = new System.Drawing.Rectangle(e.Bounds.X + checkBoxAreaWidth, e.Bounds.Top, e.Bounds.Width - checkBoxAreaWidth, e.Bounds.Height);

                // update information
                DestinationBase fc = (DestinationBase)e.Item.Tag;
                string display = Escape(fc.Display);
                string address = Escape(fc.AddressDisplay);
                string additional = Escape(fc.AdditionalDisplayInfo);
                string tooltip = String.Format("{0}\r\n{1}{2}", fc.Display, fc.AddressDisplay, (!String.IsNullOrEmpty(fc.AdditionalDisplayInfo) ? String.Format("\r\n{0}", fc.AdditionalDisplayInfo) : null));
                e.Item.ToolTipText = tooltip;
                // NOTE: dont set the .Text or .SubItem properties here - it causes an erratic exception

                bool drawEnabled = ShouldDrawEnabled(fc);
                bool selected = this.SelectedIndices.Contains(e.ItemIndex);

                // draw the background for selected states
                if(drawEnabled && selected)
                {
                    e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
                }
                else
                {
                    e.DrawBackground();
                }

                // draw the focus rectangle
                if (selected)
                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);

                // draw icon
                int newX = bounds.X;
                DestinationBase db = e.Item.Tag as DestinationBase;
                if (db != null)
                {
                    System.Drawing.Image img = db.GetIcon();

                    // size
                    if (img.Width > IMAGE_SIZE)
                    {
                        System.Drawing.Image resized = new System.Drawing.Bitmap(IMAGE_SIZE, IMAGE_SIZE);
                        System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(resized);
                        using (g)
                        {
                            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                            g.DrawImage(img, 0, 0, IMAGE_SIZE, IMAGE_SIZE);
                        }
                        img = resized;
                    }

                    if (img != null)
                    {
                        int x = bounds.X;
                        int y = bounds.Top;
                        if (drawEnabled)
                            e.Graphics.DrawImage(img, new System.Drawing.Rectangle(x, y, img.Width, img.Height));
                        else
                            ControlPaint.DrawImageDisabled(e.Graphics, img, x, y, System.Drawing.Color.Transparent);
                        newX += IMAGE_SIZE + this.Margin.Right;
                    }
                }

                // offset the text vertically a bit so it lines up with the icon better
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, bounds.Top, bounds.Right - newX, e.Item.Font.Height);
                rect.Offset(0, 4);

                // draw main text
                System.Drawing.Color textColor = (drawEnabled ? e.Item.ForeColor : System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb()));
                System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
                sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
                sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;
                System.Drawing.SolidBrush textBrush = new System.Drawing.SolidBrush(textColor);
                using (textBrush)
                {
                    e.Graphics.DrawString(display,
                        e.Item.Font,
                        textBrush,
                        rect,
                        sf);
                }

                // draw additional information text
                System.Drawing.Color subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());
                System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);
                using (subBrush)
                {
                    // draw address display (line 2)
                    rect.Offset(0, e.Item.Font.Height);
                    e.Graphics.DrawString(address,
                        e.Item.Font,
                        subBrush,
                        rect,
                        sf);

                    // draw additional display (line 3)
                    rect.Offset(0, e.Item.Font.Height);
                    e.Graphics.DrawString(additional,
                        e.Item.Font,
                        subBrush,
                        rect,
                        sf);
                }

                // draw checkbox
                System.Windows.Forms.VisualStyles.CheckBoxState state = System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal;
                if (fc.Enabled)
                    state = System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal;
                else
                    state = System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal;
                CheckBoxRenderer.DrawCheckBox(e.Graphics, new System.Drawing.Point(e.Bounds.Left + CHECKBOX_PADDING, e.Bounds.Top + CHECKBOX_PADDING), state);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
Пример #26
0
        private void lstInventorySearch_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            Graphics g = e.Graphics;
            e.DrawBackground();

            if (!(e.Item.Tag is SearchResult))
                return;

            if (e.Item.Selected)
            {
                g.FillRectangle(SystemBrushes.Highlight, e.Bounds);
            }

            SearchResult res = e.Item.Tag as SearchResult;
            int offset = 20 * (res.Level + 1);
            Rectangle rec = new Rectangle(e.Bounds.X + offset, e.Bounds.Y, e.Bounds.Width - offset, e.Bounds.Height);

            Image icon = null;
            int iconIx = 0;

            if (res.Inv is InventoryFolder)
            {
                iconIx = GetDirImageIndex(((InventoryFolder)res.Inv).PreferredType.ToString().ToLower());
            }
            else if (res.Inv is InventoryWearable)
            {
                iconIx = GetItemImageIndex(((InventoryWearable)res.Inv).WearableType.ToString().ToLower());
            }
            else if (res.Inv is InventoryItem)
            {
                iconIx = GetItemImageIndex(((InventoryItem)res.Inv).AssetType.ToString().ToLower());
            }

            if (iconIx < 0)
            {
                iconIx = 0;
            }

            try
            {
                icon = frmMain.ResourceImages.Images[iconIx];
                g.DrawImageUnscaled(icon, e.Bounds.X + offset - 18, e.Bounds.Y);
            }
            catch { }

            using (StringFormat sf = new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.LineLimit))
            {
                string label = ItemLabel(res.Inv, false);
                SizeF len = e.Graphics.MeasureString(label, lstInventorySearch.Font, rec.Width, sf);

                e.Graphics.DrawString(
                    ItemLabel(res.Inv, false),
                    lstInventorySearch.Font,
                    e.Item.Selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText,
                    rec,
                    sf);

                if (res.Inv is InventoryItem)
                {
                    string desc = ((InventoryItem)res.Inv).Description.Trim();
                    if (desc != string.Empty)
                    {
                        using (Font descFont = new Font(lstInventorySearch.Font, FontStyle.Italic))
                        {
                            e.Graphics.DrawString(desc,
                                descFont,
                                e.Item.Selected ? SystemBrushes.HighlightText : SystemBrushes.GrayText,
                                rec.X + len.Width + 5,
                                rec.Y,
                                sf);
                        }
                    }
                }
            }
        }
Пример #27
0
        private void lvTitles_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            //if (e.Index < 0) return;

            // Find the printing bounds
            int x = e.Bounds.X;
            int y = e.Bounds.Y;
            //int w = e.Bounds.Width;
            //int w = lvTitles.Size.Width - 20;
            int w = lvTitles.ClientRectangle.Width;
            int h = e.Bounds.Height;

            // Create the brushes
            if (_brushTitleListSelected == null)
            {
                _brushTitleListSelected = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Bounds.Height), Color.LimeGreen, Color.PaleGreen);
                _brushTitleListFolder = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Bounds.Height), Color.Gainsboro, Color.Silver);
                _brushTitleListFolderSelected = new LinearGradientBrush(new Point(0, 0), new Point(0, e.Bounds.Height), Color.Silver, Color.LightGreen);
            }

            Title currentTitle = null;
            int? currentTitleID = null;
            if (e.Item.Text == "All Media")
            {
                currentTitle = new Title();
                currentTitle.Name = e.Item.Text;
                currentTitle.TitleType = TitleTypes.Collection;
            }
            else
            {
                currentTitleID = Convert.ToInt32(e.Item.Text);
                currentTitle = _movieList[(int)currentTitleID];
            }

            // Setup string formatting
            StringFormat stf = new StringFormat();
            stf.Trimming = StringTrimming.EllipsisCharacter;
            stf.FormatFlags = StringFormatFlags.NoWrap;

            e.DrawBackground();

            if ((currentTitle.TitleType & TitleTypes.AllFolders) != 0)
            {
                // Folder specific paint goes here
                if (lvTitles.SelectedItems.ContainsKey(currentTitle.Id.ToString()))
                {
                    e.Graphics.FillRectangle(_brushTitleListFolderSelected, x, y, w, h);
                }
                else
                {
                    e.Graphics.FillRectangle(_brushTitleListFolder, x, y, w, h);
                }
                e.Graphics.DrawString(currentTitle.Name, new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold), new SolidBrush(Color.Black), new RectangleF(x, y + 2, w - 65, h), stf);

                int titleCount = 0;
                if (currentTitleID == null)
                {
                    titleCount = _movieRootCount;
                }
                else
                {
                    if (_movieCount.ContainsKey((int)currentTitleID))
                    {
                        titleCount = _movieCount[(int)currentTitleID];
                    }
                }

                e.Graphics.DrawString("Total titles " + titleCount.ToString(), new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular), new SolidBrush(Color.Black), new RectangleF(x, y + 18, w - 65, h), stf);

                e.Graphics.DrawString(currentTitle.Name, new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold), new SolidBrush(Color.Black), new RectangleF(x, y + 2, w - 65, h), stf);
            }
            else
            {
                if (lvTitles.SelectedItems.ContainsKey(currentTitle.Id.ToString()))
                {
                    e.Graphics.FillRectangle(_brushTitleListSelected, x, y, w, h);
                }

                // Media specific paint goes here
                e.Graphics.DrawString(currentTitle.Name, new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular), new SolidBrush(Color.Black), new RectangleF(x, y + 2, w - 65, h), stf);
                e.Graphics.DrawString(currentTitle.ReleaseDate.ToShortDateString(), new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular), new SolidBrush(Color.Black), new RectangleF(w - 60, y + 2, w, h), stf);
                //e.Graphics.DrawString(currentTitle.Runtime.ToString() + " minutes, " + currentTitle.Studio, new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular), new SolidBrush(Color.Gray), new RectangleF(8, y + 16, w - 40, h), stf);
                e.Graphics.DrawString(currentTitle.Runtime.ToString() + " minutes", new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular), new SolidBrush(Color.Gray), new RectangleF(x + 22, y + 19, w - 102, h), stf);

                // Draw percentage complete box
                Image MetaPercentage = ImgMetaPercentage1;

                if (currentTitle.PercentComplete <= .2M)
                {
                    MetaPercentage = ImgMetaPercentage1;
                }
                else if (currentTitle.PercentComplete <= .4M)
                {
                    MetaPercentage = ImgMetaPercentage2;
                }
                else if (currentTitle.PercentComplete <= .6M)
                {
                    MetaPercentage = ImgMetaPercentage3;
                }
                else if (currentTitle.PercentComplete <= .8M)
                {
                    MetaPercentage = ImgMetaPercentage4;
                }
                else
                {
                    MetaPercentage = ImgMetaPercentage5;
                }

                e.Graphics.DrawImageUnscaled(MetaPercentage,x + 4,y + 18);
                //e.Graphics.FillEllipse(bb, new Rectangle(x + w - 30, y + 16, 14, 14));
                //e.Graphics.DrawEllipse(new Pen(Color.Black), new Rectangle(x + w - 30, y + 16, 14, 14));
            }

            // Common painting goes here
            e.Graphics.DrawLine(new Pen(Color.Gray), 0, y + h - 1, w, y + h - 1);

            // Draw rating stars
            Image Stars = null;
            switch (currentTitle.UserStarRating)
            {
                case 0: Stars = ImgStars0; break;
                case 1:
                case 2: Stars = ImgStars1; break;
                case 3:
                case 4: Stars = ImgStars2; break;
                case 5:
                case 6: Stars = ImgStars3; break;
                case 7:
                case 8:
                case 9: Stars = ImgStars4; break;
                default: Stars = ImgStars5; break;
            }
            e.Graphics.DrawImageUnscaled(Stars, x + w - 82, y + 18);
        }
 private void listView_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     e.DrawBackground();
     e.DrawText();
 }
Пример #29
0
        internal void DrawItemInternal(DrawListViewItemEventArgs e)
        {
            if (base.View == View.Details)
            {
                return;
            }

            Graphics g = e.Graphics;
            ListViewItem item = e.Item;
            ListViewItemStates itemState = e.State;
            ImageList imageList = item.ImageList;

            e.DrawBackground();

            bool bDrawImage =
                (imageList != null) &&
                (item.ImageIndex != -1 ||
                !string.IsNullOrEmpty(item.ImageKey));
            bool bSelected =
                (itemState & ListViewItemStates.Selected) != 0;

            if (bDrawImage)
            {
                DrawImage(g, item, bSelected);
            }

            if (!string.IsNullOrEmpty(item.Text))
            {
                Rectangle textRect =
                    item.GetBounds(ItemBoundsPortion.Label);
                DrawBackground(g, e.ItemIndex, textRect, bSelected);
                DrawText(g, item, textRect, bSelected);
            }
        }
Пример #30
0
        void HistoryListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (e.ItemIndex < 0) return;

            if (this.View == View.Tile)
            {
                // draw the background and focus rectangle for selected and non-selected states
                if (this.SelectedIndices.Contains(e.ItemIndex))
                {
                    e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
                }
                else
                {
                    e.DrawBackground();
                }

                // draw icon
                PastNotification pn = (PastNotification)e.Item.Tag;
                int newX = e.Bounds.Left;
                if (pn != null)
                {
                    System.Drawing.Image img = PastNotificationManager.GetImage(pn);
                    using (img)
                    {
                        if (img != null)
                        {
                            int x = e.Bounds.Left + 1;
                            int y = e.Bounds.Top + 1;
                            e.Graphics.DrawImage(img, x, y);
                            newX = e.Bounds.Left + img.Width + this.Margin.Right;
                        }
                    }
                }

                // draw main text
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);
                System.Drawing.StringFormat sf = new System.Drawing.StringFormat();
                sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
                sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;
                System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(e.Item.ForeColor);
                string text = e.Item.Text.Replace("\r", " - ");
                using (foreBrush)
                {
                    e.Graphics.DrawString(text,
                        e.Item.Font,
                        foreBrush,
                        rect,
                        sf);
                }

                // draw subitems
                System.Drawing.Color subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());
                System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);
                using (subBrush)
                {
                    for (int i = 1; i < this.Columns.Count; i++)
                    {
                        if (i < e.Item.SubItems.Count)
                        {
                            text = e.Item.SubItems[i].Text.Replace("\r", " - ");
                            rect.Offset(0, e.Item.Font.Height);
                            e.Graphics.DrawString(text,
                                e.Item.Font,
                                subBrush,
                                rect,
                                sf);
                        }
                    }
                }
            }
            else
            {
                // DO NOT call e.DrawDefault or the DrawSubItem event will not be fired
                //e.DrawDefault = true;
            }
        }
Пример #31
0
 private void listViewModelContents_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     if (e.Item.Selected)
     {
         e.DrawDefault = true;
         return;
     }
     // custom drawing performed to avoid truncated text on non-selected items
     // see http://entityframework.codeplex.com/workitem/2046 for more details
     e.DrawBackground();
     var image = e.Item.ImageList.Images[e.Item.ImageKey];
     Debug.Assert(image!=null, "Images shouldn't be null");
     e.Graphics.DrawImage(
         image, 
         e.Bounds.X + (e.Bounds.Width - image.Width) / 2, 
         e.Bounds.Y + 2);
     var textBounds = e.Bounds;
     textBounds.Y = e.Bounds.Y + image.Height + 5;
     TextRenderer.DrawText(
         e.Graphics, e.Item.Text, e.Item.Font, textBounds, e.Item.ForeColor,
         TextFormatFlags.WordBreak |
         TextFormatFlags.HorizontalCenter |
         TextFormatFlags.NoPadding);
 }