82 lines
2.3 KiB
C#
82 lines
2.3 KiB
C#
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;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|