public BrushProperies(My_Figure figure, EntityDrawningCore core)
 {
     InitializeComponent();
     this.brush  = figure.brush;
     this.figure = figure;
     this.core   = core;
     LoadData();
 }
        private void buttonApply_Click(object sender, EventArgs e)
        {
            BrushType type = (BrushType)comboBoxType.SelectedItem;

            switch (type)
            {
            case BrushType.SolidBrush:
            {
                Color color1 = Color.FromArgb((byte)numericUpDownAlpha1.Value, colorDialog1.Color);
                brush = new My_SolidBrush(color1);
            }
            break;

            case BrushType.HatchBrush:
            {
                HatchStyle style  = (HatchStyle)comboBoxHatchBrushes.SelectedItem;
                Color      color1 = Color.FromArgb((byte)numericUpDownAlpha1.Value, colorDialog1.Color);
                Color      color2 = Color.FromArgb((byte)numericUpDownAlpha2.Value, colorDialog2.Color);
                brush = new My_HatchBrush(color1, color2, style);
            }
            break;

            case BrushType.LinearGradientBrush:
            {
                Color color1            = Color.FromArgb((byte)numericUpDownAlpha1.Value, colorDialog1.Color);
                Color color2            = Color.FromArgb((byte)numericUpDownAlpha2.Value, colorDialog2.Color);
                LinearGradientMode mode = (LinearGradientMode)comboBoxGradientBrushes.SelectedItem;
                brush = new My_LinearGradientBrush(color1, color2, mode, core.Form.ClientRectangle);
            }
            break;

            case BrushType.PathGradientBrush:
            {
                Color    color1 = Color.FromArgb((byte)numericUpDownAlpha1.Value, colorDialog1.Color);
                Color    color2 = Color.FromArgb((byte)numericUpDownAlpha2.Value, colorDialog2.Color);
                WrapMode w      = (WrapMode)comboBoxWrapMode.SelectedItem;
                brush = new My_PathGradientBrush(w, figure.Points, color1, color2);
            }
            break;

            case BrushType.TextureBrush:
            {
                string filename = textBoxFile.Text;
                if (string.IsNullOrEmpty(filename) == false)
                {
                    Image img = Image.FromFile(filename);
                    brush = new My_TextureBrush(img);
                }
            }
            break;
            }
            pictureBoxPreview.Invalidate();
        }