Exemplo n.º 1
0
        private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            Rectangle bounds = e.SubItem.Bounds;

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

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

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

            int xOffset = 0;

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

                MyTask task = e.Item.Tag as MyTask;

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

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

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

            //If a different tabstop than the default is needed, will have to p/invoke DrawTextEx from win32.
            TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.Item.ListView.Font, rec, e.SubItem.ForeColor, flags);
        }
Exemplo n.º 2
0
        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;
            }
        }
        public override void Draw(DrawListViewSubItemEventArgs e)
        {
            if (this.hot != Rectangle.Empty)
            {
                if (this.hot != e.Bounds)
                {
                    this.ListView.Invalidate(this.hot);
                    this.hot = Rectangle.Empty;
                }
            }

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

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

            if ((this.ListView.GetItemAt(mouse.X, mouse.Y) == e.Item) && (e.Item.GetSubItemAt(mouse.X, mouse.Y) == e.SubItem))
            {
                ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, true, PushButtonState.Hot);
                this.hot = e.Bounds;
            }
            else
            {
                ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, false, PushButtonState.Default);
            }
        }
        private void dataSelectionList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            Color color;
            switch (e.ColumnIndex)
            {
                case 2:
                    color = Color.FromArgb(int.Parse(e.SubItem.Text));

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

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

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

                    using (Pen pen = new Pen(color, thickness))
                    {
                        e.Graphics.DrawLine(pen, x1, y, x2, y);
                    }
                    break;
                default:
                    e.DrawDefault = true;
                    break;
            }
        }
Exemplo n.º 5
0
        private void nodeListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex > 0)
            {
                Rectangle bounds = e.SubItem.Bounds;

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

                e.DrawText(TextFormatFlags.VerticalCenter);
                e.Graphics.DrawLine(LINE_PEN, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            e.DrawDefault = true;
            base.OnDrawSubItem(e);
            double d;

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

                    e.Item.BackColor = Color.Azure;
                    int count = e.Item.SubItems.Count - 1;
                    while (count >= 1)
                    {
                        e.Item.SubItems[count].BackColor = Color.Azure;
                        count--;
                    }
                    //e.Item.SubItems[2].BackColor = Color.FromArgb(247, 247, 247);
                }
                else
                {
                    //e.Item.ForeColor = Color.;
                }
            }
        }
Exemplo n.º 7
0
 void this_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     if (e.SubItem is IOwnerDrawLVSubItem)
         //描画をカスタマイズするサブアイテムの場合は描画を呼ぶ
         ((IOwnerDrawLVSubItem)e.SubItem).DrawSubItem(e);
     else
         //そうでなければシステムに描画を任せる
         e.DrawDefault = true;
 }
 protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
 {
     if ( !this.ContainsFocus && !_HideSelection )
     {
         ListViewItemStates status = e.Item.Selected ? ListViewItemStates.Selected : e.ItemState;
         base.OnDrawSubItem(new DrawListViewSubItemEventArgs(e.Graphics, e.Bounds, e.Item, e.SubItem, e.ItemIndex, e.ColumnIndex, e.Header, status));
     }
     else
         base.OnDrawSubItem(e);
 }
Exemplo n.º 9
0
 protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
 {
     object o = ((OLVListItem) e.Item).RowObject;
     if (o is TreePathReference)
     {
         TreePathReference r = (TreePathReference) o;
         e.Item.ForeColor = ActiveGetter(r) ? ActiveForegroudColor : InactiveForegroudColor;
     }
     base.OnDrawSubItem(e);
 }
 private void HandleDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     if (e.ItemIndex == -1)
         return;
     e.Graphics.FillRectangle(new SolidBrush(e.ItemState.HasFlag(ListViewItemStates.Selected) ? oRAColours.Colour_Item_BG_0 : oRAColours.Colour_BG_P0), e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1);
     if (e.Item.Text == "")
         e.Graphics.DrawLine(new Pen(oRAColours.Colour_BG_P1), Columns[0].Width - 1, e.Bounds.Y, Columns[0].Width - 1, e.Bounds.Y + e.Bounds.Height);
     else
         e.Graphics.DrawLine(new Pen(oRAColours.Colour_BG_P1), e.Bounds.X - 1, e.Bounds.Y, e.Bounds.X - 1, e.Bounds.Y + e.Bounds.Height);
     e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
     e.Graphics.DrawString(e.SubItem.Text, oRAFonts.Font_SubDescription, e.ItemState.HasFlag(ListViewItemStates.Selected) ? new SolidBrush(oRAColours.Colour_Text_H) : new SolidBrush(oRAColours.Colour_Text_N), e.Bounds.Left + 22, e.Bounds.Top + e.Bounds.Height / 2 - e.Graphics.MeasureString(e.Item.Text, oRAFonts.Font_SubDescription).Height / 2);
 }
        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);
        }
Exemplo n.º 12
0
        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);

            }
        }
Exemplo n.º 13
0
        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            ImageListViewSubItem item = e.SubItem as ImageListViewSubItem;

            if (item == null)
            {
                e.DrawDefault = true;
                base.OnDrawSubItem(e);
            }
            else
            {
                using (e.Graphics)
                    item.Drawable.Draw(e.Graphics, e.Bounds);
            }
        }
Exemplo n.º 14
0
        private void RssListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {

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

                e.DrawDefault = true;
                //e.Graphics.DrawString(e.SubItem.Text,Font,Brushes.Black,e.Bounds);
            }
        }
