public void DrawText_NullGraphics_ThrowsArgumentNullException()
        {
            var e = new DrawListViewColumnHeaderEventArgs(null, new Rectangle(1, 2, 3, 4), -1, new ColumnHeader(), ListViewItemStates.Checked, Color.Red, Color.Blue, SystemFonts.DefaultFont);

            Assert.Throws <ArgumentNullException>("dc", () => e.DrawText());
            Assert.Throws <ArgumentNullException>("dc", () => e.DrawText(TextFormatFlags.Left));
        }
 public void DrawText_NullHeader_ThrowsNullReferenceException()
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var e = new DrawListViewColumnHeaderEventArgs(graphics, new Rectangle(1, 2, 3, 4), -1, null, ListViewItemStates.Checked, Color.Red, Color.Blue, SystemFonts.DefaultFont);
             Assert.Throws <NullReferenceException>(() => e.DrawText());
             Assert.Throws <NullReferenceException>(() => e.DrawText(TextFormatFlags.Left));
         }
 }
Пример #3
0
 public void DrawListViewColumnHeaderEventArgs_DrawText_NullHeader_Success(Rectangle bounds, int columnIndex, ListViewItemStates state, Color foreColor, Color backColor, Font font)
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var e = new DrawListViewColumnHeaderEventArgs(graphics, bounds, columnIndex, null, state, foreColor, backColor, font);
             e.DrawText();
             e.DrawText(TextFormatFlags.Left);
         }
 }
Пример #4
0
 protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
 {
     base.OnDrawColumnHeader(e);
     //e.DrawDefault = true;
     e.Graphics.FillRectangle(Brushes.LightSteelBlue, e.Bounds);
     e.DrawText(TextFormatFlags.VerticalCenter);
 }
 private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     TextFormatFlags flags = TextFormatFlags.LeftAndRightPadding;
     e.DrawBackground();
     CheckBoxRenderer.DrawCheckBox(e.Graphics, ClientRectangle.Location, state);
     e.DrawText(flags);
 }
Пример #6
0
 // Handle DrawColumnHeader event
 private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     // Draw the column header normally
     e.DrawDefault = true;
     e.DrawBackground();
     e.DrawText();
 }
        private void resultListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                var cck = new CheckBox();
                // With...
                Text    = "";
                Visible = true;
                resultListView.SuspendLayout();
                e.DrawBackground();
                cck.BackColor = e.BackColor;
                cck.UseVisualStyleBackColor = true;

                cck.SetBounds(e.Bounds.X, e.Bounds.Y, cck.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).Width, cck.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).Width);
                cck.Size       = new Size((cck.GetPreferredSize(new Size((e.Bounds.Width - 1), e.Bounds.Height)).Width + 1), e.Bounds.Height);
                cck.Location   = new Point(4, 0);
                cck.CheckState = _headerCheckState;
                resultListView.Controls.Add(cck);
                cck.Show();
                cck.BringToFront();
                e.DrawText((TextFormatFlags.VerticalCenter | TextFormatFlags.Left));
                cck.Click += resultListViewheaderCheckAll;
                resultListView.ResumeLayout(true);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
Пример #8
0
 private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     // Fill header background with solid yello color.
     e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds);
     // Let ListView draw everything else.
     e.DrawText();
 }
Пример #9
0
 protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
 {
     base.OnDrawColumnHeader(e);
     if (e.ColumnIndex == 0)
     {
         var headerCheckBox = new CheckBox {
             Text = "", Visible = true
         };
         SuspendLayout();
         e.DrawBackground();
         headerCheckBox.BackColor = Color.Transparent;
         headerCheckBox.UseVisualStyleBackColor = true;
         headerCheckBox.BackgroundImage         = Resources.ListViewHeaderCheckboxBackgroud;
         headerCheckBox.SetBounds(e.Bounds.X, e.Bounds.Y,
                                  headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).
                                  Width,
                                  headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).
                                  Height);
         headerCheckBox.Size =
             new Size(headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width - 1, e.Bounds.Height)).Width + 1,
                      e.Bounds.Height);
         headerCheckBox.Location = new Point(4, 0);
         Controls.Add(headerCheckBox);
         headerCheckBox.Show();
         headerCheckBox.BringToFront();
         e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
         headerCheckBox.CheckedChanged += OnHeaderCheckboxCheckedChanged;
         ResumeLayout(true);
     }
     else
     {
         e.DrawDefault = true;
     }
 }
