/// <summary> /// Add Model event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { if (_worker == null || !_worker.IsBusy) { toolStripLabel.Text = string.Empty; } OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "All XBim Files|*.ifc;*.ifcxml;*.ifczip;*.xbim|IFC Files|*.ifc;*.ifcxml;*.ifczip|Xbim Files|*.xbim"; //|XLS Files|*.xls dlg.Title = "Choose a refrence model file to add to federation"; dlg.CheckFileExists = true; // Show open file dialog box if (dlg.ShowDialog() == DialogResult.OK) { var xbimFile = Path.ChangeExtension(dlg.FileName, "xbim"); FileInfo file = new FileInfo(xbimFile); if (!RefModels.Contains(file, new FileInfoComparer())) { if (Path.GetExtension(dlg.FileName).ToUpper().Contains(".IFC")) { _filesToProcess.Push(dlg.FileName); if (_worker == null) { _worker = CreateWorker(); _worker.DoWork += CreateXBimFile; } if (!_worker.IsBusy) { btnSave.Enabled = false; _worker.RunWorkerAsync(_filesToProcess.Pop()); } } rolesList.Enabled = true; RefModels.Add(file); var roles = RoleFilter.Unknown; FileRoles.Add(file, roles); if (_worker == null || !_worker.IsBusy) { labelPath.Text = "Path:" + file.FullName; } //highlight added name listBox.SelectedIndex = RefModels.Count - 1; rolesList.Roles = FileRoles[file]; } else { toolStripLabel.Text = "File already added"; } } }
/// <summary> /// Remove model event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRemove_Click(object sender, EventArgs e) { if (_worker == null || !_worker.IsBusy) { toolStripLabel.Text = string.Empty; } if (listBox.SelectedIndex >= 0) { var file = RefModels[listBox.SelectedIndex]; RefModels.Remove(file); FileRoles.Remove(file); if (listBox.SelectedIndex >= 0) { file = RefModels[listBox.SelectedIndex]; toolStripLabel.Text = file.FullName; rolesList.Roles = FileRoles[file]; } } else { toolStripLabel.Text = string.Empty; } }