Exemplo n.º 15
0
        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            ListViewItem.ListViewSubItem oitem = e.Item.SubItems[e.ColumnIndex];
            ProgressSubItem item = null;

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

                //绘制进度条
                Rectangle progressRect = new Rectangle(rect.X + 1, rect.Y + 3, rect.Width - 2, rect.Height - 5);
                g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(0x51, 0x51, 0x51)), 1), progressRect);

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

                if(item.ShowPercentOverflowProgress)
                {
                    //绘制进度百分比
                    percent *= 100;
                    string percentText = string.Format("{0}% ", percent.ToString("F2"));
                    Size size = TextRenderer.MeasureText(percentText.ToString(), Font);
                    int x = (progressRect.Width - size.Width) / 2;
                    int y = (progressRect.Height - size.Height) / 2 + 3;
                    if (x <= 0) x = 1;
                    if (y <= 0) y = 1;
                    int w = size.Width;
                    int h = size.Height;
                    if (w > progressRect.Width) w = progressRect.Width;
                    if (h > progressRect.Height) h = progressRect.Height;
                    g.DrawString(percentText, this.Font, new SolidBrush(Color.Black), new Rectangle(rect.X + x, rect.Y + y, w, h));
                }
            }
            else
            {
                e.DrawDefault = true;
                base.OnDrawSubItem(e);
            }
        }
Exemplo n.º 16
0
		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);
		}
Exemplo n.º 17
0
		public void DrawSubItemBackground(object sender, DrawListViewSubItemEventArgs e)
		{
			Rectangle r = e.Bounds;

			Brush b = Form.Skin.ListViewNormalBackBrush;

			if(e.ItemIndex % 2 == 1)
				b = Form.Skin.ListViewNormal2BackBrush;

			if(e.Item.Selected)
				b = Form.Skin.ListViewSelectedBackBrush;

			if(e.Item.Focused)
				b = Form.Skin.ListViewFocusedBackBrush;
			
			e.Graphics.FillRectangle(b, r);

			e.Graphics.DrawRectangle(Form.Skin.ListViewGridPen, r);
		}
Exemplo n.º 18
0
        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();
            }
        }
