Example #1
0
        public static async void DoFileOpen(string sFilename, bool bInteractive, Action <string> onCompletedF = null)
        {
            if (string.IsNullOrEmpty(sFilename))
            {
                return;
            }
            if (File.Exists(sFilename) == false)
            {
                CotangentUI.ShowModalMessageDialog("File Does Not Exist",
                                                   "File " + sFilename + " does not exist",
                                                   "Ok", null, null);
                return;
            }

            HaveOpenedOrImportedFile = true;

            if (sFilename.EndsWith(".cota", StringComparison.OrdinalIgnoreCase))
            {
                // [TODO] make this multi threaded?
                OpenSceneFile(sFilename);
                FPlatform.SetPrefsString("LastImportPath", sFilename);
            }
            else
            {
                ClearScene();
                MeshImporter importer = new MeshImporter();
                CCStatus.BeginOperation("reading");
                await importer.ImportInteractive(sFilename, onCompletedF);

                CCStatus.EndOperation("reading");
            }
        }
Example #2
0
        public static async void run_arguments_imports(List <string> filenames)
        {
            int             count        = 0;
            Action <string> onCompletedF = (filename) => {
                count++;
            };

            CCStatus.BeginOperation("reading");

            foreach (string filename in filenames)
            {
                if (filename.Length > 0 && File.Exists(filename))
                {
                    MeshImporter importer = new MeshImporter();
                    await importer.ImportInteractive(filename, onCompletedF);
                }
            }

            CCStatus.EndOperation("reading");

            if (count > 0)
            {
                // discard history
                CC.ActiveScene.History.Clear();
            }
            else
            {
                // show an error message or something...
            }
        }
        /*
         * Background compute thread for file monitor
         */

        private void ProcessingThread()
        {
            List <PrintMeshSO> toProcess = new List <PrintMeshSO>();

            while (true)
            {
                processThreadEvent.WaitOne(CCPreferences.AutoReloadCheckFrequencyS * 1000);

                if (FPlatform.ShutdownBackgroundThreadsOnQuit)
                {
                    break;
                }

                toProcess.Clear();
                lock (TrackedMeshes) {
                    toProcess.AddRange(TrackedMeshes);
                }

                foreach (PrintMeshSO so in toProcess)
                {
                    if (so.AutoUpdateOnSourceFileChange == false)
                    {
                        continue;
                    }

                    long cur_timestamp = File.GetLastWriteTime(so.SourceFilePath).Ticks;
                    if (cur_timestamp != so.LastReadFileTimestamp)
                    {
                        MeshImporter importer = new MeshImporter();
                        importer.ImportAutoUpdate(so);
                    }
                }
            }
        }
Example #4
0
        public static async void DoDragDropImport(List <string> filenames)
        {
            List <string> meshFiles, sceneFiles;

            get_valid_filenames(filenames, out meshFiles, out sceneFiles);

            if (sceneFiles.Count > 0)
            {
                HaveOpenedOrImportedFile = true;
                DoDragDropOpen(sceneFiles);
            }

            int             count        = 0;
            Action <string> onCompletedF = (filename) => {
                count++;
            };

            if (CurrentSceneIsStartupScene)
            {
                ClearScene();
            }
            HaveOpenedOrImportedFile = true;

            CC.Slicer.InvalidateSlicing();

            CCStatus.BeginOperation("reading");

            foreach (string filename in filenames)
            {
                if (filename.Length > 0 && File.Exists(filename))
                {
                    MeshImporter importer = new MeshImporter();
                    await importer.ImportInteractive(filename, onCompletedF);
                }
            }

            CCStatus.EndOperation("reading");

            if (count > 0)
            {
                CC.ActiveScene.History.PushInteractionCheckpoint();
                CCActions.UpdateViewClippingBounds();
            }
            else
            {
                // show an error message or something...
            }
        }