コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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
        }
コード例 #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
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: kashifiqb/Aspose.3D-for-.NET
        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();
        }
コード例 #5
0
 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);
 }