Exemplo n.º 19
0
        private void lvTaskList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            //Get the task associated with the list view item
            WlbScheduledTask task = TaskFromItem(e.Item);

            //Set the row color based on the Opt Mode
            Color color = GetTaskOptMode(task) == WlbPoolPerformanceMode.MaximizePerformance ? COLOR_MAX_PERFORMANCE : COLOR_MAX_DENSITY;
            Color subItemTextColor = GetTaskOptMode(task) == WlbPoolPerformanceMode.MaximizePerformance ? COLOR_MAX_PERFORMANCE_SUBITEM_TEXT : COLOR_MAX_DENSITY_SUBITEM_TEXT;

            if (!task.Enabled)
            {
                subItemTextColor = COLOR_DISABLED_TASK;
            }

            //Get the base rectangle
            Rectangle rect = e.Bounds;

            if (e.Item.Selected)
            {
                using (SolidBrush brush = new SolidBrush(SystemColors.Highlight))
                    e.Graphics.FillRectangle(brush, rect);
                subItemTextColor = GetTaskOptMode(task) == WlbPoolPerformanceMode.MaximizePerformance ? COLOR_HIGHLIGHTED_MAX_PERFORMANCE_SUBITEM_TEXT : COLOR_HIGHLIGHTED_MAX_DENSITY_SUBITEM_TEXT;
            }
            else
            {
                Rectangle topRect = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height / 2);
                Rectangle botRect = new Rectangle(rect.X, rect.Y + topRect.Height, rect.Width, rect.Height / 2);
                if (e.ItemIndex ==0 || (e.ItemIndex> 0 && lvTaskList.Items[e.ItemIndex - 1].SubItems[2].Text != e.Item.SubItems[2].Text))
                {
                    using (LinearGradientBrush brush = new LinearGradientBrush(topRect, COLOR_NEW_DAY, ControlPaint.LightLight(color), 90f)) // SystemBrushes.Highlight;
                    {
                        e.Graphics.FillRectangle(brush, topRect);
                    }
                }
                else
                {
                    using (LinearGradientBrush brush = new LinearGradientBrush(topRect, color, ControlPaint.LightLight(color), 90f)) // SystemBrushes.Highlight;
                    {
                        e.Graphics.FillRectangle(brush, topRect);
                    }
                }
                using (LinearGradientBrush brush = new LinearGradientBrush(botRect, ControlPaint.LightLight(color), color, 90f)) // SystemBrushes.Highlight;
                {
                    e.Graphics.FillRectangle(brush, botRect);
                }
            }

            // Draw subitem text
            Font font = new Font(this.Font, FontStyle.Regular); // FontStyle.Bold);
            TextRenderer.DrawText(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, font, e.Bounds, subItemTextColor, TextFormatFlags.EndEllipsis);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Owner draw a single subitem
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            //System.Diagnostics.Debug.WriteLine(String.Format("OnDrawSubItem ({0}, {1})", e.ItemIndex, e.ColumnIndex));
            // Don't try to do owner drawing at design time
            if (this.DesignMode) {
                e.DrawDefault = true;
                return;
            }

            // Calculate where the subitem should be drawn
            Rectangle r = e.Bounds;

            // Optimize drawing by only redrawing subitems that touch the area that was damaged
            //if (!r.IntersectsWith(this.lastUpdateRectangle))
            //    return;

            // Get the special renderer for this column. If there isn't one, use the default draw mechanism.
            OLVColumn column = this.GetColumn(e.ColumnIndex);
            IRenderer renderer = column.Renderer ?? this.DefaultRenderer;

            // Get a graphics context for the renderer to use.
            // But we have more complications. Virtual lists have a nasty habit of drawing column 0
            // whenever there is any mouse move events over a row, and doing it in an un-double-buffered manner,
            // which results in nasty flickers! There are also some unbuffered draw when a mouse is first
            // hovered over column 0 of a normal row. So, to avoid all complications,
            // we always manually double-buffer the drawing.
            // Except with Mono, which doesn't seem to handle double buffering at all :-(
            Graphics g = e.Graphics;
            BufferedGraphics buffer = null;
            bool avoidFlickerMode = true; // set this to false to see the problems with flicker
            if (avoidFlickerMode) {
                buffer = BufferedGraphicsManager.Current.Allocate(e.Graphics, r);
                g = buffer.Graphics;
            }

            g.TextRenderingHint = ObjectListView.TextRenderingHint;
            g.SmoothingMode = ObjectListView.SmoothingMode;

            // Finally, give the renderer a chance to draw something
            e.DrawDefault = !renderer.RenderSubItem(e, g, r, ((OLVListItem)e.Item).RowObject);

            if (buffer != null) {
                if (!e.DrawDefault)
                    buffer.Render();
                buffer.Dispose();
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Handle the Custom draw series of notifications
        /// </summary>
        /// <param name="m">The message</param>
        /// <returns>True if the message has been handled</returns>
        protected virtual bool HandleCustomDraw(ref Message m)
        {
            const int CDDS_PREPAINT = 1;
            const int CDDS_POSTPAINT = 2;
            const int CDDS_PREERASE = 3;
            const int CDDS_POSTERASE = 4;
            //const int CDRF_NEWFONT = 2;
            //const int CDRF_SKIPDEFAULT = 4;
            const int CDDS_ITEM = 0x00010000;
            const int CDDS_SUBITEM = 0x00020000;
            const int CDDS_ITEMPREPAINT = (CDDS_ITEM | CDDS_PREPAINT);
            const int CDDS_ITEMPOSTPAINT = (CDDS_ITEM | CDDS_POSTPAINT);
            const int CDDS_ITEMPREERASE = (CDDS_ITEM | CDDS_PREERASE);
            const int CDDS_ITEMPOSTERASE = (CDDS_ITEM | CDDS_POSTERASE);
            const int CDDS_SUBITEMPREPAINT = (CDDS_SUBITEM | CDDS_ITEMPREPAINT);
            const int CDDS_SUBITEMPOSTPAINT = (CDDS_SUBITEM | CDDS_ITEMPOSTPAINT);
            const int CDRF_NOTIFYPOSTPAINT = 0x10;
            //const int CDRF_NOTIFYITEMDRAW = 0x20;
            //const int CDRF_NOTIFYSUBITEMDRAW = 0x20; // same value as above!
            const int CDRF_NOTIFYPOSTERASE = 0x40;

            NativeMethods.NMLVCUSTOMDRAW nmcustomdraw = (NativeMethods.NMLVCUSTOMDRAW)m.GetLParam(typeof(NativeMethods.NMLVCUSTOMDRAW));
            //System.Diagnostics.Debug.WriteLine(String.Format("cd: {0:x}, {1}, {2}", nmcustomdraw.nmcd.dwDrawStage, nmcustomdraw.dwItemType, nmcustomdraw.nmcd.dwItemSpec));

            // There is a bug in owner drawn virtual lists which causes lots of custom draw messages
            // to be sent to the control *outside* of a WmPaint event. AFAIK, these custom draw events
            // are spurious and only serve to make the control flicker annoyingly.
            // So, we ignore messages that are outside of a paint event.
            if (!this.isInWmPaintEvent)
                return true;

            // One more complication! Sometimes with owner drawn virtual lists, the act of drawing
            // the overlays triggers a second attempt to paint the control -- which makes an annoying
            // flicker. So, we only do the custom drawing once per WmPaint event.
            if (!this.shouldDoCustomDrawing)
                return true;

            switch (nmcustomdraw.nmcd.dwDrawStage) {
                case CDDS_PREPAINT:
                    //System.Diagnostics.Debug.WriteLine("CDDS_PREPAINT");
                    // Remember which items were drawn during this paint cycle
                    if (this.prePaintLevel == 0)
                        this.drawnItems = new List<OLVListItem>();

                    // If there are any items, we have to wait until at least one has been painted
                    // before we draw the overlays. If there aren't any items, there will never be any
                    // item paint events, so we can draw the overlays whenever
                    this.isAfterItemPaint = (this.GetItemCount() == 0);
                    this.prePaintLevel++;
                    base.WndProc(ref m);

                    // Make sure that we get postpaint notifications
                    m.Result = (IntPtr)((int)m.Result | CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYPOSTERASE);
                    return true;

                case CDDS_POSTPAINT:
                    //System.Diagnostics.Debug.WriteLine("CDDS_POSTPAINT");
                    this.prePaintLevel--;

                    // When in group view, we have two problems. On XP, the control sends
                    // a whole heap of PREPAINT/POSTPAINT messages before drawing any items.
                    // We have to wait until after the first item paint before we draw overlays.
                    // On Vista, we have a different problem. On Vista, the control nests calls
                    // to PREPAINT and POSTPAINT. We only want to draw overlays on the outermost
                    // POSTPAINT.
                    if (this.prePaintLevel == 0 && (this.isMarqueSelecting || this.isAfterItemPaint)) {
                        this.shouldDoCustomDrawing = false;

                        // Draw our overlays after everything has been drawn
                        using (Graphics g = Graphics.FromHdc(nmcustomdraw.nmcd.hdc)) {
                            this.DrawAllDecorations(g, this.drawnItems);
                        }
                    }
                    break;

                case CDDS_ITEMPREPAINT:
                    //System.Diagnostics.Debug.WriteLine("CDDS_ITEMPREPAINT");

                    // When in group view on XP, the control send a whole heap of PREPAINT/POSTPAINT
                    // messages before drawing any items.
                    // We have to wait until after the first item paint before we draw overlays
                    this.isAfterItemPaint = true;

                    // This scheme of catching custom draw msgs works fine, except
                    // for Tile view. Something in .NET's handling of Tile view causes lots
                    // of invalidates and erases. So, we just ignore completely
                    // .NET's handling of Tile view and let the underlying control
                    // do its stuff. Strangely, if the Tile view is
                    // completely owner drawn, those erasures don't happen.
                    if (this.View == View.Tile) {
                        if (this.OwnerDraw && this.ItemRenderer != null)
                            base.WndProc(ref m);
                    } else {
                        base.WndProc(ref m);
                    }

                    m.Result = (IntPtr)((int)m.Result | CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYPOSTERASE);
                    return true;

                case CDDS_ITEMPOSTPAINT:
                    //System.Diagnostics.Debug.WriteLine("CDDS_ITEMPOSTPAINT");
                    if (this.Columns.Count > 0) {
                        OLVListItem olvi = this.GetItem((int)nmcustomdraw.nmcd.dwItemSpec);
                        if (olvi != null)
                            this.drawnItems.Add(olvi);
                    }
                    break;

                case CDDS_SUBITEMPREPAINT:
                    //System.Diagnostics.Debug.WriteLine(String.Format("CDDS_SUBITEMPREPAINT ({0},{1})", (int)nmcustomdraw.nmcd.dwItemSpec, nmcustomdraw.iSubItem));

                    // There is a bug in the .NET framework which appears when column 0 of an owner drawn listview
                    // is dragged to another column position.
                    // The bounds calculation always returns the left edge of column 0 as being 0.
                    // The effects of this bug become apparent
                    // when the listview is scrolled horizontally: the control can think that column 0
                    // is no longer visible (the horizontal scroll position is subtracted from the bounds, giving a
                    // rectangle that is offscreen). In those circumstances, column 0 is not redraw because
                    // the control thinks it is not visible and so does not trigger a DrawSubItem event.

                    // To fix this problem, we have to detected the situation -- owner drawing column 0 in any column except 0 --
                    // trigger our own DrawSubItem, and then prevent the default processing from occuring.

                    // Are we owner drawing column 0 when it's in any column except 0?
                    if (!this.OwnerDraw)
                        return false;

                    int columnIndex = nmcustomdraw.iSubItem;
                    if (columnIndex != 0)
                        return false;

                    int displayIndex = this.Columns[0].DisplayIndex;
                    if (displayIndex == 0)
                        return false;

                    int rowIndex = (int)nmcustomdraw.nmcd.dwItemSpec;
                    OLVListItem item = this.GetItem(rowIndex);
                    if (item == null)
                        return false;

                    // OK. We have the error condition, so lets do what the .NET framework should do.
                    // Trigger an event to draw column 0 when it is not at display index 0
                    using (Graphics g = Graphics.FromHdc(nmcustomdraw.nmcd.hdc)) {

                        // Correctly calculate the bounds of cell 0
                        Rectangle r = item.GetSubItemBounds(0);

                        // We can hardcode "0" here since we know we are only doing this for column 0
                        DrawListViewSubItemEventArgs args = new DrawListViewSubItemEventArgs(g, r, item, item.SubItems[0], rowIndex, 0,
                            this.Columns[0], (ListViewItemStates)nmcustomdraw.nmcd.uItemState);
                        this.OnDrawSubItem(args);

                        // If the event handler wants to do the default processing (i.e. DrawDefault = true), we are stuck.
                        // There is no way we can force the default drawing because of the bug in .NET we are trying to get around.
                        System.Diagnostics.Trace.Assert(!args.DrawDefault, "Default drawing is impossible in this situation");
                    }
                    m.Result = (IntPtr)4;

                    return true;

                case CDDS_SUBITEMPOSTPAINT:
                    //System.Diagnostics.Debug.WriteLine("CDDS_SUBITEMPOSTPAINT");
                    break;

                // I have included these stages, but it doesn't seem that they are sent for ListViews.
                // http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2006-08/msg00220.html

                case CDDS_PREERASE:
                    //System.Diagnostics.Debug.WriteLine("CDDS_PREERASE");
                    break;

                case CDDS_POSTERASE:
                    //System.Diagnostics.Debug.WriteLine("CDDS_POSTERASE");
                    break;

                case CDDS_ITEMPREERASE:
                    //System.Diagnostics.Debug.WriteLine("CDDS_ITEMPREERASE");
                    break;

                case CDDS_ITEMPOSTERASE:
                    //System.Diagnostics.Debug.WriteLine("CDDS_ITEMPOSTERASE");
                    break;
            }

            return false;
        }
Exemplo n.º 22
0
        void HistoryListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ItemIndex < 0) return;

            //Console.WriteLine(e.ItemIndex + "-" + e.Bounds);

            if (this.SelectedIndices.Contains(e.ItemIndex))
            {
                e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);
                ControlPaint.DrawFocusRectangle(e.Graphics, e.Item.Bounds);
            }
            else
            {
                e.DrawBackground();
            }

            // if this is the first column, we want to draw an icon as well
            int newX = e.Bounds.Left;
            if (e.ColumnIndex == 0)
            {
                // draw the icon
                newX = newX + 20;
                PastNotification pn = (PastNotification)e.Item.Tag;
                if (pn != null)
                {
                    System.Drawing.Image img = PastNotificationManager.GetImage(pn);
                    using (img)
                    {
                        if (img != null)
                        {
                            int x = e.Bounds.Left + 2;
                            int y = e.Bounds.Top;
                            e.Graphics.DrawImage(img, new System.Drawing.Rectangle(x, y, 16, 16));
                        }
                    }
                }
            }

            // draw text
            string text = e.SubItem.Text.Replace("\r", " - ");
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(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.StringFormatFlags.NoWrap;
            System.Drawing.Color color = (e.ColumnIndex == 0 ? e.Item.ForeColor : System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb()));
            System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(color);
            using (foreBrush)
            {
                //TextFormatFlags flags = TextFormatFlags.Default | TextFormatFlags.ExternalLeading | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.NoClipping | TextFormatFlags.EndEllipsis | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine;
                //TextRenderer.DrawText(e.Graphics, text, e.SubItem.Font, rect, e.SubItem.ForeColor, System.Drawing.Color.Transparent, flags);

                e.Graphics.DrawString(text,
                    e.SubItem.Font,
                    foreBrush,
                    rect,
                    sf);
            }
        }
 private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     e.DrawBackground();
     e.DrawText();
 }
