private void OpenConfig(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                OpenFileDialog openDialog = new OpenFileDialog();
                openDialog.Filter           = "Batch Configuration File (*.xml)|*.xml";
                openDialog.Title            = "Open Batch Configuration File";
                openDialog.InitialDirectory = settings.RemoteSetup.DirectoryName;
                openDialog.Multiselect      = false;
                if (openDialog.ShowDialog() == true)
                {
                    string xmlFile = openDialog.FileName;
                    bool   read    = BatchSetupUtils.ReadBatchConfig(xmlFile, out batch);
                    if (read)
                    {
                        processUnits   = BatchSetupUtils.ExtractProcessUnits(batch);
                        commonRuleSets = BatchSetupUtils.ExtractRulesets(batch);
                        DisplayConfig();
                        isEditing = false;
                    }
                }

                /*
                 * OpenFileWindow openWindow = new OpenFileWindow(settings.RemoteSetup.DirectoryName);
                 * openWindow.Owner = this;
                 * if (openWindow.ShowDialog() == true)
                 * {
                 *  string xmlFile = openWindow.ConfigFileName;
                 *  bool read = BatchSetupUtils.ReadBatchConfig(xmlFile, out batch);
                 *  if (read)
                 *  {
                 *      processUnits = BatchSetupUtils.ExtractProcessUnits(batch);
                 *      commonRuleSets = BatchSetupUtils.ExtractRulesets(batch);
                 *      DisplayConfig();
                 *      isEditing = false;
                 *  }
                 * }*/
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to open configuration file.\n" + ex.Message, "Open Configuration", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
 private void NewConfig(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         if (isEditing)
         {
             MessageBoxResult result = MessageBox.Show("Would you like to save the curent configuration file?", "Save File", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes || result == MessageBoxResult.No)
             {
                 if (result == MessageBoxResult.Yes)
                 {
                     SaveConfig();
                 }
                 batch          = new Batch();
                 processUnits   = BatchSetupUtils.ExtractProcessUnits(batch);
                 commonRuleSets = BatchSetupUtils.ExtractRulesets(batch);
                 DisplayConfig();
                 statusLable.Text = "Ready";
                 isEditing        = false;
             }
         }
         else
         {
             batch          = new Batch();
             processUnits   = BatchSetupUtils.ExtractProcessUnits(batch);
             commonRuleSets = BatchSetupUtils.ExtractRulesets(batch);
             DisplayConfig();
             statusLable.Text = "Ready";
             isEditing        = false;
         }
     }
     catch (Exception ex)
     {
         string message = ex.Message;
     }
 }
        private void Window_Drop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[]      files        = (string[])e.Data.GetData(DataFormats.FileDrop);
                    string        xmlFile      = "";
                    List <string> solibriFiles = new List <string>();
                    List <string> ifcFiles     = new List <string>();
                    List <string> rulesetFiles = new List <string>();
                    foreach (string file in files)
                    {
                        if (System.IO.Path.GetExtension(file).Contains("smc"))
                        {
                            solibriFiles.Add(file);
                        }
                        if (System.IO.Path.GetExtension(file).Contains("xml"))
                        {
                            xmlFile = file; break;
                        }
                        if (System.IO.Path.GetExtension(file).Contains("ifc"))
                        {
                            ifcFiles.Add(file);
                        }
                        if (System.IO.Path.GetExtension(file).Contains("cset"))
                        {
                            rulesetFiles.Add(file);
                        }
                    }

                    if (!string.IsNullOrEmpty(xmlFile))
                    {
                        bool read = BatchSetupUtils.ReadBatchConfig(xmlFile, out batch);
                        if (read)
                        {
                            processUnits   = BatchSetupUtils.ExtractProcessUnits(batch);
                            commonRuleSets = BatchSetupUtils.ExtractRulesets(batch);
                            DisplayConfig();
                        }
                    }
                    else
                    {
                        if (solibriFiles.Count > 0)
                        {
                            foreach (string sfile in solibriFiles)
                            {
                                ProcessUnit pUnit = new ProcessUnit();
                                pUnit.OpenSolibri = new OpenModel(sfile);
                                pUnit             = ApplySettings(pUnit);
                                processUnits.Add(pUnit);
                            }
                            dataGridOpenSolibri.SelectedIndex = processUnits.Count - 1;
                            isEditing = true;
                        }

                        if (rulesetFiles.Count > 0)
                        {
                            bool updateBCF = false;
                            if (commonRuleSets.Count == 0)
                            {
                                updateBCF = true;
                            }

                            foreach (string ruleset in rulesetFiles)
                            {
                                commonRuleSets.Add(new OpenRuleset(ruleset));
                            }
                            if (updateBCF)
                            {
                                UpdateSettings();
                            }
                            isEditing = true;
                        }
                        if (ifcFiles.Count > 0)
                        {
                            ProcessUnit pUnit = new ProcessUnit();
                            foreach (string ifcFile in ifcFiles)
                            {
                                pUnit.IfcFiles.Add(new OpenModel(ifcFile));
                            }
                            IFCWindow ifcWindow = new IFCWindow(pUnit);
                            if (ifcWindow.ShowDialog() == true)
                            {
                                pUnit = ifcWindow.Unit;
                                pUnit = ApplySettings(pUnit);
                                processUnits.Add(pUnit);
                                dataGridOpenSolibri.SelectedIndex = processUnits.Count - 1;
                                isEditing = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to drop files.\n" + ex.Message, "File Drop", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }