private void buttonDeleteClass_Click(object sender, RoutedEventArgs e) { try { for (int i = dataGridClassification.SelectedItems.Count - 1; i > -1; i--) { OpenClassification classification = dataGridClassification.SelectedItems[i] as OpenClassification; settings.Classifications.Remove(classification); } } catch (Exception ex) { string message = ex.Message; } }
private void buttonDeleteClass_Click(object sender, RoutedEventArgs e) { try { if (dataGridTasks.SelectedIndex > -1 && dataGridClassification.SelectedItems.Count > 0) { int taskIndex = dataGridTasks.SelectedIndex; for (int i = dataGridClassification.SelectedItems.Count - 1; i > -1; i--) { OpenClassification classification = dataGridClassification.SelectedItems[i] as OpenClassification; processUnits[taskIndex].Classifications.Remove(classification); } } } catch (Exception ex) { string message = ex.Message; } }
public static ObservableCollection <ProcessUnit> ExtractProcessUnits(Batch batch) { ObservableCollection <ProcessUnit> processUnits = new ObservableCollection <ProcessUnit>(); try { ProcessUnit unit = new ProcessUnit(); ObservableCollection <GenericElement> elements = batch.Target.Elements; for (int i = 0; i < elements.Count; i++) { GenericElement element = elements[i]; string elementType = element.GetType().Name; switch (elementType) { case "OpenModel": OpenModel openModel = element as OpenModel; if (openModel.FileExtension == ".smc") { unit.OpenSolibri = openModel; } else if (modelExtensions.Contains(openModel.FileExtension)) { InputModel modeltoOpen = new InputModel(openModel); unit.Models.Add(modeltoOpen); } break; case "UpdateModel": UpdateModel updateModel = element as UpdateModel; InputModel modeltoUpdate = new InputModel(updateModel); unit.Models.Add(modeltoUpdate); break; case "OpenRuleset": OpenRuleset ruleset = element as OpenRuleset; unit.Rulesets.Add(ruleset); break; case "OpenClassification": OpenClassification classification = element as OpenClassification; unit.Classifications.Add(classification); break; case "Check": Check check = element as Check; check.IsSpecified = true; unit.CheckTask = check; break; case "AutoComment": AutoComment comment = element as AutoComment; comment.IsSpecified = true; unit.CommentTask = comment; break; case "WriterReport": unit.CheckingReport = element as WriterReport; break; case "CreatePresentation": CreatePresentation createP = element as CreatePresentation; createP.IsSelected = true; unit.PresentationCreate = createP; break; case "UpdatePresentation": UpdatePresentation updateP = element as UpdatePresentation; updateP.IsSelected = true; unit.PresentationUpdate = updateP; break; case "GeneralReport": unit.PresentationReport = element as GeneralReport; break; case "BCFReport": unit.BCFReport = element as BCFReport; break; case "CoordinationReport": unit.CoordReport = element as CoordinationReport; break; case "SaveModel": unit.SaveSolibri = element as SaveModel; unit.TaskName = System.IO.Path.GetFileNameWithoutExtension(unit.SaveSolibri.File); break; case "CloseModel": processUnits.Add(unit); unit = new ProcessUnit(); break; } } } catch (Exception ex) { MessageBox.Show("Failed to extract process units.\n" + ex.Message, "Extract Process Unit", MessageBoxButton.OK, MessageBoxImage.Warning); } return(processUnits); }