private void AddPneuCylCommand_Executed(object sender, ExecutedRoutedEventArgs e) { AddItemDlg dlg = new AddItemDlg { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, Tag = "Cylinder" }; dlg.ShowDialog(); if (dlg.DialogResult == true) { if (SelectedItem.GetType().ToString() == "PLCcodeGen.Station") { PneuCyl cyl = new PneuCyl(((App)Application.Current).MyProjects[0].PlcName + ((Station)SelectedItem).Name.Substring(1), dlg.itemName.Text); ((Station)SelectedItem).Items.Add(cyl); } else { MessageBox.Show("You can only add Cylinders to a Station", "Input Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void AddCellCommand_Executed(object sender, ExecutedRoutedEventArgs e) { AddItemDlg dlg = new AddItemDlg { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, Tag = "Cell" }; dlg.ShowDialog(); if (dlg.DialogResult == true) { ((Project)SelectedItem).Cells.Add(new Cell(dlg.itemName.Text)); } }
private void AddValveCommand_Executed(object sender, ExecutedRoutedEventArgs e) { AddItemDlg dlg = new AddItemDlg { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, Tag = "Valve" }; dlg.ShowDialog(); if (dlg.DialogResult == true) { if (SelectedItem.GetType().ToString() == "PLCcodeGen.Station") { Valve valve = new Valve(dlg.itemName.Text); ((Station)SelectedItem).Items.Add(valve); } else { MessageBox.Show("You can only add Valves to a Station", "Input Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }