Example #1
0
        private void MenuItemAddFavoriteFolder_Clicked(object sender, RoutedEventArgs e)
        {
            UserPreferences up     = UserPreferences.Instance;
            var             node_e = ViewModel.FirstGeneration.GetEnumerator();

            node_e.MoveNext();
            var node = node_e.Current;

            if (node.ExplorerType == ExplorerType.Folder)
            {
                up.AddToFavoriteFolders(node.Path);
                up.Save();
                this.MenuItemFavoriteFolders.GetBindingExpression(MenuItem.ItemsSourceProperty).UpdateTarget();
            }
            else
            {
                MainViewModel.MessageBoxShow("Not folder");
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService)
        {
            // Init data service
            _dataService = dataService;
            _dataService.GetData(
                (item, error) =>
                {
                    if (error != null)
                    {
                        // Report error here
                        return;
                    }

                    _initializeData(item);
                });

            // Init in-between view model messenger
            _initializeMessenger();

            // Connecting window event with command
            OnLoadedCommand = new RelayCommand(OnLoaded, () => true);
            OnClosingCommand = new RelayCommand(OnClosing, () => true);
            FileNewCommand = new RelayCommand(OnFileNew, () => true);
            FileSaveCommand = new RelayCommand(OnFileSave, () => EditTextSavable);
            EditText1_TextChangedCommand = new RelayCommand(OnEditText1_TextChanged, () => true);
            EditHtml1_TextChangedCommand = new RelayCommand(OnEditHtml1_TextChanged, () => true);
            FolderNewCommand = new RelayCommand(OnFolderNew, () => true);
            FileRenameCommand = new RelayCommand(OnFileRename, () => true);
            FileChangeExtensionTXTCommand = new RelayCommand(OnFileChangeExtensionTXT, () => true);
            FileChangeExtensionHTMLCommand = new RelayCommand(OnFileChangeExtensionHTML, () => true);
            SetAsRootCommand = new RelayCommand(OnSetAsRoot, () =>
                CurrentExplorerNode != null &&
                CurrentExplorerNode.ExplorerType == ExplorerType.Folder);
            RunExplorerCommand = new RelayCommand(OnRunExplorer, () =>
                CurrentExplorerNode != null &&
                CurrentExplorerNode.ExplorerType == ExplorerType.Folder);
            FileDeleteCommand = new RelayCommand(OnFileDelete, () => true);
            FileExplorerRefreshCommand = new RelayCommand(OnFileExplorerRefresh, () => true);
            HelpInfoCommand = new RelayCommand(OnHelpInfo, () => true);
            FolderChangeCommand = new RelayCommand(OnFolderChange, () => true);
            ExitCommand = new RelayCommand(OnExit, () => true);
            SettingCommand = new RelayCommand(OnSetting, () => true);
            EditHtmlCommand = new RelayCommand(OnEditHtml, () => true);

            // Loading user preference
            this._userPrefs = UserPreferences.Instance;
        }