Exemplo n.º 24
0
        private void SubtitleListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            Color backgroundColor = Items[e.ItemIndex].SubItems[e.ColumnIndex].BackColor;
            if (Focused && backgroundColor == BackColor)
            {
                e.DrawDefault = true;
                return;
            }

            using (var sf = new StringFormat())
            {
                switch (e.Header.TextAlign)
                {
                    case HorizontalAlignment.Center:
                        sf.Alignment = StringAlignment.Center;
                        break;
                    case HorizontalAlignment.Right:
                        sf.Alignment = StringAlignment.Far;
                        break;
                }

                if (e.Item.Selected)
                {
                    Rectangle rect = e.Bounds;
                    if (Configuration.Settings != null)
                    {
                        if (backgroundColor == BackColor)
                            backgroundColor = Configuration.Settings.Tools.ListViewUnfocusedSelectedColor;
                        else
                        {
                            int r = backgroundColor.R - 39;
                            int g = backgroundColor.G - 39;
                            int b = backgroundColor.B - 39;
                            if (r < 0)
                                r = 0;
                            if (g < 0)
                                g = 0;
                            if (b < 0)
                                b = 0;
                            backgroundColor = Color.FromArgb(backgroundColor.A, r, g, b);
                        }
                        SolidBrush sb = new SolidBrush(backgroundColor);
                        e.Graphics.FillRectangle(sb, rect);
                    }
                    else
                    {
                        e.Graphics.FillRectangle(Brushes.LightBlue, rect);
                    }
                    //rect = new Rectangle(e.Bounds.Left + 4, e.Bounds.Top+2, e.Bounds.Width - 3, e.Bounds.Height);
                    TextRenderer.DrawText(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, _subtitleFont, new Point(e.Bounds.Left + 3, e.Bounds.Top + 2), e.Item.ForeColor, TextFormatFlags.NoPrefix);
                }
                else
                {
                    e.DrawDefault = true;
                }
            }
        }
