Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
        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);
                }
            }
        }