private void Borrar(BloqueWPF bloqueIn) { for (int i = 0; i < bloqueIn.logic.logicLines.Count; i++) { for (int j = 0; j < this.linesInCanvas.Count; j++) { if (this.linesInCanvas[j].Name.Equals(bloqueIn.logic.logicLines[i].id)) { this.myCanvas.Children.Remove(this.linesInCanvas[j]); } } this.myMap.lineasCreadas.Remove(bloqueIn.logic.logicLines[i]); } for (int i = 0; i < bloqueIn.logic.logicLines.Count; i++) { for (int j = 0; j < this.myMap.bloquesCreados.Count; j++) { if (!this.myMap.bloquesCreados[j].Equals(bloqueIn.logic)) { if (this.myMap.bloquesCreados[j].logicLines.Contains(bloqueIn.logic.logicLines[i])) { this.myMap.bloquesCreados[j].logicLines.Remove(bloqueIn.logic.logicLines[i]); this.myMap.bloquesCreados[j].CurrentConnections--; } } } } if (bloqueIn.logic.type.Equals(Herramientas.Types.Input.ToString())) { this.inputStack.Remove(bloqueIn.logic); } for (int i = 0; i < this.myMap.bloquesCreados.Count; i++) { if (this.myMap.bloquesCreados[i].Input1 != null) { if (this.myMap.bloquesCreados[i].Input1.Equals(bloqueIn.logic)) { this.myMap.bloquesCreados[i].AvailablePort1 = true; } } if (this.myMap.bloquesCreados[i].Input2 != null) { if (this.myMap.bloquesCreados[i].Input2.Equals(bloqueIn.logic)) { this.myMap.bloquesCreados[i].AvailablePort2 = true; } } } this.myCanvas.Children.Remove(bloqueIn); this.myMap.bloquesCreados.Remove(bloqueIn.logic); }
private void StartLine3(BloqueWPF bloqueSender) { if (this.inputPoint == default(Point) && this.outputPoint == default(Point) && bloqueSender.logic.AvailablePort3) { this.inputPoint = Mouse.GetPosition(this); this.portBloque3 = bloqueSender; } }
private void MenuItem_Click_ClearScreen(object sender, RoutedEventArgs e) { this.myCanvas.Children.RemoveRange(1, this.myCanvas.Children.Count - 1); this.myMap.bloquesCreados.Clear(); this.myMap.lineasCreadas.Clear(); this.inputStack.Clear(); this.linesInCanvas.Clear(); this.portBloque1 = null; this.portBloque2 = null; this.nextBloque = null; this.inputPoint = default(Point); this.outputPoint = default(Point); }
private void MenuItem_Click_Load(object sender, RoutedEventArgs e) { try { this.MenuItem_Click_ClearScreen(sender, e); this.myMap = Herramientas.Load(); int auxInt1 = this.myMap.bloquesCreados.Count; int auxInt2 = this.myMap.lineasCreadas.Count; #region LoadBloques for (int i = 0; i < auxInt1; i++) { string name = this.myMap.bloquesCreados[i].type; BloqueWPF auxBloque; switch (name) { case "Input": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Input.ToString()); inputStack.Add(auxBloque.logic); break; case "Output_Final": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Output_Final.ToString()); break; case "Output_Intermedio": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Output_Intermedio.ToString()); break; case "Separador": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Separador.ToString()); break; case "Aritmetico": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Aritmetico.ToString()); break; case "Funcion": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Funcion.ToString()); break; case "Comparador": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Comparador.ToString()); break; case "Plot_Sen": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Plotter.ToString()); break; case "Plot_Cos": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Plotter.ToString()); break; case "Plot_Factorial": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Plotter.ToString()); break; case "Plot_Fibonacci": auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Plotter.ToString()); break; default: auxBloque = new BloqueWPF(this.myMap.bloquesCreados[i], Herramientas.Types.Input.ToString()); inputStack.Add(auxBloque.logic); break; } if (auxBloque.logic.Input1 != null) { auxBloque.logic.Input1.Execute += auxBloque.UpdateInput1; } if (auxBloque.logic.Input2 != null) { auxBloque.logic.Input2.Execute += auxBloque.UpdateInput2; } if (auxBloque.logic.Input3 != null) { auxBloque.logic.Input3.Execute += auxBloque.UpdateInput3; } Canvas.SetTop(auxBloque, auxBloque.logic.cY); Canvas.SetLeft(auxBloque, auxBloque.logic.cX); this.myCanvas.Children.Add(auxBloque); this.Initialize_BloqueEvents(auxBloque); } #endregion #region LoadLines for (int i = 0; i < auxInt2; i++) { Line auxLine = new Line(); auxLine.Name = this.myMap.lineasCreadas[i].id; auxLine.X1 = this.myMap.lineasCreadas[i].cX1; auxLine.Y1 = this.myMap.lineasCreadas[i].cY1; auxLine.X2 = this.myMap.lineasCreadas[i].cX2; auxLine.Y2 = this.myMap.lineasCreadas[i].cY2; auxLine.Stroke = Brushes.Black; auxLine.StrokeThickness = 3; this.myCanvas.Children.Add(auxLine); this.linesInCanvas.Add(auxLine); } #endregion } catch { } }
private void MenuItem_Click_AddButton(object sender, RoutedEventArgs e) { Bloque logic; string name = ((MenuItem)sender).Name; switch (name) { case "Input": logic = new Input(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Input.ToString()); inputStack.Add(this.nextBloque.logic); break; case "Final": logic = new Final(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Output_Final.ToString()); break; case "Intermedio": logic = new Intermedio(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Output_Intermedio.ToString()); break; case "Suma": logic = new Suma(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Aritmetico.ToString()); break; case "Resta": logic = new Resta(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Aritmetico.ToString()); break; case "Multiplicacion": logic = new Multiplicacion(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Aritmetico.ToString()); break; case "Division": logic = new Division(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Aritmetico.ToString()); break; case "Sen": logic = new Sen(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Funcion.ToString()); break; case "Cos": logic = new Cos(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Funcion.ToString()); break; case "Factorial": logic = new Factorial(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Funcion.ToString()); break; case "Fibonacci": logic = new Fibonacci(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Funcion.ToString()); break; case "Igual": logic = new Igual(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Comparador.ToString()); break; case "Distinto": logic = new Distinto(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Comparador.ToString()); break; case "MayorEstricto": logic = new Mayor(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Comparador.ToString()); break; case "MenorEstricto": logic = new Menor(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Comparador.ToString()); break; case "MayorIgual": logic = new MayorIgual(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Comparador.ToString()); break; case "MenorIgual": logic = new MenorIgual(); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Comparador.ToString()); break; case "Plot_Sen": logic = new Plotter(name); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Plotter.ToString()); break; case "Plot_Cos": logic = new Plotter(name); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Plotter.ToString()); break; case "Plot_Factorial": logic = new Plotter(name); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Plotter.ToString()); break; case "Plot_Fibonacci": logic = new Plotter(name); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Plotter.ToString()); break; default: break; } if (this.nextBloque != null) { this.Initialize_BloqueEvents(this.nextBloque); } }
private void MainWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (nextBloque != null) { Point currentPos = Mouse.GetPosition(this); Canvas.SetTop(nextBloque, currentPos.Y); Canvas.SetLeft(nextBloque, currentPos.X); this.nextBloque.logic.cX = currentPos.X; this.nextBloque.logic.cY = currentPos.Y; this.myCanvas.Children.Add(this.nextBloque); this.myMap.bloquesCreados.Add(this.nextBloque.logic); this.nextBloque = null; } }
private void Initialize_BloqueEvents(BloqueWPF bloqueIn) { bloqueIn.deleteElement += this.Borrar; bloqueIn.startLine_Intermedio1 += this.StartLine1; bloqueIn.startLine_Intermedio2 += this.StartLine2; bloqueIn.startLine_Intermedio3 += this.StartLine3; bloqueIn.endLine_Intermedio += this.EndLine; bloqueIn.logic.Plot += bloqueIn.Plot; }
private void EndLine(BloqueWPF bloqueSender) { if (this.inputPoint != default(Point) && this.outputPoint == default(Point) && bloqueSender.logic.CurrentConnections < bloqueSender.logic.MaxConnections) { bloqueSender.logic.CurrentConnections++; this.outputPoint = Mouse.GetPosition(this); #region NuevaLineaLogica DataLine logicLine = new DataLine(); logicLine.cX1 = inputPoint.X; logicLine.cY1 = inputPoint.Y; logicLine.cX2 = outputPoint.X; logicLine.cY2 = outputPoint.Y; bloqueSender.logic.logicLines.Add(logicLine); this.myMap.lineasCreadas.Add(logicLine); #endregion #region NuevaLineaGrafica Line line = new Line(); line.Name = logicLine.id; line.X1 = inputPoint.X; line.Y1 = inputPoint.Y; line.X2 = outputPoint.X; line.Y2 = outputPoint.Y; line.Stroke = Brushes.Black; line.StrokeThickness = 3; this.linesInCanvas.Add(line); #endregion this.myCanvas.Children.Add(line); if (portBloque1 != null) { portBloque1.logic.AvailablePort1 = false; portBloque1.logic.Input1 = bloqueSender.logic; bloqueSender.logic.Execute += portBloque1.UpdateInput1; portBloque1.logic.logicLines.Add(logicLine); } else if (portBloque2 != null) { portBloque2.logic.AvailablePort2 = false; portBloque2.logic.Input2 = bloqueSender.logic; bloqueSender.logic.Execute += portBloque2.UpdateInput2; portBloque2.logic.logicLines.Add(logicLine); } else if (portBloque3 != null) { portBloque3.logic.AvailablePort3 = false; portBloque3.logic.Input3 = bloqueSender.logic; bloqueSender.logic.Execute += portBloque3.UpdateInput3; portBloque3.logic.logicLines.Add(logicLine); } this.portBloque1 = null; this.portBloque2 = null; this.portBloque3 = null; this.inputPoint = default(Point); this.outputPoint = default(Point); } }
private void CreateSeparador(int maxConnectionsIn) { Bloque logic = new Separador(maxConnectionsIn); this.nextBloque = new BloqueWPF(logic, Herramientas.Types.Separador.ToString()); this.Initialize_BloqueEvents(this.nextBloque); }