Exemple #1
0
    public MainViewModel()
    {
      m_window = new MainWindow {DataContext = this};
      m_layoutManager = new LayoutManager(this);

      m_tabTrees = Enum.GetValues(typeof(TabTrees)).Cast<TabTrees>().ToList();
      m_closeFileCommand = new GenericManualCommand<IFileViewModel>(CloseFile);
      m_saveFileCommand = new ManualCommand(Save, () => LayoutManager.ActiveLayoutElement != null && LayoutManager.ActiveLayoutElement.SelectedFile != null && LayoutManager.ActiveLayoutElement.SelectedFile.HasUnsavedChanges);
      m_saveAllFilesCommand = new ManualCommand(SaveAll, () => LayoutManager.LayoutElements.Any(layout => layout.OpenFiles.Any(n => n.HasUnsavedChanges)));
      m_openFileViewModelCommand = new GenericManualCommand<IFileViewModel>(file => OpenFile(file));
      m_openFileCommand = new ManualCommand(OpenFile);
      m_openFolderCommand = new ManualCommand(OpenFolder);
      m_exitCommand = new ManualCommand(() => Environment.Exit(0));
      m_newFileCommand = new ManualCommand(CreateNewFile);
      m_changeSettingsPathCommand = new ManualCommand(ChangeSettingsPath);
      m_renameSelectedNodeCommand = new ManualCommand(() => m_selectedNode.IsRenaming = true);
      m_renameSelectedNodeDoneCommand = new ManualCommand(() => m_selectedNode.IsRenaming = false);
      m_renameSelectedNodeCancelCommand = new ManualCommand(() => { m_selectedNode.RenameString = null; m_selectedNode.IsRenaming = false; });
      m_createFileCommand = new GenericManualCommand<string>(s => CreateNewFileAtSelectedNode(s));
      m_reloadFilesDialogViewModel = new ReloadFilesDialogViewModel();
      m_createFolderCommand = new ManualCommand(() => CreateFolder("Newfolder"));
      m_deleteSelectedNodeCommand = new ManualCommand(DeleteSelectedNode);

      m_dialogHelper = new DialogHelper(this);
      ServiceProvider.Registre<IDialogHelper>(DialogHelper);

      if (string.IsNullOrEmpty(Properties.Settings.Default.SettingPath) ||
          !Directory.Exists(Properties.Settings.Default.SettingPath))
      {
        m_folderBrowserDialogViewModel = new FolderBrowserDialogViewModel();
        m_folderBrowserDialogViewModel.PropertyChanged += StartFolderBrowserDialogViewModelOnPropertyChanged;
        m_folderBrowserDialogViewModel.Title = "Select settings path";
        m_folderBrowserDialogViewModel.Path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\sharpE\\settings";
        DialogHelper.ShowDialog(m_folderBrowserDialogViewModel);
      }
      else
      {
        Init();
      }
    }
Exemple #2
0
 private void ChangeSettingsPath()
 {
   if (m_folderBrowserDialogViewModel == null)
     m_folderBrowserDialogViewModel = new FolderBrowserDialogViewModel();
   m_folderBrowserDialogViewModel.PropertyChanged += FolderBrowserDialogViewModelOnPropertyChanged;
   m_folderBrowserDialogViewModel.Title = "Select settings path";
   m_folderBrowserDialogViewModel.Path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\sharpE\\settings";
   DialogHelper.ShowDialog(m_folderBrowserDialogViewModel);
 }