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

public DrawFocusRectangle ( ) : void
Результат void
Пример #1
0
 void listViewResults_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     if (0 != (e.State & ListViewItemStates.Selected))
     {
         e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds);
         //ForeColor = Color.White;
     }
     else
     {
         //ForeColor = Color.Black;
         if (e.ItemIndex % 2 == 0)
         {
             e.Graphics.FillRectangle(Brushes.BlanchedAlmond, e.Bounds);
         }
         else
         {
             e.Graphics.FillRectangle(Brushes.White, e.Bounds);
         }
         if (0 != (e.State & ListViewItemStates.Focused))
         {
             e.DrawFocusRectangle();
         }
     }
     e.DrawText();
 }
Пример #2
0
        private void listChars_DrawItem(object sender, System.Windows.Forms.DrawListViewItemEventArgs e)
        {
            if ((e.State & (ListViewItemStates.Selected | ListViewItemStates.Hot)) != 0)
            {
                e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Highlight, e.Bounds);
            }
            else
            {
                e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Info, e.Bounds);
            }
            e.Graphics.DrawRectangle(System.Drawing.Pens.Black, e.Bounds);

            Types.C64Character character = (Types.C64Character)e.Item.Tag;
            if (character == null)
            {
                return;
            }
            System.Drawing.Brush brush = System.Drawing.SystemBrushes.WindowText;

            if ((e.State & (ListViewItemStates.Selected | ListViewItemStates.Hot)) != 0)
            {
                brush = System.Drawing.SystemBrushes.HighlightText;
            }
            e.Graphics.DrawString(e.Item.Text, listChars.Font, brush, new System.Drawing.PointF(e.Bounds.Left + 2, e.Bounds.Top + 2));
            e.Graphics.DrawString(character.PetSCIIValue.ToString("X02"), _DefaultFont, brush, new System.Drawing.PointF(e.Bounds.Left + 40, e.Bounds.Top + 2));
            e.Graphics.DrawString(character.Desc, _DefaultFont, brush, new System.Drawing.PointF(e.Bounds.Left, e.Bounds.Top + e.Bounds.Height * 0.5f));

            if ((e.State & ListViewItemStates.Focused) != 0)
            {
                e.DrawFocusRectangle();
            }
        }
Пример #3
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);
        }
Пример #4
0
 private void RssListView_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     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);
         }*/
     }
 }
Пример #5
0
        private void listViewdrawItem(object sender, DrawListViewItemEventArgs e)
        {
            int graphic = (int)e.Item.Tag;
            int hue = 0;
            frames = Animations.GetAnimation(graphic, 0, 1, ref hue, false, true);

            if (frames == null)
                return;
            Bitmap bmp = frames[0].Bitmap;
            int width = bmp.Width;
            int height = bmp.Height;

            if (width > e.Bounds.Width)
                width = e.Bounds.Width;

            if (height > e.Bounds.Height)
                height = e.Bounds.Height;

            e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height);
            e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
            if (listView.SelectedItems.Contains(e.Item))
                e.DrawFocusRectangle();
            else
                e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
        }
Пример #6
0
        void lvLibrary_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if ((e.State & ListViewItemStates.Selected) != 0) {
                // Draw the background and focus rectangle for a selected item.
                //e.Graphics.FillRectangle(Brushes.YellowGreen, e.Bounds);

                if (this.lvLibrary.SelectedItems.Contains(e.Item)) {
                    e.Graphics.FillRectangle(Brushes.Gold, e.Bounds);
                }

                TileViewItem vSVI = (TileViewItem)e.Item;
                e.Graphics.DrawImage(vSVI.mTile.Image, e.Bounds.Location.X, e.Bounds.Location.Y, Tile.WIDTH_PX*2, Tile.HEIGHT_PX*2);

                Rectangle vR = new Rectangle(e.Bounds.Location, e.Bounds.Size);
                vR.Offset(Tile.WIDTH_PX * 2, 0);
                e.Graphics.DrawString(
                    vSVI.mTile.UID.ToString(),
                    lvLibrary.Font,
                    Brushes.Black,
                    vR,
                    StringFormat.GenericDefault
                );

                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);
                }
            }
        }
