public async void OpenFile(string fileName)
        {
            FileFormat format = FileFormat.Detect(fileName);

            if (format == null)
            {
                MessageBox.Show(this, "Unsupported file format", "Open file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //create load option and allow user to modify the load options
            LoadOptions opt = format.CreateLoadOptions();

            if (OptionDialog.ShowDialog(this, "Import Settings", opt) == DialogResult.Cancel)
            {
                return;
            }



            currentFileName = fileName;
            UpdateTitle();
            long elapsed = 0;

            try
            {
                lblStatus.Text               = string.Format("Loading {0}", fileName);
                fileListView1.Enabled        = false;
                propertyGrid1.SelectedObject = null;
                Stopwatch st = Stopwatch.StartNew();
                OnMovementChanged(btnOrbital, null);
                //open the scene using user modified load option in background thread.
                await Task.Run(() => scene.Open(fileName, opt));

                elapsed = st.ElapsedMilliseconds;

                renderView1.SceneUpdated(fileName);
                sceneHierarchy.UpdateHierarchy(scene);
            }
            catch (Exception e)
            {
                MessageBox.Show(this, "Cannot open file " + fileName + "\n" + e.Message, "Open file",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (elapsed > 0)
                {
                    lblStatus.Text = string.Format("Loaded in {0}ms, Ready.", elapsed);
                }
                else
                {
                    lblStatus.Text = "Ready.";
                }
                fileListView1.Enabled = true;
            }
        }
        public static void Run()
        {
            // ExStart:DetectFormat
            // Detect the format of a 3D file
            FileFormat inputFormat = FileFormat.Detect(RunExamples.GetDataFilePath("document.fbx"));

            // Display the file format
            Console.WriteLine("File Format: " + inputFormat.ToString());
            // ExEnd:DetectFormat
        }
Beispiel #3
0
        public static void Run()
        {
            //ExStart:DetectFormat
            // The path to the documents directory.
            string MyDir = RunExamples.GetDataDir();
            // Detect the format of a 3D file
            FileFormat inputFormat = FileFormat.Detect(MyDir + "document.fbx");

            // Display the file format
            Console.WriteLine("File Format: " + inputFormat.ToString());
            //ExEnd:DetectFormat
        }
Beispiel #4
0
        private void OnOpenInput(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.CheckFileExists = true;
            dialog.Filter          = "All files (*.*)|*.*";
            if (dialog.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }
            FileFormat inputFormat = FileFormat.Detect(dialog.FileName);

            if (inputFormat == null)
            {
                MessageBox.Show(this, "Unsupported 3D file format", "Open file", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            tbInput.Text = dialog.FileName;
            //show load options for this format
            pgInput.SelectedObject = loadOptions = inputFormat.CreateLoadOptions();
        }
 private FileFormat DetectFormat(StorageFileNames fileNames, MetaDataT metaData, out int mainFile)
 {
     mainFile = -1;
     if (metaData.InputFilenames == null || metaData.InputFilenames.Length == 0)
     {
         return(null);
     }
     for (int i = 0; i < metaData.InputFilenames.Length; i++)
     {
         var inputFile = fileNames.GetFileName(SourceFile, i);
         using (var fs = FileIO.OpenRead(inputFile))
         {
             var sourceFmt = FileFormat.Detect(fs, metaData.InputFilenames[i]);
             if (sourceFmt != null)
             {
                 mainFile = i;
                 return(sourceFmt);
             }
         }
     }
     return(null);
 }