private void Random_Pair_Click_Array(string[] A) { for (int i = 0; i < Line_Array.Length; i++) { Line_Array[i].Show(canvas, false); My_Line obj = new My_Line(canvas); My_List_Line[My_List_Line.IndexOf(Line_Array[i])] = obj; Line_Array[i] = obj; Line_Array[i].Show(canvas, false); } for (int i = 0; i < Rect_Array.Length; i++) { Rect_Array[i].Show(canvas, false); My_Rectangle obj1 = new My_Rectangle(canvas); My_List_Rect[My_List_Rect.IndexOf(Rect_Array[i])] = obj1; Rect_Array[i] = obj1; Rect_Array[i].Show(canvas, false); } for (int i = 0; i < Ell_Array.Length; i++) { Ell_Array[i].Show(canvas, false); My_Ellipse obj2 = new My_Ellipse(canvas); My_List_Ell[My_List_Ell.IndexOf(Ell_Array[i])] = obj2; Ell_Array[i] = obj2; Ell_Array[i].Show(canvas, false); } for (int i = 0; i < Circ_Array.Length; i++) { Circ_Array[i].Show(canvas, false); My_Circle obj3 = new My_Circle(canvas); My_List_Circ[My_List_Circ.IndexOf(Circ_Array[i])] = obj3; Circ_Array[i] = obj3; Circ_Array[i].Show(canvas, false); } for (int i = 0; i < Arr_Array.Length; i++) { Arr_Array[i].Show(canvas, false); My_Arrow obj4 = new My_Arrow(canvas); My_List_Arr[My_List_Arr.IndexOf(Arr_Array[i])] = obj4; Arr_Array[i] = obj4; Arr_Array[i].Show(canvas, false); } for (int i = 0; i < Romb_Array.Length; i++) { Romb_Array[i].Show(canvas, false); My_Romb obj4 = new My_Romb(canvas); My_List_Romb[My_List_Romb.IndexOf(Romb_Array[i])] = obj4; Romb_Array[i] = obj4; Romb_Array[i].Show(canvas, false); } for (int i = 0; i < Trap_Array.Length; i++) { Trap_Array[i].Show(canvas, false); My_Trap obj4 = new My_Trap(canvas); My_List_Trap[My_List_Trap.IndexOf(Trap_Array[i])] = obj4; Trap_Array[i] = obj4; Trap_Array[i].Show(canvas, false); } }
private void Random_Create_Click(object sender, RoutedEventArgs e) { if (Changed_figure == "Line") { My_Line obj = new My_Line(canvas); Add_to_ComboBox(obj, Count_Line); My_List_Line.Add(obj); My_List_Line[Count_Line++].Show(canvas, false); } if (Changed_figure == "Rectangle") { My_Rectangle obj = new My_Rectangle(canvas); Add_to_ComboBox(obj, Count_Rect); My_List_Rect.Add(obj); My_List_Rect[Count_Rect++].Show(canvas, false); } if (Changed_figure == "Arrow") { My_Arrow obj = new My_Arrow(canvas); Add_to_ComboBox(obj, Count_Arr); My_List_Arr.Add(obj); My_List_Arr[Count_Arr++].Show(canvas, false); } if (Changed_figure == "Ellipse") { My_Ellipse obj = new My_Ellipse(canvas); Add_to_ComboBox(obj, Count_Ell); My_List_Ell.Add(obj); My_List_Ell[Count_Ell++].Show(canvas, false); } if (Changed_figure == "Circle") { My_Circle obj = new My_Circle(canvas); Add_to_ComboBox(obj, Count_Circ); My_List_Circ.Add(obj); My_List_Circ[Count_Circ++].Show(canvas, false); } if (Changed_figure == "Romb") { My_Romb obj = new My_Romb(canvas); Add_to_ComboBox(obj, Count_Romb); My_List_Romb.Add(obj); My_List_Romb[Count_Romb++].Show(canvas, false); } if (Changed_figure == "Trap") { My_Trap obj = new My_Trap(canvas); Add_to_ComboBox(obj, Count_Trap); My_List_Trap.Add(obj); My_List_Trap[Count_Trap++].Show(canvas, false); } }
private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (Change == "Move") { try { string[] A = ComboBox.Text.Split(new char[] { '.' }); if (ComboBox.Text != "" && isEmpty()) { if (A[1] == "My_Line") { My_List_Line[Convert.ToInt32(A[2])].MoveTo(e, canvas, start_X, start_Y); } if (A[1] == "My_Rectangle") { My_List_Rect[Convert.ToInt32(A[2])].MoveTo(e, canvas, start_X, start_Y); } if (A[1] == "My_Ellipse") { My_List_Ell[Convert.ToInt32(A[2])].MoveTo(e, canvas, start_X, start_Y); } if (A[1] == "My_Circle") { My_List_Circ[Convert.ToInt32(A[2])].MoveTo(e, canvas, start_X, start_Y); } if (A[1] == "My_Arrow") { My_List_Arr[Convert.ToInt32(A[2])].MoveTo(e, canvas, start_X, start_Y); } if (A[1] == "My_Romb") { My_List_Romb[Convert.ToInt32(A[2])].MoveTo(e, canvas, start_X, start_Y); } if (A[1] == "My_Trap") { My_List_Trap[Convert.ToInt32(A[2])].MoveTo(e, canvas, start_X, start_Y); } } foreach (My_Line i in Line_Array) { i.MoveTo(e, canvas, start_X, start_Y); } foreach (My_Rectangle i in Rect_Array) { i.MoveTo(e, canvas, start_X, start_Y); } foreach (My_Circle i in Circ_Array) { i.MoveTo(e, canvas, start_X, start_Y); } foreach (My_Arrow i in Arr_Array) { i.MoveTo(e, canvas, start_X, start_Y); } foreach (My_Ellipse i in Ell_Array) { i.MoveTo(e, canvas, start_X, start_Y); } foreach (My_Romb i in Romb_Array) { i.MoveTo(e, canvas, start_X, start_Y); } foreach (My_Trap i in Trap_Array) { i.MoveTo(e, canvas, start_X, start_Y); } } catch { MessageBox.Show("Выберите элемент из ChekBox"); } } if (Change == "Create") { if (Changed_figure == "Line") { My_Line obj = new My_Line(e, start_X, start_Y, isMenuCaptured); Add_to_ComboBox(obj, Count_Line); My_List_Line.Add(obj); My_List_Line[Count_Line++].Show(canvas, false); } if (Changed_figure == "Rectangle") { My_Rectangle obj = new My_Rectangle(start_X, start_Y, e.GetPosition(null).X, e.GetPosition(null).Y, isMenuCaptured); Add_to_ComboBox(obj, Count_Rect); My_List_Rect.Add(obj); My_List_Rect[Count_Rect++].Show(canvas, false); } if (Changed_figure == "Arrow") { My_Arrow obj = new My_Arrow(e, start_X, start_Y, isMenuCaptured); Add_to_ComboBox(obj, Count_Arr); My_List_Arr.Add(obj); My_List_Arr[Count_Arr++].Show(canvas, false); } if (Changed_figure == "Ellipse") { My_Ellipse obj = new My_Ellipse(e.GetPosition(null).X, e.GetPosition(null).Y, start_X, start_Y, isMenuCaptured, canvas); Add_to_ComboBox(obj, Count_Ell); My_List_Ell.Add(obj); My_List_Ell[Count_Ell++].Show(canvas, false); } if (Changed_figure == "Circle") { My_Circle obj = new My_Circle(e.GetPosition(null).X, e.GetPosition(null).Y, start_X, start_Y, isMenuCaptured, canvas); Add_to_ComboBox(obj, Count_Circ); My_List_Circ.Add(obj); My_List_Circ[Count_Circ++].Show(canvas, false); } if (Changed_figure == "Romb") { My_Romb obj = new My_Romb(e.GetPosition(null).X, e.GetPosition(null).Y, start_X, start_Y, isMenuCaptured); Add_to_ComboBox(obj, Count_Romb); My_List_Romb.Add(obj); My_List_Romb[Count_Romb++].Show(canvas, false); } if (Changed_figure == "Trap") { My_Trap obj = new My_Trap(e.GetPosition(null).X, e.GetPosition(null).Y, start_X, start_Y, isMenuCaptured); Add_to_ComboBox(obj, Count_Trap); My_List_Trap.Add(obj); My_List_Trap[Count_Trap++].Show(canvas, false); } } }
private void Random_Pair_Click(object sender, RoutedEventArgs e) { try { string[] A = ComboBox.Text.Split(new char[] { '.' }); if (ComboBox.Text != "" && isEmpty()) { if (A[1] == "My_Line") { My_List_Line[Convert.ToInt32(A[2])].Show(canvas, false); My_Line obj = new My_Line(canvas); My_List_Line[Convert.ToInt32(A[2])] = obj; My_List_Line[Convert.ToInt32(A[2])].Show(canvas, false); } if (A[1] == "My_Rectangle") { My_List_Rect[Convert.ToInt32(A[2])].Show(canvas, false); My_Rectangle obj = new My_Rectangle(canvas); My_List_Rect[Convert.ToInt32(A[2])] = obj; My_List_Rect[Convert.ToInt32(A[2])].Show(canvas, false); } if (A[1] == "My_Ellipse") { My_List_Ell[Convert.ToInt32(A[2])].Show(canvas, false); My_Ellipse obj = new My_Ellipse(canvas); My_List_Ell[Convert.ToInt32(A[2])] = obj; My_List_Ell[Convert.ToInt32(A[2])].Show(canvas, false); } if (A[1] == "My_Circle") { My_List_Circ[Convert.ToInt32(A[2])].Show(canvas, false); My_Circle obj = new My_Circle(canvas); My_List_Circ[Convert.ToInt32(A[2])] = obj; My_List_Circ[Convert.ToInt32(A[2])].Show(canvas, false); } if (A[1] == "My_Arrow") { My_List_Arr[Convert.ToInt32(A[2])].Show(canvas, false); My_Arrow obj = new My_Arrow(canvas); My_List_Arr[Convert.ToInt32(A[2])] = obj; My_List_Arr[Convert.ToInt32(A[2])].Show(canvas, false); } if (A[1] == "My_Romb") { My_List_Romb[Convert.ToInt32(A[2])].Show(canvas, false); My_Romb obj = new My_Romb(canvas); My_List_Romb[Convert.ToInt32(A[2])] = obj; My_List_Romb[Convert.ToInt32(A[2])].Show(canvas, false); } if (A[1] == "My_Trap") { My_List_Trap[Convert.ToInt32(A[2])].Show(canvas, false); My_Trap obj = new My_Trap(canvas); My_List_Trap[Convert.ToInt32(A[2])] = obj; My_List_Trap[Convert.ToInt32(A[2])].Show(canvas, false); } } Random_Pair_Click_Array(A); } catch (Exception er) { } }
/// <summary> /// Иницализация данных при зоздании FSM с языком VHDL /// </summary> /// <param name="options"></param> /// <param name="vhdl_module"></param> public static void InitVHDLData( FSM_OptionsHelper options, VHDL_Module vhdl_module, Constructor_Core core ) { //загружаем данные VHDL //Добавляем порты List <My_Port> NewPortsFSM = new List <My_Port>(); Point pt = new Point(50, 50); foreach (VHDL_Port p in vhdl_module.PortList) { My_Port new_port = CreatePort(p, pt, core); NewPortsFSM.Add(new_port); pt.Y += 40; } core.Graph.AddFigureRange(NewPortsFSM); //----------------------------- core.Graph.VHDLModule = vhdl_module; //добавляем состояния if (options.NumberOfStates != 0) { #region Add States switch (options.StatesLayout) { case FSM_OptionsHelper.FSMStatesLayout.LinearHorisontal: { pt = new Point(100, 70); System.Drawing.Size size = new System.Drawing.Size(40, 40); int Distance = 100; for (int i = 0; i < options.NumberOfStates; i++) { My_State state = new My_State(core, new Rectangle(pt, size), true); state.name = string.Format("S{0}", i); core.Graph.AddFigure(state); pt.X += Distance; } } break; case FSM_OptionsHelper.FSMStatesLayout.LinearVertical: { pt = new Point(100, 70); System.Drawing.Size size = new System.Drawing.Size(40, 40); int Distance = 100; for (int i = 0; i < options.NumberOfStates; i++) { My_State state = new My_State(core, new Rectangle(pt, size), true); state.name = string.Format("S{0}", i); core.Graph.AddFigure(state); pt.Y += Distance; } } break; case FSM_OptionsHelper.FSMStatesLayout.Circular: { Point Start_Point = new Point(100, 70); System.Drawing.Size size = new System.Drawing.Size(40, 40); double angle = 0; int Radius = (options.NumberOfStates / 4 + 1) * 50; for (int i = 0; i < options.NumberOfStates; i++) { pt.X = (int)(Radius * Math.Cos(angle)) + Radius + Start_Point.X; pt.Y = (int)(Radius * Math.Sin(angle)) + Radius + Start_Point.Y; My_State state = new My_State(core, new Rectangle(pt, size), true); state.name = string.Format("S{0}", i); core.Graph.AddFigure(state); angle += (2 * Math.PI / (double)options.NumberOfStates); } } break; default: break; } #endregion ; #region Add Transitions switch (options.Transition) { case FSM_OptionsHelper.FSMTransition.None: { } break; case FSM_OptionsHelper.FSMTransition.Forward: { for (int i = 0; i < options.NumberOfStates; i++) { My_State s1 = core.Graph.States[i]; My_State s2 = (i < (options.NumberOfStates - 1)) ? core.Graph.States[i + 1] : core.Graph.States[0]; My_Line line = new My_Line(s1, s2, string.Format("L{0}", i), "", core); core.Graph.AddFigure(line); } } break; case FSM_OptionsHelper.FSMTransition.Backward: { for (int i = 0; i < options.NumberOfStates; i++) { My_State s2 = core.Graph.States[i]; My_State s1 = (i < (options.NumberOfStates - 1)) ? core.Graph.States[i + 1] : core.Graph.States[0]; My_Line line = new My_Line(s1, s2, string.Format("L{0}", i), "", core); core.Graph.AddFigure(line); } } break; case FSM_OptionsHelper.FSMTransition.Both: { for (int i = 0; i < options.NumberOfStates; i++) { My_State s1 = core.Graph.States[i]; My_State s2 = (i < (options.NumberOfStates - 1)) ? core.Graph.States[i + 1] : core.Graph.States[0]; My_Line line1 = new My_Line(s1, s2, string.Format("L{0}", 2 * i), "", core); core.Graph.AddFigure(line1); My_Line line2 = new My_Line(s2, s1, string.Format("L{0}", 2 * i + 1), "", core); core.Graph.AddFigure(line2); core.Graph.UpdateLinesAggle(s1, s2); } } break; default: break; } #endregion #region AddReset #endregion } //----------------------------- }