Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Utils/Styling/SolidPaintStyle.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Utils/Styling/SolidPaintStyle.cs
r2768 r4068 1 using System;2 using System.Collections.Generic;3 using System.Text;4 1 using System.Drawing; 5 using System.Drawing.Drawing2D;6 2 7 namespace Netron.Diagramming.Core 8 { 9 // ---------------------------------------------------------------------- 3 namespace Netron.Diagramming.Core { 4 // ---------------------------------------------------------------------- 5 /// <summary> 6 /// The solid paint style. 7 /// </summary> 8 // ---------------------------------------------------------------------- 9 public partial class SolidPaintStyle : IPaintStyle, IVersion { 10 // ------------------------------------------------------------------ 10 11 /// <summary> 11 /// The solid paint style.12 /// Event raised when this paint style is changed. 12 13 /// </summary> 13 // ---------------------------------------------------------------------- 14 public partial class SolidPaintStyle : IPaintStyle, IVersion 15 { 16 // ------------------------------------------------------------------ 17 /// <summary> 18 /// Event raised when this paint style is changed. 19 /// </summary> 20 // ------------------------------------------------------------------ 21 public event PaintStyleChangedEventHandler PaintStyleChanged; 14 // ------------------------------------------------------------------ 15 public event PaintStyleChangedEventHandler PaintStyleChanged; 22 16 23 17 #region Fields 24 18 25 26 27 28 29 30 31 19 // ------------------------------------------------------------------ 20 /// <summary> 21 /// Implementation of IVersion - the current version of 22 /// SolidPaintStyle. 23 /// </summary> 24 // ------------------------------------------------------------------ 25 protected const double solidPaintStyleVersion = 1.0; 32 26 33 34 35 36 37 38 27 // ------------------------------------------------------------------ 28 /// <summary> 29 /// the SolidColor field 30 /// </summary> 31 // ------------------------------------------------------------------ 32 private Color mSolidColor; 39 33 40 41 42 43 44 45 34 // ------------------------------------------------------------------ 35 /// <summary> 36 /// the Alpha field 37 /// </summary> 38 // ------------------------------------------------------------------ 39 private int mAlpha = 255; 46 40 47 41 #endregion 48 42 49 43 #region Properties 50 44 51 // ------------------------------------------------------------------ 52 /// <summary> 53 /// Gets the current version. 54 /// </summary> 55 // ------------------------------------------------------------------ 56 public virtual double Version 57 { 58 get 59 { 60 return solidPaintStyleVersion; 61 } 62 } 45 // ------------------------------------------------------------------ 46 /// <summary> 47 /// Gets the current version. 48 /// </summary> 49 // ------------------------------------------------------------------ 50 public virtual double Version { 51 get { 52 return solidPaintStyleVersion; 53 } 54 } 63 55 64 // ------------------------------------------------------------------ 65 /// <summary> 66 /// Gets or sets the SolidColor 67 /// </summary> 68 // ------------------------------------------------------------------ 69 public Color SolidColor 70 { 71 get 72 { 73 return mSolidColor; 74 } 75 set 76 { 77 mSolidColor = value; 78 RaisePaintStyleChanged(); 79 } 80 } 56 // ------------------------------------------------------------------ 57 /// <summary> 58 /// Gets or sets the SolidColor 59 /// </summary> 60 // ------------------------------------------------------------------ 61 public Color SolidColor { 62 get { 63 return mSolidColor; 64 } 65 set { 66 mSolidColor = value; 67 RaisePaintStyleChanged(); 68 } 69 } 81 70 82 // ------------------------------------------------------------------ 83 /// <summary> 84 /// Gets or sets the Alpha 85 /// </summary> 86 // ------------------------------------------------------------------ 87 public int Alpha 88 { 89 get 90 { 91 return mAlpha; 92 } 93 set 94 { 95 mAlpha = value; 96 RaisePaintStyleChanged(); 97 } 98 } 71 // ------------------------------------------------------------------ 72 /// <summary> 73 /// Gets or sets the Alpha 74 /// </summary> 75 // ------------------------------------------------------------------ 76 public int Alpha { 77 get { 78 return mAlpha; 79 } 80 set { 81 mAlpha = value; 82 RaisePaintStyleChanged(); 83 } 84 } 99 85 100 86 #endregion 101 87 102 88 #region Constructor 103 89 104 // ------------------------------------------------------------------ 105 ///<summary> 106 ///Default constructor. 107 ///</summary> 108 // ------------------------------------------------------------------ 109 public SolidPaintStyle(Color color) 110 { 111 mSolidColor = color; 112 } 90 // ------------------------------------------------------------------ 91 ///<summary> 92 ///Default constructor. 93 ///</summary> 94 // ------------------------------------------------------------------ 95 public SolidPaintStyle(Color color) { 96 mSolidColor = color; 97 } 113 98 114 // ------------------------------------------------------------------ 115 /// <summary> 116 /// Initializes a new instance of the 117 /// <see cref="T:SolidPaintStyle"/> class. 118 /// </summary> 119 // ------------------------------------------------------------------ 120 public SolidPaintStyle() 121 { 122 mSolidColor = ArtPalette.RandomLowSaturationColor; 123 } 99 // ------------------------------------------------------------------ 100 /// <summary> 101 /// Initializes a new instance of the 102 /// <see cref="T:SolidPaintStyle"/> class. 103 /// </summary> 104 // ------------------------------------------------------------------ 105 public SolidPaintStyle() { 106 mSolidColor = ArtPalette.RandomLowSaturationColor; 107 } 124 108 125 109 #endregion 126 110 127 // ------------------------------------------------------------------ 128 /// <summary> 129 /// Gets the brush with which an entity can fe painted. 130 /// </summary> 131 /// <param name="rectangle">Rectangle: The rectangle.</param> 132 /// <returns>Brush</returns> 133 // ------------------------------------------------------------------ 134 public Brush GetBrush(Rectangle rectangle) 135 { 136 return new SolidBrush(Color.FromArgb(mAlpha, mSolidColor)); 137 } 111 // ------------------------------------------------------------------ 112 /// <summary> 113 /// Gets the brush with which an entity can fe painted. 114 /// </summary> 115 /// <param name="rectangle">Rectangle: The rectangle.</param> 116 /// <returns>Brush</returns> 117 // ------------------------------------------------------------------ 118 public Brush GetBrush(Rectangle rectangle) { 119 return new SolidBrush(Color.FromArgb(mAlpha, mSolidColor)); 120 } 138 121 139 // ------------------------------------------------------------------ 140 /// <summary> 141 /// Raises the PaintStyleChanged event. 142 /// </summary> 143 // ------------------------------------------------------------------ 144 protected virtual void RaisePaintStyleChanged() 145 { 146 if (this.PaintStyleChanged != null) 147 { 148 // Raise the event 149 this.PaintStyleChanged( 150 this, 151 new PaintStyleChangedEventArgs(this, FillType.Solid)); 152 } 153 } 122 // ------------------------------------------------------------------ 123 /// <summary> 124 /// Raises the PaintStyleChanged event. 125 /// </summary> 126 // ------------------------------------------------------------------ 127 protected virtual void RaisePaintStyleChanged() { 128 if (this.PaintStyleChanged != null) { 129 // Raise the event 130 this.PaintStyleChanged( 131 this, 132 new PaintStyleChangedEventArgs(this, FillType.Solid)); 133 } 154 134 } 135 } 155 136 }
Note: See TracChangeset
for help on using the changeset viewer.