Esempio n. 1
0
    private void ListBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
    {
        if (e.Index == -1)
        {
            return;
        }
        int i = System.Convert.ToInt32(ListBox1.Items[e.Index]);

        e.DrawBackground();
        if (i % 4 != 0)
        {
            string spaces = new string(' ', 20);
            e.Graphics.DrawString(
                "Item #: " + i.ToString() + spaces.Replace(" ", " <Filler>"),
                ListBox1.Font,
                System.Drawing.Brushes.Black,
                0,
                e.Bounds.Top);
        }
        else
        {
            e.Graphics.DrawLine(
                System.Drawing.Pens.Blue,
                10,
                e.Bounds.Top + 1,
                52,
                e.Bounds.Top + 1);
        }
        e.DrawFocusRectangle();
    }
Esempio n. 2
0
 private void StyleComboBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (this.iarray_0.Count != 0)
     {
         e.DrawBackground();
         try
         {
             IStyleGalleryItem styleGalleryItem = this.iarray_0.get_Element(e.Index) as IStyleGalleryItem;
             if (styleGalleryItem != null)
             {
                 System.IntPtr hdc       = e.Graphics.GetHdc();
                 IStyleDraw    styleDraw = StyleDrawFactory.CreateStyleDraw(styleGalleryItem.Item);
                 if (styleDraw != null)
                 {
                     e.Bounds.Inflate(-2, -4);
                     styleDraw.Draw(hdc.ToInt32(), e.Bounds, 72.0, 1.0);
                 }
                 e.Graphics.ReleaseHdc(hdc);
             }
             else
             {
                 Brush brush = new SolidBrush(e.ForeColor);
                 e.Graphics.DrawString(base.Items[e.Index].ToString(), e.Font, brush, (float)(e.Bounds.Left + 3),
                                       (float)(e.Bounds.Top + 3));
             }
         }
         catch
         {
         }
     }
 }
Esempio n. 3
0
        public void EventAllConfigsLB_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            System.Windows.Forms.ListBox _ListBox = (System.Windows.Forms.ListBox)sender;

            e.DrawBackground();
            System.Drawing.Brush myBrush = System.Drawing.Brushes.White;
            string currentItem           = _ListBox.Items[e.Index].ToString();

            if (_ListBox.SelectedIndex != e.Index)//e.State != System.Windows.Forms.DrawItemState.Selected)//
            {
                string currItemValue = currentItem.Split('=').Last();
                if (currItemValue == "enabled")
                {
                    myBrush = System.Drawing.Brushes.DarkGreen;
                }
                else if (currItemValue == "disabled")
                {
                    myBrush = System.Drawing.Brushes.DarkRed;
                }
                else// if (currItemValue == "enabled(auto)")
                {
                    myBrush = System.Drawing.Brushes.Black;
                }
            }

            e.Graphics.DrawString(currentItem, e.Font, myBrush, e.Bounds, System.Drawing.StringFormat.GenericDefault);
        }
Esempio n. 4
0
 private void ColorRampComboBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (this.iarray_0.Count != 0)
     {
         e.DrawBackground();
         System.IntPtr hdc = e.Graphics.GetHdc();
         this.DrawColorRamp(hdc.ToInt32(), e.Bounds, (IColorRamp)this.iarray_0.get_Element(e.Index));
         e.Graphics.ReleaseHdc(hdc);
     }
 }
Esempio n. 5
0
 private void SymbolListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (base.Items.Count != 0)
     {
         SymbolListItem symbolListItem = (SymbolListItem)base.Items[e.Index];
         e.DrawBackground();
         Bitmap image;
         if (symbolListItem.m_bVisible)
         {
             image =
                 new Bitmap(
                     base.GetType().Assembly.GetManifestResourceStream("Yutai.ArcGIS.Common.SymbolLib.Check.bmp"));
         }
         else
         {
             image =
                 new Bitmap(
                     base.GetType()
                     .Assembly.GetManifestResourceStream("Yutai.ArcGIS.Common.SymbolLib.UnCheck.bmp"));
         }
         Bitmap image2;
         if (symbolListItem.m_bLockColor)
         {
             image2 =
                 new Bitmap(
                     base.GetType().Assembly.GetManifestResourceStream("Yutai.ArcGIS.Common.SymbolLib.Lock.bmp"));
         }
         else
         {
             image2 =
                 new Bitmap(
                     base.GetType()
                     .Assembly.GetManifestResourceStream("Yutai.ArcGIS.Common.SymbolLib.UnLock.bmp"));
         }
         Rectangle rect      = new Rectangle(2, e.Bounds.Y + (e.Bounds.Height - 16) / 2, 16, 16);
         Rectangle rect2     = new Rectangle(e.Bounds.Right - 21, e.Bounds.Y + (e.Bounds.Height - 16) / 2, 16, 16);
         Rectangle rectangle = new Rectangle(rect.Right + 2, e.Bounds.Y + 1, e.Bounds.Width - 46,
                                             e.Bounds.Height - 2);
         e.Graphics.DrawImageUnscaled(image, rect);
         e.Graphics.DrawImageUnscaled(image2, rect2);
         e.Graphics.FillRectangle(Brushes.White, rectangle);
         Graphics      graphics = e.Graphics;
         System.IntPtr hdc      = graphics.GetHdc();
         this.DrawSymbol(hdc.ToInt32(), rectangle, symbolListItem.m_pSymbol);
         graphics.ReleaseHdc(hdc);
     }
 }
