private void buttonCombineIFC_Click(object sender, RoutedEventArgs e) { try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "IFC files (*.ifc)|*.ifc"; openFileDialog.RestoreDirectory = false; openFileDialog.Title = "Open IFC Files"; openFileDialog.Multiselect = true; if (openFileDialog.ShowDialog() == true) { if (openFileDialog.FileNames.Length > 0) { ProcessUnit unit = new ProcessUnit(); foreach (string fileName in openFileDialog.FileNames) { unit.IfcFiles.Add(new OpenModel(fileName)); } IFCWindow ifcWindow = new IFCWindow(unit); if (ifcWindow.ShowDialog() == true) { unit = ifcWindow.Unit; if (commonRuleSets.Count > 0) { //autorunSetting unit = ApplySettings(unit); } processUnits.Add(unit); } isEditing = true; } } } catch (Exception ex) { MessageBox.Show("Failed to combine IFC files.\n" + ex.Message, "Combine IFC files", MessageBoxButton.OK, MessageBoxImage.Warning); } }
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); } }