Пример #10
0
        private void listView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            if (SortingInfo == null || e.ColumnIndex != (int)SortingInfo.SortColumn)
            {
                e.DrawBackground();
                e.DrawText(TextFormatFlags.VerticalCenter);
                return;
            }
            e.DrawBackground();
            e.DrawText(TextFormatFlags.VerticalCenter);
            var image = SortingInfo.SortDirection == SortDirection.Ascending ? Resources.ascending : Resources.descending;
            var x     = e.Bounds.X + e.Bounds.Width - image.Width - 5;
            var y     = (e.Bounds.Height - image.Height) / 2 - 1;

            e.Graphics.DrawImage(image, x, y);
        }
Пример #11
0
        // Token: 0x0600013C RID: 316 RVA: 0x0001895C File Offset: 0x00016B5C
        private void listView4_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            bool flag = e.ColumnIndex == 0 && this.first == 0;

            if (flag)
            {
                this.first = 1;
                CheckBox checkBox = new CheckBox();
                base.Visible = true;
                this.listViewRRS.SuspendLayout();
                e.DrawBackground();
                checkBox.BackColor = Color.Transparent;
                checkBox.UseVisualStyleBackColor = true;
                checkBox.SetBounds(e.Bounds.X, e.Bounds.Y, checkBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).Width, checkBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).Width);
                checkBox.Size     = new Size(checkBox.GetPreferredSize(new Size(e.Bounds.Width - 1, e.Bounds.Height)).Width + 1, e.Bounds.Height);
                checkBox.Location = new Point(3, 0);
                this.listViewRRS.Controls.Add(checkBox);
                checkBox.Show();
                checkBox.BringToFront();
                e.DrawText(TextFormatFlags.VerticalCenter);
                checkBox.Click += this.Bink;
                this.listViewRRS.ResumeLayout(true);
            }
            else
            {
                e.DrawDefault = true;
            }
        }
Пример #12
0
        private void OnDrawHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            e.DrawBackground();
            e.DrawText();
            if (SortColumn != e.ColumnIndex)
            {
                return;
            }
            if (sortOrder == SortOrder.None)
            {
                return;
            }

            Image img = null;

            if (sortOrder == SortOrder.Ascending)
            {
                img = ArrowDrawer.get().getImage(0);
            }
            else
            {
                img = ArrowDrawer.get().getImage(1);
            }
            Rectangle rect = new Rectangle(e.Bounds.Right - 16, e.Bounds.Bottom - 16, 11, 11);

            e.Graphics.DrawImage(img, rect);
        }
Пример #13
0
 private void listView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     using (var sb = new SolidBrush(Color.FromArgb(109, 116, 131)))
     {
         e.Graphics.FillRectangle(sb, e.Bounds);
         e.DrawText();
     }
 }
Пример #14
0
        private void lstMods_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            TextFormatFlags flags = TextFormatFlags.LeftAndRightPadding;

            e.DrawBackground();
            CheckBoxRenderer.DrawCheckBox(e.Graphics, DrawOffset, state);
            e.DrawText(flags);
        }
Пример #15
0
        private void fastListViewMain_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            e.DrawBackground();
            e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
            var bound = e.Bounds;

            e.Graphics.DrawLine(this.fastListViewMain.GridLineColorPen, bound.X, bound.Y + bound.Height - 1, bound.X + bound.Width, bound.Y + bound.Height - 1);
        }
