private void LoadModelThread(object state) { var asyncModelLoadData = state as ModelLoadingManager.AsyncModelLoadData; var model = (M3D.Graphics.Ext3D.ModelRendering.Model)null; ModelLoadingManager.Result result = ModelLoadingManager.Result.Success; try { model = ModelLoadingManager.LoadModelFromFile(asyncModelLoadData.filename); model.fileName = asyncModelLoadData.filename; } catch (Exception ex) { result = ModelLoadingManager.Result.Failed; } if (model == null || result == ModelLoadingManager.Result.Failed) { ShowFileLoadingExeption(new Exception("load failure"), asyncModelLoadData.filename, asyncModelLoadData.onFailCallback); DecFilesLoading(); } else { if (asyncModelLoadData.loadedCallback == null) { return; } asyncModelLoadData.loadedCallback(result, model, asyncModelLoadData.objectDetails); } }
public PrinterStatusDialogOrganizer(SpoolerConnection spooler_connection, ModelLoadingManager modelLoadingManager, SettingsManager settingsManager, Form1 mainform, GUIHost gui_host, PrinterView printerView, PopupMessageBox messagebox) { this.spooler_connection = spooler_connection; this.modelLoadingManager = modelLoadingManager; this.settingsManager = settingsManager; this.mainform = mainform; this.messagebox = messagebox; this.printerView = printerView; this.gui_host = gui_host; this.spooler_connection.OnGotNewPrinter += new SpoolerClient.OnGotNewPrinterDel(OnGotNewPrinter); this.spooler_connection.OnPrinterDisconnected += new SpoolerClient.OnPrinterDisconnectedDel(OnPrinterDisconnected); connected_printers = new List <PrinterStatusDialog>(); InitGUIElement(gui_host, printerView.GetEditFrame()); }
public static M3D.Graphics.Ext3D.ModelRendering.Model LoadModelFromFile(string fileName) { return(new M3D.Graphics.Ext3D.ModelRendering.Model(ModelLoadingManager.GetModelLoader(fileName).Load(fileName), fileName)); }
private bool LoadZip(string zipFileName, ModelLoadingManager.OnModelLoadedDel loadedCallback, ModelLoadingManager.LoadFailedCallback onFailCallback) { IncFilesLoading(); var asyncZipLoadData = new ModelLoadingManager.AsyncZipLoadData(zipFileName, loadedCallback); FileStream file; try { file = File.OpenRead(zipFileName); } catch (IOException ex) { DecFilesLoading(); ShowFileLoadingExeption(ex, zipFileName, onFailCallback); return(false); } try { asyncZipLoadData.zf = new ZipFile(file); asyncZipLoadData.iconFile = null; asyncZipLoadData.extractTo = Path.Combine(Paths.PublicDataFolder, "ExtractedZipFiles", Path.GetFileNameWithoutExtension(zipFileName)); foreach (ZipEntry zipEntry in asyncZipLoadData.zf) { if (zipEntry.IsFile) { var str = Path.Combine(asyncZipLoadData.extractTo, Path.GetFileName(zipEntry.Name)); if (ModelLoadingManager.GetModelLoader(zipEntry.Name) != null) { asyncZipLoadData.modelFiles.Add(str); } else if (zipEntry.Name.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) { asyncZipLoadData.xmlFiles.Add(str); } else if (zipEntry.Name.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) || zipEntry.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase) || zipEntry.Name.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase)) { asyncZipLoadData.iconFile = str; } } } if (asyncZipLoadData.modelFiles.Count > 0) { if (asyncZipLoadData.xmlFiles.Count > 0) { printerview.RemovePrintableModels(); xmlPrinterSettingsZipFileLoaded = true; } if (!Directory.Exists(asyncZipLoadData.extractTo)) { Directory.CreateDirectory(asyncZipLoadData.extractTo); } } } catch (Exception ex) { file.Close(); DecFilesLoading(); return(false); } if (asyncZipLoadData.modelFiles.Count > 0) { libraryview.RecentModels.CopyAndAssignIconForLibrary(zipFileName, asyncZipLoadData.iconFile); ThreadPool.QueueUserWorkItem(new WaitCallback(LoadZipWorkerThread), asyncZipLoadData); return(true); } file.Close(); DecFilesLoading(); return(false); }