Exemple #1
0
        /// <summary>
        /// Configure this viewmodel (+ attached browser viewmodel) with the given settings and
        /// initialize viewmodels with UserProfile.CurrentPath location.
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        bool IConfigExplorerSettings.ConfigureExplorerSettings(ExplorerSettingsModel settings)
        {
            if (settings == null)
            {
                return(false);
            }

            if (settings.UserProfile == null)
            {
                return(false);
            }

            if (settings.UserProfile.CurrentPath == null)
            {
                return(false);
            }

            try
            {
                this.NavigateToFolder(settings.UserProfile.CurrentPath);
                this.Filters.ClearFilter();

                // Set file filter in file/folder list view
                foreach (var item in settings.FilterCollection)
                {
                    this.Filters.AddFilter(item.FilterDisplayName, item.FilterText);
                }

                // Add a current filter setting (if any is available)
                if (settings.UserProfile.CurrentFilter != null)
                {
                    this.Filters.SetCurrentFilter(settings.UserProfile.CurrentFilter.FilterDisplayName,
                                                  settings.UserProfile.CurrentFilter.FilterText);
                }

                this.RecentFolders.ClearFolderCollection();

                // Set collection of recent folder locations
                foreach (var item in settings.RecentFolders)
                {
                    this.RecentFolders.AddFolder(item);
                }

                this.FolderItemsView.SetShowIcons(settings.ShowIcons);
                this.FolderItemsView.SetIsFolderVisible(settings.ShowFolders);
                this.FolderItemsView.SetShowHidden(settings.ShowHiddenFiles);
                this.FolderItemsView.SetIsFiltered(settings.IsFiltered);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Compare given <paramref name="input"/> settings with current settings
        /// and return a new settings model if the current settings
        /// changed in comparison to the given <paramref name="input"/> settings.
        /// 
        /// Always return current settings if <paramref name="input"/> settings is null.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public ExplorerSettingsModel GetExplorerSettings(ExplorerSettingsModel input)
        {
            var settings = new ExplorerSettingsModel();

            try
            {
                settings.UserProfile.SetCurrentPath(this.SelectedFolder);

                if (Filters.SelectedItem != null)
                    settings.UserProfile.SetCurrentFilter(
                        new FilterItemModel(Filters.SelectedItem.FilterDisplayName, Filters.SelectedItem.FilterText));

                foreach (var item in settings.FilterCollection)
                {
                    if (item == settings.UserProfile.CurrentFilter)
                        this.AddFilter(item.FilterDisplayName, item.FilterText, true);
                    else
                        this.AddFilter(item.FilterDisplayName, item.FilterText);
                }

                foreach (var item in this.Filters.CurrentItems)
                {
                    if (item == this.Filters.SelectedItem)
                        settings.AddFilter(item.FilterDisplayName, item.FilterText, true);
                    else
                        settings.AddFilter(item.FilterDisplayName, item.FilterText);
                }

                foreach (var item in this.RecentFolders.DropDownItems)
                    settings.AddRecentFolder(item.ItemPath);

                if (string.IsNullOrEmpty(this.SelectedRecentLocation) == false)
                {
                    settings.LastSelectedRecentFolder = this.SelectedRecentLocation;
                    settings.AddRecentFolder(this.SelectedRecentLocation);
                }

                settings.ShowIcons = this.FolderItemsView.ShowIcons;
                settings.ShowFolders = this.FolderItemsView.ShowFolders;
                settings.ShowHiddenFiles = this.FolderItemsView.ShowHidden;
                settings.IsFiltered = this.FolderItemsView.IsFiltered;

                if (ExplorerSettingsModel.CompareSettings(input, settings) == false)
                    return settings;
                else
                    return null;
            }
            catch
            {
                throw;
            }
        }
Exemple #3
0
        /// <summary>
        /// Load Explorer (Tool Window) seetings from persistence.
        /// </summary>
        /// <param name="settingsManager"></param>
        /// <param name="vm"></param>
        public static void LoadSettings(ISettingsManager settingsManager,
                                        FileExplorerViewModel vm)
        {
            ExplorerSettingsModel settings = null;

            settings = settingsManager.SettingData.ExplorerSettings;

            if (settings == null)
            {
                settings = new ExplorerSettingsModel();
            }

            settings.UserProfile = settingsManager.SessionData.LastActiveExplorer;

            // (re-)configure previous explorer settings and (re-)activate current location
            vm.Settings.ConfigureExplorerSettings(settings);
        }
        /// <summary>
        /// Configure this viewmodel (+ attached browser viewmodel) with the given settings and
        /// initialize viewmodels with UserProfile.CurrentPath location.
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        public bool ConfigureExplorerSettings(ExplorerSettingsModel settings)
        {
            if (settings == null)
                return false;

            if (settings.UserProfile == null)
                return false;

            if (settings.UserProfile.CurrentPath == null)
                return false;

            try
            {
//// This should be done on visibility of tool_window view
////                this.NavigateToFolder(settings.UserProfile.CurrentPath);
                this.Filters.ClearFilter();

                // Set file filter in file/folder list view
                foreach (var item in settings.FilterCollection)
                    this.Filters.AddFilter(item.FilterDisplayName, item.FilterText);

                // Add a current filter setting (if any is available)
                if (settings.UserProfile.CurrentFilter != null)
                {
                    this.Filters.SetCurrentFilter(settings.UserProfile.CurrentFilter.FilterDisplayName,
                                                  settings.UserProfile.CurrentFilter.FilterText);
                }

                this.RecentFolders.ClearFolderCollection();

                // Set collection of recent folder locations
                foreach (var item in settings.RecentFolders)
                    this.RecentFolders.AddFolder(item);

                this.FolderItemsView.SetShowIcons(settings.ShowIcons);
                this.FolderItemsView.SetIsFolderVisible(settings.ShowFolders);
                this.FolderItemsView.SetShowHidden(settings.ShowHiddenFiles);
                this.FolderItemsView.SetIsFiltered(settings.IsFiltered);
            }
            catch
            {
                return false;
            }

            return true;
        }
Exemple #5
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public FileExplorerViewModel(ISettingsManager programSettings,
                                     IFileOpenService fileOpenService)
            : base("Explorer")
        {
            base.ContentId = ToolContentId;

            this.mFileOpenService = fileOpenService;

            this.OnActiveDocumentChanged(null, null);

            this.FolderView = new FolderListViewModel(this.FolderItemsView_OnFileOpen);

            this.SynchronizedTreeBrowser = new BrowserViewModel();
            this.SynchronizedTreeBrowser.SetSpecialFoldersVisibility(false);

            // This must be done before calling configure since browser viewmodel is otherwise not available
            this.FolderView.AttachFolderBrowser(this.SynchronizedTreeBrowser);

            ExplorerSettingsModel settings = null;

            if (programSettings != null)
            {
                if (programSettings.SessionData != null)
                {
                    settings = programSettings.SettingData.ExplorerSettings;
                }
            }

            if (settings == null)
            {
                settings = new ExplorerSettingsModel();
            }

            if (programSettings.SessionData.LastActiveExplorer != null)
            {
                settings.UserProfile = programSettings.SessionData.LastActiveExplorer;
            }
            else
            {
                settings.UserProfile.SetCurrentPath(@"C:");
            }

            this.FolderView.ConfigureExplorerSettings(settings);
            this.mFileOpenMethod = this.mFileOpenService.FileOpen;
        }
Exemple #6
0
        private void RegisterFileExplorerViewModel()
        {
            var FileExplorer = new FileExplorerViewModel(this.mSettingsManager, this.mFileOpenService);

            ExplorerSettingsModel settings = null;

            settings = this.mSettingsManager.SettingData.ExplorerSettings;

            if (settings == null)
            {
                settings = new ExplorerSettingsModel();
            }

            settings.UserProfile = this.mSettingsManager.SessionData.LastActiveExplorer;

            // (re-)configure previous explorer settings and (re-)activate current location
            FileExplorer.Settings.ConfigureExplorerSettings(settings);

            this.mToolRegistry.RegisterTool(FileExplorer);
        }
Exemple #7
0
        private void RegisterFileExplorerViewModel(ISettingsManager programSettings,
                                                   IToolWindowRegistry toolRegistry
                                                   , IFileOpenService fileOpenService)
        {
            var FileExplorer = new FileExplorerViewModel(programSettings, fileOpenService);

            ExplorerSettingsModel settings = null;

            settings = programSettings.SettingData.ExplorerSettings;

            if (settings == null)
            {
                settings = new ExplorerSettingsModel();
            }

            settings.SetUserProfile(programSettings.SessionData.LastActiveExplorer);

            // (re-)configure previous explorer settings and (re-)activate current location
            FileExplorer.ConfigureExplorerSettings(settings);

            toolRegistry.RegisterTool(FileExplorer);
        }
Exemple #8
0
 public ExplorerSettingsModel GetExplorerSettings(ExplorerSettingsModel input)
 {
     return(this.Settings.GetExplorerSettings(input));
 }
        /// <summary>
        /// Class constructor
        /// </summary>
        public FileExplorerViewModel(ISettingsManager programSettings,
                                     IFileOpenService fileOpenService)
            : base("Explorer")
        {
            base.ContentId = ToolContentId;

            this.mFileOpenService = fileOpenService;

            this.OnActiveDocumentChanged(null, null);

            //
            _SlowStuffSemaphore = new SemaphoreSlim(1, 1);
            _OneTaskScheduler   = new OneTaskLimitedScheduler();
            _CancelTokenSourc   = new CancellationTokenSource();

            FolderItemsView = FileListView.Factory.CreateFileListViewModel();
            FolderTextPath  = FolderControlsLib.Factory.CreateFolderComboBoxVM();
            RecentFolders   = FileSystemModels.Factory.CreateBookmarksViewModel();
            TreeBrowser     = FolderBrowser.FolderBrowserFactory.CreateBrowserViewModel(false);

            // This is fired when the user selects a new folder bookmark from the drop down button
            RecentFolders.BrowseEvent += FolderTextPath_BrowseEvent;

            // This is fired when the text path in the combobox changes to another existing folder
            FolderTextPath.BrowseEvent += FolderTextPath_BrowseEvent;

            Filters = FilterControlsLib.Factory.CreateFilterComboBoxViewModel();
            Filters.OnFilterChanged += this.FileViewFilter_Changed;

            // This is fired when the current folder in the listview changes to another existing folder
            this.FolderItemsView.BrowseEvent += FolderTextPath_BrowseEvent;

            // Event fires when the user requests to add a folder into the list of recently visited folders
            this.FolderItemsView.BookmarkFolder.RequestEditBookmarkedFolders += this.FolderItemsView_RequestEditBookmarkedFolders;

            // This event is fired when a user opens a file
            this.FolderItemsView.OnFileOpen += this.FolderItemsView_OnFileOpen;

            TreeBrowser.BrowseEvent += FolderTextPath_BrowseEvent;

            // Event fires when the user requests to add a folder into the list of recently visited folders
            TreeBrowser.BookmarkFolder.RequestEditBookmarkedFolders += this.FolderItemsView_RequestEditBookmarkedFolders;

            ExplorerSettingsModel settings = null;

            if (programSettings != null)
            {
                if (programSettings.SessionData != null)
                {
                    settings = programSettings.SettingData.ExplorerSettings;
                }
            }

            if (settings == null)
            {
                settings = new ExplorerSettingsModel();
            }

            if (programSettings.SessionData.LastActiveExplorer != null)
            {
                settings.SetUserProfile(programSettings.SessionData.LastActiveExplorer);
            }
            else
            {
                settings.UserProfile.SetCurrentPath(@"C:");
            }

            if (settings.UserProfile.CurrentPath != null)
            {
                _InitialPath = settings.UserProfile.CurrentPath.Path;
            }


            this.ConfigureExplorerSettings(settings);
            this.mFileOpenMethod = this.mFileOpenService.FileOpen;
        }