Пример #7
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);
            }
        }
Пример #8
0
        private void MyList_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (e.State == 0)
            {
                return;
            }

            e.DrawDefault = false;
            if (e.Item.Selected)
            {
                // 選択中の行
                var brs1 = ((Control)sender).Focused ? _brsHighLight : _brsDeactiveSelection;
                e.Graphics.FillRectangle(brs1, e.Bounds);
            }
            else
            {
                var cl = e.Item.BackColor;
                var brs2 =
                    cl == _clrSelf ? _brsBackColorMine :
                    cl == _clrAtSelf ? _brsBackColorAt :
                    cl == _clrTarget ? _brsBackColorYou :
                    cl == _clrAtTarget ? _brsBackColorAtYou :
                    cl == _clrAtFromTarget ? _brsBackColorAtFromTarget :
                    cl == _clrAtTo ? _brsBackColorAtTo : _brsBackColorNone;
                e.Graphics.FillRectangle(brs2, e.Bounds);
            }

            if ((e.State & ListViewItemStates.Focused) == ListViewItemStates.Focused)
            {
                e.DrawFocusRectangle();
            }

            DrawListViewItemIcon(e);
        }
Пример #9
0
        private static void OnDrawItem(object sender, DrawListViewItemEventArgs e)
        {
            //Check if the item is selected
            bool isExternal = ((Workshare.Reports.MailMessage.Message)e.Item.Tag).SentExternally;
            if (( e.State & ListViewItemStates.Selected) != 0)
            {
                // Draw the back ground in light green
                e.Graphics.FillRectangle(Brushes.LightGreen, e.Bounds);
                e.DrawFocusRectangle();
            }
            else
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, (isExternal ? m_settings.ExternalEmailColour.Background : Color.WhiteSmoke), Color.WhiteSmoke, LinearGradientMode.Horizontal))
                {
                    e.Graphics.FillRectangle(brush, e.Bounds);
                }
            }

            // Draw the image List icon
            Icon ico = Icon.FromHandle(((Bitmap)e.Item.ImageList.Images[e.Item.ImageIndex]).GetHicon());
            e.Graphics.DrawIcon(ico, e.Bounds.X, e.Bounds.Y);
            if ( string.Compare( View.Columns[0].Tag.ToString(), "RatingIcon", true, System.Threading.Thread.CurrentThread.CurrentCulture) != 0 )
            {
                using (Font headerFont = new Font(View.Font.FontFamily, View.Font.Size))
                {
                    using( SolidBrush sb = new SolidBrush((isExternal ? m_settings.ExternalEmailColour.Foreground : Color.Black)) )
                    {
                        e.Graphics.DrawString(e.Item.Text, headerFont, sb, e.Bounds.X + 16, e.Bounds.Y);
                    }
                }
            }
            else
            {
                Icon rate = Properties.Resources.RATING_NONE;
                if (string.Compare(Properties.Resources.TEXT_HIGH, e.Item.Text, true, System.Threading.Thread.CurrentThread.CurrentCulture) == 0)
                    rate = Properties.Resources.RATING_HIGH;
                if (string.Compare(Properties.Resources.TEXT_MEDIUM, e.Item.Text, true, System.Threading.Thread.CurrentThread.CurrentCulture) == 0)
                    rate = Properties.Resources.RATING_MEDIUM;
                if (string.Compare(Properties.Resources.TEXT_LOW, e.Item.Text, true, System.Threading.Thread.CurrentThread.CurrentCulture) == 0)
                    rate = Properties.Resources.RATING_LOW;
                e.Graphics.DrawIcon(rate, e.Bounds.X +17, e.Bounds.Y);
            }           
        }
