private void SetUp(string filename) { if (!string.IsNullOrEmpty(filename) && (Path.GetExtension(filename).ToUpper() == ".XBIMF") ) { try { FileInfo file = new FileInfo(filename); if (file.Exists) { using (FederatedModel fedModel = new FederatedModel(file)) { if (fedModel.Model.IsFederation) { txtAuthor.Text = fedModel.Author; txtOrg.Text = fedModel.Organisation; txtPrj.Text = fedModel.ProjectName; FileRoles = fedModel.RefModelRoles.ToDictionary(m => new FileInfo(m.Key.Name), m => m.Value); RefModels = new BindingList <FileInfo>(FileRoles.Keys.ToList()); Text += " : " + file.Name; FileName = filename; rolesList.Enabled = true; } } } } catch (ArgumentException Ex) //bad paths etc.. { toolStripLabel.Text = Ex.Message; } } }
private void UpdateUiFromFilename() { UpdateCheckOpenExcel(); var fileExt = Path.GetExtension(txtPath.Text); MapRefModelsRoles.Clear(); if (string.IsNullOrEmpty(fileExt)) { return; } if (fileExt.Equals(".xbimf", StringComparison.OrdinalIgnoreCase)) { // this gets the federated model from an xbimf file using (var fedModel = new FederatedModel(new FileInfo(txtPath.Text))) { if (fedModel.Model.IsFederation) { MapRefModelsRoles = fedModel.RefModelRoles.ToDictionary(m => new FileInfo(m.Key.Name), m => m.Value); } else { throw new XbimException(string.Format("Model is not Federated: {0}", txtPath.Text)); } } } rolesList.Enabled = !( fileExt.Equals(".xbimf", StringComparison.OrdinalIgnoreCase) || fileExt.Equals(".json", StringComparison.OrdinalIgnoreCase) || fileExt.Equals(".xml", StringComparison.OrdinalIgnoreCase) || fileExt.Equals(".xls", StringComparison.OrdinalIgnoreCase) || fileExt.Equals(".xlsx", StringComparison.OrdinalIgnoreCase) ); }
/// <summary> /// Create Federation file /// </summary> /// <param name="file">FileInfo</param> /// <param name="author">Authors name</param> /// <param name="organisation">Organisation name</param> /// <param name="prjName">Project name</param> private void CreateFedFile(string author, string organisation, string prjName) { using (var fedModel = new FederatedModel(author, organisation, prjName)) { foreach (var item in FileRoles) { fedModel.AddRefModel(item.Key, organisation, item.Value); } fedModel.Model.SaveAs(FileName); } }