/// <summary> /// Tidies up any open files and closes any open models /// </summary> private void CloseAndDeleteTemporaryFiles() { try { if (_worker != null && _worker.IsBusy) { _worker.CancelAsync(); //tell it to stop } var model = ModelProvider.ObjectInstance as XbimModel; SetOpenedModelFileName(null); if (model != null) { model.Dispose(); ModelProvider.ObjectInstance = null; ModelProvider.Refresh(); } SetDefaultModeStyler(null, null); } finally { if (!(_worker != null && _worker.IsBusy && _worker.CancellationPending)) //it is still busy but has been cancelled { if (!string.IsNullOrWhiteSpace(_temporaryXbimFileName) && File.Exists(_temporaryXbimFileName)) { File.Delete(_temporaryXbimFileName); } _temporaryXbimFileName = null; } //else do nothing it will be cleared up in the worker thread } }
/// <summary> /// Tidies up any open files and closes any open models /// </summary> private void CloseAndDeleteTemporaryFiles() { try { if (_worker != null && _worker.IsBusy) { _worker.CancelAsync(); //tell it to stop } SetOpenedModelFileName(null); if (Model != null) { Model.Close(); // Make sure we close the model (cache) properly Model.Dispose(); ModelProvider.ObjectInstance = null; ModelProvider.Refresh(); } if (!(DrawingControl.DefaultLayerStyler is SurfaceLayerStyler)) { SetDefaultModeStyler(null, null); } } finally { if (!(_worker != null && _worker.IsBusy && _worker.CancellationPending)) //it is still busy but has been cancelled { if (!string.IsNullOrWhiteSpace(_temporaryXbimFileName) && File.Exists(_temporaryXbimFileName)) { File.Delete(_temporaryXbimFileName); } _temporaryXbimFileName = null; } //else do nothing it will be cleared up in the worker thread } }
private void SmartHouse_Loaded(object sender, RoutedEventArgs e) { var model = IfcStore.Create(null, XbimSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel); ModelProvider.ObjectInstance = model; ModelProvider.Refresh(); }
/// <summary> /// Tidies up any open files and closes any open models /// </summary> private void CloseAndDeleteTemporaryFiles() { try { if (_loadFileBackgroundWorker != null && _loadFileBackgroundWorker.IsBusy) { _loadFileBackgroundWorker.CancelAsync(); //tell it to stop } if (Model != null) { Model.Dispose(); ModelProvider.ObjectInstance = null; ModelProvider.Refresh(); } if (!(DrawingControl.DefaultLayerStyler is SurfaceLayerStyler)) { SetDefaultModeStyler(null, null); } } finally { if (!(_loadFileBackgroundWorker != null && _loadFileBackgroundWorker.IsBusy && _loadFileBackgroundWorker.CancellationPending)) //it is still busy but has been cancelled { if (!string.IsNullOrWhiteSpace(tempFileName) && File.Exists(tempFileName)) { File.Delete(tempFileName); } tempFileName = null; } //else do nothing it will be cleared up in the worker thread } }
void XplorerMainWindow_Loaded(object sender, RoutedEventArgs e) { XbimModel model = XbimModel.CreateTemporaryModel(); model.Initialise(); ModelProvider.ObjectInstance = model; ModelProvider.Refresh(); }
private void OnFind(int id_room) { var model = IfcStore.Create(null, XbimSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel); ModelProvider.ObjectInstance = model; ModelProvider.Refresh(); var path = to_model?.Invoke(id_room, rooms[active_index].Settings) as string; if (path == "") { MessageBox.Show("Модель не была найдена"); return; } dlg_OpenAnyFile(path); }
//Complete load private void FileLoadCompleted(object s, RunWorkerCompletedEventArgs args) { if (args.Result is IfcStore) //all ok { //this Triggers the event to load the model into the views ModelProvider.ObjectInstance = args.Result; ModelProvider.Refresh(); ProgressBar.Value = 0; StatusMsg.Text = "Готово"; } else //we have a problem { var errMsg = args.Result as string; if (!string.IsNullOrEmpty(errMsg)) { MessageBox.Show(this, errMsg, "Ошибка открытия файла", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.None); } var exception = args.Result as Exception; if (exception != null) { var sb = new StringBuilder(); var indent = ""; while (exception != null) { sb.AppendFormat("{0}{1}\n", indent, exception.Message); exception = exception.InnerException; indent += "\t"; } MessageBox.Show(this, sb.ToString(), "Ошибка открытия Ifc файла", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.None); } ProgressBar.Value = 0; StatusMsg.Text = "Ошибка/Готово"; SetOpenedModelFileName(""); } FireLoadingComplete(s, args); }
private void FileLoadCompleted(object s, RunWorkerCompletedEventArgs args) { if (args.Result is IfcStore) //all ok { //this Triggers the event to load the model into the views this.Dispatcher.Invoke(() => { ModelProvider.ObjectInstance = args.Result; ModelProvider.Refresh(); //ProgressBar.Value = 0; //StatusMsg.Text = "Ready"; //AddRecentFile(); }); } else //we have a problem { this.Dispatcher.Invoke(() => { var errMsg = args.Result as string; if (!string.IsNullOrEmpty(errMsg)) { MessageBox.Show(errMsg, "Error Opening File", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.None); } var exception = args.Result as Exception; if (exception != null) { var sb = new StringBuilder(); var indent = ""; while (exception != null) { sb.AppendFormat("{0}{1}\n", indent, exception.Message); exception = exception.InnerException; indent += "\t"; } MessageBox.Show(sb.ToString(), "Error Opening Ifc File", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.None); } SetOpenedModelFileName(""); }); } FireLoadingComplete(s, args); }
void XplorerMainWindow_Loaded(object sender, RoutedEventArgs e) { // this enables a basic configuration for the logger. BasicConfigurator.Configure(); var model = IfcStore.Create(null, IfcSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel); ModelProvider.ObjectInstance = model; ModelProvider.Refresh(); // logging information warnings _appender = new EventAppender { Tag = "MainWindow" }; _appender.Logged += appender_Logged; var hier = LogManager.GetRepository() as Hierarchy; hier?.Root.AddAppender(_appender); }
void XplorerMainWindow_Loaded(object sender, RoutedEventArgs e) { var model = XbimModel.CreateTemporaryModel(); model.Initialise(); ModelProvider.ObjectInstance = model; ModelProvider.Refresh(); // logging information warnings appender = new EventAppender { Tag = "MainWindow" }; appender.Logged += appender_Logged; var hier = LogManager.GetRepository() as Hierarchy; if (hier != null) { hier.Root.AddAppender(appender); } }
private void FileLoadCompleted(object s, RunWorkerCompletedEventArgs args) { if (args.Result is IfcStore) //all ok { ModelProvider.ObjectInstance = args.Result; //this Triggers the event to load the model into the views // PropertiesControl.Model = (XbimModel)args.Result; // // done thtough binding in xaml ModelProvider.Refresh(); ProgressBar.Value = 0; StatusMsg.Text = "Ready"; AddRecentFile(); } else //we have a problem { var errMsg = args.Result as string; if (!string.IsNullOrEmpty(errMsg)) { MessageBox.Show(this, errMsg, "Error Opening File", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.None); } var exception = args.Result as Exception; if (exception != null) { var sb = new StringBuilder(); var indent = ""; while (exception != null) { sb.AppendFormat("{0}{1}\n", indent, exception.Message); exception = exception.InnerException; indent += "\t"; } MessageBox.Show(this, sb.ToString(), "Error Opening Ifc File", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.None); } ProgressBar.Value = 0; StatusMsg.Text = "Error/Ready"; } FireLoadingComplete(s, args); }
private void CreateWorker() { _worker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; _worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args) { if (args.ProgressPercentage < 0 || args.ProgressPercentage > 100) { return; } ProgressBar.Value = args.ProgressPercentage; StatusMsg.Text = (string)args.UserState; }; _worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { if (args.Result is XbimModel) //all ok { ModelProvider.ObjectInstance = args.Result; //this Triggers the event to load the model into the views // PropertiesControl.Model = (XbimModel)args.Result; // // done thtough binding in xaml ModelProvider.Refresh(); ProgressBar.Value = 0; StatusMsg.Text = "Ready"; AddRecentFile(); // todo: file extensions need to be registered to allow an easy use of the jumplist // this is best done in the installer. //// METHOD 1 - for a task //// Configure a new JumpTask. //// //FileInfo Fi = new FileInfo(_openedModelFileName); //JumpTask jumpTask1 = new JumpTask(); //// Get the path to Calculator and set the JumpTask properties. //jumpTask1.ApplicationPath = Assembly.GetExecutingAssembly().Location; //jumpTask1.Arguments = _openedModelFileName; //jumpTask1.IconResourcePath = Assembly.GetExecutingAssembly().Location; //jumpTask1.Title = Fi.Name; //jumpTask1.Description = Fi.FullName; //var v = JumpList.GetJumpList(Application.Current); //v.JumpItems.Add(jumpTask1); //v.Apply(); // METHOD 2: recent files. //// Get the JumpList from the application and update it. //var jumpList1 = JumpList.GetJumpList(App.Current); //jumpList1.JumpItems.Add() //JumpList.AddToRecentCategory(_openedModelFileName); //jumpList1.Apply(); } else //we have a problem { var errMsg = args.Result as string; if (!string.IsNullOrEmpty(errMsg)) { MessageBox.Show(this, errMsg, "Error Opening File", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.None); } if (args.Result is Exception) { var sb = new StringBuilder(); var ex = args.Result as Exception; var indent = ""; while (ex != null) { sb.AppendFormat("{0}{1}\n", indent, ex.Message); ex = ex.InnerException; indent += "\t"; } MessageBox.Show(this, sb.ToString(), "Error Opening Ifc File", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None, MessageBoxOptions.None); } ProgressBar.Value = 0; StatusMsg.Text = "Error/Ready"; } FireLoadingComplete(s, args); }; }