Пример #10
0
 private void SubtitleListView_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     if (!Focused && (e.State & ListViewItemStates.Selected) != 0)
     {
         //Rectangle r = new Rectangle(e.Bounds.Left + 1, e.Bounds.Top + 1, e.Bounds.Width - 2, e.Bounds.Height - 2);
         //e.Graphics.FillRectangle(Brushes.LightGoldenrodYellow, r);
         if (e.Item.Focused)
             e.DrawFocusRectangle();
     }
     else
     {
         e.DrawDefault = true;
     }
 }
Пример #11
0
		/// <summary>
		/// Raises the <see cref="ListView.DrawItem"/> event.
		/// </summary>
		/// <remarks>
		/// This is where the owner draws the complete item. We handle this
		/// is the item contains a sub item that has an associated message;
		/// otherwise we let the default drawing take place.
		/// </remarks>
		/// <param name="e">A <see cref="DrawListViewItemEventArgs"/> describing the event arguments.</param>
		protected override void OnDrawItem(DrawListViewItemEventArgs e)
		{
			e.DrawDefault = true;

			Int32 intSubItemsRight = 0;
			for (Int32 i = 0; i < e.Item.SubItems.Count; i++)
			{
				if (Messages.ContainsKey(e.Item.SubItems[i]))
					e.DrawDefault = false;
				if (i > 0 && intSubItemsRight < e.Item.SubItems[i].Bounds.Right)
					intSubItemsRight += e.Item.SubItems[i].Bounds.Right;
			}
			if (!e.DrawDefault)
			{
				if (e.Item.Focused && !CheckBoxes)
					e.DrawFocusRectangle();
				if (e.Item.Selected)
				{
					Color clrBackColor = e.Item.ListView.Focused ? SystemColors.Highlight : SystemColors.Control;
					e.Graphics.FillRectangle(new SolidBrush(clrBackColor), new Rectangle(intSubItemsRight, e.Bounds.Y, e.Item.Bounds.Width - intSubItemsRight, e.Bounds.Height));
				}
			}
			base.OnDrawItem(e);
		}
Пример #12
0
        private void listView2_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (_pdfDoc != null)
            {
                Rectangle bounds = e.Bounds;
                bounds.Offset(-1, -5);

                Rectangle shadowRect = new Rectangle(bounds.Location, bounds.Size);
                Rectangle pageRect = new Rectangle(bounds.Location, bounds.Size);

                int pgNum = e.ItemIndex + 1;
                PDFPage pg;
                if(!_pdfDoc.Pages.TryGetValue(pgNum,out pg))
                    return;
                pg.RenderThumbnailFinished -= new RenderNotifyFinishedHandler(pg_RenderThumbnailFinished);
                pg.RenderThumbnailFinished+=new RenderNotifyFinishedHandler(pg_RenderThumbnailFinished);

                shadowRect.Offset(3, 3);
                shadowRect.Inflate(-6, -10);
                pageRect.Inflate(-6, -10);

                e.Graphics.FillRectangle(Brushes.LightGray, shadowRect);

                Bitmap bmp = pg.LoadThumbnail(128, (int)(128 * pg.Height / pg.Width));
                if(bmp!=null)
                    e.Graphics.DrawImageUnscaledAndClipped(bmp, pageRect);

                e.Graphics.DrawRectangle(Pens.LightGray, pageRect);

                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;

                e.Graphics.DrawString(e.Item.Text, listView2.Font, Brushes.Black, new RectangleF(e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 10, e.Bounds.Width, 10), stringFormat);

                e.DrawFocusRectangle();
            }
        }
