private void LoadData() { // Using old? tech Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); openFileDialog.Filter = "UML (*.uml)|*.uml"; if (openFileDialog.ShowDialog() == true) { String filename = openFileDialog.FileName; // check file exist, etc? // Delete any created objs: ClassBoxes.Clear(); Lines.Clear(); // TODO: empty undoRedo stack // https://msdn.microsoft.com/en-us/library/ms973893.aspx IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); LinkedList <Object> data = (LinkedList <Object>)formatter.Deserialize(stream); data.ToList().ForEach(serializeShapeData => { ClassBox shape = new ClassBox(); shape.LoadSerializedData(serializeShapeData); ClassBoxes.Add(new ClassBoxViewModel(shape)); }); stream.Close(); } }
public static int test_0_nullable_box() { IFaceBox c = new ClassBox(); int i = 5; object o = c.box <int?> (i); if ((int)o != i) { return(1); } if (c.box <int?> (null) != null) { return(2); } long l = Int64.MaxValue - 1; o = c.box <long?> (l); if ((long)o != l) { return(3); } if (c.box <long?> (null) != null) { return(4); } string s = "A"; if (c.box <string> (s) != (object)s) { return(5); } return(0); }
public EdgeViewModel(ClassBoxViewModel souce, ClassBoxViewModel sink) { edge = new Edge(); sink.connectedEdges.Add(this); souce.connectedEdges.Add(this); Sink = sink.classBox; Source = souce.classBox; }
private void AddRelation(Point endPoint, string label = "") { var line = new Line() { Start = (Point)_startingPoint, End = (Point)endPoint }; ClassBox class1 = (ClassBox)_drawing.FindElementAtPosition(_startingPoint); ClassBox class2 = (ClassBox)_drawing.FindElementAtPosition(endPoint); //Find where line crosses starting box. Point start = FindPointOnLine(class1, line); Point end = FindPointOnLine(class2, line); CommandFactory.Instance.CreateAndDo("addline", start, end, _lineType, label); }
private Point FindPointOnLine(ClassBox box, Line line) { Point point = new Point(-1000, -1000); if (box != null) { for (int i = box.Corner.Y; i < box.Corner.Y + box.Size.Height; i++) { if (line.ContainsPoint(new Point(box.Corner.X, i))) { point = new Point(box.Corner.X, i); return(point); } } for (int i = box.Corner.X; i < box.Corner.X + box.Size.Width; i++) { if (line.ContainsPoint(new Point(i, box.Corner.Y))) { point = new Point(i, box.Corner.Y); return(point); } } for (int i = box.Corner.Y; i < box.Corner.Y + box.Size.Height; i++) { if (line.ContainsPoint(new Point(box.Corner.X + box.Size.Width, i))) { point = new Point(box.Corner.X + box.Size.Width, i); return(point); } } for (int i = box.Corner.X; i < box.Corner.X + box.Size.Width; i++) { if (line.ContainsPoint(new Point(i, box.Corner.Y + box.Size.Height))) { point = new Point(i, box.Corner.Y + box.Size.Height); return(point); } } } return(point); }
public ClassBoxViewModel(ClassBox classBox) { this.classBox = classBox; IsSelected = false; }
public ResizeItemCommand(ClassBox _classBox, double _offsetLeft, double _offsetRight) { classBox = _classBox; offsetLeft = _offsetLeft; offsetRight = _offsetRight; }