Esempio n. 6
0
        //protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e)
        //{
        //    base.OnMeasureItem(e);
        //    e.ItemHeight = e.ItemHeight - 2;
        //}

        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            base.OnDrawItem(e);
            if (e.Index < 0)
            {
                return;
            }
            float size = this.Font.Size;

            System.Drawing.Font       myFont;
            System.Drawing.FontFamily family = this.Font.FontFamily;

            System.Drawing.Color animalColor = this.ForeColor;

            // Draw the background of the item.
            e.DrawBackground();

            // Create a square filled with the animals color. Vary the size
            // of the rectangle based on the length of the animals name.
            //System.Drawing.Rectangle rectangle = new Rectangle(2, e.Bounds.Top + 2,
            //        e.Bounds.Height, e.Bounds.Height - 4);
            //e.Graphics.FillRectangle(new SolidBrush(animalColor), rectangle);

            // Draw each string in the array, using a different size, color,
            // and font for each item.
            myFont = new Font(family, size, FontStyle.Regular);

            e.Graphics.DrawString(this.GetItemText(Items[e.Index]), myFont, System.Drawing.Brushes.Black, new PointF(e.Bounds.X + 5, e.Bounds.Y + 2));
            //new RectangleF(e.Bounds.X + e.Bounds.Height, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));
            //弹出下拉
            //if (e.State == (System.Windows.Forms.DrawItemState.NoAccelerator | System.Windows.Forms.DrawItemState.NoFocusRect))
            //{
            //    e.Graphics.DrawRectangle(new Pen(_borderColor), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
            //}
            //else//选择时
            //{
            //    e.Graphics.DrawRectangle(new Pen(_borderColor), e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1);
            //}
            // Draw the focus rectangle if the mouse hovers over an item.
            e.DrawFocusRectangle();
        }
 private void RepresentationruleListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     if (base.Items.Count != 0)
     {
         RepresentationruleListBox.RepresentationRuleWrap representationRuleWrap =
             (RepresentationruleListBox.RepresentationRuleWrap)base.Items[e.Index];
         e.DrawBackground();
         string s     = "(" + representationRuleWrap.RuleID.ToString() + ") " + representationRuleWrap.Name;
         Brush  brush = new SolidBrush(e.ForeColor);
         e.Graphics.DrawString(s, this.Font, brush, (float)e.Bounds.X, (float)e.Bounds.Y);
         brush.Dispose();
         System.IntPtr  hdc           = e.Graphics.GetHdc();
         IOutputContext outputContext = new OutputContext();
         IPoint         point         = new ESRI.ArcGIS.Geometry.Point();
         point.PutCoords((double)(e.Bounds.X + e.Bounds.Width / 2), (double)(e.Bounds.Y + e.Bounds.Height / 2 + 10));
         tagRECT tagRECT_ = default(tagRECT);
         tagRECT_.left   = e.Bounds.Left + 10;
         tagRECT_.right  = e.Bounds.Right - 10;
         tagRECT_.top    = e.Bounds.Top + 10;
         tagRECT_.bottom = e.Bounds.Bottom - 5;
         outputContext.Init(1.0, 1.5, 96.0, 0.0, point, ref tagRECT_, hdc.ToInt32());
         IGeometry geometry;
         if (this.esriGeometryType_0 == esriGeometryType.esriGeometryPolygon)
         {
             geometry = this.method_1(tagRECT_);
         }
         else if (this.esriGeometryType_0 == esriGeometryType.esriGeometryPolyline)
         {
             geometry = this.method_2(tagRECT_);
         }
         else
         {
             geometry = new ESRI.ArcGIS.Geometry.Point();
             (geometry as IPoint).PutCoords((double)((tagRECT_.left + tagRECT_.right) / 2),
                                            (double)((tagRECT_.top + tagRECT_.bottom) / 2));
         }
         representationRuleWrap.RepresentationRule.Draw(-1, outputContext, geometry, geometry.Envelope);
         e.Graphics.ReleaseHdc(hdc);
     }
 }
Esempio n. 8
0
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();

            if (e.State == System.Windows.Forms.DrawItemState.Focus)
            {
                e.DrawFocusRectangle();
            }

            if (e.Index < 0 || e.Index >= Items.Count)
            {
                return;
            }

            string text = (Items[e.Index] == null) ? "(null)" : Items[e.Index].ToString();

            using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(e.ForeColor))
            {
                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                e.Graphics.DrawString(text, e.Font, brush, e.Bounds);
            }
        }
