public static DrawingImage GetImage(LinearGradientShape val)
        {
            double height = 1;
            double width  = 2;

            //
            // Create the Geometry to draw.
            //
            var geometryGroup = new GeometryGroup();

            geometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, width, height)));

            var geometryDrawing = new GeometryDrawing()
            {
                Geometry = geometryGroup
            };

            switch (val)
            {
            case LinearGradientShape.Linear:
                geometryDrawing.Brush = new System.Windows.Media.LinearGradientBrush(Colors.Black, Colors.White, 0);
                break;

            case LinearGradientShape.SigmaBell:
            {
                var gradStop = new GradientStopCollection
                {
                    new GradientStop(Colors.Black, 0),
                    new GradientStop(Colors.Gray, 0.1),
                    new GradientStop(Colors.White, 0.5),
                    new GradientStop(Colors.Gray, 0.9),
                    new GradientStop(Colors.Black, 1)
                };
                geometryDrawing.Brush = new System.Windows.Media.LinearGradientBrush(gradStop, 0);
            }
            break;

            case LinearGradientShape.Triangular:
            {
                var gradStop = new GradientStopCollection
                {
                    new GradientStop(Colors.Black, 0),
                    new GradientStop(Colors.White, 0.5),
                    new GradientStop(Colors.Black, 1)
                };
                geometryDrawing.Brush = new System.Windows.Media.LinearGradientBrush(gradStop, 0);
            }
            break;

            default:
                break;
            }

            var geometryImage = new DrawingImage(geometryDrawing);

            // Freeze the DrawingImage for performance benefits.
            geometryImage.Freeze();
            return(geometryImage);
        }
    void SetDataSource(LinearGradientShape selected)
    {
      this.BeginUpdate();

      Items.Clear();
      foreach (LinearGradientShape o in Enum.GetValues(typeof(LinearGradientShape)))
        Items.Add(o);

      SelectedItem = selected;

      this.EndUpdate();
    }
示例#3
0
        void SetDataSource(LinearGradientShape selected)
        {
            this.BeginUpdate();

            Items.Clear();
            foreach (LinearGradientShape o in Enum.GetValues(typeof(LinearGradientShape)))
            {
                Items.Add(o);
            }

            SelectedItem = selected;

            this.EndUpdate();
        }
示例#4
0
 public BrushX(BrushX from)
 {
     _brushType              = from._brushType;                                                            // Type of the brush
     _cachedBrush            = null;                                                                       // this is the cached brush object
     _foreColor              = from._foreColor;                                                            // Color of the brush
     _backColor              = from._backColor;                                                            // Backcolor of brush, f.i.f. HatchStyle brushes
     _hatchStyle             = from._hatchStyle;                                                           // für HatchBrush
     _textureImage           = null == from._textureImage ? null : (ImageProxy)from._textureImage.Clone(); // für Texturebrush
     _wrapMode               = from._wrapMode;                                                             // für TextureBrush und LinearGradientBrush
     _brushBoundingRectangle = from._brushBoundingRectangle;
     _focus              = from._focus;
     _exchangeColors     = from._exchangeColors;
     this._gradientMode  = from._gradientMode;
     this._gradientShape = from._gradientShape;
     this._scale         = from._scale;
 }
示例#5
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics  grfx      = e.Graphics;
            Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);

            rectColor.Inflate(-1, -1);

            Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
                                               e.Bounds.Top,
                                               e.Bounds.Width - 2 * e.Bounds.Height,
                                               e.Bounds.Height);

            if (this.Enabled)
            {
                e.DrawBackground();
            }

            LinearGradientShape item = e.Index >= 0 ? (LinearGradientShape)Items[e.Index] : LinearGradientShape.Linear;

            Rectangle rectShape = new Rectangle(rectColor.X + rectColor.Width / 4, rectColor.Y, rectColor.Width / 2, rectColor.Height);

            using (LinearGradientBrush br = new LinearGradientBrush(rectShape, e.ForeColor, e.BackColor, LinearGradientMode.Horizontal))
            {
                if (item == LinearGradientShape.Triangular)
                {
                    br.SetBlendTriangularShape(0.5f);
                }
                else if (item == LinearGradientShape.SigmaBell)
                {
                    br.SetSigmaBellShape(0.5f);
                }

                grfx.FillRectangle(br, rectColor);
            }
            SolidBrush foreColorBrush = new SolidBrush(e.ForeColor);

            grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText);
        }
 public LinearGradientShapeComboBox(LinearGradientShape selected)
   : this()
 {
   SetDataSource(selected);
 }
示例#7
0
 public LinearGradientShapeComboBox(LinearGradientShape selected)
     : this()
 {
     SetDataSource(selected);
 }
		public static DrawingImage GetImage(LinearGradientShape val)
		{
			double height = 1;
			double width = 2;

			//
			// Create the Geometry to draw.
			//
			GeometryGroup geometryGroup = new GeometryGroup();
			geometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, width, height)));

			var geometryDrawing = new GeometryDrawing() { Geometry = geometryGroup };

			switch (val)
			{
				case LinearGradientShape.Linear:
					geometryDrawing.Brush = new System.Windows.Media.LinearGradientBrush(Colors.Black, Colors.White, 0);
					break;

				case LinearGradientShape.SigmaBell:
					{
						var gradStop = new GradientStopCollection();
						gradStop.Add(new GradientStop(Colors.Black, 0));
						gradStop.Add(new GradientStop(Colors.Gray, 0.1));
						gradStop.Add(new GradientStop(Colors.White, 0.5));
						gradStop.Add(new GradientStop(Colors.Gray, 0.9));
						gradStop.Add(new GradientStop(Colors.Black, 1));
						geometryDrawing.Brush = new System.Windows.Media.LinearGradientBrush(gradStop, 0);
					}
					break;

				case LinearGradientShape.Triangular:
					{
						var gradStop = new GradientStopCollection();
						gradStop.Add(new GradientStop(Colors.Black, 0));
						gradStop.Add(new GradientStop(Colors.White, 0.5));
						gradStop.Add(new GradientStop(Colors.Black, 1));
						geometryDrawing.Brush = new System.Windows.Media.LinearGradientBrush(gradStop, 0);
					}
					break;

				default:
					break;
			}

			DrawingImage geometryImage = new DrawingImage(geometryDrawing);

			// Freeze the DrawingImage for performance benefits.
			geometryImage.Freeze();
			return geometryImage;
		}
示例#9
0
 public BrushX(BrushX from)
 {
   _brushType = from._brushType; // Type of the brush
   _cachedBrush = null;      // this is the cached brush object
   _foreColor = from._foreColor; // Color of the brush
   _backColor = from._backColor; // Backcolor of brush, f.i.f. HatchStyle brushes
   _hatchStyle = from._hatchStyle; // für HatchBrush
   _textureImage = null == from._textureImage ? null : (ImageProxy)from._textureImage.Clone(); // für Texturebrush
   _wrapMode = from._wrapMode; // für TextureBrush und LinearGradientBrush
   _brushBoundingRectangle = from._brushBoundingRectangle;
   _focus = from._focus;
   _exchangeColors = from._exchangeColors;
   this._gradientMode = from._gradientMode;
   this._gradientShape = from._gradientShape;
   this._scale = from._scale;
 }