Clicking the shape button toggles which shape you are adding.

This commit is contained in:
Tim Young 2018-02-27 09:16:42 -06:00
parent c75f1407f9
commit 3ff8f1488c
7 changed files with 83 additions and 11 deletions

View File

@ -414,6 +414,7 @@
</FileAssociation>
</ItemGroup>
<ItemGroup>
<None Include="Resources\Square.png" />
<None Include="Resources\Shapes.png" />
<None Include="Resources\tree.png" />
<None Include="Resources\WAP.png" />
@ -442,6 +443,7 @@
<None Include="Resources\Laptop.png" />
<None Include="Resources\microwave.png" />
<None Include="Resources\Animations.png" />
<None Include="Resources\Circle.png" />
<Content Include="Resources\NBIco.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -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<Rectangle> Corners()
{
int sz = DragSize;
List<Rectangle> tCorners = new List<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);
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)

View File

@ -53,6 +53,8 @@ namespace EduNetworkBuilder
private List<NetworkDevice> ItemsSelected = new List<NetworkDevice>();
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;
}
}
}

View File

@ -110,6 +110,16 @@ namespace EduNetworkBuilder.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Circle {
get {
object obj = ResourceManager.GetObject("Circle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream.
/// </summary>
@ -1250,6 +1260,16 @@ namespace EduNetworkBuilder.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Square {
get {
object obj = ResourceManager.GetObject("Square", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -505,9 +505,15 @@
<data name="Level0_Frozen" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Level0_Frozen.enbx;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Circle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Shapes" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Shapes.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Square" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Square.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="tree" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\tree.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B