[2768] | 1 | using System;
|
---|
| 2 | using System.Drawing;
|
---|
[4068] | 3 | namespace Netron.Diagramming.Core {
|
---|
| 4 | /// <summary>
|
---|
| 5 | /// Abstract base class for shape materials
|
---|
| 6 | /// </summary>
|
---|
| 7 | public abstract partial class ShapeMaterialBase : IShapeMaterial {
|
---|
| 8 | #region Fields
|
---|
| 9 |
|
---|
| 10 | // ------------------------------------------------------------------
|
---|
[2768] | 11 | /// <summary>
|
---|
[4068] | 12 | /// Implementation of IVersion - the current version of
|
---|
| 13 | /// ShapeMaterialBase.
|
---|
[2768] | 14 | /// </summary>
|
---|
[4068] | 15 | // ------------------------------------------------------------------
|
---|
| 16 | protected double shapeMaterialBaseVersion = 1.0;
|
---|
[2768] | 17 |
|
---|
[4068] | 18 | // ------------------------------------------------------------------
|
---|
| 19 | /// <summary>
|
---|
| 20 | /// the Gliding field
|
---|
| 21 | /// </summary>
|
---|
| 22 | // ------------------------------------------------------------------
|
---|
| 23 | private bool mGliding = true;
|
---|
[2768] | 24 |
|
---|
[4068] | 25 | // ------------------------------------------------------------------
|
---|
| 26 | /// <summary>
|
---|
| 27 | /// the Resizable field
|
---|
| 28 | /// </summary>
|
---|
| 29 | // ------------------------------------------------------------------
|
---|
| 30 | private bool mResizable = true;
|
---|
[2768] | 31 |
|
---|
[4068] | 32 | // ------------------------------------------------------------------
|
---|
| 33 | /// <summary>
|
---|
| 34 | /// the Rectangle field
|
---|
| 35 | /// </summary>
|
---|
| 36 | // ------------------------------------------------------------------
|
---|
| 37 | private Rectangle mRectangle = Rectangle.Empty;
|
---|
[2768] | 38 |
|
---|
[4068] | 39 | // ------------------------------------------------------------------
|
---|
| 40 | /// <summary>
|
---|
| 41 | /// the Shape field
|
---|
| 42 | /// </summary>
|
---|
| 43 | // ------------------------------------------------------------------
|
---|
| 44 | private IShape mShape;
|
---|
[2768] | 45 |
|
---|
[4068] | 46 | // ------------------------------------------------------------------
|
---|
| 47 | /// <summary>
|
---|
| 48 | /// the Visible field
|
---|
| 49 | /// </summary>
|
---|
| 50 | // ------------------------------------------------------------------
|
---|
| 51 | private bool mVisible = true;
|
---|
[2768] | 52 |
|
---|
[4068] | 53 | protected ITextStyle myTextStyle = new TextStyle(
|
---|
| 54 | Color.Black,
|
---|
| 55 | new Font("Arial", 10),
|
---|
| 56 | StringAlignment.Near,
|
---|
| 57 | StringAlignment.Near);
|
---|
[2768] | 58 |
|
---|
[4068] | 59 | #endregion
|
---|
[2768] | 60 |
|
---|
[4068] | 61 | #region Properties
|
---|
[2768] | 62 |
|
---|
[4068] | 63 | // ------------------------------------------------------------------
|
---|
| 64 | /// <summary>
|
---|
| 65 | /// Gets the current version.
|
---|
| 66 | /// </summary>
|
---|
| 67 | // ------------------------------------------------------------------
|
---|
| 68 | public virtual double Version {
|
---|
| 69 | get {
|
---|
| 70 | return shapeMaterialBaseVersion;
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
[2768] | 73 |
|
---|
[4068] | 74 | // ------------------------------------------------------------------
|
---|
| 75 | /// <summary>
|
---|
| 76 | /// Gets or sets the TextStyle.
|
---|
| 77 | /// </summary>
|
---|
| 78 | // ------------------------------------------------------------------
|
---|
| 79 | public virtual ITextStyle TextStyle {
|
---|
| 80 | get {
|
---|
| 81 | return myTextStyle;
|
---|
| 82 | }
|
---|
| 83 | set {
|
---|
| 84 | myTextStyle = value;
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
[2768] | 87 |
|
---|
[4068] | 88 | // ------------------------------------------------------------------
|
---|
| 89 | /// <summary>
|
---|
| 90 | /// Gets or sets the Gliding
|
---|
| 91 | /// </summary>
|
---|
| 92 | // ------------------------------------------------------------------
|
---|
| 93 | public bool Gliding {
|
---|
| 94 | get { return mGliding; }
|
---|
| 95 | set { mGliding = value; }
|
---|
| 96 | }
|
---|
[2768] | 97 |
|
---|
[4068] | 98 | // ------------------------------------------------------------------
|
---|
| 99 | /// <summary>
|
---|
| 100 | /// Gets or sets the Resizable
|
---|
| 101 | /// </summary>
|
---|
| 102 | // ------------------------------------------------------------------
|
---|
| 103 | public bool Resizable {
|
---|
| 104 | get { return mResizable; }
|
---|
| 105 | set { mResizable = value; }
|
---|
| 106 | }
|
---|
[2768] | 107 |
|
---|
[4068] | 108 | // ------------------------------------------------------------------
|
---|
| 109 | /// <summary>
|
---|
| 110 | /// Gets or sets the Rectangle
|
---|
| 111 | /// </summary>
|
---|
| 112 | // ------------------------------------------------------------------
|
---|
| 113 | public virtual Rectangle Rectangle {
|
---|
| 114 | get { return mRectangle; }
|
---|
| 115 | internal set {
|
---|
| 116 | mRectangle = value;
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
[2768] | 119 |
|
---|
[4068] | 120 | // ------------------------------------------------------------------
|
---|
| 121 | /// <summary>
|
---|
| 122 | /// Gets or sets the Shape
|
---|
| 123 | /// </summary>
|
---|
| 124 | // ------------------------------------------------------------------
|
---|
| 125 | public virtual IShape Shape {
|
---|
| 126 | get { return mShape; }
|
---|
| 127 | set { mShape = value; }
|
---|
| 128 | }
|
---|
[2768] | 129 |
|
---|
[4068] | 130 | // ------------------------------------------------------------------
|
---|
| 131 | /// <summary>
|
---|
| 132 | /// Gets or sets if this material is visible.
|
---|
| 133 | /// </summary>
|
---|
| 134 | // ------------------------------------------------------------------
|
---|
| 135 | public bool Visible {
|
---|
| 136 | get { return mVisible; }
|
---|
| 137 | set { mVisible = value; }
|
---|
| 138 | }
|
---|
| 139 | #endregion
|
---|
[2768] | 140 |
|
---|
[4068] | 141 | #region Constructor
|
---|
| 142 | ///<summary>
|
---|
| 143 | ///Default constructor
|
---|
| 144 | ///</summary>
|
---|
| 145 | protected ShapeMaterialBase() {
|
---|
| 146 | }
|
---|
| 147 | #endregion
|
---|
[2768] | 148 |
|
---|
[4068] | 149 | #region Methods
|
---|
[2768] | 150 |
|
---|
[4068] | 151 | // ------------------------------------------------------------------
|
---|
| 152 | /// <summary>
|
---|
| 153 | /// Calculates the min size needed to fit this material in.
|
---|
| 154 | /// </summary>
|
---|
| 155 | /// <param name="g">Graphics</param>
|
---|
| 156 | /// <returns>Size</returns>
|
---|
| 157 | // ------------------------------------------------------------------
|
---|
| 158 | public abstract Size CalculateMinSize(Graphics g);
|
---|
[2768] | 159 |
|
---|
[4068] | 160 | /// <summary>
|
---|
| 161 | /// Transforms the specified rectangle.
|
---|
| 162 | /// </summary>
|
---|
| 163 | /// <param name="rectangle">The rectangle.</param>
|
---|
| 164 | public virtual void Transform(Rectangle rectangle) {
|
---|
| 165 | this.mRectangle = rectangle;
|
---|
| 166 | }
|
---|
[2768] | 167 |
|
---|
[4068] | 168 | /// <summary>
|
---|
| 169 | /// Paints the entity using the given graphics object
|
---|
| 170 | /// </summary>
|
---|
| 171 | /// <param name="g"></param>
|
---|
| 172 | public abstract void Paint(Graphics g);
|
---|
[2768] | 173 |
|
---|
| 174 |
|
---|
[4068] | 175 | /// <summary>
|
---|
| 176 | /// Gets the service object of the specified type.
|
---|
| 177 | /// </summary>
|
---|
| 178 | /// <param name="serviceType">An object that specifies the type of service object to get.</param>
|
---|
| 179 | /// <returns>
|
---|
| 180 | /// A service object of type serviceType.-or- null if there is no service object of type serviceType.
|
---|
| 181 | /// </returns>
|
---|
| 182 | public virtual object GetService(Type serviceType) {
|
---|
| 183 | return null;
|
---|
| 184 | }
|
---|
[2768] | 185 |
|
---|
[4068] | 186 | #endregion
|
---|
[2768] | 187 |
|
---|
[4068] | 188 | }
|
---|
[2768] | 189 | }
|
---|