Starting to add the initial shapelist edit window

This commit is contained in:
Tim Young 2018-02-28 16:50:50 -06:00
parent 9f2974cf6b
commit 69814ad21e
7 changed files with 466 additions and 3 deletions

View File

@ -183,6 +183,12 @@
<DependentUpon>RTFWindow.cs</DependentUpon>
</Compile>
<Compile Include="SchoolworkClass.cs" />
<Compile Include="ShapeEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ShapeEditor.Designer.cs">
<DependentUpon>ShapeEditor.cs</DependentUpon>
</Compile>
<Compile Include="TranslationWindow.cs">
<SubType>Form</SubType>
</Compile>
@ -244,6 +250,9 @@
<EmbeddedResource Include="RTFWindow.resx">
<DependentUpon>RTFWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ShapeEditor.resx">
<DependentUpon>ShapeEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="TranslationWindow.resx">
<DependentUpon>TranslationWindow.cs</DependentUpon>
</EmbeddedResource>

View File

@ -134,6 +134,14 @@ namespace EduNetworkBuilder
}
public override string ToString()
{
string answer = MyShape.ToString() + " " + LineColor.Name + "/" + FillColor.Name;
answer = answer + " X:" + InArea.X + " Y:" + InArea.Y;
answer = answer + "W:" + InArea.Width + " H:" + InArea.Height;
return answer;
}
public void Load(XmlNode theNode)
{
foreach (XmlNode Individual in theNode.ChildNodes)

View File

@ -68,7 +68,7 @@ namespace EduNetworkBuilder
private List<Image> PacketImages = new List<Image>();
private List<PingTestStatus> PingTestStats = new List<PingTestStatus>();
private List<string> BrokenItems = new List<string>();
private List<NetShape> Shapes = new List<NetShape>(); //For storing simple shapes which are drawn on the network
public List<NetShape> Shapes = new List<NetShape>(); //For storing simple shapes which are drawn on the network
public bool IsRandomNetwork = false;
public bool InShapeEditMode = false;
@ -78,6 +78,8 @@ namespace EduNetworkBuilder
/// WhatFrom: If we are launched from a homework, we remember it here.
/// </summary>
public SchoolworkClass WhatFrom = null;
public List<string> ColorNames = new List<string>() { "Black", "White", "Green", "LightGreen", "Blue", "LightBlue", "Grey", "Brown", "SaddleBrown", "Empty" };
public Network(string Name)
{
@ -1156,6 +1158,16 @@ namespace EduNetworkBuilder
return null;
}
public List<string> ShapeDescriptions()
{
List<string> Descriptions = new List<string>();
foreach(NetShape NS in Shapes)
{
Descriptions.Add(NS.ToString());
}
return Descriptions;
}
void KillAllExtraWindows(bool EvenRTF=false)
{
for(int i = Application.OpenForms.Count -1; i >=0; i--)

View File

@ -60,7 +60,7 @@ namespace EduNetworkBuilder
public PersonClass CurrentUser;
private List<HelpURL> HelpURLs = new List<HelpURL>();
private List<HelpURL> HelpURLs = new List<HelpURL>();
public BuilderWindow(string FirstArg="")
{
@ -100,7 +100,8 @@ namespace EduNetworkBuilder
myNetwork.RegisterDisplayArea(pbNetworkView);
List<string> ColorNames = new List<string>() { "Black","White","Green","LightGreen","Blue","LightBlue","Grey","Brown","SaddleBrown", "Empty" };
List<String> ColorNames = myNetwork.ColorNames;
ColorNames.Sort();
cbFillColor.Items.Clear();
cbLineColor.Items.Clear();

232
EduNetworkBuilder/ShapeEditor.Designer.cs generated Normal file
View File

@ -0,0 +1,232 @@
namespace EduNetworkBuilder
{
partial class ShapeEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lbShapeList = new System.Windows.Forms.ListBox();
this.lblShapes = new System.Windows.Forms.Label();
this.btnDone = new System.Windows.Forms.Button();
this.tbX = new System.Windows.Forms.TextBox();
this.lblX = new System.Windows.Forms.Label();
this.lblY = new System.Windows.Forms.Label();
this.tbY = new System.Windows.Forms.TextBox();
this.lblWidth = new System.Windows.Forms.Label();
this.lblHeight = new System.Windows.Forms.Label();
this.tbWidth = new System.Windows.Forms.TextBox();
this.tbHeight = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.cbFillColor = new System.Windows.Forms.ComboBox();
this.cbLineColor = new System.Windows.Forms.ComboBox();
this.lblFill = new System.Windows.Forms.Label();
this.lblLine = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// lbShapeList
//
this.lbShapeList.FormattingEnabled = true;
this.lbShapeList.ItemHeight = 16;
this.lbShapeList.Location = new System.Drawing.Point(12, 29);
this.lbShapeList.Name = "lbShapeList";
this.lbShapeList.Size = new System.Drawing.Size(120, 164);
this.lbShapeList.TabIndex = 0;
this.lbShapeList.SelectedIndexChanged += new System.EventHandler(this.lbShapeList_SelectedIndexChanged);
//
// lblShapes
//
this.lblShapes.AutoSize = true;
this.lblShapes.Location = new System.Drawing.Point(12, 9);
this.lblShapes.Name = "lblShapes";
this.lblShapes.Size = new System.Drawing.Size(56, 17);
this.lblShapes.TabIndex = 1;
this.lblShapes.Text = "Shapes";
//
// btnDone
//
this.btnDone.Location = new System.Drawing.Point(191, 205);
this.btnDone.Name = "btnDone";
this.btnDone.Size = new System.Drawing.Size(75, 23);
this.btnDone.TabIndex = 2;
this.btnDone.Text = "Done";
this.btnDone.UseVisualStyleBackColor = true;
//
// tbX
//
this.tbX.Location = new System.Drawing.Point(96, 4);
this.tbX.Name = "tbX";
this.tbX.Size = new System.Drawing.Size(46, 22);
this.tbX.TabIndex = 3;
//
// lblX
//
this.lblX.AutoSize = true;
this.lblX.Location = new System.Drawing.Point(73, 7);
this.lblX.Name = "lblX";
this.lblX.Size = new System.Drawing.Size(17, 17);
this.lblX.TabIndex = 4;
this.lblX.Text = "X";
//
// lblY
//
this.lblY.AutoSize = true;
this.lblY.Location = new System.Drawing.Point(73, 35);
this.lblY.Name = "lblY";
this.lblY.Size = new System.Drawing.Size(17, 17);
this.lblY.TabIndex = 5;
this.lblY.Text = "Y";
//
// tbY
//
this.tbY.Location = new System.Drawing.Point(96, 32);
this.tbY.Name = "tbY";
this.tbY.Size = new System.Drawing.Size(47, 22);
this.tbY.TabIndex = 6;
//
// lblWidth
//
this.lblWidth.AutoSize = true;
this.lblWidth.Location = new System.Drawing.Point(46, 63);
this.lblWidth.Name = "lblWidth";
this.lblWidth.Size = new System.Drawing.Size(44, 17);
this.lblWidth.TabIndex = 7;
this.lblWidth.Text = "Width";
//
// lblHeight
//
this.lblHeight.AutoSize = true;
this.lblHeight.Location = new System.Drawing.Point(41, 91);
this.lblHeight.Name = "lblHeight";
this.lblHeight.Size = new System.Drawing.Size(49, 17);
this.lblHeight.TabIndex = 8;
this.lblHeight.Text = "Height";
//
// tbWidth
//
this.tbWidth.Location = new System.Drawing.Point(96, 60);
this.tbWidth.Name = "tbWidth";
this.tbWidth.Size = new System.Drawing.Size(47, 22);
this.tbWidth.TabIndex = 9;
//
// tbHeight
//
this.tbHeight.Location = new System.Drawing.Point(96, 88);
this.tbHeight.Name = "tbHeight";
this.tbHeight.Size = new System.Drawing.Size(47, 22);
this.tbHeight.TabIndex = 10;
//
// panel1
//
this.panel1.Controls.Add(this.lblLine);
this.panel1.Controls.Add(this.lblFill);
this.panel1.Controls.Add(this.cbLineColor);
this.panel1.Controls.Add(this.cbFillColor);
this.panel1.Controls.Add(this.tbHeight);
this.panel1.Controls.Add(this.tbWidth);
this.panel1.Controls.Add(this.lblHeight);
this.panel1.Controls.Add(this.lblWidth);
this.panel1.Controls.Add(this.tbY);
this.panel1.Controls.Add(this.lblY);
this.panel1.Controls.Add(this.lblX);
this.panel1.Controls.Add(this.tbX);
this.panel1.Location = new System.Drawing.Point(138, 29);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(146, 164);
this.panel1.TabIndex = 11;
//
// cbFillColor
//
this.cbFillColor.FormattingEnabled = true;
this.cbFillColor.Location = new System.Drawing.Point(47, 116);
this.cbFillColor.Name = "cbFillColor";
this.cbFillColor.Size = new System.Drawing.Size(96, 24);
this.cbFillColor.TabIndex = 11;
//
// cbLineColor
//
this.cbLineColor.FormattingEnabled = true;
this.cbLineColor.Location = new System.Drawing.Point(47, 141);
this.cbLineColor.Name = "cbLineColor";
this.cbLineColor.Size = new System.Drawing.Size(96, 24);
this.cbLineColor.TabIndex = 12;
//
// lblFill
//
this.lblFill.AutoSize = true;
this.lblFill.Location = new System.Drawing.Point(16, 119);
this.lblFill.Name = "lblFill";
this.lblFill.Size = new System.Drawing.Size(25, 17);
this.lblFill.TabIndex = 13;
this.lblFill.Text = "Fill";
//
// lblLine
//
this.lblLine.AutoSize = true;
this.lblLine.Location = new System.Drawing.Point(6, 144);
this.lblLine.Name = "lblLine";
this.lblLine.Size = new System.Drawing.Size(35, 17);
this.lblLine.TabIndex = 14;
this.lblLine.Text = "Line";
//
// ShapeEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(280, 243);
this.Controls.Add(this.panel1);
this.Controls.Add(this.btnDone);
this.Controls.Add(this.lblShapes);
this.Controls.Add(this.lbShapeList);
this.Name = "ShapeEditor";
this.Text = "ShapeEditor";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListBox lbShapeList;
private System.Windows.Forms.Label lblShapes;
private System.Windows.Forms.Button btnDone;
private System.Windows.Forms.TextBox tbX;
private System.Windows.Forms.Label lblX;
private System.Windows.Forms.Label lblY;
private System.Windows.Forms.TextBox tbY;
private System.Windows.Forms.Label lblWidth;
private System.Windows.Forms.Label lblHeight;
private System.Windows.Forms.TextBox tbWidth;
private System.Windows.Forms.TextBox tbHeight;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label lblLine;
private System.Windows.Forms.Label lblFill;
private System.Windows.Forms.ComboBox cbLineColor;
private System.Windows.Forms.ComboBox cbFillColor;
}
}

View File

@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EduNetworkBuilder
{
public partial class ShapeEditor : Form
{
NetShape ShapeForEditing = null;
public ShapeEditor()
{
InitializeComponent();
LocalSetup();
}
public ShapeEditor(NetShape WhatToEdit)
{
InitializeComponent();
ShapeForEditing = WhatToEdit;
LocalSetup();
}
void LocalSetup()
{
Network myNet = NB.GetNetwork();
List<String> ColorNames = myNet.ColorNames;
ColorNames.Sort();
cbFillColor.Items.Clear();
cbLineColor.Items.Clear();
foreach (string one in ColorNames)
{
cbFillColor.Items.Add(one);
cbLineColor.Items.Add(one);
}
lbShapeList.Items.Clear();
foreach(string one in myNet.ShapeDescriptions())
{
lbShapeList.Items.Add(one);
}
}
private void lbShapeList_SelectedIndexChanged(object sender, EventArgs e)
{
Network myNet = NB.GetNetwork();
//Fill in the text from the shape
ShapeForEditing = null;
foreach (NetShape oneShape in myNet.Shapes)
{
if (oneShape.ToString() == lbShapeList.Text)
ShapeForEditing = oneShape;
}
FieldsFromShape(ShapeForEditing);
}
private void FieldsFromShape(NetShape theShape)
{
ShapeForEditing = theShape;
if(ShapeForEditing != null)
{
tbX.Text = ShapeForEditing.InArea.X.ToString();
tbY.Text = ShapeForEditing.InArea.Y.ToString();
tbHeight.Text = ShapeForEditing.InArea.Height.ToString();
tbWidth.Text = ShapeForEditing.InArea.Width.ToString();
cbFillColor.Text = ShapeForEditing.FillColor.Name;
cbLineColor.Text = ShapeForEditing.LineColor.Name;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>