示例#1
0
        private void fillStyleComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            switch (this.fillStyleComboBox.SelectedIndex)
            {
            case -1:
                return;

            case 0:
                Sssh.IsFillColor = false;
                Sssh.IsHatch     = false;
                return;

            case 1:
                Sssh.IsFillColor = true;
                Sssh.IsHatch     = false;
                return;

            default:
                Sssh.IsFillColor = true;
                Sssh.IsHatch     = true;
                NamedHatchStyles nhs = Surface.Source.NamedHatchStyle;
                Sssh.Hatch = nhs.GetHatchStyle(
                    this.fillStyleComboBox.SelectedItem as string) ?? default(HatchStyle);
                break;
            }
        }
示例#2
0
 internal static Brush GetBrush(string name,
                                Color foreColor, Color backColor,
                                NamedHatchStyles nhs, NamedTextureStyles nts)
 {
     if (nhs != null)
     {
         HatchStyle?hatch = nhs.GetHatchStyle(name);
         if (hatch.HasValue)
         {
             return(new HatchBrush(hatch.Value, foreColor, backColor));
         }
     }
     if (nts != null)
     {
         Picture pic = nts.GetTexture(name);
         if (pic != null)
         {
             Image img = pic.GetImage();
             if (img != null)
             {
                 return(new TextureBrush(img));
             }
         }
     }
     return(new SolidBrush(foreColor));
 }
示例#3
0
        private static void DrawHatchItem(
            DrawItemEventArgs e, IList items, Font font,
            NamedHatchStyles nhs, NamedTextureStyles nts)
        {
            e.DrawBackground();
            Rectangle rectangle1 = e.Bounds;

            if (e.Index == -1)
            {
                return;
            }
            string    text1      = (string)items[e.Index];
            Rectangle rectangle2 = rectangle1;

            rectangle2.Width = rectangle2.Left + 0x19;
            rectangle1.X     = rectangle2.Right;
            using (Brush brush1 = UICommon.GetBrush(text1, e.ForeColor, e.BackColor, nhs, nts))
            {
                e.Graphics.FillRectangle(brush1, rectangle2);
            }
            StringFormat format1 = new StringFormat();

            format1.Alignment = StringAlignment.Near;
            using (SolidBrush brush2 = new SolidBrush(Color.White))
            {
                if ((e.State & DrawItemState.Focus) == DrawItemState.None)
                {
                    brush2.Color = SystemColors.Window;
                    e.Graphics.FillRectangle(brush2, rectangle1);
                    brush2.Color = SystemColors.WindowText;
                    e.Graphics.DrawString(text1, font, brush2, (RectangleF)rectangle1, format1);
                }
                else
                {
                    brush2.Color = SystemColors.Highlight;
                    e.Graphics.FillRectangle(brush2, rectangle1);
                    brush2.Color = SystemColors.HighlightText;
                    e.Graphics.DrawString(text1, font, brush2, (RectangleF)rectangle1, format1);
                }
            }
            e.DrawFocusRectangle();
        }
示例#4
0
 public void Load(Picture background, Size size,
                  NamedHatchStyles namedHatchStyle,
                  NamedTextureStyles namedTextureStyle,
                  IEnumerable <IShape> shapes)
 {
     Clear();
     OnLoading(EventArgs.Empty);
     _size = size;
     CheckSize(true);
     _background = background;
     if (shapes == null)
     {
         ShapesPrivate = new ShapeList();
     }
     else
     {
         ShapesPrivate = new ShapeList(shapes);
     }
     _namedHatchStyle   = namedHatchStyle;
     _namedTextureStyle = namedTextureStyle;
     RedrawCore();
     _isLoaded = true;
     OnLoaded(EventArgs.Empty);
 }