Example #1
0
        private void AddExistingAsset()
        {
            string       path   = null;
            DialogResult result = m_fileDialogService.OpenFileName(ref path, Localizer.Localize("All Files") + "  (*.*)|*.*");

            if (result == DialogResult.OK)
            {
                IAssetFolder parent = m_currentAssetFolder;
                IResource    asset  = parent.CreateAsset();
                asset.Uri = new Uri(path);
                //OnObjectInserted(new ItemInsertedEventArgs<object>(parent.Assets.Count - 1, asset, parent));
            }
        }
Example #2
0
        /// <summary>
        /// Gets the file name for file "Open" operation, starting at the specified directory</summary>
        /// <param name="service">File dialog service</param>
        /// <param name="pathName">Resulting file name</param>
        /// <param name="filter">File extension filter, e.g., "Setting file (*.xml;*.txt)|*.xml;*.txt|Any (*.*)|*.*"</param>
        /// <param name="directory">Directory that the user first sees, or null for default behavior</param>
        /// <returns>True iff operation is not cancelled</returns>
        public static FileDialogResult OpenFileName(this IFileDialogService service, ref string pathName, string filter, string directory)
        {
            string originalDir = service.ForcedInitialDirectory;

            try
            {
                service.ForcedInitialDirectory = directory;
                return(service.OpenFileName(ref pathName, filter));
            }
            finally
            {
                service.ForcedInitialDirectory = originalDir;
            }
        }