Esempio n. 9
0
    protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
    {
        e.DrawBackground();
        e.DrawFocusRectangle();
        GListBoxItem item;
        Rectangle    bounds    = e.Bounds;
        Size         imageSize = _myImageList.ImageSize;

        try
        {
            item = (GListBoxItem)Items[e.Index];
            if (item.ImageIndex != -1)
            {
                imageList.Draw(e.Graphics, bounds.Left, bounds.Top, item.ImageIndex);
                e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
                                      bounds.Left + imageSize.Width, bounds.Top);
            }
            else
            {
                e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
                                      bounds.Left, bounds.Top);
            }
        }
        catch
        {
            if (e.Index != -1)
            {
                e.Graphics.DrawString(Items[e.Index].ToString(), e.Font,
                                      new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
            }
            else
            {
                e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
                                      bounds.Left, bounds.Top);
            }
        }
        base.OnDrawItem(e);
    }
    private void listBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
    {
        Brush brush;

        // Create the brush using the ForeColor specified by the DrawItemEventArgs
        if (foreColorBrush == null)
        {
            foreColorBrush = new SolidBrush(e.ForeColor);
        }
        else if (foreColorBrush.Color != e.ForeColor)
        {
            // The control's ForeColor has changed, so dispose of the cached brush and
            // create a new one.
            foreColorBrush.Dispose();
            foreColorBrush = new SolidBrush(e.ForeColor);
        }

        // Select the appropriate brush depending on if the item is selected.
        // Since State can be a combinateion (bit-flag) of enum values, you can't use
        // "==" to compare them.
        if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
        {
            brush = SystemBrushes.HighlightText;
        }
        else
        {
            brush = foreColorBrush;
        }

        // Perform the painting.
        Font font = ((ListBoxFontItem)listBox1.Items[e.Index]).Font;

        e.DrawBackground();
        e.Graphics.DrawString(font.Name, font, brush, e.Bounds);
        e.DrawFocusRectangle();
    }
Esempio n. 11
0
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            int i1 = e.Index;

            if (i1 < 0)
            {
                return;
            }
            if (Items[i1].ToString() == "-----")
            {
                return;
            }
            bool flag = false;

            if (((i1 - 1) > 0) && Items[i1 - 1].ToString() == "-----")
            {
                flag = true;
            }
            if (!Enabled)
            {
                System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.SystemColors.Control);
                e.Graphics.FillRectangle(brush, ClientRectangle);
                brush.Dispose();
            }
            else
            {
                e.DrawBackground();
            }
            System.Drawing.Graphics  graphics   = e.Graphics;
            System.Drawing.Rectangle rectangle1 = e.Bounds;
            System.Drawing.Point     point1     = rectangle1.Location;
            int i2 = point1.Y + _separatorWidth - 8;

            if (flag)
            {
                System.Drawing.Pen pen = new System.Drawing.Pen(_separatorColor, (float)_separatorWidth);
                pen.DashStyle = _separatorStyle;
                System.Drawing.Rectangle rectangle2 = e.Bounds;
                System.Drawing.Point     point2     = rectangle2.Location;
                System.Drawing.Rectangle rectangle3 = e.Bounds;
                System.Drawing.Point     point3     = rectangle3.Location;
                System.Drawing.Rectangle rectangle4 = e.Bounds;
                graphics.DrawLine(pen, point2.X + _separatorMargin, i2, point3.X + rectangle4.Width - _separatorMargin, i2);
                pen.Dispose();
            }
            System.Drawing.Rectangle rectangle5 = e.Bounds;
            System.Drawing.Point     point4     = rectangle5.Location;
            i2 = point4.Y + _separatorWidth;
            string s = Items[i1].ToString();

            if (!System.String.IsNullOrEmpty(DisplayMember))
            {
                System.Reflection.PropertyInfo propertyInfo = Items[i1].GetType().GetProperty(DisplayMember);
                s = propertyInfo.GetValue(Items[i1], null).ToString();
            }
            System.Drawing.Color color = ForeColor;
            if (System.Windows.Forms.DrawItemState.Selected == (System.Windows.Forms.DrawItemState.Selected & e.State))
            {
                color = System.Drawing.SystemColors.HighlightText;
            }
            if (System.Windows.Forms.DrawItemState.Disabled == (System.Windows.Forms.DrawItemState.Disabled & e.State))
            {
                color = System.Drawing.SystemColors.GrayText;
            }
            System.Drawing.Rectangle rectangle6 = e.Bounds;
            System.Windows.Forms.TextRenderer.DrawText(graphics, s, e.Font, rectangle6.Location, color);
            base.OnDrawItem(e);
        }