Пример #13
0
        /// <summary>
        /// Draws the backgrounds for entire ListView items. 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListView_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if ((e.State & ListViewItemStates.Selected) != 0)
            {
                // Draw the background and focus rectangle for a selected item.
                e.Graphics.FillRectangle(Brushes.Aqua, e.Bounds);
                e.DrawFocusRectangle();
            }
            else
            {
                // Draw the background for an unselected item.
                using (LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, Color.White, Color.Aqua, LinearGradientMode.BackwardDiagonal))
                {
                    e.Graphics.FillRectangle(brush, e.Bounds);
                }
            }

            // Draw the item text for views other than the Details view.
            //if (listView1.View != View.Details)
            //{
                e.DrawText();
            //}
        }
Пример #14
0
		private void List_DrawItem(object sender, DrawListViewItemEventArgs e)
		{

			var backgroundColor = ThemeColorTable.TextBoxBackgroundColor;
			if ((e.State & ListViewItemStates.Selected) != 0)
			{
				// Draw the background and focus rectangle for a selected item.
				backgroundColor = ThemeColorTable.BackgroundColor;
				e.Graphics.FillRectangle(new SolidBrush(backgroundColor), e.Bounds);
				e.DrawFocusRectangle();
			}
			else
			{
				e.Graphics.FillRectangle(new SolidBrush(ThemeColorTable.TextBoxBackgroundColor), e.Bounds);
			}

			TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Item.Font, e.Bounds, ThemeColorTable.ForeColor, backgroundColor, TextFormatFlags.VerticalCenter);
		}
Пример #15
0
        private void lvContacts_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            Rectangle ImageRect = e.Bounds;
            ImageRect.Inflate(-2, -2);
            ImageRect.Width = 32;

            Rectangle TextRect = e.Bounds;
            TextRect.X = ImageRect.Right + 2;
            TextRect.Width = e.Bounds.Width - TextRect.X;

            Rectangle IconRect = TextRect;
            IconRect.Inflate(-1, 0);
            IconRect.Y = ImageRect.Bottom - 16;
            IconRect.Width = 16;
            IconRect.Height = 16;

            if ((e.State & ListViewItemStates.Selected) != 0)
            {
                // Draw the background and focus rectangle for a selected item.
                e.Graphics.FillRectangle(lvBackgroundBrush, e.Bounds);
                e.DrawFocusRectangle();
            }
            else
            {
                // Draw the background for an unselected item.
                e.Graphics.FillRectangle(Brushes.White, e.Bounds);
            }

            // Draw the item text for views other than the Details view.
            if (lvContacts.View != View.Details)
            {
                JabberID jabberID = (JabberID) e.Item.Tag;
                Contact contact = AppController.Instance.Contacts[jabberID.UserName];

                e.Graphics.DrawImage(contact.AvatarImage, ImageRect);

                //e.DrawText();
                TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Item.Font, TextRect, e.Item.ForeColor,
                                      TextFormatFlags.GlyphOverhangPadding);
                e.Graphics.DrawImage(StatusImageList.Images[(int) contact.UserStatus], IconRect);
            }
        }
Пример #16
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();
        }
Пример #17
0
        private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            e.DrawDefault = false;

            Image img = imageList1.Images[0];

            if (e.Item.ImageIndex == 0)
                e.Graphics.DrawImage(img, new Point(e.Bounds.Left, e.Bounds.Top + 1));

            int newTextY = e.Bounds.Y;

            if (e.Item.Text.Contains('\n') == false)
            {
                newTextY += ((e.Bounds.Height / 2) - (e.Item.Font.Height / 2));
            }
            else
            {
                newTextY += ((e.Bounds.Height / 2) - ((int) (e.Graphics.MeasureString(e.Item.Text, e.Item.Font).Height / 2)));
            }

            Point newLoc = new Point(e.Bounds.Left + img.Width + 1, newTextY);
            Size newSize = new Size(e.Bounds.Width - img.Width - 1, e.Bounds.Height);

            Rectangle textBounds = new Rectangle( newLoc, newSize );

            e.DrawFocusRectangle();

            e.Graphics.DrawString(e.Item.Text, e.Item.Font, Brushes.White, textBounds, StringFormat.GenericTypographic);
        }
