public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            }

            if (service != null)
            {
                // This is the code you want to run when the [...] is clicked and after it has been verified.
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.InitialDirectory = SceneManager.GameProject.ProjectPath;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string path = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, ofd.FileName);

                    if (File.Exists(SceneManager.GameProject.ProjectPath + "\\" + path))
                    {
                        value = path;
                    }
                }

                // Return the newly selected color.
                // value =
            }

            return(value);
        }
Example #2
0
        /// <summary>
        /// Loads a scene to memory from a file.
        /// The active scene is updated to this one if loaded with success.
        /// </summary>
        /// <param name="scenePath">The path of the scene to load</param>
        /// <returns>True if successfully loaded</returns>
        public static bool LoadScene(string scenePath, bool saveHistory)
        {
            try
            {
#if WINDOWS
                GameScene gameScene = (GameScene)GibboHelper.DeserializeObject(scenePath);
#elif WINRT
                GameScene gameScene = (GameScene)GibboHelper.DeserializeObject(typeof(GameScene), scenePath);
#endif
                ActiveScene     = gameScene;
                ActiveScenePath = scenePath;

                // Update last saved scene:
                if (GameProject != null && !scenePath.StartsWith("_") && saveHistory)
                {
                    GameProject.EditorSettings.LastOpenScenePath = GibboHelper.MakeExclusiveRelativePath(GameProject.ProjectPath, ActiveScenePath);
                }

                // Load with success, notify:
                return(true);
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error loading scene: " + exception.Message + "\n>" + exception.ToString());
                // Not loaded, notify:
                return(false);
            }
        }