Exemplo n.º 25
0
        private void SubtitleListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            Color backgroundColor = Items[e.ItemIndex].SubItems[e.ColumnIndex].BackColor;
            if (Focused && backgroundColor == BackColor)
            {
                e.DrawDefault = true;
                return;
            }

            using (var sf = new StringFormat())
            {
                switch (e.Header.TextAlign)
                {
                    case HorizontalAlignment.Center:
                        sf.Alignment = StringAlignment.Center;
                        break;
                    case HorizontalAlignment.Right:
                        sf.Alignment = StringAlignment.Far;
                        break;
                }

                if (e.Item.Selected)
                {
                    if (RightToLeftLayout)
                    {
                        int w = Columns.Count;
                        for (int i = 0; i < Columns.Count; i++)
                            w += Columns[i].Width;

                        int extra = 0;
                        int extra2 = 0;
                        if (!IsVerticalScrollbarVisible())
                        {
                            // no vertical scrollbar
                            extra = 14;
                            extra2 = 11;
                        }
                        else
                        {
                            // no vertical scrollbar
                            extra = -3;
                            extra2 = -5;
                        }

                        var rect = new Rectangle(w - (e.Bounds.Left + e.Bounds.Width + 2) + extra, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
                        if (Configuration.Settings != null)
                        {
                            if (backgroundColor == BackColor)
                                backgroundColor = Configuration.Settings.Tools.ListViewUnfocusedSelectedColor;
                            else
                            {
                                int r = backgroundColor.R - 39;
                                int g = backgroundColor.G - 39;
                                int b = backgroundColor.B - 39;
                                if (r < 0)
                                    r = 0;
                                if (g < 0)
                                    g = 0;
                                if (b < 0)
                                    b = 0;
                                backgroundColor = Color.FromArgb(backgroundColor.A, r, g, b);
                            }
                            var sb = new SolidBrush(backgroundColor);
                            e.Graphics.FillRectangle(sb, rect);
                        }
                        else
                        {
                            e.Graphics.FillRectangle(Brushes.LightBlue, rect);
                        }
                        var rtlBounds = new Rectangle(w - (e.Bounds.Left + e.Bounds.Width) + extra2, e.Bounds.Top + 2, e.Bounds.Width, e.Bounds.Height);
                        sf.FormatFlags = StringFormatFlags.DirectionRightToLeft;
                        e.Graphics.DrawString(e.SubItem.Text, Font, new SolidBrush(e.Item.ForeColor), rtlBounds, sf);
                    }
                    else
                    {
                        Rectangle rect = e.Bounds;
                        if (Configuration.Settings != null)
                        {
                            if (backgroundColor == BackColor)
                                backgroundColor = Configuration.Settings.Tools.ListViewUnfocusedSelectedColor;
                            else
                            {
                                int r = backgroundColor.R - 39;
                                int g = backgroundColor.G - 39;
                                int b = backgroundColor.B - 39;
                                if (r < 0)
                                    r = 0;
                                if (g < 0)
                                    g = 0;
                                if (b < 0)
                                    b = 0;
                                backgroundColor = Color.FromArgb(backgroundColor.A, r, g, b);
                            }
                            var sb = new SolidBrush(backgroundColor);
                            e.Graphics.FillRectangle(sb, rect);
                        }
                        else
                        {
                            e.Graphics.FillRectangle(Brushes.LightBlue, rect);
                        }
                        TextRenderer.DrawText(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, _subtitleFont, new Point(e.Bounds.Left + 3, e.Bounds.Top + 2), e.Item.ForeColor, TextFormatFlags.NoPrefix);
                    }
                }
                else
                {
                    e.DrawDefault = true;
                }
            }
        }
