public MainWindow() { InitializeComponent(); this.myMap = new Map(); MouseLeftButtonDown += new MouseButtonEventHandler(MainWindow_MouseLeftButtonDown); }
public static void Save(Map mapIn) { for (int i = 0; i < mapIn.bloquesCreados.Count; i++) { mapIn.bloquesCreados[i].UnSuscribe(); } SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.FileName = "Data"; saveDialog.DefaultExt = ".bin"; saveDialog.Filter = "Binary Documents (.bin)|*.bin"; saveDialog.ShowDialog(); Stream stream = saveDialog.OpenFile(); br.Serialize(stream, mapIn); stream.Close(); }
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 { } }