示例#1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            if ((Environment.CommandLine.IndexOf("-reset") >= 0) || (Environment.CommandLine.IndexOf("/reset") >= 0))
            {
                PermanentSettings.Reset();
            }

            base.OnStartup(e);
        }
        public MainViewModel(Window window) : base(window)
        {
            this._settings = new PermanentSettings();

            // File
            this.FileNewCommand           = new CommandBase(this.OnFileNewCommand);
            this.FileOpenCommand          = new CommandBase(this.OnFileOpenCommand);
            this.FileOpenRecentCommand    = new CommandBase <String>(this.OnFileOpenRecentCommand);
            this.FileSaveCommand          = new CommandBase(this.OnFileSaveCommand);
            this.FileSaveAsCommand        = new CommandBase(this.OnFileSaveAsCommand);
            this.FileSaveImageAsCommand   = new CommandBase(this.OnFileSaveImageAsCommand);
            this.FileExportImageAsCommand = new CommandBase(this.OnFileExportImageAsCommand);
            this.ExitCommand = new CommandBase(this.OnExitCommand);
            // Edit
            // View
            this.ViewZoom100Command = new CommandBase(this.OnViewZoom100Command);
            this.ViewZoomInCommand  = new CommandBase(this.OnViewZoomInCommand);
            this.ViewZoomOutCommand = new CommandBase(this.OnViewZoomOutCommand);
            this.RefreshCommand     = new CommandBase(this.OnRefreshCommand);
            // Style
            // Git
            this.GitAddCommand              = new CommandBase(this.OnGitAddCommand);
            this.GitCommitCommand           = new CommandBase(this.OnGitCommitCommand);
            this.GitPushCommand             = new CommandBase(this.OnGitPushCommand);
            this.GitPullCommand             = new CommandBase(this.OnGitPullCommand);
            this.GitCommandLineCommand      = new CommandBase(this.OnGitCommandLineCommand);
            this.GitExtensionsBrowseCommand = new CommandBase(this.OnGitExtensionsBrowseCommand);
            // Plugins
            // Tools
            this.ToolsOptionsCommand = new CommandBase(this.OnToolsOptionsCommand);
            // Help
            this.AboutCommand = new CommandBase(this.OnAboutCommand);

            this.ErrorSelectedCommand = new CommandBase <Int32>(OnErrorSelectedCommand);

            this.Errors = new ThreadSafeObservableCollection <ErrorViewModel>();

            this._timer          = new Timer(1000);
            this._timer.Elapsed += OnTimerElapsed;

            this.RecentFilesMenuItems = new RecentFiles(this._settings, this.FileOpenRecentCommand);

            this.PluginMenuItems = new ThreadSafeObservableCollection <MenuItemViewModel>();
            var plugins = PluginManager.FindPlugins();

            foreach (var plugin in plugins)
            {
                this.PluginMenuItems.Add(new MenuItemViewModel(plugin.GetMenuName(), new CommandBase(() => this.WsdScript = plugin.ModifyScript(this.WsdScript))));
            }
        }