Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.6/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Core/Ambience.cs @ 13398

Last change on this file since 13398 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 12.5 KB
Line 
1using System;
2using System.Drawing;
3
4namespace Netron.Diagramming.Core {
5  /// <summary>
6  /// <para>
7  /// The ambient properties of the canvas (background style, default line
8  /// style etc) are collected in this class. The ambience class is part
9  /// of the model and is serialized together with the diagram.
10  /// </para>
11  /// </summary>
12  public partial class Ambience : IDisposable, IVersion {
13    #region Events
14    /// <summary>
15    /// Occurs when the Ambience has changed
16    /// </summary>
17    public event EventHandler<AmbienceEventArgs> OnAmbienceChanged;
18    #endregion
19
20    #region Fields
21
22    // ------------------------------------------------------------------
23    /// <summary>
24    /// Implementation of IVersion - the current version of
25    /// Ambience.
26    /// </summary>
27    // ------------------------------------------------------------------
28    protected const double ambienceVersion = 1.0;
29
30    // ------------------------------------------------------------------
31    /// <summary>
32    /// pointer to the model
33    /// </summary>
34    // ------------------------------------------------------------------
35    private IModel mModel;
36
37    // ------------------------------------------------------------------
38    /// <summary>
39    /// the background type
40    /// </summary>
41    // ------------------------------------------------------------------
42    private CanvasBackgroundTypes mBackgroundType;
43
44    // ------------------------------------------------------------------
45    /// <summary>
46    /// the GradientColor1 field
47    /// </summary>
48    // ------------------------------------------------------------------
49    private Color mGradientColor1;
50
51    /// <summary>
52    /// the GradientColor2 field
53    /// </summary>
54    private Color mGradientColor2;
55
56    // ------------------------------------------------------------------
57    /// <summary>
58    /// the BackgroundColor field
59    /// </summary>
60    // ------------------------------------------------------------------
61    private Color mBackgroundColor;
62
63    // ------------------------------------------------------------------
64    /// <summary>
65    /// The color of the page.
66    /// </summary>
67    // ------------------------------------------------------------------
68    private Color mPageColor;
69
70    // ------------------------------------------------------------------
71    /// <summary>
72    /// The starting gradient color for the page.
73    /// </summary>
74    // ------------------------------------------------------------------
75    private Color mPageGradientColor1;
76
77    // ------------------------------------------------------------------
78    /// <summary>
79    /// The ending gradient color for the page.
80    /// </summary>
81    // ------------------------------------------------------------------
82    private Color mPageGradientColor2;
83
84    // ------------------------------------------------------------------
85    /// <summary>
86    /// The background type of the page.
87    /// </summary>
88    // ------------------------------------------------------------------
89    private CanvasBackgroundTypes mPageBackgroundType =
90        CanvasBackgroundTypes.FlatColor;
91
92    // ------------------------------------------------------------------
93    /// <summary>
94    /// Specifies if the page is rendered in landscape orientation.
95    /// </summary>
96    // ------------------------------------------------------------------
97    private bool mLandscape = true;
98
99    // ------------------------------------------------------------------
100    /// <summary>
101    /// The size of the page in mils (thousandths of an inch).
102    /// </summary>
103    // ------------------------------------------------------------------
104    private Size mPageSize = new Size(8500, 11000);
105
106    // ------------------------------------------------------------------
107    /// <summary>
108    /// The title of the page.
109    /// </summary>
110    // ------------------------------------------------------------------
111    private string mTitle = "Default page: no title.";
112
113    // ------------------------------------------------------------------
114    /// <summary>
115    /// the Page field
116    /// </summary>
117    // ------------------------------------------------------------------
118    private IPage mPage;
119
120    #endregion
121
122    #region Properties
123
124    // ------------------------------------------------------------------
125    /// <summary>
126    /// Gets the current version.
127    /// </summary>
128    // ------------------------------------------------------------------
129    public virtual double Version {
130      get {
131        return ambienceVersion;
132      }
133    }
134
135    // ------------------------------------------------------------------
136    /// <summary>
137    /// Gets or sets the title of the page.
138    /// </summary>
139    /// <value>The title.</value>
140    // ------------------------------------------------------------------
141    public string Title {
142      get { return mTitle; }
143      set { mTitle = value; }
144    }
145
146    // ------------------------------------------------------------------
147    /// <summary>
148    /// Gets or sets the size of the page in mils (thousandths of an inch). 
149    /// The default is letter 8.5" x 11".
150    /// </summary>
151    /// <value>The size of the page.</value>
152    // ------------------------------------------------------------------
153    public Size PageSize {
154      get { return mPageSize; }
155      set { mPageSize = value; }
156    }
157
158    // ------------------------------------------------------------------
159    /// <summary>
160    /// Gets or sets the Page to which this ambience belongs
161    /// </summary>
162    // ------------------------------------------------------------------
163    public IPage Page {
164      get {
165        return mPage;
166      }
167      set {
168        mPage = value;
169      }
170    }
171
172    // ------------------------------------------------------------------
173    /// <summary>
174    /// Gets or sets if the page is rendered and printed in landscape
175    /// orientation.
176    /// </summary>
177    // ------------------------------------------------------------------
178    public bool Landscape {
179      get {
180        return mLandscape;
181      }
182      set {
183        mLandscape = value;
184      }
185    }
186
187    // ------------------------------------------------------------------
188    /// <summary>
189    /// Gets or sets the type of the background.
190    /// </summary>
191    /// <value>The type of the background.</value>
192    // ------------------------------------------------------------------
193    public CanvasBackgroundTypes BackgroundType {
194      get { return this.mBackgroundType; }
195      set {
196        this.mBackgroundType = value;
197        RaiseOnAmbienceChanged();
198      }
199    }
200
201    // ------------------------------------------------------------------
202    /// <summary>
203    /// Gets or sets the type of the background for the page portion.
204    /// </summary>
205    /// <value>The type of the background.</value>
206    // ------------------------------------------------------------------
207    public CanvasBackgroundTypes PageBackgroundType {
208      get { return this.mPageBackgroundType; }
209      set {
210        this.mPageBackgroundType = value;
211        RaiseOnAmbienceChanged();
212      }
213    }
214
215    // ------------------------------------------------------------------
216    /// <summary>
217    /// Gets or sets the first gradient color for the background.
218    /// </summary>
219    /// <value>The first gradient color.</value>
220    // ------------------------------------------------------------------
221    public Color BackgroundGradientColor1 {
222      get { return mGradientColor1; }
223      set {
224        mGradientColor1 = value;
225        RaiseOnAmbienceChanged();
226      }
227    }
228
229    // ------------------------------------------------------------------
230    /// <summary>
231    /// Gets or sets the second gradient color
232    /// </summary>
233    /// <value>The second gradient color.</value>
234    // ------------------------------------------------------------------
235    public Color BackgroundGradientColor2 {
236      get { return mGradientColor2; }
237      set {
238        mGradientColor2 = value;
239        RaiseOnAmbienceChanged();
240      }
241    }
242
243    // ------------------------------------------------------------------
244    /// <summary>
245    /// Gets or sets the BackgroundColor
246    /// </summary>
247    /// <value>The color of the background.</value>
248    // ------------------------------------------------------------------
249    public Color BackgroundColor {
250      get { return mBackgroundColor; }
251      set {
252        mBackgroundColor = value;
253        //notify the world that things have changed
254        RaiseOnAmbienceChanged();
255
256      }
257    }
258
259    // ------------------------------------------------------------------
260    /// <summary>
261    /// Gets or sets the first gradient color for the background.
262    /// </summary>
263    /// <value>The first gradient color.</value>
264    // ------------------------------------------------------------------
265    public Color PageGradientColor1 {
266      get { return mPageGradientColor1; }
267      set {
268        mPageGradientColor1 = value;
269        RaiseOnAmbienceChanged();
270      }
271    }
272
273    // ------------------------------------------------------------------
274    /// <summary>
275    /// Gets or sets the second gradient color
276    /// </summary>
277    /// <value>The second gradient color.</value>
278    // ------------------------------------------------------------------
279    public Color PageGradientColor2 {
280      get { return mPageGradientColor2; }
281      set {
282        mPageGradientColor2 = value;
283        RaiseOnAmbienceChanged();
284      }
285    }
286
287    // ------------------------------------------------------------------
288    /// <summary>
289    /// Gets or sets the BackgroundColor
290    /// </summary>
291    /// <value>The color of the background.</value>
292    // ------------------------------------------------------------------
293    public Color PageColor {
294      get { return mPageColor; }
295      set {
296        mPageColor = value;
297        //notify the world that things have changed
298        RaiseOnAmbienceChanged();
299
300      }
301    }
302
303    // ------------------------------------------------------------------
304    /// <summary>
305    /// Gets the model.
306    /// </summary>
307    /// <value>The model.</value>
308    // ------------------------------------------------------------------
309    public IModel Model {
310      get {
311        return mModel;
312      }
313      internal set {
314        mModel = value;
315      }
316    }
317
318    #endregion
319
320    #region Constructor
321
322    // ------------------------------------------------------------------
323    /// <summary>
324    /// Default constructor
325    /// </summary>
326    /// <param name="page">The page.</param>
327    // ------------------------------------------------------------------
328    public Ambience(IPage page) {
329      if (page == null)
330        throw new ArgumentNullException(
331            "The page paramter cannot be 'null'");
332      if (page.Model == null)
333        throw new ArgumentNullException("The Model is 'null'");
334
335      //set default ambience
336      //mBackgroundColor = Color.FromArgb(116, 118, 124);
337      mBackgroundColor = ArtPalette.DefaultPageBackgroundColor;
338      mBackgroundType = CanvasBackgroundTypes.FlatColor;
339      mGradientColor1 = Color.WhiteSmoke;
340      mGradientColor2 = Color.LightSlateGray;
341      mPageBackgroundType = CanvasBackgroundTypes.FlatColor;
342      mPageColor = ArtPalette.DefaultPageColor;
343      mPageGradientColor1 = Color.WhiteSmoke;
344      mPageGradientColor2 = Color.Silver;
345      mModel = page.Model;
346    }
347
348    #endregion
349
350    #region Methods
351
352    /// <summary>
353    /// Raises the <see cref="OnAmbienceChanged"/> event
354    /// </summary>
355    protected virtual void RaiseOnAmbienceChanged() {
356      EventHandler<AmbienceEventArgs> handler = OnAmbienceChanged;
357      if (handler != null) {
358        handler(this, new AmbienceEventArgs(this));
359      }
360    }
361
362    #endregion
363
364    #region Standard IDispose implementation
365    /// <summary>
366    /// Disposes the view
367    /// </summary>
368    public void Dispose() {
369      Dispose(true);
370      GC.SuppressFinalize(this);
371
372
373    }
374    /// <summary>
375    /// Part of the dispose implementation
376    /// </summary>
377    /// <param name="disposing">if set to <c>true</c> disposing.</param>
378    protected virtual void Dispose(bool disposing) {
379      if (disposing) {
380        #region free managed resources
381
382        #endregion
383      }
384
385    }
386
387    #endregion
388  }
389}
Note: See TracBrowser for help on using the repository browser.