Exemplo n.º 26
0
 protected virtual void OnDrawSubItem(DrawListViewSubItemEventArgs e)
 {
     throw null;
 }
 /*************************************************************
  * CSVリストビューを縞模様に描画
  *************************************************************/
 private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     // 奇数行の場合は背景色を変更し、縞々に見えるようにする
     if (e.ItemIndex % 2 > 0)
     {
         e.Graphics.FillRectangle(Brushes.Azure, e.Bounds);
     }
     // テキストを忘れずに描画する
     e.DrawText();
 }
Exemplo n.º 28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handles the DrawSubItem event of the lvMappings control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DrawListViewSubItemEventArgs"/>
		/// instance containing the event data.</param>
		/// ------------------------------------------------------------------------------------
		private void lvMappings_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
		{
			// The StyleListHelper is responsible for column 1.
			if (e.ColumnIndex == 1)
				return;

			FwListView lv = (FwListView)sender;

			ImportMappingInfo mapping = e.Item.Tag as ImportMappingInfo;
			Debug.Assert(mapping != null);

			Color foreColor = lv.GetTextColor(e);

			if (e.ColumnIndex != 0 || mapping == null || !mapping.IsInline)
			{
				TextRenderer.DrawText(e.Graphics, e.SubItem.Text, lv.Font, e.Bounds, foreColor,
					TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
				return;
			}

			TextRenderer.DrawText(e.Graphics, mapping.BeginMarker, lv.Font, e.Bounds, foreColor,
				TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);

			Rectangle rect = e.Bounds;
			int textWidth = (int)Math.Round(e.Graphics.MeasureString(mapping.BeginMarker, lv.Font).Width);
			rect.X += textWidth;
			rect.Width -= textWidth;
			Color backColor = e.Item.Selected ? SystemColors.Highlight : lv.BackColor;
			TextRenderer.DrawText(e.Graphics, "...", lv.Font, rect, ColorUtil.LightInverse(backColor),
				TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);

			textWidth = (int)Math.Round(e.Graphics.MeasureString("...", lv.Font).Width);
			rect.X += textWidth;
			rect.Width -= textWidth;
			TextRenderer.DrawText(e.Graphics, mapping.EndMarker, lv.Font, rect, foreColor,
				TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
		}
Exemplo n.º 29
0
        private void MyList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            if (e.ItemState == 0) return;

            if (e.ColumnIndex > 0)
            {
                //アイコン以外の列
                RectangleF rct = e.Bounds;
                RectangleF rctB = e.Bounds;
                rct.Width = e.Header.Width;
                rctB.Width = e.Header.Width;
                if (_iconCol)
                {
                    rct.Y += e.Item.Font.Height;
                    rct.Height -= e.Item.Font.Height;
                    rctB.Height = e.Item.Font.Height;
                }

                int heightDiff;
                int drawLineCount = Math.Max(1, Math.DivRem((int)rct.Height, e.Item.Font.Height, out heightDiff));

                //if (heightDiff > e.Item.Font.Height * 0.7)
                //{
                //    rct.Height += e.Item.Font.Height;
                //    drawLineCount += 1;
                //}

                //フォントの高さの半分を足してるのは保険。無くてもいいかも。
                if (!_iconCol && drawLineCount <= 1)
                {
                    //rct.Inflate(0, heightDiff / -2);
                    //rct.Height += e.Item.Font.Height / 2;
                }
                else if (heightDiff < e.Item.Font.Height * 0.7)
                {
                    //最終行が70%以上欠けていたら、最終行は表示しない
                    //rct.Height = (float)((e.Item.Font.Height * drawLineCount) + (e.Item.Font.Height / 2));
                    rct.Height = (e.Item.Font.Height * drawLineCount) - 1;
                }
                else
                {
                    drawLineCount += 1;
                }

                //if (!_iconCol && drawLineCount > 1)
                //{
                //    rct.Y += e.Item.Font.Height * 0.2;
                //    if (heightDiff >= e.Item.Font.Height * 0.8) rct.Height -= e.Item.Font.Height * 0.2;
                //}
                if (!e.Item.Selected)     //e.ItemStateでうまく判定できない???
                {
                    //選択されていない行
                    //文字色
                    SolidBrush brs = null;
                    bool flg = false;

                    if (e.Item.ForeColor == _clUnread)
                    {
                        brs = _brsForeColorUnread;
                    }
                    else if (e.Item.ForeColor == _clReaded)
                    {
                        brs = _brsForeColorReaded;
                    }
                    else if (e.Item.ForeColor == _clFav)
                    {
                        brs = _brsForeColorFav;
                    }
                    else if (e.Item.ForeColor == _clOWL)
                    {
                        brs = _brsForeColorOWL;
                    }
                    else if (e.Item.ForeColor == _clRetweet)
                    {
                        brs = _brsForeColorRetweet;
                    }
                    else
                    {
                        brs = new SolidBrush(e.Item.ForeColor);
                        flg = true;
                    }

                    if (rct.Width > 0)
                    {
                        if (_iconCol)
                        {
                            using (Font fnt = new Font(e.Item.Font, FontStyle.Bold))
                            {
                                //e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems[2].Text, e.Item.Font, brs, rct, sf);
                                //e.Graphics.DrawString(e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]", fnt, brs, rctB, sf);
                                TextRenderer.DrawText(e.Graphics,
                                                      e.Item.SubItems[2].Text,
                                                      e.Item.Font,
                                                      Rectangle.Round(rct),
                                                      brs.Color,
                                                      TextFormatFlags.WordBreak |
                                                      TextFormatFlags.EndEllipsis |
                                                      TextFormatFlags.GlyphOverhangPadding |
                                                      TextFormatFlags.NoPrefix);
                                TextRenderer.DrawText(e.Graphics,
                                                      e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]",
                                                      fnt,
                                                      Rectangle.Round(rctB),
                                                      brs.Color,
                                                      TextFormatFlags.SingleLine |
                                                      TextFormatFlags.EndEllipsis |
                                                      TextFormatFlags.GlyphOverhangPadding |
                                                      TextFormatFlags.NoPrefix);
                            }
                        }
                        else if (drawLineCount == 1)
                        {
                            TextRenderer.DrawText(e.Graphics,
                                                  e.SubItem.Text,
                                                  e.Item.Font,
                                                  Rectangle.Round(rct),
                                                  brs.Color,
                                                  TextFormatFlags.SingleLine |
                                                  TextFormatFlags.EndEllipsis |
                                                  TextFormatFlags.GlyphOverhangPadding |
                                                  TextFormatFlags.NoPrefix |
                                                  TextFormatFlags.VerticalCenter);
                        }
                        else
                        {
                            //e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, brs, rct, sf);
                            TextRenderer.DrawText(e.Graphics,
                                                  e.SubItem.Text,
                                                  e.Item.Font,
                                                  Rectangle.Round(rct),
                                                  brs.Color,
                                                  TextFormatFlags.WordBreak |
                                                  TextFormatFlags.EndEllipsis |
                                                  TextFormatFlags.GlyphOverhangPadding |
                                                  TextFormatFlags.NoPrefix);
                        }
                    }
                    if (flg) brs.Dispose();
                }
                else
                {
                    if (rct.Width > 0)
                    {
                        //選択中の行
                        using (Font fnt = new Font(e.Item.Font, FontStyle.Bold))
                        {
                            if (((Control)sender).Focused)
                            {
                                if (_iconCol)
                                {
                                    //e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems[2].Text, e.Item.Font, _brsHighLightText, rct, sf);
                                    //e.Graphics.DrawString(e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]", fnt, _brsHighLightText, rctB, sf);
                                    TextRenderer.DrawText(e.Graphics,
                                                          e.Item.SubItems[2].Text,
                                                          e.Item.Font,
                                                          Rectangle.Round(rct),
                                                          _brsHighLightText.Color,
                                                          TextFormatFlags.WordBreak |
                                                          TextFormatFlags.EndEllipsis |
                                                          TextFormatFlags.GlyphOverhangPadding |
                                                          TextFormatFlags.NoPrefix);
                                    TextRenderer.DrawText(e.Graphics,
                                                          e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]",
                                                          fnt,
                                                          Rectangle.Round(rctB),
                                                          _brsHighLightText.Color,
                                                          TextFormatFlags.SingleLine |
                                                          TextFormatFlags.EndEllipsis |
                                                          TextFormatFlags.GlyphOverhangPadding |
                                                          TextFormatFlags.NoPrefix);
                                }
                                else if (drawLineCount == 1)
                                {
                                    TextRenderer.DrawText(e.Graphics,
                                                          e.SubItem.Text,
                                                          e.Item.Font,
                                                          Rectangle.Round(rct),
                                                          _brsHighLightText.Color,
                                                          TextFormatFlags.SingleLine |
                                                          TextFormatFlags.EndEllipsis |
                                                          TextFormatFlags.GlyphOverhangPadding |
                                                          TextFormatFlags.NoPrefix |
                                                          TextFormatFlags.VerticalCenter);
                                }
                                else
                                {
                                    //e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, _brsHighLightText, rct, sf);
                                    TextRenderer.DrawText(e.Graphics,
                                                          e.SubItem.Text,
                                                          e.Item.Font,
                                                          Rectangle.Round(rct),
                                                          _brsHighLightText.Color,
                                                          TextFormatFlags.WordBreak |
                                                          TextFormatFlags.EndEllipsis |
                                                          TextFormatFlags.GlyphOverhangPadding |
                                                          TextFormatFlags.NoPrefix);
                                }
                            }
                            else
                            {
                                if (_iconCol)
                                {
                                    //e.Graphics.DrawString(System.Environment.NewLine + e.Item.SubItems[2].Text, e.Item.Font, _brsForeColorUnread, rct, sf);
                                    //e.Graphics.DrawString(e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]", fnt, _brsForeColorUnread, rctB, sf);
                                    TextRenderer.DrawText(e.Graphics,
                                                          e.Item.SubItems[2].Text,
                                                          e.Item.Font,
                                                          Rectangle.Round(rct),
                                                          _brsForeColorUnread.Color,
                                                          TextFormatFlags.WordBreak |
                                                          TextFormatFlags.EndEllipsis |
                                                          TextFormatFlags.GlyphOverhangPadding |
                                                          TextFormatFlags.NoPrefix);
                                    TextRenderer.DrawText(e.Graphics,
                                                          e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]",
                                                          fnt,
                                                          Rectangle.Round(rctB),
                                                          _brsForeColorUnread.Color,
                                                          TextFormatFlags.SingleLine |
                                                          TextFormatFlags.EndEllipsis |
                                                          TextFormatFlags.GlyphOverhangPadding |
                                                          TextFormatFlags.NoPrefix);
                                }
                                else if (drawLineCount == 1)
                                {
                                    TextRenderer.DrawText(e.Graphics,
                                                          e.SubItem.Text,
                                                          e.Item.Font,
                                                          Rectangle.Round(rct),
                                                          _brsForeColorUnread.Color,
                                                          TextFormatFlags.SingleLine |
                                                          TextFormatFlags.EndEllipsis |
                                                          TextFormatFlags.GlyphOverhangPadding |
                                                          TextFormatFlags.NoPrefix |
                                                          TextFormatFlags.VerticalCenter);
                                }
                                else
                                {
                                    //e.Graphics.DrawString(e.SubItem.Text, e.Item.Font, _brsForeColorUnread, rct, sf);
                                    TextRenderer.DrawText(e.Graphics,
                                                          e.SubItem.Text,
                                                          e.Item.Font,
                                                          Rectangle.Round(rct),
                                                          _brsForeColorUnread.Color,
                                                          TextFormatFlags.WordBreak |
                                                          TextFormatFlags.EndEllipsis |
                                                          TextFormatFlags.GlyphOverhangPadding |
                                                          TextFormatFlags.NoPrefix);
                                }
                            }
                        }
                    }
                }
                //if (e.ColumnIndex == 6) this.DrawListViewItemStateIcon(e, rct);
            }
        }
