private void CreateLine(Schematix.FSM.My_State st1, Schematix.FSM.My_State st2) { this.state_begin = st1; this.state_end = st2; if ((st1.CenterPoint.X == st2.CenterPoint.X) && (st1.CenterPoint.Y == st2.CenterPoint.Y)) { Angle1 = new Point((st1.CenterPoint.X - 2 * st1.rect.Width), (st1.CenterPoint.Y - 2 * st1.rect.Height)); Angle2 = new Point((st1.CenterPoint.X - 2 * st1.rect.Width), (st1.CenterPoint.Y + 2 * st1.rect.Height)); } else { int deltax = (state_end.CenterPoint.X - state_begin.CenterPoint.X) / 3; int deltay = (state_end.CenterPoint.Y - state_begin.CenterPoint.Y) / 3; Angle1 = new Point((state_begin.CenterPoint.X + deltax), (state_begin.CenterPoint.Y + deltay)); Angle2 = new Point((state_end.CenterPoint.X - deltax), (state_end.CenterPoint.Y - deltay)); } mouse_move = MouseMove; mouse_down = MouseDown; mouse_up = MouseUp; draw = Draw; core.Graph.UpdateLinesAggle(st1, st2); //core.AddToHistory("Line " + name + " created"); }
public StateProperties(Schematix.FSM.My_State state, Schematix.FSM.Constructor_Core core) { InitializeComponent(); this.core = core; this.state = state; LoadState(); }
/// <summary> /// Создать новое состояние в графе /// </summary> public void CreateNewState() { if (Lock == true) { MessageBox.Show("You must create figure " + SelectedFigure.name + " before.", "Fatal Error :)", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } graph.UnselectAllFigures(); Schematix.FSM.My_State state = new Schematix.FSM.My_State(this); SelectedFigure = state; graph.AddFigure(state); Lock = true; form.Invalidate(); }
/// <summary> /// Создание нового состояния при помощи ToolBox /// </summary> /// <param name="rect"></param> public void CreateNewState_Dragged(Rectangle rect) { rect.Location = form.PointToClient(rect.Location); if (Lock == true) { MessageBox.Show("You must create figure " + SelectedFigure.name + " before.", "Fatal Error :)", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } graph.UnselectAllFigures(); Schematix.FSM.My_State state = new Schematix.FSM.My_State(this, rect, true); graph.AddFigure(state); Lock = false; //AddToHistory("New state Draged"); bitmap.UpdateBitmap(); form.Invalidate(); }
public void Delete_State(Schematix.FSM.My_State state) { DialogResult res = MessageBox.Show("Are you sure want to delete " + state.name + "?", "Delete State?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { List <Schematix.FSM.My_Line> removed_lines = new List <My_Line>(); foreach (Schematix.FSM.My_Line line in Lines) { if (line.state_begin == state) { removed_lines.Add(line); } if (line.state_end == state) { removed_lines.Add(line); } } RemoveFigureRange(removed_lines); RemoveFigure(state); } }
public Point GetCommonPoint(Schematix.FSM.My_State state, Schematix.FSM.My_Line line, bool angle /*true - angle1 else - angle2*/) { Point p = state.CenterPoint; Point line_angle; if (angle == true) { line_angle = line.Angle1; } else { line_angle = line.Angle2; } if (ArrowPaint == true) { Rectangle rect = state.rect; //Найдем уравнение прямой //y = k*x+b double K = (double)(state.CenterPoint.Y - line_angle.Y) / (double)(state.CenterPoint.X - line_angle.X); //данные для еллипса double a = (double)(rect.Width / 2); if (a < 10) { return(state.CenterPoint); } double b = (double)(rect.Height / 2); //x^2/a^2 + y^2/b^2 = 1; if (line_angle.Y > state.CenterPoint.Y) { double x = (b * b) / (K * K + ((b * b) / (a * a))); x = Math.Sqrt(x); if (line_angle.X < state.CenterPoint.X) { x = -x; } double y = (b / a) * Math.Sqrt(a * a - x * x); y += state.CenterPoint.Y; x += state.CenterPoint.X; p.X = (int)x; p.Y = (int)y; return(p); } else { double x = (b * b) / (K * K + ((b * b) / (a * a))); x = Math.Sqrt(x); if (line_angle.X < state.CenterPoint.X) { x = -x; } double y = -(b / a) * Math.Sqrt(a * a - x * x); y += state.CenterPoint.Y; x += state.CenterPoint.X; p.X = (int)x; p.Y = (int)y; return(p); } } return(p); }