private void ButtonProperties_Click(object sender, EventArgs e) { ClassRectangle rect = (ClassRectangle)_figure; _classDialogForm.OpenCurrentFigure(rect); this.Close(); }
public void MouseDown(object sender, MouseEventArgs e) { _painter.CurentFigure = _painter.Factory.GetFigure(); AbstractArrow curentArrow = (AbstractArrow)_painter.CurentFigure; foreach (IFigure a in _painter.Figures) { if (a is ClassRectangle) { ClassRectangle temp = (ClassRectangle)a; foreach (Port b in temp.Ports) { if (b.SelectedPort(e.Location) && (b.ArrowType == Painter.FigureType.NoDefine || b.ArrowType == _painter.CurentFigure.figureType) ) { curentArrow.StartPort = b; _painter.CurentFigure.StartPoint = b.ConnectingPoint; curentArrow.Links.Add(a); break; } } } } if (curentArrow.StartPort is null) { _painter.CurentFigure = null; } }
public void DeserializeDiagram(string openFile) { Figures.Clear(); JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, TypeNameHandling = TypeNameHandling.All, PreserveReferencesHandling = PreserveReferencesHandling.Objects }; List <IFigure> temp = JsonConvert.DeserializeObject <List <IFigure> >(openFile, jsonSerializerSettings); foreach (IFigure fgr in temp) { fgr.FigurePen.Color = fgr.PenColor; fgr.FigurePen.Width = fgr.PenWidth; if (fgr is ClassRectangle) { ClassRectangle classRectangle = (ClassRectangle)fgr; classRectangle.FigureBrush.Color = classRectangle.FigureBackColor; classRectangle.textFont = new Font(classRectangle.textFont.FontFamily, classRectangle.FontSize * _painter.Scale, classRectangle.textFont.Style); } Figures.Add(fgr); } Refresh(); }
public void OpenCurrentFigure(ClassRectangle classRectangle) { _currentFigure = classRectangle; textBoxTitle.Text = _currentFigure.Title.ToString(); textBoxFields.Text = _currentFigure.Fields.ToString(); textBoxProperties.Text = _currentFigure.Properties.ToString(); textBoxMethods.Text = _currentFigure.Methods.ToString(); colorDialogBackground.Color = _currentFigure.FigureBrush.Color; buttonBackColor.BackColor = _currentFigure.FigureBrush.Color; colorDialogText.Color = _currentFigure.FigurePen.Color; buttonTextColor.BackColor = _currentFigure.FigurePen.Color; trackBar1.Value = (int)_currentFigure.FigurePen.Width; _painter = Painter.GetPainter(); this.ShowDialog(); }
private void trackBarScale_Scroll(object sender, EventArgs e) { textBoxScale.Text = (trackBarScale.Value).ToString(); _painter.Scale = (float)trackBarScale.Value / 100; _painter.Clear(); foreach (IFigure a in _painter.Figures) { if (a.figureType == Painter.FigureType.ClassRectangle) { ClassRectangle cur = (ClassRectangle)a; cur.textFont = new Font(cur.textFont.FontFamily, cur.FontSize * _painter.Scale, cur.textFont.Style); } a.Draw(); } _painter.SetMainBitmap(); _painter.UpdatePictureBox(); }
public void MouseUp(object sender, MouseEventArgs e) { AbstractArrow curentArrow = (AbstractArrow)_painter.CurentFigure; _painter.UpdatePictureBox(); if (curentArrow != null) { foreach (IFigure a in _painter.Figures) { if (a is ClassRectangle) { ClassRectangle temp = (ClassRectangle)a; foreach (Port b in temp.Ports) { if (b.SelectedPort(e.Location) && (b.ArrowType == Painter.FigureType.NoDefine || b.ArrowType == _painter.CurentFigure.figureType) ) { curentArrow.FinishPort = b; _painter.CurentFigure.FinishPoint = b.ConnectingPoint; _painter.CurentFigure.Links.Add(a); break; } } } } if (curentArrow.FinishPort != null) { _painter.CurentFigure.Draw(); _painter.SetMainBitmap(); _painter.Figures.Add(_painter.CurentFigure); foreach (IFigure a in _painter.CurentFigure.Links) { a.Links.Add(_painter.CurentFigure); } curentArrow.FinishPort.ArrowType = curentArrow.figureType; curentArrow.StartPort.ArrowType = curentArrow.figureType; _painter.CurentFigure = null; _painter.UpdatePictureBox(); } } }