Exemplo n.º 30
0
		/// <summary>
		/// Render one cell within an ObjectListView when it is in Details mode.
		/// </summary>
		/// <param name="e">The event</param>
		/// <param name="g">A Graphics for rendering</param>
		/// <param name="cellBounds">The bounds of the cell</param>
		/// <param name="rowObject">The model object to be drawn</param>
		/// <returns>Return true to indicate that the event was handled and no further processing is needed.</returns>
		public virtual bool RenderSubItem(DrawListViewSubItemEventArgs e, Graphics g, Rectangle cellBounds, object rowObject) {
			return false;
		}
Exemplo n.º 31
0
		/// <summary>
		/// Render one cell
		/// </summary>
		/// <param name="e"></param>
		/// <param name="g"></param>
		/// <param name="cellBounds"></param>
		/// <param name="rowObject"></param>
		/// <returns></returns>
		public override bool RenderSubItem(DrawListViewSubItemEventArgs e, Graphics g, Rectangle cellBounds, object rowObject) {
			this.ClearState();

			this.Event = e;
			this.ListItem = (OLVListItem)e.Item;
			this.SubItem = (OLVListSubItem)e.SubItem;
			this.ListView = (ObjectListView)this.ListItem.ListView;
			this.Column = (OLVColumn)e.Header;
			this.RowObject = rowObject;
			this.Bounds = cellBounds;
			this.IsItemSelected = this.ListItem.Selected;

			return this.OptionalRender(g, cellBounds);
		}
Exemplo n.º 32
0
 private void OnDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     e.DrawDefault = true;
 }
Exemplo n.º 33
0
 protected override void OnDrawSubItem(System.Windows.Forms.DrawListViewSubItemEventArgs e)
 {
     base.OnDrawSubItem(e);
 }