From 3ff8f1488c120265a38a1525dde1373af2c55057 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Tue, 27 Feb 2018 09:16:42 -0600 Subject: [PATCH] Clicking the shape button toggles which shape you are adding. --- EduNetworkBuilder/EduNetworkBuilder.csproj | 2 + EduNetworkBuilder/NetShape.cs | 25 +++++++---- EduNetworkBuilder/NetworkBuilder.cs | 41 ++++++++++++++++-- .../Properties/Resources.Designer.cs | 20 +++++++++ EduNetworkBuilder/Properties/Resources.resx | 6 +++ EduNetworkBuilder/Resources/Circle.png | Bin 0 -> 1802 bytes EduNetworkBuilder/Resources/Square.png | Bin 0 -> 530 bytes 7 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 EduNetworkBuilder/Resources/Circle.png create mode 100644 EduNetworkBuilder/Resources/Square.png diff --git a/EduNetworkBuilder/EduNetworkBuilder.csproj b/EduNetworkBuilder/EduNetworkBuilder.csproj index 1a976ef..3631a73 100644 --- a/EduNetworkBuilder/EduNetworkBuilder.csproj +++ b/EduNetworkBuilder/EduNetworkBuilder.csproj @@ -414,6 +414,7 @@ + @@ -442,6 +443,7 @@ + diff --git a/EduNetworkBuilder/NetShape.cs b/EduNetworkBuilder/NetShape.cs index de23ccc..a43ad3c 100644 --- a/EduNetworkBuilder/NetShape.cs +++ b/EduNetworkBuilder/NetShape.cs @@ -61,18 +61,27 @@ namespace EduNetworkBuilder if (FillColor == Color.Black) edgeColor = Color.White; coloredBrush = new SolidBrush(edgeColor); //We want to put drag-marks on the corners of our rectangle - Rectangle TL = new Rectangle(InArea.X, InArea.Y, sz, sz); - Rectangle TR = new Rectangle(InArea.X + InArea.Width - sz, InArea.Y, sz, sz); - Rectangle BL = new Rectangle(InArea.X, InArea.Y + InArea.Height - sz, sz, sz); - Rectangle BR = new Rectangle(InArea.X + InArea.Width - sz, InArea.Y + InArea.Height - sz, sz, sz); - G.FillRectangle(coloredBrush, TL); - G.FillRectangle(coloredBrush, TR); - G.FillRectangle(coloredBrush, BL); - G.FillRectangle(coloredBrush, BR); + foreach(Rectangle one in Corners()) + G.FillRectangle(coloredBrush, one); } G.Dispose(); } + List Corners() + { + int sz = DragSize; + List tCorners = new List(); + Rectangle TL = new Rectangle(InArea.X, InArea.Y, sz, sz); + Rectangle TR = new Rectangle(InArea.X + InArea.Width - sz, InArea.Y, sz, sz); + Rectangle BL = new Rectangle(InArea.X, InArea.Y + InArea.Height - sz, sz, sz); + Rectangle BR = new Rectangle(InArea.X + InArea.Width - sz, InArea.Y + InArea.Height - sz, sz, sz); + tCorners.Add(TL); + tCorners.Add(TR); + tCorners.Add(BL); + tCorners.Add(BR); + return tCorners; + } + public void Load(XmlNode theNode) { foreach (XmlNode Individual in theNode.ChildNodes) diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index c64b89b..298a59a 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -52,7 +52,9 @@ namespace EduNetworkBuilder private NetworkDevice ItemClickedOn = null; private List ItemsSelected = new List(); private Point OrigClickPoint = new Point(-1, -1); - + + private NetShapeType CurrentShape = NetShapeType.none; + private string InitialFileLoad = ""; public PersonClass CurrentUser; @@ -558,7 +560,8 @@ namespace EduNetworkBuilder UpdateMenu(); UpdateMessages(); UpdateVisuals(); - if(selectedButton == "btnShapes") + btnUpdateShape(); + if (selectedButton == "btnShapes") { cbFillColor.Visible = true; cbLineColor.Visible = true; @@ -744,11 +747,21 @@ namespace EduNetworkBuilder myNetwork.InShapeEditMode = true; if (selectedButton == "btnShapes") { myNetwork.InShapeEditMode = true; + if (CurrentShape == NetShapeType.none) CurrentShape = NetShapeType.rectangle; + if(doupdate) + { + //The shape was already selected. Toggle it + if (CurrentShape == NetShapeType.rectangle) CurrentShape = NetShapeType.circle; + else CurrentShape = NetShapeType.rectangle; + } + if (CurrentShape == NetShapeType.rectangle) btn.BackgroundImage = Properties.Resources.Square; + if (CurrentShape == NetShapeType.circle) btn.BackgroundImage = Properties.Resources.Circle; doupdate = true; } else { myNetwork.InShapeEditMode = false; + CurrentShape = NetShapeType.none; } } else @@ -756,15 +769,37 @@ namespace EduNetworkBuilder btn.BackColor = Button.DefaultBackColor; } } - if (doupdate) { UpdateForm(); } + if (doupdate) { + UpdateForm(); + } } + private void btnReset() { foreach (Control btn in Buttons) { lblStatus.Text = ""; selectedButton = ""; + CurrentShape = NetShapeType.none; btn.BackColor = Button.DefaultBackColor; + if(btn.Name == "btnShapes") + { + if (CurrentShape == NetShapeType.rectangle) btn.BackgroundImage = Properties.Resources.Square; + if (CurrentShape == NetShapeType.circle) btn.BackgroundImage = Properties.Resources.Circle; + if (CurrentShape == NetShapeType.none) btn.BackgroundImage = Properties.Resources.Shapes; + } + } + } + private void btnUpdateShape() + { + foreach (Control btn in Buttons) + { + if (btn.Name == "btnShapes") + { + if (CurrentShape == NetShapeType.rectangle) btn.BackgroundImage = Properties.Resources.Square; + if (CurrentShape == NetShapeType.circle) btn.BackgroundImage = Properties.Resources.Circle; + if (CurrentShape == NetShapeType.none) btn.BackgroundImage = Properties.Resources.Shapes; + } } } diff --git a/EduNetworkBuilder/Properties/Resources.Designer.cs b/EduNetworkBuilder/Properties/Resources.Designer.cs index ecc5eb5..ced1681 100644 --- a/EduNetworkBuilder/Properties/Resources.Designer.cs +++ b/EduNetworkBuilder/Properties/Resources.Designer.cs @@ -110,6 +110,16 @@ namespace EduNetworkBuilder.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Circle { + get { + object obj = ResourceManager.GetObject("Circle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. /// @@ -1250,6 +1260,16 @@ namespace EduNetworkBuilder.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Square { + get { + object obj = ResourceManager.GetObject("Square", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/EduNetworkBuilder/Properties/Resources.resx b/EduNetworkBuilder/Properties/Resources.resx index c8ef0b6..160eb31 100644 --- a/EduNetworkBuilder/Properties/Resources.resx +++ b/EduNetworkBuilder/Properties/Resources.resx @@ -505,9 +505,15 @@ ..\Resources\Level0_Frozen.enbx;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\Circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\Shapes.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Square.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\tree.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/EduNetworkBuilder/Resources/Circle.png b/EduNetworkBuilder/Resources/Circle.png new file mode 100644 index 0000000000000000000000000000000000000000..645702e7b85d3f97521189a5c4fedca0444996f1 GIT binary patch literal 1802 zcmai!`BxH%7RS}WrOYjTYNg?jr8b3o;Et&WcrK-R)Ub47&~X6?C9vEcPHs4*h?!br zjygEz(xBp2Zbx&W)R&5g8zvbeh9(m3`RM%t@11+@{hs?hpL_28>E>MZgKHc;c~n6` zK?8~K43O*4w^UP+*ZPo#GP$Urz2Tk;hu@;SvzjhFcGsq;yJ4@fd+n^Dnt&932=!^uXhA5phI$tDxW!A90HqfiWRR6QfMvNZ+d%aD=LS zLmbl6Juq=bJkO5}|Jk@_<4S61!C7$!X;_~angz0n%>Ts%3_1Vn&BE{F4AN)+N^E_p z(d*W8s@Dl``|1(J9F(~H7iwPLj=lzoUCqNe;DUGi-qQGC#0FnF9V6cQ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