Пример #18
0
        private void MyList_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            if (e.State == 0) return;
            e.DrawDefault = false;
            if (!e.Item.Selected)     //e.ItemStateでうまく判定できない???
            {
                SolidBrush brs2 = null;

                if (e.Item.BackColor == _clSelf)
                    brs2 = _brsBackColorMine;
                else if (e.Item.BackColor == _clAtSelf)
                    brs2 = _brsBackColorAt;
                else if (e.Item.BackColor == _clTarget)
                    brs2 = _brsBackColorYou;
                else if (e.Item.BackColor == _clAtTarget)
                    brs2 = _brsBackColorAtYou;
                else if (e.Item.BackColor == _clAtFromTarget)
                    brs2 = _brsBackColorAtFromTarget;
                else if (e.Item.BackColor == _clAtTo)
                    brs2 = _brsBackColorAtTo;
                else
                    brs2 = _brsBackColorNone;

                e.Graphics.FillRectangle(brs2, e.Bounds);
            }
            else
            {
                //選択中の行
                if (((Control)sender).Focused)
                    e.Graphics.FillRectangle(_brsHighLight, e.Bounds);
                else
                    e.Graphics.FillRectangle(_brsDeactiveSelection, e.Bounds);
            }
            if ((e.State & ListViewItemStates.Focused) == ListViewItemStates.Focused) e.DrawFocusRectangle();
            this.DrawListViewItemIcon(e);
        }
Пример #19
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);
            }
        }
Пример #20
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();
        }
Пример #21
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);
        }
Пример #22
0
 private void lstFiles_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     e.DrawBackground();
     e.DrawDefault = true;
     e.DrawText();
     e.DrawFocusRectangle();
 }
Пример #23
0
        private void drawitem(object sender, DrawListViewItemEventArgs e)
        {
            int i = (int)e.Item.Tag;

            bool patched;
            Bitmap bmp = Textures.GetTexture(i, out patched);

            if (bmp != null)
            {
                int width = bmp.Width;
                int height = bmp.Height;

                if (width >= e.Bounds.Width)
                    width = e.Bounds.Width - 2;

                if (height >= e.Bounds.Height)
                    height = e.Bounds.Height - 2;

                e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, width, height));

                if (listView1.SelectedItems.Contains(e.Item))
                    e.DrawFocusRectangle();
                else if (patched)
                    e.Graphics.DrawRectangle(Pens.LightCoral, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                else
                    e.Graphics.DrawRectangle(Pens.Gray, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
            }
        }
            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);
            }
Пример #25
0
        private void drawitem(object sender, DrawListViewItemEventArgs e)
        {
            int i = (int)listView1.Items[e.ItemIndex].Tag;

            bool patched;
            Bitmap bmp = Art.GetLand(i, out patched);

            if (bmp != null)
            {
                if (listView1.SelectedItems.Contains(e.Item))
                    e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                else if (patched)
                    e.Graphics.FillRectangle(Brushes.LightCoral, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                else
                    e.Graphics.FillRectangle(Brushes.White, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);

                int width = bmp.Width;
                int height = bmp.Height;

                if (width > e.Bounds.Width)
                    width = e.Bounds.Width - 2;

                if (height > e.Bounds.Height)
                    height = e.Bounds.Height - 2;

                e.Graphics.DrawImage(bmp, e.Bounds.X + 1, e.Bounds.Y + 1,
                                     new Rectangle(0, 0, e.Bounds.Width - 1, e.Bounds.Height - 1),
                                     GraphicsUnit.Pixel);

                if (listView1.SelectedItems.Contains(e.Item))
                    e.DrawFocusRectangle();
                else
                    e.Graphics.DrawRectangle(Pens.Gray, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
            }
        }
Пример #26
0
 private void KaiListView_DrawItem(object sender, DrawListViewItemEventArgs e)
 {
     if ((e.State & ListViewItemStates.Selected) != 0)
     {
         e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
         e.DrawFocusRectangle();
     }
 }