root/plot/Pybrary.Plot/SymbolDescription.cs

Revision 746, 1.9 kB (checked in by mfenniak, 2 years ago)

--

Line 
1 using System;
2 using System.Drawing;
3
4 namespace Pybrary.Plot
5 {
6     public delegate void SymbolDescriptionChangedHandler();
7
8     public class SymbolDescription
9     {
10         public event SymbolDescriptionChangedHandler OnSymbolDescriptionChanged;
11
12         private SymbolType type;
13         private PenDescription foreground;
14         private BrushDescription background;
15         private float size;
16
17         public SymbolDescription(SymbolType type, PenDescription f, BrushDescription b, float size)
18         {
19             this.type = type;
20             this.foreground = f;
21             this.background = b;
22             this.size = size;
23
24             this.foreground.OnPenDescriptionChanged += delegate() { raiseChanged(); };
25             this.background.OnBrushDescriptionChanged += delegate() { raiseChanged(); };
26         }
27
28         public SymbolType Type
29         {
30             get
31             {
32                 return this.type;
33             }
34             set
35             {
36                 this.type = value;
37                 raiseChanged();
38             }
39         }
40
41         public PenDescription Foreground
42         {
43             get
44             {
45                 return foreground;
46             }
47         }
48
49         public BrushDescription Background
50         {
51             get
52             {
53                 return background;
54             }
55         }
56
57         public float Size
58         {
59             get
60             {
61                 return size;
62             }
63             set
64             {
65                 size = value;
66                 raiseChanged();
67             }
68         }
69
70         public Symbol CreateSymbol()
71         {
72             return SymbolFactory.CreateSymbol(type, foreground, background, size);
73         }
74
75         private void raiseChanged()
76         {
77             SymbolDescriptionChangedHandler tmp = OnSymbolDescriptionChanged;
78             if (tmp != null)
79                 tmp();
80         }   
81     }
82 }
Note: See TracBrowser for help on using the browser.