Пример #16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Must have this when owner draw is turned on, even if this item isn't custom drawn.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            if (m_sortColumn != e.ColumnIndex)
            {
                e.DrawDefault = true;
                base.OnDrawColumnHeader(e);
                return;
            }

            e.DrawDefault = false;
            e.DrawBackground();

            // For some reason, the default formatting doesn't yield the same result you
            // get when letting the base class draw the text. This formatting is as close
            // as I could get to that. Maybe it's a Windows 7 thing.
            var flags = TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis |
                        TextFormatFlags.SingleLine | TextFormatFlags.NoPadding;

            if (RightToLeft == RightToLeft.Yes)
            {
                flags |= TextFormatFlags.RightToLeft;
            }

            e.DrawText(flags);

            // Draw the arrow glyph, indicating the sort direction. The
            // arrow will be drawn from its wider end to the point.
            int inc   = 1;
            int start = e.Bounds.Top + ((e.Bounds.Height - 5) / 2) - 1;

            if (m_sortOrder == SortOrder.Ascending)
            {
                // Draw fat end at the bottom and move up.
                start += 4;
                inc    = -1;
            }

            var pt1 = new Point(e.Bounds.Right - 20, start);
            var pt2 = new Point(pt1.X + 8, start);

            // Draw four lines, each successive line being two pixels shorter
            // than the previous and one line up or down from the previous.
            for (int i = 0; i < 4; i++)
            {
                e.Graphics.DrawLine(SystemPens.ControlDark, pt1, pt2);
                pt1.X++;
                pt2.X--;
                pt1.Y += inc;
                pt2.Y += inc;
            }

            // Draw the point. Since a line cannot be 1 pixel long, draw a vertical
            // line that starts at the pixel that is the point and ends one pixel
            // into the body of the arrow.
            pt2.Y -= inc;
            e.Graphics.DrawLine(SystemPens.ControlDark, pt1, pt2);
        }
Пример #17
0
 public void DrawListViewColumnHeaderEventArgs_DrawText_InvokeTextFormatFlags_Success()
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var e = new DrawListViewColumnHeaderEventArgs(graphics, new Rectangle(1, 2, 3, 4), -1, new ColumnHeader(), ListViewItemStates.Checked, Color.Red, Color.Blue, SystemFonts.DefaultFont);
             e.DrawText(TextFormatFlags.Bottom);
         }
 }
Пример #18
0
        private void ListViewLibrary_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            var b = e.Bounds;

            b.Height = (int)(b.Height * 0.6f);   // the title columns are too tall??!
            var color = Brushes.LightGray;

            e.Graphics.FillRectangle(color, b);
            e.DrawText();
        }
Пример #19
0
 private void ListViewMessage_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     e.Graphics.FillRectangle(new SolidBrush(ColorWnFrm.BackgroundColorInput), e.Bounds);
     //using (var sf = new StringFormat()) {
     //    sf.Alignment = StringAlignment.Center;
     //    using (var headerFont = new Font("Microsoft Sans Serif", 9, FontStyle.Bold)) {
     //        e.Graphics.DrawString(e.Header.Text, headerFont, Brushes.DeepSkyBlue, e.Bounds, sf);
     //    }
     //}
     e.DrawText();
 }
Пример #20
0
 public void DrawListViewColumnHeaderEventArgs_DrawText_Invoke_Success(HorizontalAlignment textAlign)
 {
     using (var image = new Bitmap(10, 10))
         using (Graphics graphics = Graphics.FromImage(image))
         {
             var header = new ColumnHeader {
                 TextAlign = textAlign
             };
             var e = new DrawListViewColumnHeaderEventArgs(graphics, new Rectangle(1, 2, 3, 4), -1, header, ListViewItemStates.Checked, Color.Red, Color.Blue, SystemFonts.DefaultFont);
             e.DrawText();
         }
 }
Пример #21
0
        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            // Background
            e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds);
            // Borders at the bottom and between header cells
            Rectangle rect = e.Bounds;

            rect.Inflate(1, 0);
            rect.Offset(0, -1);
            e.Graphics.DrawRectangle(SystemPens.ControlDark, rect);
            // Text
            e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
            // Alert event subscribers
            base.OnDrawColumnHeader(e);
        }
Пример #22
0
        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds);
            e.Graphics.DrawLine(
                SystemPens.ControlDark,
                new Point(e.Bounds.X + e.Bounds.Width - 1, 0),
                new Point(e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Height));
            e.Graphics.DrawLine(
                SystemPens.ControlDark,
                new Point(e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1),
                new Point(e.Bounds.X + e.Bounds.Width, e.Bounds.Y + e.Bounds.Height - 1));

            e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.NoPadding);

            base.OnDrawColumnHeader(e);
        }
