├── .gitignore
├── Controller
└── FlowChartController.cs
├── Entities
├── FlowChartComponent.cs
├── FlowChartContainer.cs
├── FlowChartPoint.cs
├── FlowChartPointConverter.cs
├── FlowChartReference.cs
└── MouseState.cs
├── Factory
└── ViewAbstractFactory.cs
├── FlowChart.csproj
├── FlowChart.sln
├── FlowChart.suo
├── FormMain.Designer.cs
├── FormMain.cs
├── FormMain.resx
├── LICENSE
├── Models
├── BaseBoxComponent.cs
├── BaseComponent.cs
├── BaseLineComponent.cs
├── CurvedLineComponent.cs
├── DatabaseComponent.cs
├── FlowChartModel.cs
├── LineComponent.cs
├── PointF.cs
├── RectangleComponent.cs
├── RhombusComponent.cs
└── RoundComponent.cs
├── Persistance
├── BaseStorage.cs
├── FileStorage.cs
├── ImageStorage.cs
└── MemoryStorage.cs
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── DataSources
│ └── FlowChart.Entities.FlowChartContainer.datasource
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── README.md
├── Tools
├── BaseInputTool.cs
└── DefaultInputTool.cs
├── Utility
├── GraphicsSettings.cs
├── GraphicsUtil.cs
└── Util.cs
├── Views
├── BaseBoxView.cs
├── BaseLineView.cs
├── BaseView.cs
├── CurvedLineView.cs
├── DatabaseView.cs
├── Default
│ ├── CurvedLineView.cs
│ ├── DatabaseView.cs
│ ├── DefaultViewFactory.cs
│ ├── RectangleView.cs
│ ├── RhombusView.cs
│ ├── RoundView.cs
│ └── StraightLineView.cs
├── FlowChartPage.Designer.cs
├── FlowChartPage.cs
├── FlowChartPage.resx
├── Grey
│ ├── CurvedLineView.cs
│ ├── DatabaseView.cs
│ ├── GreyViewFactory.cs
│ ├── RectangleView.cs
│ ├── RhombusView.cs
│ ├── RoundView.cs
│ └── StraightLineView.cs
├── RectangleView.cs
├── RhombusView.cs
├── RoundView.cs
└── StraightLineView.cs
└── Visitors
├── BaseVisitor.cs
├── BoxMoveVisitor.cs
├── LinePointMovedVisitor.cs
├── ObjectCreateVisitor.cs
├── ObjectModifyVisitor.cs
└── ViewDirectorVisitor.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | /.vs/**/*
6 | /bin/**/*
7 | /obj/**/*
8 |
--------------------------------------------------------------------------------
/Controller/FlowChartController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Models;
6 | using FlowChart.Entities;
7 | using FlowChart.Utility;
8 | using System.IO;
9 | using FlowChart.Views;
10 | using FlowChart.Visitors;
11 | using System.Drawing;
12 | using FlowChart.Tools;
13 | using FlowChart.Persistance;
14 | using FlowChart.Factory;
15 |
16 | namespace FlowChart.Controller
17 | {
18 | public class FlowChartController
19 | {
20 | ///
21 | ///
22 | ///
23 | public event Action Resize;
24 | ///
25 | /// On Flow Chart Component Selected
26 | ///
27 | public event Action Selected;
28 | ///
29 | /// On Flow Chart Component Moved
30 | ///
31 | public event Action Changed;
32 | ///
33 | ///
34 | ///
35 | public event Action OnFlowChartChange;
36 | private bool isReseting;
37 |
38 |
39 | ///
40 | ///
41 | ///
42 | public FlowChartModel Model
43 | {
44 | get;
45 | private set;
46 | }
47 |
48 | private BaseComponent selectedComponent;
49 | internal BaseComponent SelectedComponent
50 | {
51 | get
52 | {
53 | return selectedComponent;
54 | }
55 | set
56 | {
57 | this.inputTool.SelectedComponent = value;
58 | this.view.SelectedComponent = value;
59 |
60 | if (value == this.selectedComponent)
61 | {
62 | return;
63 | }
64 |
65 | if (this.selectedComponent != null)
66 | {
67 | this.selectedComponent.IsSelected = false;
68 | }
69 |
70 | this.selectedComponent = value;
71 |
72 | if (selectedComponent != null)
73 | {
74 | selectedComponent.IsSelected = true;
75 | }
76 |
77 | if (this.Selected != null)
78 | {
79 | this.Selected(selectedComponent);
80 | }
81 | this.view.Invalidate();
82 | }
83 | }
84 |
85 |
86 | private float zoomFactor = 1.0f;
87 | internal float ZoomFactor
88 | {
89 | get
90 | {
91 | return zoomFactor;
92 | }
93 | set
94 | {
95 | if (value > 0.1 && value < 8)
96 | {
97 | zoomFactor = value;
98 | this.inputTool.ZoomFactor = zoomFactor;
99 | this.view.ZoomFactor = zoomFactor;
100 | }
101 | }
102 | }
103 |
104 | private FlowChartPage view;
105 | private DefaultInputTool inputTool;
106 | private MemoryStorage memoryStorage;
107 |
108 | private ViewAbstractFactory viewFactory;
109 | public ViewAbstractFactory ViewFactory
110 | {
111 | get
112 | {
113 | return viewFactory;
114 | }
115 | set
116 | {
117 | viewFactory = value;
118 | if (this.Model != null)
119 | {
120 | this.Model.Items.FindAll(x => x.View != null).ForEach(x => x.View.ViewFactory = viewFactory);
121 | }
122 | }
123 | }
124 |
125 | public FlowChartController(FlowChartPage view, ViewAbstractFactory viewFactory)
126 | {
127 | this.view = view;
128 | this.ViewFactory = viewFactory;
129 | this.Model = new FlowChartModel();
130 | this.inputTool = new DefaultInputTool(Model, view);
131 | this.view.Model = Model;
132 | this.memoryStorage = new MemoryStorage();
133 |
134 | this.inputTool.Add += new Action(inputTool_Add);
135 | this.inputTool.DblClick += new Action(inputTool_DblClick);
136 | this.inputTool.Delete += new Action(inputTool_Delete);
137 | this.inputTool.Scroll += new Action(inputTool_Scroll);
138 | this.inputTool.Zoom += new Action(inputTool_Zoom);
139 | this.inputTool.Select += new Action(inputTool_Select);
140 |
141 | this.ZoomFactor = 1.0f;
142 | }
143 |
144 | #region Input Handler
145 |
146 | internal void ResetView(float maxTop, float minTop, float maxLeft, float minLeft)
147 | {
148 | inputTool.ResetView(maxTop, minTop, maxLeft, minLeft);
149 | }
150 |
151 | void inputTool_Select(BaseComponent obj)
152 | {
153 | this.SelectedComponent = obj;
154 | }
155 |
156 | void inputTool_Zoom(float f, float x, float y)
157 | {
158 | this.ZoomFactor *= f;
159 | }
160 |
161 | void inputTool_Scroll(float delta, float x, float y)
162 | {
163 |
164 | }
165 |
166 | void inputTool_Delete(BaseComponent obj)
167 | {
168 | RemoveComponent(SelectedComponent);
169 | SelectedComponent = null;
170 | }
171 |
172 | void inputTool_DblClick(float arg1, float arg2)
173 | {
174 | this.view.ShowTextEditor(this.SelectedComponent);
175 | }
176 |
177 | void inputTool_Add(BaseComponent cmp)
178 | {
179 | Add(cmp);
180 | SelectedComponent = cmp;
181 | }
182 | #endregion
183 |
184 | internal void Component_Change(BaseComponent obj)
185 | {
186 | if (this.Changed != null)
187 | {
188 | this.Changed(obj);
189 | }
190 | CommitChange();
191 | this.view.Invalidate();
192 | }
193 |
194 | internal void Add(BaseComponent component)
195 | {
196 | component.Accept(new ObjectModifyVisitor(this.Model));
197 | component.Accept(new ViewDirectorVisitor(ViewFactory, this.view.Font));
198 | component.Init();
199 | this.Model.Items.Add(component);
200 | this.Model.Items = this.Model.Items.OrderBy(x => x.SortOrder).ToList();
201 | this.view.Invalidate();
202 | component.Changed += new Action(Component_Change);
203 | this.SelectedComponent = component;
204 | CommitChange();
205 | }
206 |
207 | internal void RemoveComponent(BaseComponent component)
208 | {
209 | this.Model.Items.Remove(component);
210 | CommitChange();
211 | }
212 |
213 | #region Persist FlowChart
214 |
215 | internal void Load(FlowChartContainer container)
216 | {
217 | this.isReseting = true;
218 | this.SelectedComponent = null;
219 | this.Model.Items.Clear();
220 |
221 | container.Items.ForEach(x => {
222 | BaseComponent c = (BaseComponent)Activator.CreateInstance(Type.GetType(x.Type));
223 | c.SetComponent(x);
224 | this.Add(c);
225 | });
226 |
227 | container.Items.ForEach(x =>
228 | {
229 | BaseComponent c = this.Model.Items.Find(y => y.ID == x.ID);
230 | c.Accept(new ObjectCreateVisitor(Model, x));
231 | });
232 |
233 | this.view.Invalidate();
234 | this.isReseting = false;
235 | }
236 |
237 | private void CommitChange()
238 | {
239 | if (!isReseting)
240 | {
241 | memoryStorage.Save(Model);
242 | if (this.OnFlowChartChange != null)
243 | {
244 | this.OnFlowChartChange();
245 | }
246 | }
247 | }
248 | #endregion
249 |
250 | internal void PropertyChanged()
251 | {
252 | if (this.SelectedComponent != null)
253 | {
254 | this.SelectedComponent.IsSelected = false;
255 | CommitChange();
256 | }
257 | }
258 |
259 | internal List GetUndoBuffers()
260 | {
261 | return memoryStorage.GetUndoBuffers();
262 | }
263 | }
264 | }
265 |
--------------------------------------------------------------------------------
/Entities/FlowChartComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace FlowChart.Entities
7 | {
8 | public class FlowChartComponent
9 | {
10 | public string ID { get; set; }
11 | public string Type { get; set; }
12 | public string Text { get; set; }
13 | public List ConnectionIds { get; set; }
14 | public List Points { get; set; }
15 | public FlowChartComponent()
16 | {
17 | this.Points = new List();
18 | this.ConnectionIds = new List();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Entities/FlowChartContainer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace FlowChart.Entities
7 | {
8 | public class FlowChartContainer
9 | {
10 | public string DisplayName { get; set; }
11 | public List Items { get; set; }
12 | public FlowChartContainer()
13 | {
14 | Items = new List();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Entities/FlowChartPoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 |
7 | namespace FlowChart.Entities
8 | {
9 | public class FlowChartPoint
10 | {
11 | private float x;
12 | private float y;
13 | public event Action OnChange;
14 | public float X
15 | {
16 | get
17 | {
18 | return x;
19 | }
20 | set
21 | {
22 | float old = x;
23 | x = value;
24 | if (OnChange != null)
25 | {
26 | OnChange(old, Y);
27 | }
28 | }
29 | }
30 | public float Y
31 | {
32 | get
33 | {
34 | return y;
35 | }
36 | set
37 | {
38 | float old = y;
39 | y = value;
40 | if (OnChange != null)
41 | {
42 | OnChange(X,old);
43 | }
44 | }
45 | }
46 | public FlowChartPoint()
47 | {
48 | }
49 | public FlowChartPoint(float x, float y)
50 | {
51 | this.X = x;
52 | this.Y = y;
53 | }
54 |
55 | public FlowChartPoint Add(FlowChartPoint another)
56 | {
57 | this.X += another.X;
58 | this.Y += another.Y;
59 | return this;
60 | }
61 |
62 | public FlowChartPoint Subtract(FlowChartPoint another)
63 | {
64 | this.X -= another.X;
65 | this.Y -= another.Y;
66 | return this;
67 | }
68 |
69 | public FlowChartPoint CloneAndSubtract(FlowChartPoint another)
70 | {
71 | return new FlowChartPoint(X - another.X, Y - another.Y);
72 | }
73 |
74 | public FlowChartPoint CloneAndAdd(FlowChartPoint another)
75 | {
76 | return new FlowChartPoint(X + another.X, Y + another.Y);
77 | }
78 |
79 | public FlowChartPoint CloneAndAdd(int dX, int dY)
80 | {
81 | return new FlowChartPoint(X+dX, Y+dY);
82 | }
83 | public FlowChartPoint CloneAndAdd(float dX, float dY)
84 | {
85 | return new FlowChartPoint(X + dX, Y + dY);
86 | }
87 |
88 | internal Rectangle MakeRectangleTill(FlowChartPoint endPoint)
89 | {
90 | return new Rectangle((int)X, (int)Y, (int)(endPoint.X - X), (int)(endPoint.Y - Y));
91 | }
92 | internal RectangleF MakeRectangleFTill(FlowChartPoint endPoint)
93 | {
94 | return new RectangleF(X, Y, endPoint.X - X, endPoint.Y - Y);
95 | }
96 | internal PointF MakePointF()
97 | {
98 | return new PointF(X, Y);
99 | }
100 |
101 | internal PointF[] MakePointFArrayWith(FlowChartPoint endPoint)
102 | {
103 | return new PointF[] {
104 | new PointF(X, Y),
105 | new PointF(endPoint.X, Y),
106 | new PointF(endPoint.X, endPoint.Y),
107 | new PointF(X, endPoint.Y)
108 | };
109 | }
110 | internal FlowChartPoint[] MakeFlowChartPointArrayWith(FlowChartPoint endPoint)
111 | {
112 | return new FlowChartPoint[] {
113 | new FlowChartPoint(X, Y),
114 | new FlowChartPoint(endPoint.X, Y),
115 | new FlowChartPoint(endPoint.X, endPoint.Y),
116 | new FlowChartPoint(X, endPoint.Y)
117 | };
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Entities/FlowChartPointConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing.Design;
6 | using System.ComponentModel;
7 | using System.Globalization;
8 |
9 | namespace FlowChart.Entities
10 | {
11 |
12 | public class FlowChartPointConverter : TypeConverter
13 | {
14 | // Overrides the CanConvertFrom method of TypeConverter.
15 | // The ITypeDescriptorContext interface provides the context for the
16 | // conversion. Typically, this interface is used at design time to
17 | // provide information about the design-time container.
18 | public override bool CanConvertFrom(ITypeDescriptorContext context,
19 | Type sourceType)
20 | {
21 |
22 | if (sourceType == typeof(string))
23 | {
24 | return true;
25 | }
26 | return base.CanConvertFrom(context, sourceType);
27 | }
28 | // Overrides the ConvertFrom method of TypeConverter.
29 | public override object ConvertFrom(ITypeDescriptorContext context,
30 | CultureInfo culture, object value)
31 | {
32 | if (value is string)
33 | {
34 | string[] v = ((string)value).Split(new char[] { ',' });
35 | return new FlowChartPoint(int.Parse(v[0]), int.Parse(v[1]));
36 | }
37 | return base.ConvertFrom(context, culture, value);
38 | }
39 | // Overrides the ConvertTo method of TypeConverter.
40 | public override object ConvertTo(ITypeDescriptorContext context,
41 | CultureInfo culture, object value, Type destinationType)
42 | {
43 | if (destinationType == typeof(string))
44 | {
45 | return ((FlowChartPoint)value).X + "," + ((FlowChartPoint)value).Y;
46 | }
47 | return base.ConvertTo(context, culture, value, destinationType);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Entities/FlowChartReference.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace FlowChart.Entities
7 | {
8 | public class FlowChartReference
9 | {
10 | public string ID { get; set; }
11 | public string Name { get; set; }
12 | public int Key1 { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Entities/MouseState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace FlowChart.Entities
7 | {
8 | public enum MouseState
9 | {
10 | None,
11 | Move,
12 | Resize
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Factory/ViewAbstractFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Views;
6 | using System.Drawing;
7 |
8 | namespace FlowChart.Factory
9 | {
10 | public abstract class ViewAbstractFactory
11 | {
12 | public abstract Color GradStartColor { get; }
13 | public abstract Color GradEndColor { get; }
14 |
15 | public abstract Pen BoundingBoxPen { get; }
16 | public abstract Pen LinePen { get; }
17 |
18 | public abstract Pen SelectedPen { get; }
19 |
20 | public abstract Pen BorderPen { get; }
21 | public abstract Pen TextPen { get; }
22 | public abstract Pen LabelPen { get; }
23 | public abstract Pen EdgePen { get; }
24 | public abstract Pen ResizePen { get; }
25 |
26 | public abstract Brush LabelBrush { get; }
27 | public abstract Brush ArrowBrush { get; }
28 | public abstract Pen ArrowPen { get; }
29 |
30 | public abstract float EdgeBoxWidth { get; }
31 | public abstract float ResizeBoxWidth { get; }
32 | public abstract float ArrowLength { get; }
33 |
34 | public abstract StraightLineView CreateStraightLineView();
35 | public abstract CurvedLineView CreateCurvedLineView();
36 | public abstract DatabaseView CreateDatabaseView();
37 | public abstract RectangleView CreateRectangleView();
38 |
39 | public abstract RhombusView CreateRhombusView();
40 | public abstract RoundView CreateRoundView();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/FlowChart.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {0BCACB82-AAB7-4A43-A51C-EE503F585C99}
9 | WinExe
10 | Properties
11 | FlowChart
12 | FlowChart
13 | v3.5
14 | 512
15 |
16 |
17 | x86
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | x86
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | UserControl
98 |
99 |
100 | FlowChartPage.cs
101 |
102 |
103 | Form
104 |
105 |
106 | FormMain.cs
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 | FormMain.cs
119 |
120 |
121 | ResXFileCodeGenerator
122 | Resources.Designer.cs
123 | Designer
124 |
125 |
126 | True
127 | Resources.resx
128 |
129 |
130 | FlowChartPage.cs
131 |
132 |
133 |
134 | SettingsSingleFileGenerator
135 | Settings.Designer.cs
136 |
137 |
138 | True
139 | Settings.settings
140 | True
141 |
142 |
143 |
144 |
145 |
146 |
147 |
154 |
--------------------------------------------------------------------------------
/FlowChart.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.5.33627.172
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowChart", "FlowChart.csproj", "{0BCACB82-AAB7-4A43-A51C-EE503F585C99}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {0BCACB82-AAB7-4A43-A51C-EE503F585C99}.Debug|x86.ActiveCfg = Debug|x86
15 | {0BCACB82-AAB7-4A43-A51C-EE503F585C99}.Debug|x86.Build.0 = Debug|x86
16 | {0BCACB82-AAB7-4A43-A51C-EE503F585C99}.Release|x86.ActiveCfg = Release|x86
17 | {0BCACB82-AAB7-4A43-A51C-EE503F585C99}.Release|x86.Build.0 = Release|x86
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {52A41571-2168-4994-9D87-EB6DD101B07C}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/FlowChart.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pradeepkodical/FlowChart/2593932ae9d85b7796f3c2429a6931fb03460ecd/FlowChart.suo
--------------------------------------------------------------------------------
/FormMain.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Windows.Forms;
4 | using FlowChart.Models;
5 | using FlowChart.Controller;
6 | using FlowChart.Entities;
7 | using FlowChart.Persistance;
8 | using FlowChart.Views.Default;
9 | using FlowChart.Views.Grey;
10 |
11 | namespace FlowChart
12 | {
13 | public partial class FormMain : Form
14 | {
15 | private FlowChartController controller;
16 | public FormMain()
17 | {
18 | InitializeComponent();
19 | controller = new FlowChartController(flowChartPage1, new GreyViewFactory());
20 | flowChartContainerBindingSource.DataSource = controller.GetUndoBuffers();
21 | controller.ViewFactory = new DefaultViewFactory();
22 | panel1.Resize+=new EventHandler(panel1_Resize);
23 |
24 |
25 | controller.Resize += new Action(controller_Resize);
26 | controller.Selected += new Action(controller_OnSelected);
27 | controller.Changed += new Action(controller_OnChange);
28 | controller.OnFlowChartChange += new Action(controller_OnFlowChartChange);
29 |
30 | propertyGrid1.SelectedGridItemChanged += new SelectedGridItemChangedEventHandler(propertyGrid1_SelectedGridItemChanged);
31 | propertyGrid1.Leave += new EventHandler(propertyGrid1_Leave);
32 | undoGrid.CellContentClick += new DataGridViewCellEventHandler(undoGrid_CellContentClick);
33 | lstAllObjects.SelectedIndexChanged += new EventHandler(lstAllObjects_SelectedIndexChanged);
34 |
35 | potraitToolStripMenuItem_Click(this, null);
36 | }
37 |
38 | void lstAllObjects_SelectedIndexChanged(object sender, EventArgs e)
39 | {
40 | if (lstAllObjects.SelectedItems.Count > 0)
41 | {
42 | controller.SelectedComponent = lstAllObjects.SelectedItems[0].Tag as BaseComponent;
43 | }
44 | }
45 |
46 | void undoGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
47 | {
48 | if (e.ColumnIndex == 1 && e.RowIndex >= 0 && e.RowIndex < undoGrid.Rows.Count)
49 | {
50 | var fc = undoGrid.Rows[e.RowIndex].DataBoundItem as FlowChartContainer;
51 | if (fc != null)
52 | {
53 | controller.Load(fc);
54 | }
55 | }
56 | }
57 |
58 | void controller_OnFlowChartChange()
59 | {
60 | lstAllObjects.Items.Clear();
61 |
62 | controller.Model.Items.ForEach(x => {
63 | var lv = new ListViewItem(x.Text) {
64 | Tag = x,
65 | ImageIndex = x.ImageIndex
66 | };
67 | lstAllObjects.Items.Add(lv);
68 | });
69 |
70 | flowChartContainerBindingSource.ResetBindings(false);
71 | }
72 |
73 | void propertyGrid1_Leave(object sender, EventArgs e)
74 | {
75 | controller.PropertyChanged();
76 | }
77 |
78 | void propertyGrid1_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e)
79 | {
80 | flowChartPage1.Invalidate();
81 | }
82 |
83 | void controller_OnChange(BaseComponent obj)
84 | {
85 | if (obj != null && obj.SelectedPoint != null)
86 | {
87 | txtStatusText.Text = string.Format("{0} - {1}", obj.SelectedPoint.X, obj.SelectedPoint.Y);
88 | }
89 | propertyGrid1.SelectedObject = obj;
90 | }
91 |
92 | void controller_OnSelected(BaseComponent obj)
93 | {
94 | propertyGrid1.SelectedObject = obj;
95 | }
96 |
97 | private void Form1_Load(object sender, EventArgs e)
98 | {
99 | panel1_Resize(sender, e);
100 | }
101 |
102 | private void btnBox_Click(object sender, EventArgs e)
103 | {
104 | controller.Add(new RectangleComponent() {
105 | Text = "Process",
106 | TopLeftCorner = new FlowChartPoint(50, 50),
107 | BottomRightCorner = new FlowChartPoint(100, 100) });
108 | }
109 |
110 | private void btnCircle_Click(object sender, EventArgs e)
111 | {
112 | controller.Add(new RoundComponent()
113 | {
114 | Text = "Terminator",
115 | TopLeftCorner = new FlowChartPoint(50, 50),
116 | BottomRightCorner = new FlowChartPoint(100, 100)
117 | });
118 | }
119 |
120 | private void btnLine_Click(object sender, EventArgs e)
121 | {
122 | controller.Add(new LineComponent()
123 | {
124 | Text = "Connector",
125 | StartPoint = new FlowChartPoint(100, 100),
126 | EndPoint = new FlowChartPoint(200, 200)
127 | });
128 | }
129 |
130 | private void btnCurvedLine_Click(object sender, EventArgs e)
131 | {
132 | controller.Add(new CurvedLineComponent()
133 | {
134 | Text="Connector",
135 | StartPoint = new FlowChartPoint(200, 200),
136 | EndPoint = new FlowChartPoint(200, 100),
137 | ControlPoint2 = new FlowChartPoint(100, 100),
138 | ControlPoint1 = new FlowChartPoint(100, 200)
139 | });
140 | }
141 |
142 | private void btnRhombus_Click(object sender, EventArgs e)
143 | {
144 | controller.Add(new RhombusComponent()
145 | {
146 | Text = "Decision",
147 | TopLeftCorner = new FlowChartPoint(50, 50),
148 | BottomRightCorner = new FlowChartPoint(100, 100)
149 | });
150 | }
151 |
152 | private void btnDatabase_Click(object sender, EventArgs e)
153 | {
154 | controller.Add(new DatabaseComponent()
155 | {
156 | Text = "Database",
157 | TopLeftCorner = new FlowChartPoint(50, 50),
158 | BottomRightCorner = new FlowChartPoint(100, 100)
159 | });
160 | }
161 |
162 | private void panel1_Resize(object sender, EventArgs e)
163 | {
164 | float offSet = 10;
165 | controller.ResetView(
166 | offSet,
167 | panel1.Height - flowChartPage1.Height - offSet,
168 | offSet,
169 | panel1.Width - flowChartPage1.Width - offSet);
170 |
171 | controller_Resize();
172 | }
173 |
174 | void controller_Resize()
175 | {
176 | int left = (int)((panel1.Width - flowChartPage1.Width) / 2.0f);
177 | if (left > 4)
178 | {
179 | flowChartPage1.Left = left;
180 | }
181 | }
182 |
183 | private void btnSave_Click(object sender, EventArgs e)
184 | {
185 | saveFileDialog1.ShowDialog();
186 | }
187 |
188 | private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
189 | {
190 | new FileStorage(saveFileDialog1.FileName).Save(controller.Model);
191 | }
192 |
193 | private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
194 | {
195 | controller.Load(new FileStorage(openFileDialog1.FileName).Load());
196 | }
197 |
198 | private void btnOpen_Click(object sender, EventArgs e)
199 | {
200 | openFileDialog1.ShowDialog();
201 | }
202 |
203 | private void btnExport_Click(object sender, EventArgs e)
204 | {
205 | saveFileDialog2.ShowDialog();
206 | }
207 |
208 | private void saveFileDialog2_FileOk(object sender, CancelEventArgs e)
209 | {
210 | new ImageStorage(saveFileDialog2.FileName).Save(controller.Model);
211 | }
212 |
213 | private void btnZoomIn_Click(object sender, EventArgs e)
214 | {
215 | controller.ZoomFactor*=1.5f;
216 | panel1_Resize(sender, e);
217 | }
218 |
219 | private void btnZoomOut_Click(object sender, EventArgs e)
220 | {
221 | controller.ZoomFactor /= 1.5f;
222 | panel1_Resize(sender, e);
223 | }
224 |
225 | private void btnFit_Click(object sender, EventArgs e)
226 | {
227 | controller.ZoomFactor = 1.0f;
228 | panel1_Resize(sender, e);
229 | }
230 |
231 | private void ddlTheme_SelectedIndexChanged(object sender, EventArgs e)
232 | {
233 | controller.ViewFactory = new GreyViewFactory();
234 | }
235 |
236 | private void potraitToolStripMenuItem_Click(object sender, EventArgs e)
237 | {
238 | this.flowChartPage1.Width = 601;
239 | this.flowChartPage1.Height = 851;
240 | }
241 |
242 | private void landscapeToolStripMenuItem_Click(object sender, EventArgs e)
243 | {
244 | this.flowChartPage1.Width = 851;
245 | this.flowChartPage1.Height = 601;
246 | }
247 | }
248 | }
249 |
--------------------------------------------------------------------------------
/FormMain.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 232, 17
122 |
123 |
124 | 348, 17
125 |
126 |
127 | 484, 17
128 |
129 |
130 |
131 |
132 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
133 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHjSURBVDhPfZJLKIRhFIY/jCKESZSdMguRa2kSuRUKJYYs
134 | JHcmhmYao8xoSsqGDSthIzY2UlIsZ2MzCwsWVpPLzIjJZe7345zp488w/1vv5u99n/985/vYtwZWVrr7
135 | jcYpMSuMxmIe/yuFXj/tCYfhPRCAF68XrG43PLhccO90xnxqMgFleg0GGa/8Vs/y8owrGAQHFu2fn2Bx
136 | OODu+RlubTa4sVrh6PwcSJT7F9Kt0yndCHjzeP6FbB8e/ljW3m7gNUFdWu2sNxSCDxw/EYQmoeNQltcE
137 | tanVcz7cgdPnE4UQgLK8JqhVpVL5EeD2+0UhtFjK8pqgFqVyIRiJgBf3IAah26Esrwmqn5xUhxDgxz2I
138 | QV7wG2V5TVDdyIgmHI1CAI+RCDJ8NQ+VF62Qt1V+xWuCaoeGtBEE0BSJIJVnzTDxtgiS/fxHXhNUMzio
139 | i+JDCSMgHjJmwj+fNKEbof91CiRbBU9sP9fM9qQ7vM5YRV/fEr20KE4RD6k6boRme+8fs+0cM68zJuvo
140 | 0BOAFA8Zv1BB1UFDzGUPDSBZy7OyjUwz28yKTZCOzi+Qy1d5PyY6Du2EFksguuLq3XootJRCymK2jTq8
141 | y6TosrSiIk1GScm6mJMVudfJo6n2pM60S+owxqRfZJFD73bmYb4AAAAASUVORK5CYII=
142 |
143 |
144 |
145 |
146 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
147 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKASURBVDhPjZJdSJNRHMb/F930dWGX66KbeSMJedOFBBHG
148 | 7CKaGNQuBtYgwTBJiYEyM3W6paTDmXNoRjXNytBGLFNhNYJSsQTFrKlrX37NfThf9z3/nXN6Vd7oogd+
149 | 8Bx4nx/nwAu7mdLC9Ukt1P4P9Ft+tp+JRqjn7Fpc+3gN161FyM3cw7S7G3H5qZD1PqTf8rP9fFZDA26+
150 | xp3gK4y52tH/pQzfG/Jw5F2LgNExPQ6pj3fws/18UoMmHXiBqTUTIx18iVODt9Dj9+MKx6Gb4AyH8Y3N
151 | hg01kuFClSqTn/6JrRaaUr4+TC4/YdA+3q/AWbsdv83P46LPh3MrK9hrsSBNQWVliUBivQsPkqvPMO5+
152 | xKDd9liG3xcWmGQ5FGISvcm0R2Z+voqfA4xWgy7u7cGIo5NBu7X7Cv5YWmKSDfKEXQm9CX2OpLy8lJ8D
153 | DFdBe9TZhZy9nUH7mLEQ7Q4HkwS3twUS99YW5pWWlvFzgLdKMESWDBie1zFoH+6Q4qLTySSb0ahAshqJ
154 | 4Nni4tv8HGBICV3czzYMzTYzaLe0XUQHEVAJF4sJJAFyPqNQVPBzgIEK6AnPtaB/WsOg3dx6AZ0uF5NE
155 | EgmBJEzOp+XyO/wcoK8MTKGZJvRN1TFoH2yWoMvtZpJYMimQcKTnyGRKuj1IOGa8AebgNPmVJ2oYQXKL
156 | gfvn0ePxMEkylRJItkk/KZVWU0EGQVwigc4RXU540VyS2Jisw8DXBuxvPIderxc9hPTODqYIiXQa40QW
157 | J12Um6ulgr0Yi6HAoADj8yrRh/HeS7+Ulw+4DonF+sNZWU1Hs7M1f3NELL7JT4VpLYJTzXJQ1V+Fh+R4
158 | giD6N5DxG6r1XQjZiWGIAAAAAElFTkSuQmCC
159 |
160 |
161 |
162 |
163 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
164 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGsSURBVDhPrY3dK0NxGMef4/wBLpULV67dKNdciRtFI3nJ
165 | vOWCOyWlpghjbGqaVl7DhpQpYSNjMikXXkNeI6LV0Gi12uN8T78VpWPKrz6dep7P5zn0L68ywVKnl809
166 | OoOhNh7gohE5kV7u6z2bemO86C/gwUUjcqIK2WQ+HA1wJBrlcCSiCRy4aEROVCab+veHn/ldEV4+PjSB
167 | AxeNyInKZaN1z/7AwXCYH19fNYEDF43IiUqkTtuu7Y6flD9cBwKawIGLRuRExVK73W+94avLF74PhTSB
168 | AxeNyHGgbchnuWB352FcwEUjcqIiyTDq7T1jY+E4d+nGfgS7GDsDt4xG5EQ6qWVi1XjMpuJJ9vt3eHPT
169 | 9w3MsJtp8rG51Mlb/ZeMRuREBVKzc6XjgC1l0+zxeLklZ0BlYWFJBTPscMBWPc8bfeeMRuREeVLTnKfr
170 | iK36OXa53OoXOJ0uldgMB0bql3nddMpoRE6UQflZuVKDuzXbFpydXeHBGpeKw7GoEpvhgKPRy2vdJwxf
171 | 5JSikJZKGVWZVL0ty3L3T2D3lXTKHRYtJSokKST/EaWhxE9C7iVGGC6e7AAAAABJRU5ErkJggg==
172 |
173 |
174 |
175 |
176 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
177 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHCSURBVDhPldPNS9twHMfx79/hceJpu+wgnnRUNjyIXoYM
178 | L5PRefSsx8CQHYYPbOIDCGMPCKMxVK1Cp2xqTWOqwuwh8amLmqSxTdrZ0tHjb/2EX1Bhhxh4880vfF+Q
179 | HELRUVcYfFtimBTyumNeCnmWVOvnmPcpMNQ3nBP6hs/Y7HLeLlTqmTBhFwbWf6XuoUN2Va6rRvHvepiw
180 | C+NjXE9eycz+U1cMp5oME3ZhOCdqfbHObLcmnzjVtTBhF4Zzoke9S8xwayndqiZud3hxLe3o3udk1plO
181 | HOQnJdV8h5RTbwGGc6KWLpGdXdW2ssb1Etr/XRa//3LmRNUaj+2aY37yTdta4SsM50QPnsbYsV35cZAr
182 | SZta8YuUsd7H0tZkbLeRYk34E2fUOKd0bwGGc6LmZxLTLisbG1nnk6iaU2L6pkXF/BAUPNvW3G8wnOMT
183 | Vtl+rrwqqdasqFzOINzfPgfPMFNHrgjDOdHDnp9MPvbi8Yw5H7TI+999SvPiMJwTPX6+x3aOvJX4nv0x
184 | TNiF8XFbvy609WtsZMo4SeteIkzYhYGl9oEL/8fAvE+BoUi0IHS+LrKOAeNN44WawoRdmEi0IPwD2Yh/
185 | YzQ4FHgAAAAASUVORK5CYII=
186 |
187 |
188 |
189 |
190 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
191 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIxSURBVDhPY8AFjMv2mBmX7coB0VAh4oB++XYFo7Jd3oYl
192 | u3P///9/BkQblu1KBImB5KDKMIF9/X4Ww9Jdzr7thzKXHH44afae20sMinfmTdt5Z+HjN982gsRAciA1
193 | ILVQbQhgWLLDo3D++dLHb7/uevzmy4H7r77uRsYgMZAcSA1ILVQbBOgU7dAI7j6a9/jV1113nn/aCcQ7
194 | cOCdIDUgtSA9UO0MDLqFW6O2nnsyE6To1tNPW/FhkBqQWpAesGatvE022vlbSvs331h69dGHTcj4/L13
195 | a47ceLVgx4UXUzeeedq3+uTjLhBuXH5pFkgPSC/IgApQaIPoCw8+rAfhU3ferdpx4fmMlcce96w88hCM
196 | Vxx52A3DyHoYNHPW22rmbKxqX391yenbb9fuv/Jq4apjjyauOPqoDxkvP/KoH4RB7Kpl5+eA9ID0gr2h
197 | nr0hcdXRB9P3Xn65ZMXRh5OXH304CRdec/zR9IX77vWB9IA1g4B69npd98Y9ZYeuvly6CqgAaMs0bBgk
198 | d+jayyWuDTtLQXqg2iFAJWNNcEz/wZojQEOAAQb0xsNZILz6+OPZIBokBpIDqQGphWpDAsZprJI+9QEW
199 | ZRsru9ddnHTwyvOFhXNPLVFIXtFatfDsSpAYSA6kBqQWqgsOQElTHIi1udScPCUCu7Ok4hbUS8Yu7AOF
200 | NogGiYHkgGpATpeA6oEDJiDmAWIxIJaCYeGAPn+RiDnTQDSSOMgikFqQHkoBAwMAfJe7luc9BswAAAAA
201 | SUVORK5CYII=
202 |
203 |
204 |
205 |
206 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
207 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIaSURBVDhPY8AF7Oe9nGk398UZEAaxocLEAfv6/yy2s5+d
208 | mfLg///J9///B7FBYlBpwsB89l1x29kPz3dc+fO//fKf/w5zHp43nXJfAipNGJj233b3XvLwRmX93H+V
209 | 9XP+gdgm/Xc8odKEgWHXtQkJm54+y1j77gsIJ65/9Vy/69p0qDR+oNd6Qceg/dzZ+GP3f3vOvXPbdfbt
210 | O9k7rvwxar94XqvlvBlUGQ5Q/59Jve7kwqAlt58l73j5Ta3u+DEQTt7x7Jv3nGsv1epOrjFOO8MKVY0J
211 | lMr322jVH79UXj/ln2XnmZuK5YcKlcoOFpgD2bm7n//XqT92Rb5kvwdUOSaQydvV5jTr4jP3RdffS+Xu
212 | 2CFZv4kLhEFs1+nX39tMvfxCOn9nD1Q5JhBL37TFbdWdL7rNh25LZG6NgwozgNhqjYduW8++8k08fctO
213 | qDAmEEhYc9J+z/6/EpkbLvCnr1eACjOA2GJAMdMt+/+C1ECFEUC0ZP9MID4DwnaHfv+HsUWK96WBMIyv
214 | vusXXA6IEcmbO3RBDHvYwjPiO///Z9z0/7/Ijv//QXyukPkeIAxi826DyHFvhciB9EC1QwCTTUkMa+Cc
215 | M4JAzSAaxIdKweU4gJrR5WBAAIjlmYxSCph8Z5wB0UC+MhBLA7EMiA2XM04uBPJB4QPSAwccQAwSEAdi
216 | KSAWA2IhIOaDYhAbJAaSA2UqkFqgHgYGAOYcEDmZnkUyAAAAAElFTkSuQmCC
217 |
218 |
219 |
220 |
221 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
222 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADpSURBVDhPYzAu22NmXLYrB0QzkAMMS3bn/v///wyIhgqR
223 | BozKdlkYFO/MMyjdmaVTuUccKkw6MC3ZImFQsiMOREOFSAdgQ4q3xWtRYghIs07h1kSNgu2SUCHSAUiz
224 | Tv7mJIoN0S7YlKJRsJZ8Q9SzN0hp5G1MA9FQIdIBSLN69roMigxRTV8prZa5NgtEQ4VIByDNyulrcigy
225 | RNqjXkY+eXmDQvKKVrnEFS5QYQZGIGYGYlYg5gBibiDmA2IBIBYCYhEgFgNiUOKSlIxd2AfKOyAayAcD
226 | kgwQDujzF4mYMw2IvYF8SgEDAwB76U1l5S6M5QAAAABJRU5ErkJggg==
227 |
228 |
229 |
230 |
231 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
232 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEkSURBVDhPYzAu22NmXLYrB0QzkAMMS3bn/v///wyIhgqR
233 | BozKdlkYFO/MA9FQIdKBYfG2CP38/QJQLulAr3CHh0HxNi0ol3RgWLxFXr9gS5he8U5uqBDpQDd/i512
234 | /pYg3dxtMqGhq5i18jbZAPmlIBqqBD8Aa8rfYqCdtzlCO29jMlBjBSh2QDSIDxIHyTMA1UG14AeaOett
235 | NXM2VoFo+/r9LNqZ62W1cjaGqmevd4AqIR1oZa3iUc9aG62Ws1ERKkQ6UM1Zq6+WuT4AyiUdaGSvE1ZO
236 | X50K5ZIO5BJXuCgkr2gF0VAhBkYgBoUsKxBzADEoLfABMShlCgGxCBCLAbEEEEtKxi7sA8UOiAbywYAk
237 | A4QD+vxFIuZMA2JvIJ9SwMAAAG4RYDef+xbxAAAAAElFTkSuQmCC
238 |
239 |
240 |
241 | 127, 17
242 |
243 |
244 |
245 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
246 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAH0SURBVDhPjZI7LINRFMfvSAzCQGwkOlREB68GUyUYVMSj
247 | Ielg8ShKKlXRloqBwSQimCSi0bFEGgaLsEokRMQgJF890nj0/T7O+dyqR9v4Jydfvu/+/7977vkuS0g1
248 | M6PstlgGMlWXxVLK7X/VZTIN+qJReA2F4NnvB8HrhXuPB+7cbrF2j4+BPB1ms4RHfqrdaBzyhMPgwuDD
249 | +zvculxw/fgIl04nXAgCWB0OIJEvJURpMGi8CHjx+VJCVra3v0rS3GzmsaRa9foRfyQCb9h+Ogh1Qsch
250 | L48l1aTTjQZwBu5AICOEAOTlsaQatVptEAHeYDAtZP/kBGyHh9A4PDzGY0kpNJrxcCwGfpxDOsim3S4O
251 | sqq3d7JKparm0U819PfrIggI4hwSEAF3Pb+5gYPTU9ja24M1mw2EpycRUqZUTkvb2mp5nLG6vr6JaDwO
252 | ITxGAuLDOxHAJ32L4dpvFSsUszzOWI1arScTdZGAOLGDs6srsB8dwarVCovr63CPgyQVyuXzRXJ5PY8z
253 | VtnTY6A9ogj4Dvk+k7nlZTGcK5Mt5FVUNPDop2SdnVO0GMcu0kE2dnbAuLSU+iJJWlpMIh6VCUKXjbw8
254 | Jiobq4DOxPOi6Dg0ExosgegX0z0J4Tt5KcOzLB+rPKukZCJHKl38T5GXMoyx/A9mO1pFSi/xugAAAABJ
255 | RU5ErkJggg==
256 |
257 |
258 |
259 |
260 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
261 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHpSURBVDhPtZCxaxphGMYPRMQ1Qwf/huhS6Kq7Ci76HzSl
262 | xUxFcHAwySo4hLZcTGqiMdFTk9oavTN3l6C1qReVw7R6rTSXftCDSgulS8end+WChDjEoQ88w8f3/B7e
263 | 96WuFQqF/MFgcOkuNrImNpXf71+aTCZQVRXD4RCDwQUE4QzVahs830enM8Zo9B2a9gc+n++JiU1lFGia
264 | BlmWdVAAxzWQzZaR2ixib58Fy0k4737BV/J7joLdMjb0gly+hnrjPaTuGFfk1zwFJdBbBezmj1BrvEOn
265 | q0AlP2cXBAKB++Fw+E0qlQJN00gmk4jFYohGo4jH40gkEjD+IpFIXc8+MLGpZh2RF9uo1E5QF9poSTIG
266 | yiWutB93XyGTK+JFOodt5gCvj0W0ezLG5NscBXsMnqezSDNFvOKP8bbXw2dC5ijYZ/BsewcviwUc8iya
267 | PQkKUf/TEb1e7+0jnrZQrrOoiA3wUguSIuOTdjl7Arfb/fDmChwy+TzWM1vYKGXBCBWI/SY+kBE8Hs8j
268 | E5vK5XI9nl2wCbq8g4J4CKF/igvyEU6n88YEdt33HA7H09srNFFiqzg4OQJ3LuJM6WCojWBkDcZkqQXd
269 | i3a7fdlms61YrdYVi8VieFX3mv7+Z/1vTc+sml42GIqiFv4CLtj4wtBUKvcAAAAASUVORK5CYII=
270 |
271 |
272 |
273 |
274 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
275 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJTSURBVDhPjZJdaFJxGMYtP1gUUZnS6mJDJo0SRowkvxoy
276 | ZwxHYN4sNvDCLortbruqYJBNIhKCaDdhXu0iJKKNNtlsidlwfqXiHHO5Y23Hz+nGmQl6c3rfcQhMqj3w
277 | 4+X9v89z3nP+yvqXjJPFzjuWos1kLhIDE2QdK/Z4zlj+rsH7hH7owXfikZ30za6UFr6R+z5vfM9tnc77
278 | 8RznjLVZ2tFgp24kSrx8n3Z61oqeTKmS3K3WskWqtvFjpxqyz20t4Bx9TKRR8uFPtlFr1LcYyblj6bIP
279 | w/JhN40VHhBObFO+cWvUjz4m0qjLuhnCNpeaD2zsRNbzVLpcqe5Jbs7QWLHH82nXpgt9TKRRrVpH3fk1
280 | 60Zzh9ZB/wm8ScYTLyyjj4k0StTrIOwfNhdxE5orlcq+SPOWxnpwF6Va8s0S4UEfE2mUuH/edtcSDn1c
281 | LXwmclQAQxf7nb/vABl7Go6hj4k0Sqa+J79i8ORezaZC69tUAG//YDPUzG41+m4p7+82rBCSW1+afwWZ
282 | TNamUCjGnrxw0dLbkcLEFBlbjlOBbPnnmj9OBSdt+YRiKElcHUw0/w+USuWlvr4bD51OFy0QCMximfl6
283 | jyljU5u2CPUAWceKfY+RbN4MW6/p9QaL1xuk29tFz3g8npgZ/V8qlUpnNJqeR6MpWiLpmuJyud3M6HCS
284 | SqXjyWSBVql6X7PZbA1zfGi1CIVCDZ/Pf8zhcEag7wIkAH5nB9AGXACEwGngBNACcIGjAIsD4PA80Aqc
285 | Y/qzwBngFHASOA4cA3gAZtgsFuvIL7SlUYOP/4BVAAAAAElFTkSuQmCC
286 |
287 |
288 |
289 |
290 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
291 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAInSURBVDhPY8AH4ltfa6S0vZ6b3Pz6vk/9018gGsQHiUOV
292 | 4AYRVfcDo6sf3m+a//TE5pNvd915+vnEkSsfDvQufXkKJA6ShyrFBG45ZzS8sy/en7rxwY5D118fevTm
293 | 21kgPgfFZ+dve7wLJA9SB9WCCqxi9s/N6b14YveFFwcuPXh3AkkzGF978ulESe/FUyB1UC2oQNt70/25
294 | 2+5uP337zYWbLz89QMcg8aV77u0BqYNqQQWSbqt/7Tj//ABIsYrb6v/o+P23n88OXXl1DKQOqgUVKDmv
295 | vj9/673dIJtAioH4OTJ+/fbnrZX77h8CqYNqQQWqntvnZrSdO7v36qvD9198Oo0eBiBc3HXuEkgdVAsq
296 | sHTMtDIMPvRi9ua7Z28+QTUA6JyL6/e9PGUcfPK+TtBRzFiwtLSUt7a2Lu6YvOe/WeSFV/XTnl46duXT
297 | 6efvvl4/deXTmda5L69ZR9+6bxpxDTMd2NjYaLm6utfs2LHnv6ioaLOqZbOdffKzuY7Jj+87+jz9BaJB
298 | fPv4p5g2A221CAwMbjty5Mx/BQWlHjY2NlWoFGFga2vrHR+fPOHixbv/dXT0p7GyshpDpYgDZmZmJbdu
299 | vfpva+s8j5mZ2QUqTDTgEBMTcxEWFm5hYWHJBvL1gVgHiEH+VAFieSCWBmIxIBYEYh4g5gBiViBmAmIG
300 | FiAGSUoBsSQQS0D5IkAsBMQCQMwHxNxAzAnEbEAM0sPMwMDACAAlPFUsEy4glQAAAABJRU5ErkJggg==
301 |
302 |
303 |
304 |
305 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
306 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJESURBVDhPjZJdaFJhGMctP1gUUZnSx8VEkkYJI0aSXw2Z
307 | WwwhMG8WGxjYRbHdbVcVBLNJREIQ7O60qxFj7GZ9TFJKxIYzsxyyyNqOGUc9xzmXm583p+eRF+Ig1f7w
308 | 43mf9/n/3/Mp+pecU4Wum54C5XIX6BuT+SZW7HGfWP6uoTu0ffjuD3pyhom8WCm++c7sRMLJ7aB3lo3i
309 | Ps6JtV0DY7Eu22iCfu5nImmunC5VGtlStZFrAes5fz6Cc/SRiFCGkXfUmDcR+cqW04aRII9slhqtiqTZ
310 | WmbCm4iij0SEOm9bpKnX60t4gPbqIr+1W93GNVbscT0b2Aigj0SEUg3MN32fckE0ssUaj7ee2azGsZI+
311 | G0pyy+gjEaHUffP0zKsNPx6gti7wlVpjB8NYsccD5t7SIfSRiFCawSXqlif+Mc3+ypwd9PEIV6y3KgIv
312 | Mjf+KL6KPhIRSm+5bbjgCOUX/Mw3eHl/vgCwW69zL4NcssexQmuvvW//Cnq9vtNoNI4/fBrgddc/c/en
313 | mdXlZPlDbqvyJZosx6Yods04nKIvDq21/wcmk+lcf/+Vez5fgFcoFG6N3n2515WlLK6ftMXJNLFi3+tk
314 | 2q8MV71ktzs84XCMV6nUj2UymYaM/i+z2WxzOl1PEol1XqvtnpZKpT1ktDfpdLqJVIrjzea+Z2Kx2Eq2
315 | 96wOpVJplcvlDyQSySj03YAWwOc8A3QCpwElcBQ4BHQAUmA/IJIAODwFnAROkP44cAw4AhwGDgIHABmA
316 | GbFIJNr3G247UrBLVhCBAAAAAElFTkSuQmCC
317 |
318 |
319 |
320 |
321 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
322 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
323 | YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
324 | 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
325 | bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
326 | VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
327 | c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
328 | Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
329 | mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
330 | kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
331 | TgDQASA1MVpwzwAAAABJRU5ErkJggg==
332 |
333 |
334 |
335 | 17, 17
336 |
337 |
338 |
339 | AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
340 | LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
341 | ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABG
342 | DQAAAk1TRnQBSQFMAgEBBgEAAUABAQFAAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
343 | AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
344 | AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
345 | AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
346 | AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
347 | AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
348 | AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
349 | ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
350 | AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
351 | AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
352 | AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
353 | AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
354 | AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
355 | AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
356 | AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
357 | AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
358 | ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
359 | Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
360 | AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
361 | AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
362 | AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
363 | ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
364 | Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
365 | AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
366 | AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
367 | AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
368 | AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
369 | AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
370 | AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/xEAAf8B9AEHCu8BBwH0
371 | Af8gAAz/AfIBuwHzAQAC/wEHAfMB8QLwAQcC7wEHAQgB8AEHAv8gAAz/AbsB/wG7AwAB8AHyAfACBwH3
372 | AZIB9wHvAQcC8C4AAfMBvAHzAwAB8AHyAfACBwH3AZIB9wHvAQcC8C4AAf8B8QQAAfEB8wHxAvABBwHv
373 | AgcB8AHxAfAuAAH0AfMEAAH0Ae8CkgXsAZIB7wH0LQAB/wHyAf8EAAHxAfIB8AIHA/cB7wG8AfEB8CgA
374 | AfQB8AH0Av8B8gH0BQAB8QHyAfACBwH3AZIB9wEHAbwB8gHwJAAB/wH0AfIB8QHwAf8B8AHxAfIB9AH/
375 | BQAB8QHyAfACBwH3AZIB9wEHAbwB8gHwJAAB9AHyAv8B9AHwAfQJAAHxAfMB8QLwAQcB7wEHAbwB8AHz
376 | AfAjAAH/AfIB/w4AAfQB7wKSBewBkgHvAfQjAAHzAfQPAAHxAfIB8AIHAvcB7wEHAbwB8gHwIwAB8gH/
377 | DwAB8QHyAfACBwL3Ae8BBwG8AfMB8CIAAfQB8AH0DwAB8QHyAfACBwL3Ae8BBwG8AfMB8CIAAfEB/wHx
378 | DwAB8QHzAfEC8AMHAbwB8QHzAfAiAAH0AfEB9A8AAfIK8QHyIgAB3QHOAd0K/wHdAc4B3READv8RAAGt
379 | Ad0MrQHdAa0BAAb/AfIBuwHyBf8CAAH/AfQBvAG0AbwB9AL/AfQBvAG0AbwB9AH/AQAM/wHyAbsB8wEA
380 | Ad0BrQG1CvIBtQGtAd0BAAL/AfQB8gHwAbwBuwH/AbsB8AHyAfQC/wMAAfEBtAHZAbQB8QIAAfEBtAHZ
381 | AbQB8QIADP8BuwH/AbsCAAGtDPIBrQMAAf8B8gLwAfIDvALwAfIB/wMAAfEBtAPZAbQC8wG0A9kBtAHx
382 | DAAB/wK8AfMCAAGnDPIBpwMAAfIB8AjyAfAB8gMAAQkCtAHaArQC8QK0AdoCtAEJCwAB/wHwAf8EAAGn
383 | DPIBpwIAAfQB8AryAfAB9AQAAbQB2gG0Af8CAAH/AbQB2gG0DAAB/wHwAf8FAAGGAfML8gGGAgAB8Qzy
384 | AfEEAAG1AboBtAHyAgAB8gG0AbMBtAsAAf8B8QH/BgABhgHzC/IBhgEAAfQC8AryAvAB9AMAAQkCtAG1
385 | Av8BtQK0AQkKAAH/AfEB/wcAAYYD8wnyAYYBAAHwAf8B8AryAfAB/wHwAwAB9AG0AdsBtALxAbQBugG0
386 | AfMJAAH/AfEB/wgAAacG8wbyAacBAAH0AvAF8wXyAvAB9AMAAf8BuwG6AdsCtAG6AbQBuwH/CAAB/wHx
387 | Af8JAAGtAfQK8wH0Aa0CAALyCvMC8gUAAfQBtAHbA7oBtAH0CAAB/wHyAf8KAAGtAfQK8wH0Aa0CAAH0
388 | AfEB9AjzAfQB8QH0BgABCQTbAQkIAAH/AfIB/wsAAa0B9ArzAfQBrQMAAfMB8gH0BvMB9AHyAfMHAAHz
389 | AboC2wG6AfMHAAH/AfIB/wsAAd0BzwEJCvQBCQHPAd0CAAH/AfQC8gPwAfQC8gH0Af8HAAH/AboC3AG6
390 | Af8FAAH0AfAB8QH/DAABtAHdDLQB3QG0BAAB/wHzAfEB/wHxAfIB8wH/CQAB/wHbAtwB2wH/BQAB8QH/
391 | AfENAAHdAdUB3QoAAd0B1QHdBgAB9AHxAfQNAAEJAtsBCQYAAfQB8QH0DQABQgFNAT4HAAE+AwABKAMA
392 | AUADAAEgAwABAQEAAQEGAAEBFgAD/wEAAv8HAAEBBwABAQHAAQMEAAH/AfEBwAEDBAAB/wHzAcABAwQA
393 | Af8B8wHAAQMEAAH/AeMBwAEDBAAB/AEHAcABAwQAAcABBwHAAQMEAAHAAX8BwAEDBAABjwH/AcABAwQA
394 | AZ8B/wHAAQMEAAGfAf8BwAEDBAABHwH/AcABAwQAAR8B/wHAAQMEAAEfAf8BwAEDBgAC/wGAAQEC/wIA
395 | AYABAQGAAQEBAAEBAgABgAEBAcEBgwEAAQEBgAEBAcABAwGAAQEB/wHhAYABAQHAAQMBgAEBAf8BxwGA
396 | AQEBgAEBAeEBhwH/AY8BgAEBAYABAQHhAYcB/wEfAYABAQIAAeABBwH+AT8BgAEBAgAB4AEHAfwBfwGA
397 | AQECAAHgAQcB+AH/AYABAQGAAQEB8AEPAfEB/wGAAQEBgAEBAfgBHwHjAf8BgAEBAcABAwH4AR8BxwH/
398 | AgABwAEDAfgBHwEPAf8CAAHwAQ8B+AIfAf8BHwH4AfwBfwH8AT8BHwH/Cw==
399 |
400 |
401 |
402 | True
403 |
404 |
405 | 624, 17
406 |
407 |
408 | True
409 |
410 |
411 | 624, 17
412 |
413 |
414 | 17, 56
415 |
416 |
417 | 58
418 |
419 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014, Pradeep Kodical
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * Neither the name of the {organization} nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
29 |
--------------------------------------------------------------------------------
/Models/BaseBoxComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.ComponentModel;
7 | using FlowChart.Entities;
8 | using FlowChart.Utility;
9 | using FlowChart.Views;
10 |
11 | namespace FlowChart.Models
12 | {
13 | public abstract class BaseBoxComponent:BaseComponent
14 | {
15 | #region Private Members
16 | private RectangleF inflatedBox = new RectangleF();
17 | #endregion
18 |
19 | #region Properties
20 |
21 | [TypeConverter(typeof(FlowChartPointConverter))]
22 | [DescriptionAttribute("Top Left Corner Point")]
23 | public FlowChartPoint TopLeftCorner { get; set; }
24 |
25 | [TypeConverter(typeof(FlowChartPointConverter))]
26 | [DescriptionAttribute("Bottom Right Corner Point")]
27 | public FlowChartPoint BottomRightCorner { get; set; }
28 |
29 | [Browsable(false)]
30 | public List EdgePoints { get; private set; }
31 |
32 | [Browsable(false)]
33 | public float Width { get { return BottomRightCorner.X - TopLeftCorner.X; } }
34 |
35 | [Browsable(false)]
36 | public float Height { get { return BottomRightCorner.Y - TopLeftCorner.Y; } }
37 |
38 | #endregion
39 |
40 | #region Events
41 | public event Action BoxComponentMoving;
42 | public event Action BoxComponentMoved;
43 | #endregion
44 |
45 | #region Constructor
46 | public BaseBoxComponent()
47 | {
48 | this.EdgePoints = new List();
49 | this.SortOrder = 2;
50 | }
51 |
52 | private void Corner_OnChange(float oldX, float oldY)
53 | {
54 | this.UpdateBoundingBox();
55 | if (this.BoxComponentMoving != null)
56 | {
57 | this.BoxComponentMoving(this);
58 | }
59 | }
60 |
61 | public override void Init()
62 | {
63 | this.TopLeftCorner.OnChange += new Action(Corner_OnChange);
64 | this.BottomRightCorner.OnChange += new Action(Corner_OnChange);
65 | this.UpdateBoundingBox();
66 | }
67 | #endregion
68 |
69 | #region Abstract
70 | public abstract void RecomputeEdgePoints();
71 | #endregion
72 |
73 | #region Virtual
74 |
75 | public override bool HitTest(int x, int y)
76 | {
77 | if (GraphicsUtil.Distance(TopLeftCorner, (float)x, (float)y) < View.ViewFactory.EdgeBoxWidth / 2)
78 | {
79 | this.SelectedPoint = TopLeftCorner;
80 | this.MouseState = Entities.MouseState.Resize;
81 | return true;
82 | }
83 | if (GraphicsUtil.Distance(BottomRightCorner, (float)x, (float)y) < View.ViewFactory.EdgeBoxWidth / 2)
84 | {
85 | this.SelectedPoint = BottomRightCorner;
86 | this.MouseState = Entities.MouseState.Resize;
87 | return true;
88 | }
89 |
90 | if (HasPoint(x, y))
91 | {
92 | LastHitPoint.X = x;
93 | LastHitPoint.Y = y;
94 | this.SelectedPoint = LastHitPoint;
95 | this.MouseState = Entities.MouseState.Move;
96 | return true;
97 | }
98 | return false;
99 | }
100 |
101 | public override void MouseUp(System.Windows.Forms.MouseEventArgs e)
102 | {
103 | if (this.BoxComponentMoved != null)
104 | {
105 | this.BoxComponentMoved(this);
106 | }
107 | base.MouseUp(e);
108 | this.OnChanged();
109 | }
110 | public override void MouseMove(System.Windows.Forms.MouseEventArgs e)
111 | {
112 | base.MouseMove(e);
113 | UpdateBoundingBox();
114 | if (this.BoxComponentMoving != null)
115 | {
116 | this.BoxComponentMoving(this);
117 | }
118 | }
119 | public override void Move(System.Windows.Forms.MouseEventArgs e)
120 | {
121 | if (this.SelectedPoint != null)
122 | {
123 | float deltaX = e.X - this.SelectedPoint.X;
124 | float deltaY = e.Y - this.SelectedPoint.Y;
125 |
126 | TopLeftCorner.X += deltaX;
127 | TopLeftCorner.Y += deltaY;
128 |
129 | BottomRightCorner.X += deltaX;
130 | BottomRightCorner.Y += deltaY;
131 |
132 | this.SelectedPoint.X = e.X;
133 | this.SelectedPoint.Y = e.Y;
134 | UpdateBoundingBox();
135 | if (this.BoxComponentMoving != null)
136 | {
137 | this.BoxComponentMoving(this);
138 | }
139 | }
140 | }
141 | #endregion
142 |
143 | #region Public
144 | public void UpdateBoundingBox()
145 | {
146 | this.CenterPoint.X = TopLeftCorner.X + Width / 2;
147 | this.CenterPoint.Y = TopLeftCorner.Y + Height / 2;
148 |
149 | inflatedBox = new RectangleF(TopLeftCorner.X, TopLeftCorner.Y, Width, Height);
150 | inflatedBox.Inflate(View.ViewFactory.EdgeBoxWidth / 2, View.ViewFactory.EdgeBoxWidth / 2);
151 | RecomputeEdgePoints();
152 | }
153 |
154 | public bool HasPoint(float x1, float y1)
155 | {
156 | return inflatedBox.Contains(x1, y1);
157 | }
158 | #endregion
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/Models/BaseComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.Windows.Forms;
7 | using System.ComponentModel;
8 | using FlowChart.Entities;
9 | using FlowChart.Utility;
10 | using FlowChart.Visitors;
11 | using FlowChart.Views;
12 |
13 | namespace FlowChart.Models
14 | {
15 | public abstract class BaseComponent
16 | {
17 | #region Events
18 |
19 | public event Action Changed;
20 | protected void OnChanged()
21 | {
22 | if (this.Changed != null)
23 | {
24 | this.Changed(this);
25 | }
26 | }
27 | #endregion
28 |
29 | #region Abstract
30 | public abstract bool HitTest(int x, int y);
31 | public abstract FlowChartComponent GetComponent();
32 | public abstract void SetComponent(FlowChartComponent component);
33 | public abstract void Move(System.Windows.Forms.MouseEventArgs e);
34 | public abstract void Init();
35 | public abstract void Accept(BaseVisitor visitor);
36 | #endregion
37 |
38 | #region Properties
39 |
40 | [DescriptionAttribute("Unique ID of the item")]
41 | public string UniqueID { get{return ID;} }
42 | private string _text;
43 | [DescriptionAttribute("Text Description of the element")]
44 | public string Text
45 | {
46 | get
47 | {
48 | return _text;
49 | }
50 | set
51 | {
52 | if (_text != value)
53 | {
54 | _text = value;
55 | this.OnChanged();
56 | }
57 | }
58 | }
59 | [Browsable(false)]
60 | public FlowChartPoint CenterPoint { get; private set; }
61 | [Browsable(false)]
62 | public FlowChartPoint LastHitPoint { get; private set; }
63 | [Browsable(false)]
64 | public MouseState MouseState { get; set; }
65 | [Browsable(false)]
66 | public string ID { get; set; }
67 | [Browsable(false)]
68 | public int SortOrder { get; set; }
69 | [Browsable(false)]
70 | public int ImageIndex { get; set; }
71 | [Browsable(false)]
72 | public FlowChartPoint SelectedPoint { get; set; }
73 | private bool _IsSelected;
74 | [Browsable(false)]
75 | public bool IsSelected
76 | {
77 | get
78 | {
79 | return _IsSelected;
80 | }
81 | set
82 | {
83 | _IsSelected = value;
84 | if (!_IsSelected)
85 | {
86 | this.SelectedPoint = null;
87 | }
88 | }
89 | }
90 |
91 | [Browsable(false)]
92 | public BaseView View { get; set; }
93 | #endregion
94 |
95 | #region Constructor
96 | public BaseComponent()
97 | {
98 | this.MouseState = Entities.MouseState.None;
99 | this.LastHitPoint = new FlowChartPoint();
100 | this.CenterPoint = new FlowChartPoint();
101 | this.ID = Util.GetUniqueID();
102 | }
103 | #endregion
104 |
105 | #region Virtual
106 |
107 | public virtual void MouseMove(System.Windows.Forms.MouseEventArgs e)
108 | {
109 | if (this.SelectedPoint != null)
110 | {
111 | this.SelectedPoint.X = e.X;
112 | this.SelectedPoint.Y = e.Y;
113 | }
114 | }
115 |
116 | public virtual void MouseDown(System.Windows.Forms.MouseEventArgs e)
117 | {
118 |
119 | }
120 |
121 | public virtual void MouseUp(System.Windows.Forms.MouseEventArgs e)
122 | {
123 |
124 | }
125 | #endregion
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/Models/BaseLineComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.ComponentModel;
7 | using FlowChart.Entities;
8 | using FlowChart.Utility;
9 | using FlowChart.Views;
10 |
11 | namespace FlowChart.Models
12 | {
13 | public abstract class BaseLineComponent:BaseComponent
14 | {
15 | #region Events
16 | public event Action LinePointMovedTo;
17 | #endregion
18 |
19 | #region Properties
20 | [TypeConverter(typeof(FlowChartPointConverter))]
21 | [DescriptionAttribute("Start Point of the line")]
22 | public FlowChartPoint StartPoint { get; set; }
23 |
24 | [TypeConverter(typeof(FlowChartPointConverter))]
25 | [DescriptionAttribute("End Point of the line with Arrow")]
26 | public FlowChartPoint EndPoint { get; set; }
27 |
28 | [Browsable(false)]
29 | public BaseBoxComponent ConnectionStart { get; set; }
30 | [Browsable(false)]
31 | public BaseBoxComponent ConnectionEnd { get; set; }
32 | [Browsable(false)]
33 | public int ConnectionStartPointIndex { get; set; }
34 | [Browsable(false)]
35 | public int ConnectionEndPointIndex { get; set; }
36 |
37 | [Browsable(false)]
38 | public bool ParentMoving{ get; set; }
39 | #endregion
40 |
41 | #region Constructor
42 | public BaseLineComponent()
43 | {
44 | this.SortOrder = 5;
45 | }
46 |
47 | public override void Init()
48 | {
49 | }
50 | #endregion
51 |
52 | #region Virtual
53 | public virtual void RecomputePoints()
54 | {
55 | FlowChartPoint pt = GetWeightedPoint();
56 | this.CenterPoint.X = pt.X;
57 | this.CenterPoint.Y = pt.Y;
58 | }
59 | public virtual FlowChartPoint GetWeightedPoint()
60 | {
61 | return StartPoint.CloneAndAdd((EndPoint.X - StartPoint.X) / 2.0f, (EndPoint.Y - StartPoint.Y) / 2.0f);
62 | }
63 |
64 | public virtual void OnParentMoved(BaseBoxComponent box, bool recompute)
65 | {
66 | if (this.ConnectionStart == box)
67 | {
68 | this.StartPoint.X = box.EdgePoints[this.ConnectionStartPointIndex].X;
69 | this.StartPoint.Y = box.EdgePoints[this.ConnectionStartPointIndex].Y;
70 | this.ParentMoving = !recompute;
71 | this.RecomputePoints();
72 | }
73 | if (this.ConnectionEnd == box)
74 | {
75 | this.EndPoint.X = box.EdgePoints[this.ConnectionEndPointIndex].X;
76 | this.EndPoint.Y = box.EdgePoints[this.ConnectionEndPointIndex].Y;
77 | this.ParentMoving = !recompute;
78 | this.RecomputePoints();
79 | }
80 | }
81 | public override bool HitTest(int x, int y)
82 | {
83 | if (GraphicsUtil.Distance(StartPoint, (float)x, (float)y) < View.ViewFactory.EdgeBoxWidth / 2)
84 | {
85 | this.SelectedPoint = StartPoint;
86 | this.MouseState = Entities.MouseState.Resize;
87 | return true;
88 | }
89 | if (GraphicsUtil.Distance(EndPoint, (float)x, (float)y) < View.ViewFactory.EdgeBoxWidth / 2)
90 | {
91 | this.SelectedPoint = EndPoint;
92 | this.MouseState = Entities.MouseState.Resize;
93 | return true;
94 | }
95 | return false;
96 | }
97 |
98 | public override FlowChartComponent GetComponent()
99 | {
100 | FlowChartComponent component = new FlowChartComponent();
101 | component.ID = this.ID;
102 | component.Text = Text;
103 | component.Type = this.GetType().FullName;
104 | component.Points.Add(StartPoint);
105 | component.Points.Add(EndPoint);
106 |
107 | FlowChartReference fcRef1 = new FlowChartReference
108 | {
109 | ID = ConnectionStart != null ? ConnectionStart.ID : string.Empty,
110 | Name = "Start"
111 | };
112 | FlowChartReference fcRef2 = new FlowChartReference
113 | {
114 | ID = ConnectionEnd != null ? ConnectionEnd.ID : string.Empty,
115 | Name = "End"
116 | };
117 | component.ConnectionIds.Add(fcRef1);
118 | component.ConnectionIds.Add(fcRef2);
119 |
120 | if (ConnectionStart != null)
121 | {
122 | fcRef1.Key1 = ConnectionStartPointIndex;
123 | }
124 | if (ConnectionEnd != null)
125 | {
126 | fcRef2.Key1 = ConnectionEndPointIndex;
127 | }
128 | return component;
129 | }
130 |
131 | public override void SetComponent(FlowChartComponent component)
132 | {
133 | ID = component.ID;
134 | Text = component.Text;
135 | StartPoint = component.Points[0];
136 | EndPoint = component.Points[1];
137 | }
138 |
139 | public override void MouseUp(System.Windows.Forms.MouseEventArgs e)
140 | {
141 | base.MouseUp(e);
142 | this.OnChanged();
143 | }
144 | public override void MouseMove(System.Windows.Forms.MouseEventArgs e)
145 | {
146 | if (this.SelectedPoint != null)
147 | {
148 | this.SelectedPoint.X = e.X;
149 | this.SelectedPoint.Y = e.Y;
150 | if (this.LinePointMovedTo != null)
151 | {
152 | this.LinePointMovedTo(this, this.SelectedPoint);
153 | }
154 | }
155 | }
156 |
157 | public override void Move(System.Windows.Forms.MouseEventArgs e)
158 | {
159 | if (this.SelectedPoint != null)
160 | {
161 | StartPoint.X += e.X - this.SelectedPoint.X;
162 | StartPoint.Y += e.Y - this.SelectedPoint.Y;
163 |
164 | EndPoint.X += e.X - this.SelectedPoint.X;
165 | EndPoint.Y += e.Y - this.SelectedPoint.Y;
166 |
167 | this.SelectedPoint.X = e.X;
168 | this.SelectedPoint.Y = e.Y;
169 | }
170 | }
171 |
172 | #endregion
173 |
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/Models/CurvedLineComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.ComponentModel;
7 | using FlowChart.Entities;
8 | using FlowChart.Utility;
9 | using FlowChart.Views;
10 |
11 | namespace FlowChart.Models
12 | {
13 | public class CurvedLineComponent:BaseLineComponent
14 | {
15 | #region Properties
16 | [TypeConverter(typeof(FlowChartPointConverter))]
17 | [DescriptionAttribute("Control point 1 for the bezier curve")]
18 | public FlowChartPoint ControlPoint1 { get; set; }
19 |
20 | [TypeConverter(typeof(FlowChartPointConverter))]
21 | [DescriptionAttribute("Control point 2 for the bezier curve")]
22 | public FlowChartPoint ControlPoint2 { get; set; }
23 | #endregion
24 |
25 |
26 | #region Private
27 | public List points = new List();
28 | private PointF Bezier(FlowChartPoint a, FlowChartPoint b, FlowChartPoint c, FlowChartPoint d, float t)
29 | {
30 | FlowChartPoint
31 | ab = new FlowChartPoint(),
32 | bc = new FlowChartPoint(),
33 | cd = new FlowChartPoint(),
34 | abbc = new FlowChartPoint(),
35 | bccd = new FlowChartPoint(),
36 | dest = new FlowChartPoint();
37 | Lerp( ab, a, b, t); // point between a and b (green)
38 | Lerp( bc, b, c, t); // point between b and c (green)
39 | Lerp( cd, c, d, t); // point between c and d (green)
40 | Lerp( abbc, ab, bc, t); // point between ab and bc (blue)
41 | Lerp( bccd, bc, cd, t); // point between bc and cd (blue)
42 | Lerp( dest, abbc, bccd, t); // point on the bezier-curve (black)
43 | return dest.MakePointF();
44 | }
45 | void Lerp(FlowChartPoint dest, FlowChartPoint a, FlowChartPoint b, float t)
46 | {
47 | dest.X = a.X + (b.X - a.X) * t;
48 | dest.Y = a.Y + (b.Y - a.Y) * t;
49 | }
50 | public override void RecomputePoints()
51 | {
52 | if (!ParentMoving)
53 | {
54 | points.Clear();
55 | for (float t = 0; t < 1; t += 0.001f)
56 | {
57 | points.Add(Bezier(StartPoint, ControlPoint1, ControlPoint2, EndPoint, t));
58 | }
59 | }
60 | base.RecomputePoints();
61 | }
62 | #endregion
63 |
64 | #region Virtual
65 | public override void Init()
66 | {
67 | RecomputePoints();
68 | this.ImageIndex = 4;
69 | base.Init();
70 | }
71 | public override void Accept(Visitors.BaseVisitor visitor)
72 | {
73 | visitor.Visit(this);
74 | }
75 |
76 | public override FlowChartComponent GetComponent()
77 | {
78 | FlowChartComponent component = base.GetComponent();
79 | component.Points.Add(ControlPoint1);
80 | component.Points.Add(ControlPoint2);
81 | return component;
82 | }
83 |
84 | public override FlowChartPoint GetWeightedPoint()
85 | {
86 | FlowChartPoint pt = StartPoint.CloneAndAdd(EndPoint).CloneAndAdd(ControlPoint1).CloneAndAdd(ControlPoint2);
87 | pt.X = pt.X / 4;
88 | pt.Y = pt.Y / 4;
89 | return pt;
90 | }
91 |
92 | public override void SetComponent(FlowChartComponent component)
93 | {
94 | ControlPoint1 = component.Points[2];
95 | ControlPoint2 = component.Points[3];
96 | base.SetComponent(component);
97 | }
98 | public override void OnParentMoved(BaseBoxComponent box, bool recompute)
99 | {
100 | if (this.ConnectionStart == box && this.ConnectionEnd == box)
101 | {
102 | this.ControlPoint1.Add(box.EdgePoints[this.ConnectionStartPointIndex].CloneAndSubtract(this.StartPoint));
103 | this.ControlPoint2.Add(box.EdgePoints[this.ConnectionStartPointIndex].CloneAndSubtract(this.StartPoint));
104 | }
105 | base.OnParentMoved(box, recompute);
106 | }
107 |
108 | public override bool HitTest(int x, int y)
109 | {
110 | if (GraphicsUtil.Distance(ControlPoint1, (float)x, (float)y) < View.ViewFactory.EdgeBoxWidth / 2)
111 | {
112 | this.SelectedPoint = ControlPoint1;
113 | this.MouseState = Entities.MouseState.Resize;
114 | return true;
115 | }
116 | if (GraphicsUtil.Distance(ControlPoint2, (float)x, (float)y) < View.ViewFactory.EdgeBoxWidth / 2)
117 | {
118 | this.SelectedPoint = ControlPoint2;
119 | this.MouseState = Entities.MouseState.Resize;
120 | return true;
121 | }
122 | if (base.HitTest(x, y))
123 | {
124 | return true;
125 | }
126 | else
127 | {
128 | if (GraphicsUtil.HasPoint(new FlowChartPoint[] { StartPoint, ControlPoint1, ControlPoint2, EndPoint }, x, y) ||
129 | GraphicsUtil.HasPoint(new FlowChartPoint[] { StartPoint, ControlPoint1, EndPoint, ControlPoint2 }, x, y))
130 | {
131 | for (int i = 0; i < this.points.Count; i++)
132 | {
133 | if (GraphicsUtil.Distance(x, y, this.points[i].X, this.points[i].Y) < View.ViewFactory.EdgeBoxWidth / 2)
134 | {
135 | this.MouseState = Entities.MouseState.Move;
136 | this.LastHitPoint.X = x;
137 | this.LastHitPoint.Y = y;
138 | this.SelectedPoint = this.LastHitPoint;
139 | return true;
140 | }
141 | }
142 | }
143 | return false;
144 | }
145 | }
146 | public override void MouseMove(System.Windows.Forms.MouseEventArgs e)
147 | {
148 | RecomputePoints();
149 | base.MouseMove(e);
150 | }
151 | public override void Move(System.Windows.Forms.MouseEventArgs e)
152 | {
153 | if (this.SelectedPoint != null)
154 | {
155 | ControlPoint1.X += e.X - this.SelectedPoint.X;
156 | ControlPoint1.Y += e.Y - this.SelectedPoint.Y;
157 |
158 | ControlPoint2.X += e.X - this.SelectedPoint.X;
159 | ControlPoint2.Y += e.Y - this.SelectedPoint.Y;
160 |
161 | base.Move(e);
162 | RecomputePoints();
163 | }
164 | }
165 | #endregion
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/Models/DatabaseComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing.Drawing2D;
6 | using System.Drawing;
7 | using FlowChart.Entities;
8 | using FlowChart.Utility;
9 | using FlowChart.Views;
10 |
11 | namespace FlowChart.Models
12 | {
13 | public class DatabaseComponent:BaseBoxComponent
14 | {
15 | #region Constructor
16 | private float offSet = 16;
17 | public DatabaseComponent()
18 | {
19 | this.ImageIndex = 5;
20 | for (int i = 0; i < 6; i++)
21 | {
22 | this.EdgePoints.Add(new FlowChartPoint());
23 | }
24 | }
25 | #endregion
26 |
27 | #region Virtual
28 | public override void Accept(Visitors.BaseVisitor visitor)
29 | {
30 | visitor.Visit(this);
31 | }
32 |
33 | public override void RecomputeEdgePoints()
34 | {
35 | this.EdgePoints[0].X = TopLeftCorner.X + this.Width / 2;
36 | this.EdgePoints[0].Y = TopLeftCorner.Y + offSet;
37 |
38 | this.EdgePoints[1].X = BottomRightCorner.X;
39 | this.EdgePoints[1].Y = TopLeftCorner.Y + this.Height / 3;
40 |
41 | this.EdgePoints[2].X = BottomRightCorner.X;
42 | this.EdgePoints[2].Y = TopLeftCorner.Y + 2 * this.Height / 3;
43 |
44 | this.EdgePoints[3].X = TopLeftCorner.X + this.Width / 2;
45 | this.EdgePoints[3].Y = BottomRightCorner.Y;
46 |
47 | this.EdgePoints[4].X = TopLeftCorner.X;
48 | this.EdgePoints[4].Y = TopLeftCorner.Y + this.Height / 3;
49 |
50 | this.EdgePoints[5].X = TopLeftCorner.X;
51 | this.EdgePoints[5].Y = TopLeftCorner.Y + 2 * this.Height / 3;
52 | }
53 |
54 | public override FlowChartComponent GetComponent()
55 | {
56 | FlowChartComponent component = new FlowChartComponent();
57 | component.ID = this.ID;
58 | component.Text = Text;
59 | component.Type = this.GetType().FullName;
60 | component.Points.Add(TopLeftCorner);
61 | component.Points.Add(BottomRightCorner);
62 | return component;
63 | }
64 |
65 | public override void SetComponent(FlowChartComponent component)
66 | {
67 | ID = component.ID;
68 | Text = component.Text;
69 | TopLeftCorner = component.Points[0];
70 | BottomRightCorner = component.Points[1];
71 | }
72 |
73 | #endregion
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Models/FlowChartModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace FlowChart.Models
7 | {
8 | public class FlowChartModel
9 | {
10 | public List Items { get; set; }
11 | public FlowChartModel()
12 | {
13 | this.Items = new List();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Models/LineComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Entities;
7 | using FlowChart.Utility;
8 | using FlowChart.Views;
9 |
10 | namespace FlowChart.Models
11 | {
12 | public class LineComponent:BaseLineComponent
13 | {
14 | #region Virtual
15 | public override void Init()
16 | {
17 | this.ImageIndex = 3;
18 | base.Init();
19 | }
20 | public override void Accept(Visitors.BaseVisitor visitor)
21 | {
22 | visitor.Visit(this);
23 | }
24 |
25 | public override bool HitTest(int x, int y)
26 | {
27 | if (base.HitTest(x, y))
28 | {
29 | return true;
30 | }
31 | else
32 | {
33 | if (GraphicsUtil.HasPoint(StartPoint.MakeFlowChartPointArrayWith(EndPoint), x, y))
34 | {
35 | if (GraphicsUtil.DistanceToLine(StartPoint, EndPoint, x, y) < View.ViewFactory.EdgeBoxWidth)
36 | {
37 | this.MouseState = Entities.MouseState.Move;
38 | this.LastHitPoint.X = x;
39 | this.LastHitPoint.Y = y;
40 | this.SelectedPoint = this.LastHitPoint;
41 | return true;
42 | }
43 | }
44 | return false;
45 | }
46 | }
47 |
48 | #endregion
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Models/PointF.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace FlowChart.Models
7 | {
8 | public class ChartPoint
9 | {
10 | public float X { get; set; }
11 | public float Y { get; set; }
12 | public ChartPoint()
13 | {
14 | }
15 | public ChartPoint(float x, float y)
16 | {
17 | this.X = x;
18 | this.Y = y;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Models/RectangleComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.Drawing.Drawing2D;
7 | using FlowChart.Entities;
8 | using FlowChart.Utility;
9 | using FlowChart.Views;
10 |
11 | namespace FlowChart.Models
12 | {
13 | public class RectangleComponent: BaseBoxComponent
14 | {
15 | #region Constructor
16 | public RectangleComponent()
17 | {
18 | this.ImageIndex = 0;
19 | for (int i = 0; i < 12; i++)
20 | {
21 | this.EdgePoints.Add(new FlowChartPoint());
22 | }
23 | }
24 | #endregion
25 |
26 | #region Virtual
27 | public override void Accept(Visitors.BaseVisitor visitor)
28 | {
29 | visitor.Visit(this);
30 | }
31 |
32 | public override void RecomputeEdgePoints()
33 | {
34 | int i = 0;
35 | //Top Side
36 | this.EdgePoints[i].X = TopLeftCorner.X + this.Width * 0.25f;
37 | this.EdgePoints[i++].Y = TopLeftCorner.Y;
38 |
39 | this.EdgePoints[i].X = TopLeftCorner.X + this.Width * 0.5f;
40 | this.EdgePoints[i++].Y = TopLeftCorner.Y;
41 |
42 | this.EdgePoints[i].X = TopLeftCorner.X + this.Width * 0.75f;
43 | this.EdgePoints[i++].Y = TopLeftCorner.Y;
44 |
45 | //Right Side
46 | this.EdgePoints[i].X = BottomRightCorner.X;
47 | this.EdgePoints[i++].Y = TopLeftCorner.Y + this.Height * 0.25f;
48 |
49 | this.EdgePoints[i].X = BottomRightCorner.X;
50 | this.EdgePoints[i++].Y = TopLeftCorner.Y + this.Height * 0.5f;
51 |
52 | this.EdgePoints[i].X = BottomRightCorner.X;
53 | this.EdgePoints[i++].Y = TopLeftCorner.Y + this.Height * 0.75f;
54 |
55 | //Bottom Side
56 | this.EdgePoints[i].X = TopLeftCorner.X + this.Width * 0.25f;
57 | this.EdgePoints[i++].Y = BottomRightCorner.Y;
58 |
59 | this.EdgePoints[i].X = TopLeftCorner.X + this.Width * 0.5f;
60 | this.EdgePoints[i++].Y = BottomRightCorner.Y;
61 |
62 | this.EdgePoints[i].X = TopLeftCorner.X + this.Width * 0.75f;
63 | this.EdgePoints[i++].Y = BottomRightCorner.Y;
64 |
65 | //Left Side
66 | this.EdgePoints[i].X = TopLeftCorner.X;
67 | this.EdgePoints[i++].Y = TopLeftCorner.Y + this.Height * 0.25f;
68 |
69 | this.EdgePoints[i].X = TopLeftCorner.X;
70 | this.EdgePoints[i++].Y = TopLeftCorner.Y + this.Height * 0.5f;
71 |
72 | this.EdgePoints[i].X = TopLeftCorner.X;
73 | this.EdgePoints[i++].Y = TopLeftCorner.Y + this.Height * 0.75f;
74 | }
75 |
76 | public override FlowChartComponent GetComponent()
77 | {
78 | FlowChartComponent component = new FlowChartComponent();
79 | component.ID = this.ID;
80 | component.Text = Text;
81 | component.Type = this.GetType().FullName;
82 | component.Points.Add(TopLeftCorner);
83 | component.Points.Add(BottomRightCorner);
84 | return component;
85 | }
86 |
87 | public override void SetComponent(FlowChartComponent component)
88 | {
89 | ID = component.ID;
90 | Text = component.Text;
91 | TopLeftCorner = component.Points[0];
92 | BottomRightCorner = component.Points[1];
93 | }
94 | #endregion
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/Models/RhombusComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing.Drawing2D;
6 | using System.Drawing;
7 | using FlowChart.Entities;
8 | using FlowChart.Utility;
9 | using FlowChart.Views;
10 |
11 | namespace FlowChart.Models
12 | {
13 | public class RhombusComponent:BaseBoxComponent
14 | {
15 | private PointF[] coordinates = new PointF[4];
16 | #region Constructor
17 | public RhombusComponent()
18 | {
19 | this.ImageIndex = 2;
20 | for (int i = 0; i < 4; i++)
21 | {
22 | this.EdgePoints.Add(new FlowChartPoint());
23 | }
24 | }
25 | #endregion
26 |
27 | #region Virtual
28 | public override void Accept(Visitors.BaseVisitor visitor)
29 | {
30 | visitor.Visit(this);
31 | }
32 |
33 | public override void RecomputeEdgePoints()
34 | {
35 | this.EdgePoints[0].X = TopLeftCorner.X + this.Width / 2;
36 | this.EdgePoints[0].Y = TopLeftCorner.Y;
37 |
38 | this.EdgePoints[1].X = BottomRightCorner.X;
39 | this.EdgePoints[1].Y = TopLeftCorner.Y + this.Height / 2;
40 |
41 | this.EdgePoints[2].X = TopLeftCorner.X + this.Width / 2;
42 | this.EdgePoints[2].Y = BottomRightCorner.Y;
43 |
44 | this.EdgePoints[3].X = TopLeftCorner.X;
45 | this.EdgePoints[3].Y = TopLeftCorner.Y + this.Height / 2;
46 | }
47 |
48 | public override FlowChartComponent GetComponent()
49 | {
50 | FlowChartComponent component = new FlowChartComponent();
51 | component.ID = this.ID;
52 | component.Text = Text;
53 | component.Type = this.GetType().FullName;
54 | component.Points.Add(TopLeftCorner);
55 | component.Points.Add(BottomRightCorner);
56 | return component;
57 | }
58 |
59 | public override void SetComponent(FlowChartComponent component)
60 | {
61 | ID = component.ID;
62 | Text = component.Text;
63 | TopLeftCorner = component.Points[0];
64 | BottomRightCorner = component.Points[1];
65 | }
66 |
67 | #endregion
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Models/RoundComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing.Drawing2D;
6 | using System.Drawing;
7 | using FlowChart.Entities;
8 | using FlowChart.Utility;
9 | using FlowChart.Views;
10 |
11 | namespace FlowChart.Models
12 | {
13 | public class RoundComponent:BaseBoxComponent
14 | {
15 | #region Constructor
16 | public RoundComponent()
17 | {
18 | this.ImageIndex = 1;
19 | for (int i = 0; i < 8; i++)
20 | {
21 | this.EdgePoints.Add(new FlowChartPoint());
22 | }
23 | }
24 | #endregion
25 |
26 | #region Virtual
27 | public override void Accept(Visitors.BaseVisitor visitor)
28 | {
29 | visitor.Visit(this);
30 | }
31 |
32 | public override void RecomputeEdgePoints()
33 | {
34 | float aradius = Math.Abs(TopLeftCorner.MakeRectangleFTill(BottomRightCorner).Width)/2;
35 | float bradius = Math.Abs(TopLeftCorner.MakeRectangleFTill(BottomRightCorner).Height) / 2;
36 | FlowChartPoint centerPoint = TopLeftCorner.CloneAndAdd(BottomRightCorner);
37 | centerPoint.X /= 2;
38 | centerPoint.Y /= 2;
39 | float angle = -(float)Math.PI / 2.0f;
40 | this.EdgePoints.ForEach(x => {
41 | x.X = centerPoint.X + aradius * (float)Math.Cos(angle);
42 | x.Y = centerPoint.Y + bradius * (float)Math.Sin(angle);
43 | angle += (float)Math.PI / 4.0f;
44 | });
45 | }
46 |
47 | public override FlowChartComponent GetComponent()
48 | {
49 | FlowChartComponent component = new FlowChartComponent();
50 | component.ID = this.ID;
51 | component.Text = Text;
52 | component.Type = this.GetType().FullName;
53 | component.Points.Add(TopLeftCorner);
54 | component.Points.Add(BottomRightCorner);
55 | return component;
56 | }
57 |
58 | public override void SetComponent(FlowChartComponent component)
59 | {
60 | ID = component.ID;
61 | Text = component.Text;
62 | TopLeftCorner = component.Points[0];
63 | BottomRightCorner = component.Points[1];
64 | }
65 |
66 | #endregion
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Persistance/BaseStorage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Entities;
6 | using FlowChart.Controller;
7 | using FlowChart.Models;
8 |
9 | namespace FlowChart.Persistance
10 | {
11 | internal abstract class BaseStorage
12 | {
13 | internal abstract void Save(FlowChartModel model);
14 | internal abstract FlowChartContainer Load();
15 | internal virtual FlowChartContainer GetContent(FlowChartModel model)
16 | {
17 | FlowChartContainer container = new FlowChartContainer();
18 | model.Items.ForEach(x => container.Items.Add(x.GetComponent()));
19 | return container;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Persistance/FileStorage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using FlowChart.Utility;
7 | using FlowChart.Entities;
8 | using FlowChart.Controller;
9 | using FlowChart.Models;
10 |
11 | namespace FlowChart.Persistance
12 | {
13 | internal class FileStorage:BaseStorage
14 | {
15 | private string fileName;
16 | public FileStorage(string fileName)
17 | {
18 | this.fileName = fileName;
19 | }
20 | internal override FlowChartContainer Load()
21 | {
22 | try
23 | {
24 | string strContent = File.ReadAllText(fileName);
25 | return Util.ConvertFromJSON(strContent);
26 | }
27 | catch (Exception ex)
28 | {
29 | Console.Out.WriteLine(ex.Message);
30 | throw ex;
31 | }
32 | }
33 | internal override void Save(FlowChartModel model)
34 | {
35 | string strContent = Util.GetJSONString(GetContent(model));
36 | File.WriteAllText(fileName, strContent);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Persistance/ImageStorage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using FlowChart.Utility;
7 | using FlowChart.Entities;
8 | using FlowChart.Controller;
9 | using System.Drawing;
10 | using System.Drawing.Imaging;
11 | using FlowChart.Models;
12 |
13 | namespace FlowChart.Persistance
14 | {
15 | internal class ImageStorage:BaseStorage
16 | {
17 | private string fileName;
18 | public ImageStorage(string fileName)
19 | {
20 | this.fileName = fileName;
21 | }
22 | internal override FlowChartContainer Load()
23 | {
24 | return null;
25 | }
26 | internal override void Save(FlowChartModel model)
27 | {
28 | float ZoomFactor = 4.0f;
29 |
30 | using (Bitmap bmp = new Bitmap((int)(601*ZoomFactor), (int)(851*ZoomFactor)))
31 | {
32 | using (Graphics g = Graphics.FromImage(bmp))
33 | {
34 | System.Drawing.Drawing2D.Matrix mx = new System.Drawing.Drawing2D.Matrix(ZoomFactor, 0, 0, ZoomFactor, 0, 0);
35 | g.Transform = mx;
36 |
37 | g.PageUnit = GraphicsUnit.Pixel;
38 | g.Clear(Color.White);
39 | g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
40 | g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
41 | g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
42 |
43 | model.Items.ForEach(x =>
44 | {
45 | x.View.Draw(g);
46 | });
47 |
48 | g.Save();
49 |
50 | ImageFormat fm = ImageFormat.Bmp;
51 | if (Path.GetExtension(fileName).ToLower() == ".png")
52 | {
53 | fm = System.Drawing.Imaging.ImageFormat.Png;
54 | }
55 | else if (Path.GetExtension(fileName).ToLower() == ".jpg")
56 | {
57 | fm = System.Drawing.Imaging.ImageFormat.Jpeg;
58 | }
59 | else if (Path.GetExtension(fileName).ToLower() == ".jpeg")
60 | {
61 | fm = System.Drawing.Imaging.ImageFormat.Jpeg;
62 | }
63 | else if (Path.GetExtension(fileName).ToLower() == ".gif")
64 | {
65 | fm = System.Drawing.Imaging.ImageFormat.Gif;
66 | }
67 | else if (Path.GetExtension(fileName).ToLower() == ".tiff")
68 | {
69 | fm = System.Drawing.Imaging.ImageFormat.Tiff;
70 | }
71 | bmp.Save(fileName, fm);
72 | }
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Persistance/MemoryStorage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Entities;
6 | using FlowChart.Utility;
7 | using FlowChart.Controller;
8 | using FlowChart.Models;
9 |
10 | namespace FlowChart.Persistance
11 | {
12 | internal class MemoryStorage : BaseStorage
13 | {
14 | private List UndoBuffers = new List();
15 |
16 | internal override FlowChartContainer Load()
17 | {
18 | return this.UndoBuffers[0];
19 | }
20 | internal FlowChartContainer LoadAt(int index)
21 | {
22 | return this.UndoBuffers[index];
23 | }
24 | internal override void Save(FlowChartModel model)
25 | {
26 |
27 | FlowChartContainer newContent = Util.ConvertFromJSON(Util.GetJSONString(GetContent(model)));
28 | FlowChartContainer container = UndoBuffers.LastOrDefault();
29 | if (container == null)
30 | {
31 | newContent.DisplayName = DateTime.Now.ToString("HH:mm:ss");
32 | UndoBuffers.Add(newContent);
33 | }
34 | else
35 | {
36 | string oDisplayName = container.DisplayName;
37 | container.DisplayName = "";
38 | newContent.DisplayName = "";
39 |
40 | if (Util.GetJSONString(newContent) != Util.GetJSONString(container))
41 | {
42 | newContent.DisplayName = DateTime.Now.ToString("HH:mm:ss");
43 | UndoBuffers.Add(newContent);
44 | if (UndoBuffers.Count > 10)
45 | {
46 | UndoBuffers.RemoveAt(0);
47 | }
48 | }
49 | container.DisplayName = oDisplayName;
50 | }
51 | }
52 |
53 | internal List GetUndoBuffers()
54 | {
55 | return UndoBuffers;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace FlowChart
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// The main entry point for the application.
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new FormMain());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("FlowChart (By: Pradeep Kodical [kpradeeprao@gmail.com])")]
9 | [assembly: AssemblyDescription("Developed by: Pradeep Kodical [kpradeeprao@gmail.com]")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Kiprosh America Inc.")]
12 | [assembly: AssemblyProduct("FlowChart")]
13 | [assembly: AssemblyCopyright("Copyright © Kiprosh America Inc 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("12d1b008-aaf4-4159-a4b8-50ef958262f3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Properties/DataSources/FlowChart.Entities.FlowChartContainer.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | FlowChart.Entities.FlowChartContainer, FlowChart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.261
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace FlowChart.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FlowChart.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.261
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace FlowChart.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | FlowChart
2 | =========
3 |
4 | .NET Flowchart tool
5 |
6 | Base version.
--------------------------------------------------------------------------------
/Tools/BaseInputTool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Models;
6 |
7 | namespace FlowChart.Tools
8 | {
9 | internal abstract class BaseInputTool
10 | {
11 | public event Action Zoom;
12 | public event Action Scroll;
13 | public event Action Add;
14 | public event Action Delete;
15 | public event Action DblClick;
16 | public event Action Select;
17 |
18 | protected void OnSelect(BaseComponent obj)
19 | {
20 | if (this.Select != null)
21 | {
22 | this.Select(obj);
23 | }
24 | }
25 |
26 | protected void OnZoom(float zoom, float x , float y)
27 | {
28 | if (this.Zoom != null)
29 | {
30 | this.Zoom(zoom,x,y);
31 | }
32 | }
33 |
34 | protected void OnScroll(float delta, float x, float y)
35 | {
36 | if (this.Scroll != null)
37 | {
38 | this.Scroll(delta, x, y);
39 | }
40 | }
41 |
42 | protected void OnAdd(BaseComponent obj)
43 | {
44 | if (this.Add != null)
45 | {
46 | this.Add(obj);
47 | }
48 | }
49 |
50 | protected void OnDelete(BaseComponent obj)
51 | {
52 | if (this.Delete != null)
53 | {
54 | this.Delete(obj);
55 | }
56 | }
57 |
58 | protected void OnDblClick(float x, float y)
59 | {
60 | if (this.DblClick != null)
61 | {
62 | this.DblClick(x, y);
63 | }
64 | }
65 |
66 | public BaseComponent SelectedComponent { get; set; }
67 | public virtual float ZoomFactor { get;set;}
68 |
69 | protected abstract void KeyDown(System.Windows.Forms.KeyEventArgs e);
70 | protected abstract void MouseMove(System.Windows.Forms.MouseEventArgs e);
71 | protected abstract void MouseUp(System.Windows.Forms.MouseEventArgs e);
72 | protected abstract void MouseDown(System.Windows.Forms.MouseEventArgs e);
73 | protected abstract void MouseDoubleClick(System.Windows.Forms.MouseEventArgs e);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Tools/DefaultInputTool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Controller;
6 | using FlowChart.Models;
7 | using FlowChart.Entities;
8 | using FlowChart.Utility;
9 | using FlowChart.Visitors;
10 | using System.Windows.Forms;
11 | using FlowChart.Views;
12 | using System.Drawing;
13 | using System.Drawing.Drawing2D;
14 |
15 | namespace FlowChart.Tools
16 | {
17 | internal class DefaultInputTool:BaseInputTool
18 | {
19 | private float maxTop = 0;
20 | private float minTop = 0;
21 | private float maxLeft = 0;
22 | private float minLeft = 0;
23 |
24 | private float zoom = 1;
25 | private readonly float zoomLimit = 25;
26 | private readonly int offSet = 25;
27 | private PointF lastPoint = new PointF();
28 |
29 | public override float ZoomFactor
30 | {
31 | get
32 | {
33 | return base.ZoomFactor;
34 | }
35 | set
36 | {
37 | base.ZoomFactor = value;
38 | if (this.View != null)
39 | {
40 | float delta = (601 * ZoomFactor - this.View.Width);
41 | Zoom(delta, (int)lastPoint.X, (int)lastPoint.Y);
42 | this.View.Invalidate();
43 | /*if (this.Resize != null)
44 | {
45 | this.Resize();
46 | }*/
47 | }
48 | }
49 | }
50 | public ScrollableControl View
51 | {
52 | get;
53 | private set;
54 | }
55 |
56 | public FlowChartModel Model
57 | {
58 | get;
59 | set;
60 | }
61 |
62 | internal DefaultInputTool(FlowChartModel model, FlowChartPage view)
63 | {
64 | this.Model = model;
65 | this.View = view;
66 |
67 | View.MouseDown += new System.Windows.Forms.MouseEventHandler(View_MouseDown);
68 | View.MouseUp += new System.Windows.Forms.MouseEventHandler(View_MouseUp);
69 | View.MouseMove += new System.Windows.Forms.MouseEventHandler(View_MouseMove);
70 | View.KeyDown += new System.Windows.Forms.KeyEventHandler(View_KeyDown);
71 | View.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(View_MouseDoubleClick);
72 | View.MouseWheel += new MouseEventHandler(View_MouseWheel);
73 | view.DragMouse += new Action(view_DragMouse);
74 | }
75 |
76 | private void Zoom(float delta, int focusX, int focusY)
77 | {
78 | float oX = View.Left + focusX;
79 | float oY = View.Top + focusY;
80 |
81 | float nWidth = View.Width + delta;
82 | float nHeight = View.Height + delta;
83 |
84 | float newX = (focusX * nWidth) / View.Width;
85 | float newY = (focusY * nHeight) / View.Height;
86 |
87 | View.Width = (int)Math.Round(nWidth);
88 | View.Height = (int)Math.Round(nHeight);
89 |
90 | View.Left = (int)Math.Round(oX - newX);
91 | View.Top = (int)Math.Round(oY - newY);
92 | }
93 |
94 | internal void ResetView(float maxTop, float minTop, float maxLeft, float minLeft)
95 | {
96 | this.maxTop = maxTop;
97 | this.minTop = minTop;
98 | this.maxLeft = maxLeft;
99 | this.minLeft = minLeft;
100 | }
101 |
102 | void view_DragMouse(float x, float y)
103 | {
104 | float nTop = View.Top + y;
105 | float nLeft = View.Left + x;
106 |
107 | if (nLeft > minLeft && nLeft <= maxLeft)
108 | {
109 | View.Left += (int)x;
110 | }
111 | if (nTop > minTop && nTop <= maxTop)
112 | {
113 | View.Top += (int)y;
114 | }
115 | }
116 |
117 | void View_MouseWheel(object sender, MouseEventArgs e)
118 | {
119 | MouseEventArgs p = BacktrackMouse(e);
120 |
121 | if ((Control.ModifierKeys & Keys.Control) != Keys.None)
122 | {
123 | float f = 1.1f;
124 | if ((e.Delta / 120) < 0) f = 1 / f;
125 |
126 | this.lastPoint.X = p.X;
127 | this.lastPoint.Y = p.Y;
128 |
129 | this.OnZoom(f, p.X, p.Y);
130 | }
131 | else
132 | {
133 | float nTop = View.Top + e.Delta / 10;
134 | if (nTop > minTop && nTop <= maxTop)
135 | {
136 | View.Top += (int)e.Delta / 10;
137 | }
138 | this.OnScroll(e.Delta/10, p.X, p.Y);
139 | }
140 | }
141 |
142 | void View_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e)
143 | {
144 | this.MouseDoubleClick(BacktrackMouse(e));
145 | }
146 | void View_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
147 | {
148 | this.KeyDown(e);
149 | }
150 | void View_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
151 | {
152 | this.MouseMove(BacktrackMouse(e));
153 | }
154 |
155 | void View_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
156 | {
157 | this.MouseUp(BacktrackMouse(e));
158 | }
159 |
160 | void View_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
161 | {
162 | this.MouseDown(BacktrackMouse(e));
163 | }
164 |
165 | private void SaveInstance()
166 | {
167 | System.Windows.Forms.Clipboard.SetText(Util.GetJSONString(SelectedComponent.GetComponent()));
168 | }
169 | private void LoadInstance()
170 | {
171 | try
172 | {
173 | FlowChartComponent fc = Util.ConvertFromJSON(System.Windows.Forms.Clipboard.GetText());
174 | BaseComponent c = (BaseComponent)Activator.CreateInstance(Type.GetType(fc.Type));
175 | c.SetComponent(fc);
176 | c.ID = Util.GetUniqueID();
177 | c.Accept(new ObjectCreateVisitor(Model, fc));
178 | this.OnAdd(c);
179 | }
180 | catch
181 | {
182 | }
183 | }
184 |
185 | protected override void KeyDown(System.Windows.Forms.KeyEventArgs e)
186 | {
187 | if (e.KeyCode == System.Windows.Forms.Keys.Delete)
188 | {
189 | if (SelectedComponent != null)
190 | {
191 | this.OnDelete(SelectedComponent);
192 | this.View.Invalidate();
193 | }
194 | }
195 | else if (e.KeyCode == System.Windows.Forms.Keys.C && e.Control)
196 | {
197 | if (SelectedComponent != null)
198 | {
199 | SaveInstance();
200 | }
201 | }
202 | else if (e.KeyCode == System.Windows.Forms.Keys.V && e.Control)
203 | {
204 | LoadInstance();
205 | }
206 | }
207 | protected override void MouseDown(System.Windows.Forms.MouseEventArgs e)
208 | {
209 | if (SelectedComponent != null)
210 | {
211 | if (SelectedComponent.HitTest(e.X, e.Y))
212 | {
213 | if ((Control.ModifierKeys & Keys.Shift) != Keys.None)
214 | {
215 | SaveInstance();
216 | LoadInstance();
217 | BaseComponent addedCmp = SelectedComponent;
218 | if (addedCmp.HitTest(e.X, e.Y))
219 | {
220 | OnSelect(addedCmp);
221 | addedCmp.MouseDown(e);
222 | }
223 | return;
224 | }
225 | else
226 | {
227 | SelectedComponent.MouseDown(e);
228 | return;
229 | }
230 | }
231 | else
232 | {
233 | OnSelect(null);
234 | }
235 | }
236 |
237 | foreach (BaseComponent x in Model.Items)
238 | {
239 | x.MouseState = Entities.MouseState.None;
240 | x.IsSelected = false;
241 | if (x.HitTest(e.X, e.Y))
242 | {
243 | OnSelect(x);
244 | x.MouseDown(e);
245 | break;
246 | }
247 |
248 | }
249 | this.View.Invalidate();
250 | }
251 | protected override void MouseMove(System.Windows.Forms.MouseEventArgs e)
252 | {
253 | if (SelectedComponent != null)
254 | {
255 | if (e.Button == System.Windows.Forms.MouseButtons.Left)
256 | {
257 | if (SelectedComponent.MouseState == MouseState.Resize)
258 | {
259 | SelectedComponent.MouseMove(e);
260 | this.View.Invalidate();
261 | }
262 | else if (SelectedComponent.MouseState == MouseState.Move)
263 | {
264 | SelectedComponent.Move(e);
265 | this.View.Invalidate();
266 | }
267 | }
268 | }
269 | }
270 |
271 | protected override void MouseUp(System.Windows.Forms.MouseEventArgs e)
272 | {
273 | if (SelectedComponent != null)
274 | {
275 | SelectedComponent.MouseUp(e);
276 | this.View.Invalidate();
277 | }
278 | }
279 |
280 | protected override void MouseDoubleClick(System.Windows.Forms.MouseEventArgs e)
281 | {
282 | if (SelectedComponent != null)
283 | {
284 | MouseEventArgs p = BacktrackMouse(e);
285 | this.OnDblClick(p.X, p.Y);
286 | }
287 | }
288 |
289 | protected MouseEventArgs BacktrackMouse(MouseEventArgs e)
290 | {
291 | float zoom = this.ZoomFactor;
292 | Matrix mx = new Matrix(zoom, 0, 0, zoom, 0, 0);
293 | mx.Translate(View.AutoScrollPosition.X * (1.0f / zoom), View.AutoScrollPosition.Y * (1.0f / zoom));
294 | mx.Invert();
295 | Point[] pa = new Point[] { new Point(e.X, e.Y) };
296 | mx.TransformPoints(pa);
297 | return new MouseEventArgs(e.Button, e.Clicks, pa[0].X, pa[0].Y, e.Delta);
298 | }
299 | }
300 | }
301 |
--------------------------------------------------------------------------------
/Utility/GraphicsSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 |
7 | namespace FlowChart.Utility
8 | {
9 | class GraphicsSettings
10 | {
11 | public static readonly Pen BoundingBoxPen = new Pen(Color.Blue, 1);
12 | public static readonly Pen LinePen = new Pen(Color.DarkSlateBlue, 2);
13 |
14 | public static readonly Pen SelectedPen = new Pen(Color.OrangeRed, 2);
15 |
16 | public static readonly Pen BorderPen = new Pen(Color.Black, 2);
17 | public static readonly Pen TextPen = new Pen(Color.Black, 2);
18 | public static readonly Pen LabelPen = new Pen(Color.Red, 2);
19 | public static readonly Pen EdgePen = new Pen(Color.RoyalBlue, 1);
20 | public static readonly Pen ResizePen = new Pen(Color.SandyBrown, 2);
21 |
22 | public static float EdgeBoxWidth = 16.0f;
23 | public static float ResizeBoxWidth = 16.0f;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Utility/GraphicsUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Entities;
7 |
8 | namespace FlowChart.Utility
9 | {
10 | internal class GraphicsUtil
11 | {
12 | #region Helpers
13 |
14 | internal static float Distance(float x1, float y1, float x2, float y2)
15 | {
16 | float x = x2 - x1;
17 | float y = y2 - y1;
18 | return (float)Math.Sqrt((float)(x * x + y * y));
19 | }
20 |
21 | internal static float Distance(FlowChartPoint p1, float x, float y)
22 | {
23 | return Distance(p1.X, p1.Y, x, y);
24 | }
25 |
26 | internal static float Distance(FlowChartPoint p1, FlowChartPoint p2)
27 | {
28 | return Distance(p1, p2.X, p2.Y);
29 | }
30 |
31 | internal static bool HasPoint(FlowChartPoint[] points, float testx, float testy)
32 | {
33 | int i, j;
34 | bool c = false;
35 | for (i = 0, j = points.Length - 1; i < points.Length; j = i++)
36 | {
37 | if (((points[i].Y > testy) != (points[j].Y > testy)) &&
38 | (testx < (points[j].X - points[i].X) * (testy - points[i].Y) / (points[j].Y - points[i].Y) + points[i].X))
39 | c = !c;
40 | }
41 | return c;
42 | }
43 |
44 | internal static float DistanceToLine(FlowChartPoint StartPoint, FlowChartPoint EndPoint, int x, int y)
45 | {
46 | float A = x - StartPoint.X;
47 | float B = y - StartPoint.Y;
48 | float C = EndPoint.X - StartPoint.X;
49 | float D = EndPoint.Y - StartPoint.Y;
50 |
51 | return (float)(Math.Abs(A * D - C * B) / Math.Sqrt(C * C + D * D));
52 | }
53 | #endregion
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Utility/Util.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Models;
6 | using System.Web.Script.Serialization;
7 | using System.Drawing;
8 |
9 | namespace FlowChart.Utility
10 | {
11 | internal class Util
12 | {
13 | internal static string GetJSONString(object data)
14 | {
15 | JavaScriptSerializer serializer = new JavaScriptSerializer();
16 | return serializer.Serialize(data);
17 | }
18 | internal static T ConvertFromJSON(String json)
19 | {
20 | JavaScriptSerializer serializer = new JavaScriptSerializer();
21 | return serializer.Deserialize(json);
22 | }
23 | internal static string GetUniqueID()
24 | {
25 | return DateTime.Now.Ticks.ToString();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Views/BaseBoxView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Views
10 | {
11 | public class BaseBoxView: BaseView
12 | {
13 | public BaseBoxComponent Component{get;set;}
14 | public override void Draw(Graphics g)
15 | {
16 | DrawText(g, this.Font, this.Component.Text, ViewFactory.LabelBrush, this.Component.TopLeftCorner.MakeRectangleTill(this.Component.BottomRightCorner));
17 |
18 | if (this.Component.IsSelected)
19 | {
20 | DrawBoundingBox(g, this.Component.TopLeftCorner, this.Component.BottomRightCorner);
21 |
22 | DrawResizePoint(g, this.Component.TopLeftCorner, ViewFactory.ResizePen, ViewFactory.ResizeBoxWidth);
23 | DrawResizePoint(g, this.Component.BottomRightCorner, ViewFactory.ResizePen, ViewFactory.ResizeBoxWidth);
24 |
25 | if (this.Component.SelectedPoint != null)
26 | {
27 | Draw4Arrows(g, this.Component.SelectedPoint, ViewFactory.ArrowLength);
28 | }
29 | this.Component.EdgePoints.ForEach(x =>
30 | {
31 | DrawPoint(g, x, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
32 | });
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Views/BaseLineView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Views
10 | {
11 | public class BaseLineView: BaseView
12 | {
13 | public BaseLineComponent Component { get; set; }
14 | public override void Draw(Graphics g)
15 | {
16 | DrawText(g, this.Font, this.Component.Text, ViewFactory.LabelBrush, this.Component.GetWeightedPoint());
17 |
18 | if (this.Component.IsSelected)
19 | {
20 | DrawResizePoint(g, this.Component.StartPoint, ViewFactory.ResizePen, ViewFactory.ResizeBoxWidth);
21 | DrawResizePoint(g, this.Component.EndPoint, ViewFactory.ResizePen, ViewFactory.ResizeBoxWidth);
22 | if (this.Component.SelectedPoint != null)
23 | {
24 | Draw4Arrows(g, this.Component.SelectedPoint, ViewFactory.ArrowLength);
25 | }
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Views/BaseView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Entities;
7 | using FlowChart.Utility;
8 | using FlowChart.Factory;
9 |
10 | namespace FlowChart.Views
11 | {
12 | public abstract class BaseView
13 | {
14 | public ViewAbstractFactory ViewFactory { get; set; }
15 | public Font Font { get; set; }
16 |
17 | public abstract void Draw(Graphics g);
18 |
19 | protected void DrawText(Graphics g, Font font, string text, Brush brush, Rectangle rect)
20 | {
21 | StringFormat sf = new StringFormat(StringFormat.GenericDefault);
22 | sf.Alignment = StringAlignment.Center;
23 | sf.LineAlignment = StringAlignment.Center;
24 | g.DrawString(text, font, brush, rect, sf);
25 | }
26 |
27 | protected void DrawText(Graphics g, Font font, string text, Brush brush, FlowChartPoint point)
28 | {
29 | StringFormat sf = new StringFormat(StringFormat.GenericDefault);
30 | sf.Alignment = StringAlignment.Center;
31 | sf.LineAlignment = StringAlignment.Center;
32 | g.DrawString(text, font, brush, point.X, point.Y, sf);
33 | }
34 | protected void Draw4Arrows(Graphics g, FlowChartPoint p, float length)
35 | {
36 | /* ^
37 | * <-|->
38 | * v
39 | */
40 |
41 | DrawArrow(g, p.CloneAndAdd(0, -length), p, Brushes.YellowGreen, Pens.Red, length);
42 | DrawArrow(g, p.CloneAndAdd(0, length), p, Brushes.YellowGreen, Pens.Red, length);
43 | DrawArrow(g, p.CloneAndAdd(-length, 0), p, Brushes.YellowGreen, Pens.Red, length);
44 | DrawArrow(g, p.CloneAndAdd(length, 0), p, Brushes.YellowGreen, Pens.Red, length);
45 | }
46 |
47 | protected void DrawPoint(Graphics g, FlowChartPoint p, Pen pen, float width, bool fill)
48 | {
49 | if (fill)
50 | {
51 | g.FillRectangle(Brushes.AliceBlue, p.X - width / 2, p.Y - width / 2, width, width);
52 | }
53 | g.DrawRectangle(pen, p.X - width / 2, p.Y - width / 2, width, width);
54 | }
55 |
56 | protected void DrawPoint(Graphics g, FlowChartPoint p, Pen pen, float width)
57 | {
58 | DrawPoint(g, p, pen, width, false);
59 | }
60 |
61 | protected void DrawResizePoint(Graphics g, FlowChartPoint p, Pen pen, float width)
62 | {
63 | Draw4Arrows(g, p, 10);
64 | }
65 |
66 | protected void DrawBoundingBox(Graphics g,
67 | FlowChartPoint startPoint,
68 | FlowChartPoint endPoint)
69 | {
70 | g.DrawPolygon(ViewFactory.BoundingBoxPen, startPoint.MakePointFArrayWith(endPoint));
71 | }
72 | protected void DrawBoundingBox(Graphics g,
73 | FlowChartPoint p1,
74 | FlowChartPoint p2,
75 | FlowChartPoint p3,
76 | FlowChartPoint p4)
77 | {
78 | g.DrawPolygon(
79 | ViewFactory.BoundingBoxPen,
80 | new PointF[]
81 | {
82 | p1.MakePointF(),
83 | p2.MakePointF(),
84 | p3.MakePointF(),
85 | p4.MakePointF()
86 | });
87 | }
88 |
89 | protected void DrawArrow(Graphics g, FlowChartPoint dst, FlowChartPoint src, Brush b, Pen p, float length)
90 | {
91 | float angle = (float)Math.Atan2(dst.Y - src.Y, dst.X - src.X);
92 | float x1 = dst.X - (float)(0.5 * length * Math.Cos(angle + Math.PI / 6.0f));
93 | float y1 = dst.Y - (float)(0.5 * length * Math.Sin(angle + Math.PI / 6.0f));
94 |
95 | float x2 = dst.X - (float)(0.5 * length * Math.Cos(angle - Math.PI / 6.0f));
96 | float y2 = dst.Y - (float)(0.5 * length * Math.Sin(angle - Math.PI / 6.0f));
97 |
98 | g.FillPolygon(b, new PointF[] {
99 | new PointF(dst.X, dst.Y),
100 | new PointF(x1, y1),
101 | new PointF(x2, y2)
102 | });
103 | g.DrawPolygon(p, new PointF[] {
104 | new PointF(dst.X, dst.Y),
105 | new PointF(x1, y1),
106 | new PointF(x2, y2)
107 | });
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/Views/CurvedLineView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Views
10 | {
11 | public class CurvedLineView: BaseLineView
12 | {
13 | protected CurvedLineComponent lineComponent;
14 | public void SetComponent(CurvedLineComponent lineComponent)
15 | {
16 | this.lineComponent = lineComponent;
17 | this.Component = lineComponent;
18 | this.lineComponent.View = this;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Views/DatabaseView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views
11 | {
12 | public class DatabaseView: BaseBoxView
13 | {
14 | protected float offSet = 16;
15 | protected DatabaseComponent rectComponent;
16 | public void SetComponent(DatabaseComponent rectComponent)
17 | {
18 | this.rectComponent = rectComponent;
19 | this.Component = rectComponent;
20 | this.rectComponent.View = this;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Views/Default/CurvedLineView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Views.Default
10 | {
11 | public class DefaultCurvedLineView : CurvedLineView
12 | {
13 | public override void Draw(Graphics g)
14 | {
15 | if (this.lineComponent.IsSelected)
16 | {
17 | g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.StartPoint.X, this.lineComponent.StartPoint.Y, this.lineComponent.ControlPoint1.X, this.lineComponent.ControlPoint1.Y);
18 | g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.EndPoint.X, this.lineComponent.EndPoint.Y, this.lineComponent.ControlPoint2.X, this.lineComponent.ControlPoint2.Y);
19 | }
20 | if (this.lineComponent.ParentMoving)
21 | {
22 | g.DrawBezier(ViewFactory.LinePen,
23 | this.lineComponent.StartPoint.MakePointF(),
24 | this.lineComponent.ControlPoint1.MakePointF(),
25 | this.lineComponent.ControlPoint2.MakePointF(),
26 | this.lineComponent.EndPoint.MakePointF());
27 | }
28 | else
29 | {
30 | g.DrawLines(ViewFactory.LinePen, this.lineComponent.points.ToArray());
31 | /*DrawPoint(g, new FlowChartPoint(points[points.Count/2].X,points[points.Count/2].Y),
32 | GraphicsSettings.LabelPen, GraphicsSettings.EdgeBoxWidth);*/
33 | }
34 |
35 | DrawArrow(g, this.lineComponent.EndPoint, this.lineComponent.ControlPoint2,
36 | ViewFactory.ArrowBrush,
37 | ViewFactory.ArrowPen,
38 | ViewFactory.ArrowLength);
39 |
40 | if (this.lineComponent.IsSelected)
41 | {
42 | DrawPoint(g, this.lineComponent.ControlPoint1, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
43 | DrawPoint(g, this.lineComponent.ControlPoint2, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
44 | }
45 | base.Draw(g);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Views/Default/DatabaseView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views.Default
11 | {
12 | public class DefaultDatabaseView : DatabaseView
13 | {
14 | public override void Draw(Graphics g)
15 | {
16 | RectangleF rect = rectComponent.TopLeftCorner.CloneAndAdd(0, offSet).MakeRectangleFTill(rectComponent.BottomRightCorner.CloneAndAdd(0, -offSet));
17 | RectangleF upperRect = rectComponent.TopLeftCorner.MakeRectangleFTill(rectComponent.TopLeftCorner.CloneAndAdd(rectComponent.Width, 2 * offSet));
18 | RectangleF lowerRect = rectComponent.BottomRightCorner.CloneAndAdd(-rectComponent.Width, -2 * offSet).MakeRectangleFTill(rectComponent.BottomRightCorner);
19 |
20 | using (LinearGradientBrush brush =
21 | new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
22 | {
23 | g.FillRectangle(brush, rect);
24 | g.DrawRectangle(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
25 | }
26 |
27 |
28 | using (LinearGradientBrush brush =
29 | new LinearGradientBrush(upperRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
30 | {
31 | g.FillEllipse(brush, upperRect);
32 | g.DrawEllipse(ViewFactory.BorderPen, upperRect.X, upperRect.Y, upperRect.Width, upperRect.Height);
33 | }
34 |
35 | using (LinearGradientBrush brush =
36 | new LinearGradientBrush(lowerRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
37 | {
38 | g.FillEllipse(brush, lowerRect);
39 | g.DrawArc(ViewFactory.BorderPen, lowerRect, 0, 180);
40 | }
41 | base.Draw(g);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Views/Default/DefaultViewFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Factory;
6 | using System.Drawing;
7 |
8 | namespace FlowChart.Views.Default
9 | {
10 | public class DefaultViewFactory : ViewAbstractFactory
11 | {
12 | static readonly Pen boundingBoxPen = new Pen(Color.Blue, 1);
13 | static readonly Pen linePen = new Pen(Color.DarkSlateBlue, 2);
14 |
15 | static readonly Pen selectedPen = new Pen(Color.OrangeRed, 2);
16 |
17 | static readonly Pen borderPen = new Pen(Color.Black, 1);
18 | static readonly Pen textPen = new Pen(Color.Black, 2);
19 | static readonly Pen labelPen = new Pen(Color.Red, 2);
20 | static readonly Pen edgePen = new Pen(Color.RoyalBlue, 1);
21 | static readonly Pen resizePen = new Pen(Color.SandyBrown, 2);
22 |
23 | static readonly Brush arrowBrush = Brushes.DodgerBlue;
24 | static readonly Pen arrowPen = new Pen(Color.LightSteelBlue, 1);
25 |
26 | static readonly float edgeBoxWidth = 8.0f;
27 | static readonly float resizeBoxWidth = 16.0f;
28 | static readonly float arrowLength = 20.0f;
29 |
30 |
31 | public override Pen BoundingBoxPen { get { return boundingBoxPen; } }
32 | public override Pen LinePen { get { return linePen; } }
33 |
34 | public override Pen SelectedPen { get { return selectedPen; } }
35 |
36 | public override Pen BorderPen { get { return borderPen; } }
37 | public override Pen TextPen { get { return textPen; } }
38 | public override Pen LabelPen { get { return labelPen; } }
39 | public override Pen EdgePen { get { return edgePen; } }
40 | public override Pen ResizePen { get { return resizePen; } }
41 |
42 | public override Brush ArrowBrush { get { return arrowBrush; } }
43 | public override Pen ArrowPen { get { return arrowPen; } }
44 |
45 | public override float EdgeBoxWidth { get { return edgeBoxWidth; } }
46 | public override float ResizeBoxWidth { get { return resizeBoxWidth; } }
47 | public override float ArrowLength { get { return arrowLength; } }
48 |
49 | public override Brush LabelBrush { get { return Brushes.IndianRed; } }
50 |
51 | public override Color GradStartColor { get { return Color.White; } }
52 | public override Color GradEndColor { get { return Color.Wheat; } }
53 |
54 | public override StraightLineView CreateStraightLineView()
55 | {
56 | return new DefaultStraightLineView { ViewFactory = this};
57 | }
58 |
59 | public override CurvedLineView CreateCurvedLineView()
60 | {
61 | return new DefaultCurvedLineView { ViewFactory = this };
62 | }
63 |
64 | public override DatabaseView CreateDatabaseView()
65 | {
66 | return new DefaultDatabaseView { ViewFactory = this };
67 | }
68 |
69 | public override RectangleView CreateRectangleView()
70 | {
71 | return new DefaultRectangleView { ViewFactory = this };
72 | }
73 |
74 | public override RhombusView CreateRhombusView()
75 | {
76 | return new DefaultRhombusView { ViewFactory = this };
77 | }
78 |
79 | public override RoundView CreateRoundView()
80 | {
81 | return new DefaultRoundView { ViewFactory = this };
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Views/Default/RectangleView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views.Default
11 | {
12 | public class DefaultRectangleView : RectangleView
13 | {
14 | public override void Draw(Graphics g)
15 | {
16 | RectangleF rect = this.rectComponent.TopLeftCorner.MakeRectangleFTill(this.rectComponent.BottomRightCorner);
17 |
18 | using (LinearGradientBrush brush =
19 | new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
20 | {
21 | g.FillRectangle(brush, rect);
22 | g.DrawRectangle(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
23 |
24 | base.Draw(g);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Views/Default/RhombusView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views.Default
11 | {
12 | public class DefaultRhombusView : RhombusView
13 | {
14 | public override void Draw(Graphics g)
15 | {
16 | coordinates[0].X = this.rectComponent.TopLeftCorner.X + this.rectComponent.Width / 2;
17 | coordinates[0].Y = this.rectComponent.TopLeftCorner.Y;
18 |
19 | coordinates[1].X = this.rectComponent.TopLeftCorner.X + this.rectComponent.Width;
20 | coordinates[1].Y = this.rectComponent.TopLeftCorner.Y + this.rectComponent.Height / 2;
21 |
22 | coordinates[2].X = this.rectComponent.TopLeftCorner.X + this.rectComponent.Width / 2;
23 | coordinates[2].Y = this.rectComponent.TopLeftCorner.Y + this.rectComponent.Height;
24 |
25 | coordinates[3].X = this.rectComponent.TopLeftCorner.X;
26 | coordinates[3].Y = this.rectComponent.TopLeftCorner.Y + this.rectComponent.Height / 2;
27 |
28 | RectangleF rect = this.rectComponent.TopLeftCorner.MakeRectangleFTill(this.rectComponent.BottomRightCorner);
29 |
30 | using (LinearGradientBrush brush =
31 | new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
32 | {
33 | g.FillPolygon(brush, coordinates);
34 | g.DrawPolygon(ViewFactory.BorderPen, coordinates);
35 | base.Draw(g);
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Views/Default/RoundView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views.Default
11 | {
12 | public class DefaultRoundView : RoundView
13 | {
14 | public override void Draw(Graphics g)
15 | {
16 | RectangleF rect = this.rectComponent.TopLeftCorner.MakeRectangleFTill(this.rectComponent.BottomRightCorner);
17 |
18 | using (LinearGradientBrush brush =
19 | new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
20 | {
21 | g.FillEllipse(brush, rect);
22 | g.DrawEllipse(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
23 |
24 | base.Draw(g);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Views/Default/StraightLineView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Views.Default
10 | {
11 | public class DefaultStraightLineView : StraightLineView
12 | {
13 | public override void Draw(Graphics g)
14 | {
15 | g.DrawLine(ViewFactory.LinePen,
16 | this.lineComponent.StartPoint.X,
17 | this.lineComponent.StartPoint.Y,
18 | this.lineComponent.EndPoint.X,
19 | this.lineComponent.EndPoint.Y);
20 | DrawArrow(g, this.lineComponent.EndPoint, this.lineComponent.StartPoint,
21 | ViewFactory.ArrowBrush,
22 | ViewFactory.ArrowPen,
23 | ViewFactory.ArrowLength);
24 | base.Draw(g);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Views/FlowChartPage.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FlowChart.Views
2 | {
3 | partial class FlowChartPage
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.txtEditor = new System.Windows.Forms.TextBox();
32 | this.SuspendLayout();
33 | //
34 | // txtEditor
35 | //
36 | this.txtEditor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
37 | this.txtEditor.Location = new System.Drawing.Point(98, 66);
38 | this.txtEditor.Multiline = true;
39 | this.txtEditor.Name = "txtEditor";
40 | this.txtEditor.Size = new System.Drawing.Size(140, 56);
41 | this.txtEditor.TabIndex = 0;
42 | this.txtEditor.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
43 | this.txtEditor.Visible = false;
44 | //
45 | // FlowChartPage
46 | //
47 | this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 28F);
48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
49 | this.Controls.Add(this.txtEditor);
50 | this.Font = new System.Drawing.Font("Segoe Print", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
51 | this.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
52 | this.Name = "FlowChartPage";
53 | this.Size = new System.Drawing.Size(386, 263);
54 | this.ResumeLayout(false);
55 | this.PerformLayout();
56 |
57 | }
58 |
59 | #endregion
60 |
61 | private System.Windows.Forms.TextBox txtEditor;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Views/FlowChartPage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 | using System.Drawing.Drawing2D;
5 | using FlowChart.Models;
6 |
7 | namespace FlowChart.Views
8 | {
9 | public partial class FlowChartPage : UserControl
10 | {
11 | private Point LastDown;
12 | public event Action ZoomMouse;
13 | public event Action ScrollMouse;
14 | public event Action DragMouse;
15 |
16 | public FlowChartModel Model { get; set; }
17 | public BaseComponent SelectedComponent { get; set; }
18 | public float ZoomFactor { get; set; }
19 | private BaseComponent Component;
20 |
21 | public FlowChartPage()
22 | {
23 | InitializeComponent();
24 | SetStyle(ControlStyles.AllPaintingInWmPaint, true);
25 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
26 | SetStyle(ControlStyles.UserPaint, true);
27 |
28 | txtEditor.KeyDown += new KeyEventHandler(txtEditor_KeyDown);
29 | txtEditor.Leave += new EventHandler(txtEditor_Leave);
30 | MouseClick += new MouseEventHandler(FlowChartPage_MouseClick);
31 | }
32 |
33 | void FlowChartPage_MouseClick(object sender, MouseEventArgs e)
34 | {
35 | txtEditor_Leave(sender, e);
36 | }
37 |
38 | void txtEditor_Leave(object sender, EventArgs e)
39 | {
40 | if (Component != null)
41 | {
42 | Component.Text = txtEditor.Text;
43 | }
44 | txtEditor.Visible = false;
45 | }
46 |
47 | void txtEditor_KeyDown(object sender, KeyEventArgs e)
48 | {
49 | if (e.KeyCode == Keys.Tab)
50 | {
51 | txtEditor_Leave(sender, e);
52 | }
53 | }
54 |
55 | public void ShowTextEditor(BaseComponent component)
56 | {
57 | if (component != null)
58 | {
59 | Component = component;
60 | txtEditor.Visible = true;
61 | txtEditor.Left = (int)((component.CenterPoint.X - txtEditor.Width / 2) * ZoomFactor);
62 | txtEditor.Top = (int)((component.CenterPoint.Y - txtEditor.Height) * ZoomFactor);
63 | txtEditor.Text = Component.Text;
64 | txtEditor.Focus();
65 | txtEditor.SelectAll();
66 | }
67 | }
68 |
69 | protected override void OnMouseEnter(EventArgs e)
70 | {
71 | Focus();
72 | base.OnMouseEnter(e);
73 | }
74 |
75 | protected override void OnMouseDown(MouseEventArgs e)
76 | {
77 | LastDown = e.Location;
78 | base.OnMouseDown(e);
79 | }
80 |
81 | protected override void OnMouseMove(MouseEventArgs e)
82 | {
83 | if ((ModifierKeys & Keys.Control) != Keys.None && e.Button == MouseButtons.Left && DragMouse != null)
84 | {
85 | DragMouse?.Invoke(e.X - LastDown.X, e.Y - LastDown.Y);
86 | return;
87 | }
88 | base.OnMouseMove(e);
89 | Invalidate();
90 | }
91 | protected override void OnMouseWheel(MouseEventArgs e)
92 | {
93 | if ((ModifierKeys & Keys.Control) != Keys.None)
94 | {
95 | ZoomMouse?.Invoke(e);
96 | }
97 | else
98 | {
99 | ScrollMouse?.Invoke(e);
100 | }
101 | base.OnMouseWheel(e);
102 | Invalidate();
103 | }
104 |
105 | protected override void OnPaintBackground(PaintEventArgs e)
106 | {
107 | using (LinearGradientBrush brush =
108 | new LinearGradientBrush(e.ClipRectangle, Color.White, Color.WhiteSmoke, 90.0f))
109 | {
110 | e.Graphics.FillRectangle(brush, e.ClipRectangle);
111 | }
112 |
113 | for (int i = 0; i < Width; i += 50)
114 | {
115 | for (int j = 0; j < Height; j += 50)
116 | {
117 | e.Graphics.DrawRectangle(Pens.LightGray, i, j, 50, 50);
118 | }
119 | }
120 | e.Graphics.DrawString("FlowChart: pradeep@kiproshamerica.com", Font, Brushes.LightGray, 10, Height - 20);
121 | }
122 |
123 | protected override void OnPaint(PaintEventArgs e)
124 | {
125 | try
126 | {
127 | var mx = new Matrix(ZoomFactor, 0, 0, ZoomFactor, 0, 0);
128 | mx.Translate(AutoScrollPosition.X * (1.0f / ZoomFactor), AutoScrollPosition.Y * (1.0f / ZoomFactor));
129 |
130 | e.Graphics.Transform = mx;
131 | if (Model.Items != null)
132 | {
133 | Model.Items.ForEach(x =>
134 | {
135 | x.View.Draw(e.Graphics);
136 | });
137 | SelectedComponent?.View?.Draw(e.Graphics);
138 | }
139 | }
140 | catch
141 | {
142 | //Ignore any Paint error.
143 | }
144 | }
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/Views/FlowChartPage.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Views/Grey/CurvedLineView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Views.Grey
10 | {
11 | public class GreyCurvedLineView : CurvedLineView
12 | {
13 | public override void Draw(Graphics g)
14 | {
15 | if (this.lineComponent.IsSelected)
16 | {
17 | g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.StartPoint.X, this.lineComponent.StartPoint.Y, this.lineComponent.ControlPoint1.X, this.lineComponent.ControlPoint1.Y);
18 | g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.EndPoint.X, this.lineComponent.EndPoint.Y, this.lineComponent.ControlPoint2.X, this.lineComponent.ControlPoint2.Y);
19 | }
20 | if (this.lineComponent.ParentMoving)
21 | {
22 | g.DrawBezier(ViewFactory.LinePen,
23 | this.lineComponent.StartPoint.MakePointF(),
24 | this.lineComponent.ControlPoint1.MakePointF(),
25 | this.lineComponent.ControlPoint2.MakePointF(),
26 | this.lineComponent.EndPoint.MakePointF());
27 | }
28 | else
29 | {
30 | g.DrawLines(ViewFactory.LinePen, this.lineComponent.points.ToArray());
31 | /*DrawPoint(g, new FlowChartPoint(points[points.Count/2].X,points[points.Count/2].Y),
32 | GraphicsSettings.LabelPen, GraphicsSettings.EdgeBoxWidth);*/
33 | }
34 |
35 | DrawArrow(g, this.lineComponent.EndPoint, this.lineComponent.ControlPoint2,
36 | ViewFactory.ArrowBrush,
37 | ViewFactory.ArrowPen,
38 | ViewFactory.ArrowLength);
39 |
40 | if (this.lineComponent.IsSelected)
41 | {
42 | DrawPoint(g, this.lineComponent.ControlPoint1, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
43 | DrawPoint(g, this.lineComponent.ControlPoint2, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
44 | }
45 | base.Draw(g);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Views/Grey/DatabaseView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views.Grey
11 | {
12 | public class GreyDatabaseView : DatabaseView
13 | {
14 | public override void Draw(Graphics g)
15 | {
16 | RectangleF rect = rectComponent.TopLeftCorner.CloneAndAdd(0, offSet).MakeRectangleFTill(rectComponent.BottomRightCorner.CloneAndAdd(0, -offSet));
17 | RectangleF upperRect = rectComponent.TopLeftCorner.MakeRectangleFTill(rectComponent.TopLeftCorner.CloneAndAdd(rectComponent.Width, 2 * offSet));
18 | RectangleF lowerRect = rectComponent.BottomRightCorner.CloneAndAdd(-rectComponent.Width, -2 * offSet).MakeRectangleFTill(rectComponent.BottomRightCorner);
19 |
20 | using (LinearGradientBrush brush =
21 | new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
22 | {
23 | g.FillRectangle(brush, rect);
24 | g.DrawRectangle(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
25 | }
26 |
27 |
28 | using (LinearGradientBrush brush =
29 | new LinearGradientBrush(upperRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
30 | {
31 | g.FillEllipse(brush, upperRect);
32 | g.DrawEllipse(ViewFactory.BorderPen, upperRect.X, upperRect.Y, upperRect.Width, upperRect.Height);
33 | }
34 |
35 | using (LinearGradientBrush brush =
36 | new LinearGradientBrush(lowerRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
37 | {
38 | g.FillEllipse(brush, lowerRect);
39 | g.DrawArc(ViewFactory.BorderPen, lowerRect, 0, 180);
40 | }
41 | base.Draw(g);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Views/Grey/GreyViewFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Factory;
6 | using System.Drawing;
7 |
8 | namespace FlowChart.Views.Grey
9 | {
10 | public class GreyViewFactory : ViewAbstractFactory
11 | {
12 | static readonly Pen boundingBoxPen = new Pen(Color.Black, 1);
13 | static readonly Pen linePen = new Pen(Color.Black, 2);
14 |
15 | static readonly Pen selectedPen = new Pen(Color.Blue, 2);
16 |
17 | static readonly Pen borderPen = new Pen(Color.Black, 1);
18 | static readonly Pen textPen = new Pen(Color.Black, 2);
19 | static readonly Pen labelPen = new Pen(Color.Black, 2);
20 | static readonly Pen edgePen = new Pen(Color.Black, 1);
21 | static readonly Pen resizePen = new Pen(Color.Gray, 2);
22 |
23 | static readonly Brush arrowBrush = Brushes.Black;
24 | static readonly Pen arrowPen = new Pen(Color.Black, 1);
25 |
26 | static readonly float edgeBoxWidth = 8.0f;
27 | static readonly float resizeBoxWidth = 16.0f;
28 | static readonly float arrowLength = 20.0f;
29 |
30 |
31 | public override Pen BoundingBoxPen { get { return boundingBoxPen; } }
32 | public override Pen LinePen { get { return linePen; } }
33 |
34 | public override Pen SelectedPen { get { return selectedPen; } }
35 |
36 | public override Pen BorderPen { get { return borderPen; } }
37 | public override Pen TextPen { get { return textPen; } }
38 | public override Pen LabelPen { get { return labelPen; } }
39 | public override Pen EdgePen { get { return edgePen; } }
40 | public override Pen ResizePen { get { return resizePen; } }
41 |
42 | public override Brush ArrowBrush { get { return arrowBrush; } }
43 | public override Pen ArrowPen { get { return arrowPen; } }
44 |
45 | public override float EdgeBoxWidth { get { return edgeBoxWidth; } }
46 | public override float ResizeBoxWidth { get { return resizeBoxWidth; } }
47 | public override float ArrowLength { get { return arrowLength; } }
48 |
49 | public override Brush LabelBrush { get { return Brushes.Black; } }
50 |
51 | public override Color GradStartColor { get { return Color.White; } }
52 | public override Color GradEndColor { get { return Color.Gray; } }
53 |
54 | public override StraightLineView CreateStraightLineView()
55 | {
56 | return new GreyStraightLineView { ViewFactory = this };
57 | }
58 |
59 | public override CurvedLineView CreateCurvedLineView()
60 | {
61 | return new GreyCurvedLineView { ViewFactory = this };
62 | }
63 |
64 | public override DatabaseView CreateDatabaseView()
65 | {
66 | return new GreyDatabaseView { ViewFactory = this };
67 | }
68 |
69 | public override RectangleView CreateRectangleView()
70 | {
71 | return new GreyRectangleView { ViewFactory = this };
72 | }
73 |
74 | public override RhombusView CreateRhombusView()
75 | {
76 | return new GreyRhombusView { ViewFactory = this };
77 | }
78 |
79 | public override RoundView CreateRoundView()
80 | {
81 | return new GreyRoundView { ViewFactory = this };
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Views/Grey/RectangleView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views.Grey
11 | {
12 | public class GreyRectangleView : RectangleView
13 | {
14 | public override void Draw(Graphics g)
15 | {
16 | RectangleF rect = this.rectComponent.TopLeftCorner.MakeRectangleFTill(this.rectComponent.BottomRightCorner);
17 |
18 | using (LinearGradientBrush brush =
19 | new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
20 | {
21 | g.FillRectangle(brush, rect);
22 | g.DrawRectangle(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
23 |
24 | base.Draw(g);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Views/Grey/RhombusView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views.Grey
11 | {
12 | public class GreyRhombusView : RhombusView
13 | {
14 | public override void Draw(Graphics g)
15 | {
16 | coordinates[0].X = this.rectComponent.TopLeftCorner.X + this.rectComponent.Width / 2;
17 | coordinates[0].Y = this.rectComponent.TopLeftCorner.Y;
18 |
19 | coordinates[1].X = this.rectComponent.TopLeftCorner.X + this.rectComponent.Width;
20 | coordinates[1].Y = this.rectComponent.TopLeftCorner.Y + this.rectComponent.Height / 2;
21 |
22 | coordinates[2].X = this.rectComponent.TopLeftCorner.X + this.rectComponent.Width / 2;
23 | coordinates[2].Y = this.rectComponent.TopLeftCorner.Y + this.rectComponent.Height;
24 |
25 | coordinates[3].X = this.rectComponent.TopLeftCorner.X;
26 | coordinates[3].Y = this.rectComponent.TopLeftCorner.Y + this.rectComponent.Height / 2;
27 |
28 | RectangleF rect = this.rectComponent.TopLeftCorner.MakeRectangleFTill(this.rectComponent.BottomRightCorner);
29 |
30 | using (LinearGradientBrush brush =
31 | new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
32 | {
33 | g.FillPolygon(brush, coordinates);
34 | g.DrawPolygon(ViewFactory.BorderPen, coordinates);
35 | base.Draw(g);
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Views/Grey/RoundView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views.Grey
11 | {
12 | public class GreyRoundView : RoundView
13 | {
14 | public override void Draw(Graphics g)
15 | {
16 | RectangleF rect = this.rectComponent.TopLeftCorner.MakeRectangleFTill(this.rectComponent.BottomRightCorner);
17 |
18 | using (LinearGradientBrush brush =
19 | new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
20 | {
21 | g.FillEllipse(brush, rect);
22 | g.DrawEllipse(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
23 |
24 | base.Draw(g);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Views/Grey/StraightLineView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Views.Grey
10 | {
11 | public class GreyStraightLineView : StraightLineView
12 | {
13 | public override void Draw(Graphics g)
14 | {
15 | g.DrawLine(ViewFactory.LinePen,
16 | this.lineComponent.StartPoint.X,
17 | this.lineComponent.StartPoint.Y,
18 | this.lineComponent.EndPoint.X,
19 | this.lineComponent.EndPoint.Y);
20 | DrawArrow(g, this.lineComponent.EndPoint, this.lineComponent.StartPoint,
21 | ViewFactory.ArrowBrush,
22 | ViewFactory.ArrowPen,
23 | ViewFactory.ArrowLength);
24 | base.Draw(g);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Views/RectangleView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views
11 | {
12 | public class RectangleView: BaseBoxView
13 | {
14 | protected RectangleComponent rectComponent;
15 |
16 | public void SetComponent(RectangleComponent rectComponent)
17 | {
18 | this.rectComponent = rectComponent;
19 | this.Component = rectComponent;
20 | this.rectComponent.View = this;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Views/RhombusView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views
11 | {
12 | public class RhombusView: BaseBoxView
13 | {
14 | protected RhombusComponent rectComponent;
15 | protected PointF[] coordinates = new PointF[4];
16 |
17 | public void SetComponent(RhombusComponent rectComponent)
18 | {
19 | this.rectComponent = rectComponent;
20 | this.Component = rectComponent;
21 | this.rectComponent.View = this;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Views/RoundView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 | using System.Drawing.Drawing2D;
9 |
10 | namespace FlowChart.Views
11 | {
12 | public class RoundView: BaseBoxView
13 | {
14 | protected RoundComponent rectComponent;
15 | public void SetComponent(RoundComponent rectComponent)
16 | {
17 | this.rectComponent = rectComponent;
18 | this.Component = rectComponent;
19 | this.rectComponent.View = this;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Views/StraightLineView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Models;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Views
10 | {
11 | public class StraightLineView: BaseLineView
12 | {
13 | protected LineComponent lineComponent;
14 | public void SetComponent(LineComponent lineComponent)
15 | {
16 | this.lineComponent = lineComponent;
17 | this.Component = lineComponent;
18 | this.lineComponent.View = this;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Visitors/BaseVisitor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Models;
6 |
7 | namespace FlowChart.Visitors
8 | {
9 | public class BaseVisitor
10 | {
11 | public virtual void Visit(CurvedLineComponent cmp)
12 | {
13 | }
14 | public virtual void Visit(LineComponent cmp)
15 | {
16 | }
17 | public virtual void Visit(RectangleComponent cmp)
18 | {
19 | }
20 | public virtual void Visit(RhombusComponent cmp)
21 | {
22 | }
23 | public virtual void Visit(RoundComponent cmp)
24 | {
25 | }
26 | public virtual void Visit(DatabaseComponent cmp)
27 | {
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Visitors/BoxMoveVisitor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Models;
6 |
7 | namespace FlowChart.Visitors
8 | {
9 | public class BoxMoveVisitor:BaseVisitor
10 | {
11 | private BaseBoxComponent box;
12 | private bool recompute;
13 | public BoxMoveVisitor(BaseBoxComponent box, bool recompute)
14 | {
15 | this.box = box;
16 | this.recompute = recompute;
17 | }
18 | public override void Visit(LineComponent cmp)
19 | {
20 | BoxMoved(cmp);
21 | }
22 | public override void Visit(CurvedLineComponent cmp)
23 | {
24 | BoxMoved(cmp);
25 | }
26 | void BoxMoved(BaseLineComponent lineCmp)
27 | {
28 | if (lineCmp.ConnectionStart == box || lineCmp.ConnectionEnd == box)
29 | {
30 | lineCmp.OnParentMoved(box, recompute);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Visitors/LinePointMovedVisitor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Models;
6 | using FlowChart.Entities;
7 | using FlowChart.Utility;
8 |
9 | namespace FlowChart.Visitors
10 | {
11 | public class LinePointMovedVisitor:BaseVisitor
12 | {
13 | private BaseLineComponent lineCmp;
14 | private FlowChartPoint linePoint;
15 | public LinePointMovedVisitor(BaseLineComponent lineCmp, FlowChartPoint linePoint)
16 | {
17 | this.lineCmp = lineCmp;
18 | this.linePoint = linePoint;
19 | }
20 | public override void Visit(RectangleComponent cmp)
21 | {
22 | LinePointMoved(cmp);
23 | }
24 | public override void Visit(RhombusComponent cmp)
25 | {
26 | LinePointMoved(cmp);
27 | }
28 | public override void Visit(RoundComponent cmp)
29 | {
30 | LinePointMoved(cmp);
31 | }
32 | public override void Visit(DatabaseComponent cmp)
33 | {
34 | LinePointMoved(cmp);
35 | }
36 |
37 | void LinePointMoved(BaseBoxComponent cmp)
38 | {
39 | foreach (FlowChartPoint edgePoint in cmp.EdgePoints)
40 | {
41 | float d = GraphicsUtil.Distance(edgePoint, linePoint);
42 | cmp.IsSelected = (d < cmp.View.ViewFactory.EdgeBoxWidth * 5);
43 | if (d < cmp.View.ViewFactory.EdgeBoxWidth * 2)
44 | {
45 | linePoint.X = edgePoint.X;
46 | linePoint.Y = edgePoint.Y;
47 | if (lineCmp.StartPoint == linePoint)
48 | {
49 | lineCmp.ConnectionStart = cmp;
50 | lineCmp.ConnectionStartPointIndex = cmp.EdgePoints.IndexOf(edgePoint);
51 | }
52 | else if (lineCmp.EndPoint == linePoint)
53 | {
54 | lineCmp.ConnectionEnd = cmp;
55 | lineCmp.ConnectionEndPointIndex = cmp.EdgePoints.IndexOf(edgePoint);
56 | }
57 | return;
58 | }
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Visitors/ObjectCreateVisitor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Models;
6 | using FlowChart.Controller;
7 | using FlowChart.Entities;
8 |
9 | namespace FlowChart.Visitors
10 | {
11 | public class ObjectCreateVisitor:BaseVisitor
12 | {
13 | private FlowChartModel model;
14 | private FlowChartComponent component;
15 | public ObjectCreateVisitor(FlowChartModel model, FlowChartComponent component)
16 | {
17 | this.model = model;
18 | this.component = component;
19 | }
20 | public override void Visit(CurvedLineComponent cmp)
21 | {
22 | HookToParentBox(cmp);
23 | }
24 | public override void Visit(LineComponent cmp)
25 | {
26 | HookToParentBox(cmp);
27 | }
28 |
29 | private void HookToParentBox(BaseLineComponent c)
30 | {
31 | FlowChartReference fRef1 = component.ConnectionIds.Find(y => y.Name == "Start");
32 | if (fRef1 != null)
33 | {
34 | c.ConnectionStart = (BaseBoxComponent)this.model.Items.Find(y => y.ID == fRef1.ID);
35 | }
36 | FlowChartReference fRef2 = component.ConnectionIds.Find(y => y.Name == "End");
37 | if (fRef2 != null)
38 | {
39 | c.ConnectionEnd = (BaseBoxComponent)this.model.Items.Find(y => y.ID == fRef2.ID);
40 | }
41 |
42 | c.ConnectionStartPointIndex = fRef1.Key1;
43 | c.ConnectionEndPointIndex = fRef2.Key1;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Visitors/ObjectModifyVisitor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FlowChart.Models;
6 | using FlowChart.Controller;
7 | using FlowChart.Entities;
8 |
9 | namespace FlowChart.Visitors
10 | {
11 | public class ObjectModifyVisitor:BaseVisitor
12 | {
13 | private FlowChartModel model;
14 | public ObjectModifyVisitor(FlowChartModel model)
15 | {
16 | this.model = model;
17 | }
18 |
19 | public override void Visit(LineComponent cmp)
20 | {
21 | VisitComponent(cmp);
22 | }
23 | public override void Visit(CurvedLineComponent cmp)
24 | {
25 | VisitComponent(cmp);
26 | }
27 |
28 | public override void Visit(RectangleComponent cmp)
29 | {
30 | VisitComponent(cmp);
31 | }
32 | public override void Visit(RhombusComponent cmp)
33 | {
34 | VisitComponent(cmp);
35 | }
36 | public override void Visit(RoundComponent cmp)
37 | {
38 | VisitComponent(cmp);
39 | }
40 | public override void Visit(DatabaseComponent cmp)
41 | {
42 | VisitComponent(cmp);
43 | }
44 |
45 | public void VisitComponent(BaseLineComponent cmp)
46 | {
47 | cmp.LinePointMovedTo += new Action(LinePointMovedTo);
48 | }
49 | public void VisitComponent(BaseBoxComponent cmp)
50 | {
51 | cmp.BoxComponentMoving += new Action(BoxComponentMoving);
52 | cmp.BoxComponentMoved += new Action(BoxComponentMoved);
53 | }
54 |
55 | void LinePointMovedTo(BaseLineComponent lineCmp, FlowChartPoint point)
56 | {
57 | if (lineCmp.StartPoint == point)
58 | {
59 | lineCmp.ConnectionStart = null;
60 | }
61 | else if (lineCmp.EndPoint == point)
62 | {
63 | lineCmp.ConnectionEnd = null;
64 | }
65 |
66 | foreach (BaseComponent drawableCmp in model.Items)
67 | {
68 | drawableCmp.Accept(new LinePointMovedVisitor(lineCmp, point));
69 | }
70 | }
71 |
72 | void BoxComponentMoving(BaseBoxComponent obj)
73 | {
74 | foreach (BaseComponent drawableCmp in model.Items)
75 | {
76 | drawableCmp.Accept(new BoxMoveVisitor(obj, false));
77 | }
78 | }
79 | void BoxComponentMoved(BaseBoxComponent obj)
80 | {
81 | foreach (BaseComponent drawableCmp in model.Items)
82 | {
83 | drawableCmp.Accept(new BoxMoveVisitor(obj, true));
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Visitors/ViewDirectorVisitor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using FlowChart.Factory;
7 |
8 | namespace FlowChart.Visitors
9 | {
10 | class ViewDirectorVisitor:BaseVisitor
11 | {
12 | private Font font;
13 | private ViewAbstractFactory ViewFactory;
14 | public ViewDirectorVisitor(ViewAbstractFactory ViewFactory, Font font)
15 | {
16 | this.ViewFactory = ViewFactory;
17 | this.font = font;
18 | }
19 | public override void Visit(Models.CurvedLineComponent cmp)
20 | {
21 | this.ViewFactory.CreateCurvedLineView().SetComponent(cmp);
22 | cmp.View.Font = font;
23 | }
24 | public override void Visit(Models.DatabaseComponent cmp)
25 | {
26 | this.ViewFactory.CreateDatabaseView().SetComponent(cmp);
27 | cmp.View.Font = font;
28 | }
29 | public override void Visit(Models.LineComponent cmp)
30 | {
31 | this.ViewFactory.CreateStraightLineView().SetComponent(cmp);
32 | cmp.View.Font = font;
33 | }
34 | public override void Visit(Models.RectangleComponent cmp)
35 | {
36 | this.ViewFactory.CreateRectangleView().SetComponent(cmp);
37 | cmp.View.Font = font;
38 | }
39 | public override void Visit(Models.RhombusComponent cmp)
40 | {
41 | this.ViewFactory.CreateRhombusView().SetComponent(cmp);
42 | cmp.View.Font = font;
43 | }
44 | public override void Visit(Models.RoundComponent cmp)
45 | {
46 | this.ViewFactory.CreateRoundView().SetComponent(cmp);
47 | cmp.View.Font = font;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------