Пример #23
0
 private void listView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     if (e.ColumnIndex == 0)
     {
         //stan checkboxa zapisuję w tagu nagłówka
         //zaraz po wyrenderowaniu tag jest null co metoda Convert.ToBoolean zwraca jako false
         bool            isChecked = Convert.ToBoolean(e.Header.Tag);
         CheckBoxState   state     = isChecked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
         TextFormatFlags flags     = TextFormatFlags.VerticalCenter;
         e.DrawBackground();
         CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(e.Bounds.Left + 4, e.Bounds.Top + 4), state);//ClientRectangle.Location
         e.DrawText(flags);
     }
     else
     {
         e.DrawDefault = true;
     }
 }
Пример #24
0
        private void SortableListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            bool flag;

            if (flag = this.int_1 == e.ColumnIndex)
            {
                e.DrawBackground();
                e.DrawText(TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter);
                if ((flag && (this.bitmap_0 != null)) && (this.bitmap_1 != null))
                {
                    Point point = new Point(e.Bounds.Left + ((int)e.Graphics.MeasureString(e.Header.Text + "XY", e.Font).Width), ((e.Bounds.Top + e.Bounds.Bottom) - this.bitmap_0.Height) / 2);
                    e.Graphics.DrawImage((this.int_0 > 0) ? this.bitmap_0 : this.bitmap_1, point);
                }
                this.Refresh();
            }
            else
            {
                e.DrawDefault = true;
            }
        }
Пример #25
0
        private void listview_File_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            SolidBrush brush = new SolidBrush(Color.FromArgb(244, 243, 242));

            e.Graphics.FillRectangle(brush, e.Bounds);
            if (e.ColumnIndex == 0)
            {
                e.Graphics.DrawImage(Properties.Resources.ColumnHeaderL, new Point(e.Bounds.X, e.Bounds.Y));
            }
            else if (e.ColumnIndex == 3)
            {
                e.Graphics.DrawImage(Properties.Resources.ColumnHeaderR, new Point(e.Bounds.X, e.Bounds.Y));
            }
            else
            {
                e.Graphics.DrawImage(Properties.Resources.ColumnHeaderC, new Point(e.Bounds.X, e.Bounds.Y));
            }
            //e.Graphics.DrawImage(Properties.Resources.ColumnHeader, new Point(0, 0));
            e.DrawText();
        }
        void SortableListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            bool fSorted = (this._sortColumn == e.ColumnIndex);

            if (fSorted)
            {
                e.DrawBackground();
                e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);

                //如果是排序,并且图片不为空,那么绘制图标
                if (fSorted && (_imageAscending != null) && (this._imageDescending != null))
                {
                    Point ptImage = new Point(e.Bounds.Left + (int)e.Graphics.MeasureString(e.Header.Text + "XY", e.Font).Width, (e.Bounds.Top + e.Bounds.Bottom - _imageAscending.Height) / 2);
                    e.Graphics.DrawImage((this._sortOrder > 0) ? _imageAscending : _imageDescending, ptImage);
                }

                this.Refresh();
            }
            else
            {
                e.DrawDefault = true;
            }
        }
Пример #27
0
        public void exDrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            using (StringFormat format = new StringFormat())
            {
                // Store the column text alignment, letting it default
                // to Left if it has not been set to Center or Right.
                switch (e.Header.TextAlign)
                {
                case HorizontalAlignment.Center:
                    format.Alignment = StringAlignment.Center;
                    break;

                case HorizontalAlignment.Right:
                    format.Alignment = StringAlignment.Far;
                    break;
                }

                //format.FormatFlags = StringFormatFlags.
                // Draw the standard header background.
                e.DrawBackground();
                e.DrawText(TextFormatFlags.VerticalCenter);
            }
        }
Пример #28
0
 private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     e.Graphics.FillRectangle(Brushes.Red, e.Bounds);
     e.DrawText();
 }
Пример #29
0
 private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     e.DrawBackground();
     e.DrawText();
 }
Пример #30
0
 private void playerTable_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
 {
     e.Graphics.FillRectangle(Brushes.FloralWhite, e.Bounds);
     e.DrawText();
 }