コード例 #1
0
        public TerminalViewModel(int id, ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService, ApplicationSettings applicationSettings, string startupDirectory)
        {
            Id    = id;
            Title = DefaultTitle;

            _settingsService = settingsService;
            _settingsService.CurrentThemeChanged        += OnCurrentThemeChanged;
            _settingsService.TerminalOptionsChanged     += OnTerminalOptionsChanged;
            _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
            _settingsService.KeyBindingsChanged         += OnKeyBindingsChanged;
            _trayProcessCommunicationService             = trayProcessCommunicationService;
            _dialogService          = dialogService;
            _keyboardCommandService = keyboardCommandService;
            _applicationSettings    = applicationSettings;
            _startupDirectory       = startupDirectory;
            _resizeOverlayTimer     = new DispatcherTimer
            {
                Interval = new TimeSpan(0, 0, 2)
            };
            _resizeOverlayTimer.Tick += OnResizeOverlayTimerFinished;

            CloseCommand = new RelayCommand(async() => await InvokeCloseRequested().ConfigureAwait(false));

            _dispatcher = CoreApplication.GetCurrentView().Dispatcher;
        }
コード例 #2
0
        public App()
        {
            _mainViewModels = new List <MainViewModel>();

            InitializeComponent();

            var builder = new ContainerBuilder();

            builder.RegisterType <SettingsService>().As <ISettingsService>().SingleInstance();
            builder.RegisterType <DefaultValueProvider>().As <IDefaultValueProvider>().SingleInstance();
            builder.RegisterType <TrayProcessCommunicationService>().As <ITrayProcessCommunicationService>().SingleInstance();
            builder.RegisterType <DialogService>().As <IDialogService>().SingleInstance();
            builder.RegisterType <KeyboardCommandService>().As <IKeyboardCommandService>().InstancePerDependency();
            builder.RegisterType <MainViewModel>().InstancePerDependency();
            builder.RegisterType <SettingsViewModel>().InstancePerDependency();

            _container = builder.Build();

            _settingsService = _container.Resolve <ISettingsService>();
            _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;

            _trayProcessCommunicationService = _container.Resolve <ITrayProcessCommunicationService>();

            _applicationSettings = _settingsService.GetApplicationSettings();
        }
コード例 #3
0
        public TerminalViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService,
                                 IKeyboardCommandService keyboardCommandService, ApplicationSettings applicationSettings, ShellProfile shellProfile,
                                 IApplicationView applicationView, IClipboardService clipboardService, string terminalState = null)
        {
            MessengerInstance.Register <ApplicationSettingsChangedMessage>(this, OnApplicationSettingsChanged);
            MessengerInstance.Register <CurrentThemeChangedMessage>(this, OnCurrentThemeChanged);
            MessengerInstance.Register <TerminalOptionsChangedMessage>(this, OnTerminalOptionsChanged);
            MessengerInstance.Register <KeyBindingsChangedMessage>(this, OnKeyBindingsChanged);

            SettingsService = settingsService;

            _terminalOptions = SettingsService.GetTerminalOptions();

            TrayProcessCommunicationService = trayProcessCommunicationService;

            DialogService           = dialogService;
            _keyboardCommandService = keyboardCommandService;
            ApplicationSettings     = applicationSettings;
            ApplicationView         = applicationView;
            ClipboardService        = clipboardService;

            ShellProfile  = shellProfile;
            TerminalTheme = shellProfile.TerminalThemeId == Guid.Empty ? SettingsService.GetCurrentTheme() : SettingsService.GetTheme(shellProfile.TerminalThemeId);

            TabThemes               = new ObservableCollection <TabThemeViewModel>(SettingsService.GetTabThemes().Select(theme => new TabThemeViewModel(theme, this)));
            CloseCommand            = new AsyncCommand(TryCloseAsync, CanExecuteCommand);
            CloseLeftTabsCommand    = new RelayCommand(CloseLeftTabs, CanExecuteCommand);
            CloseRightTabsCommand   = new RelayCommand(CloseRightTabs, CanExecuteCommand);
            CloseOtherTabsCommand   = new RelayCommand(CloseOtherTabs, CanExecuteCommand);
            FindNextCommand         = new RelayCommand(FindNext, CanExecuteCommand);
            FindPreviousCommand     = new RelayCommand(FindPrevious, CanExecuteCommand);
            CloseSearchPanelCommand = new RelayCommand(CloseSearchPanel, CanExecuteCommand);
            EditTitleCommand        = new AsyncCommand(EditTitleAsync, CanExecuteCommand);
            DuplicateTabCommand     = new RelayCommand(DuplicateTab, CanExecuteCommand);
            CopyCommand             = new AsyncCommand(Copy, () => HasSelection);
            PasteCommand            = new AsyncCommand(Paste);
            CopyLinkCommand         = new AsyncCommand(() => CopyTextAsync(HoveredUri), () => !string.IsNullOrWhiteSpace(HoveredUri));
            ShowSearchPanelCommand  = new RelayCommand(() => ShowSearchPanel = true, () => !ShowSearchPanel);

            if (!string.IsNullOrEmpty(terminalState))
            {
                Restore(terminalState);
            }
            else
            {
                var defaultTabTheme = TabThemes.FirstOrDefault(t => t.Theme.Id == ShellProfile.TabThemeId);
                defaultTabTheme.IsSelected = true;
            }

            Terminal = new Terminal(TrayProcessCommunicationService, _terminalId);
            Terminal.KeyboardCommandReceived += Terminal_KeyboardCommandReceived;
            Terminal.OutputReceived          += Terminal_OutputReceived;
            Terminal.SizeChanged             += Terminal_SizeChanged;
            Terminal.TitleChanged            += Terminal_TitleChanged;
            Terminal.Exited += Terminal_Exited;
            Terminal.Closed += Terminal_Closed;

            ContextMenu    = BuidContextMenu();
            TabContextMenu = BuildTabContextMenu();
        }
コード例 #4
0
 public Terminal(ITrayProcessCommunicationService trayProcessCommunicationService, byte?terminalId = null)
 {
     _trayProcessCommunicationService = trayProcessCommunicationService;
     _trayProcessCommunicationService.TerminalExited += OnTerminalExited;
     Id = terminalId ?? trayProcessCommunicationService.GetNextTerminalId();
     _requireShellProcessStart = !terminalId.HasValue;
 }
コード例 #5
0
        public TerminalViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService,
                                 IKeyboardCommandService keyboardCommandService, ApplicationSettings applicationSettings, string startupDirectory, ShellProfile shellProfile,
                                 IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService)
        {
            Title = DefaultTitle;

            _connectedEvent = new ManualResetEventSlim(false);

            _settingsService = settingsService;
            _settingsService.CurrentThemeChanged        += OnCurrentThemeChanged;
            _settingsService.TerminalOptionsChanged     += OnTerminalOptionsChanged;
            _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
            _settingsService.KeyBindingsChanged         += OnKeyBindingsChanged;

            _trayProcessCommunicationService = trayProcessCommunicationService;
            _trayProcessCommunicationService.TerminalExited += OnTerminalExited;

            _dialogService          = dialogService;
            _keyboardCommandService = keyboardCommandService;
            ApplicationSettings     = applicationSettings;
            _startupDirectory       = startupDirectory;
            _shellProfile           = shellProfile;
            _applicationView        = applicationView;
            _clipboardService       = clipboardService;

            _resizeOverlayTimer          = dispatcherTimer;
            _resizeOverlayTimer.Interval = new TimeSpan(0, 0, 2);
            _resizeOverlayTimer.Tick    += OnResizeOverlayTimerFinished;

            CloseCommand            = new RelayCommand(async() => await TryClose().ConfigureAwait(false));
            FindNextCommand         = new RelayCommand(async() => await FindNext().ConfigureAwait(false));
            FindPreviousCommand     = new RelayCommand(async() => await FindPrevious().ConfigureAwait(false));
            CloseSearchPanelCommand = new RelayCommand(CloseSearchPanel);
        }
コード例 #6
0
        public SshInfoDialog(ISettingsService settingsService, ISshHelperService sshHelperService,
                             ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _sshHelperService = sshHelperService;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            InitializeComponent();
            PrimaryButtonText   = I18N.Translate("OK");
            SecondaryButtonText = I18N.Translate("Cancel");
            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);

            TabThemes = new ObservableCollection <TabTheme>(settingsService.GetTabThemes());

            TerminalThemes = new ObservableCollection <TerminalTheme>
            {
                new TerminalTheme
                {
                    Id   = Guid.Empty,
                    Name = "Default"
                }
            };
            foreach (var theme in settingsService.GetThemes())
            {
                TerminalThemes.Add(theme);
            }
        }
コード例 #7
0
        public SshProfilesPageViewModel(ISettingsService settingsService, IDialogService dialogService,
                                        IFileSystemService fileSystemService, IApplicationView applicationView,
                                        ITrayProcessCommunicationService trayProcessCommunicationService,
                                        IApplicationDataContainer historyContainer)
        {
            _settingsService   = settingsService;
            _dialogService     = dialogService;
            _fileSystemService = fileSystemService;
            _applicationView   = applicationView;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            _historyContainer = historyContainer;

            CreateSshProfileCommand = new RelayCommand(CreateSshProfile);
            CloneCommand            = new RelayCommand <SshProfileViewModel>(Clone);

            foreach (var sshProfile in _settingsService.GetSshProfiles())
            {
                var viewModel = new SshProfileViewModel(sshProfile, settingsService, dialogService, fileSystemService,
                                                        applicationView, _trayProcessCommunicationService, historyContainer, false);
                viewModel.Deleted += OnSshProfileDeleted;
                SshProfiles.Add(viewModel);
            }

            if (SshProfiles.Count == 0)
            {
                CreateSshProfile();
            }

            SelectedSshProfile = SshProfiles.First();
        }
コード例 #8
0
        public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService,
                             IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService)
        {
            _settingsService = settingsService;
            _settingsService.CurrentThemeChanged        += OnCurrentThemeChanged;
            _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
            _settingsService.TerminalOptionsChanged     += OnTerminalOptionsChanged;
            _settingsService.ShellProfileAdded          += OnShellProfileAdded;
            _settingsService.ShellProfileDeleted        += OnShellProfileDeleted;

            _trayProcessCommunicationService = trayProcessCommunicationService;
            _dialogService          = dialogService;
            _applicationView        = applicationView;
            _dispatcherTimer        = dispatcherTimer;
            _clipboardService       = clipboardService;
            _keyboardCommandService = keyboardCommandService;
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewTab), () => AddTerminal(null, false, Guid.Empty));
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ConfigurableNewTab), () => AddTerminal(null, true, Guid.Empty));
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ChangeTabTitle), () => SelectedTerminal.EditTitle());
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.CloseTab), CloseCurrentTab);

            // Add all of the commands for switching to a tab of a given ID, if there's one open there
            for (int i = 0; i < 9; i++)
            {
                var switchCmd = Command.SwitchToTerm1 + i;
                int tabNumber = i;
                void handler() => SelectTabNumber(tabNumber);

                _keyboardCommandService.RegisterCommandHandler(switchCmd.ToString(), handler);
            }

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NextTab), SelectNextTab);
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.PreviousTab), SelectPreviousTab);

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewWindow), () => NewWindow(false));
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ConfigurableNewWindow), () => NewWindow(true));

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ShowSettings), ShowSettings);
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ToggleFullScreen), ToggleFullScreen);

            foreach (ShellProfile profile in _settingsService.GetShellProfiles())
            {
                _keyboardCommandService.RegisterCommandHandler(profile.Id.ToString(), () => AddTerminal(profile.WorkingDirectory, false, profile.Id));
            }

            var currentTheme = _settingsService.GetCurrentTheme();
            var options      = _settingsService.GetTerminalOptions();

            Background           = currentTheme.Colors.Background;
            BackgroundOpacity    = options.BackgroundOpacity;
            _applicationSettings = _settingsService.GetApplicationSettings();
            TabsPosition         = _applicationSettings.TabsPosition;

            AddTerminalCommand  = new RelayCommand(() => AddTerminal(null, false, Guid.Empty));
            ShowAboutCommand    = new RelayCommand(ShowAbout);
            ShowSettingsCommand = new RelayCommand(ShowSettings);

            _applicationView.CloseRequested += OnCloseRequest;
            Terminals.CollectionChanged     += OnTerminalsCollectionChanged;
        }
コード例 #9
0
        public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService,
                             IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService)
        {
            _settingsService = settingsService;
            _settingsService.CurrentThemeChanged        += OnCurrentThemeChanged;
            _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
            _settingsService.TerminalOptionsChanged     += OnTerminalOptionsChanged;
            _trayProcessCommunicationService             = trayProcessCommunicationService;
            _dialogService          = dialogService;
            _applicationView        = applicationView;
            _dispatcherTimer        = dispatcherTimer;
            _clipboardService       = clipboardService;
            _keyboardCommandService = keyboardCommandService;
            _keyboardCommandService.RegisterCommandHandler(Command.NewTab, () => AddTerminal(null, false));
            _keyboardCommandService.RegisterCommandHandler(Command.ConfigurableNewTab, () => AddTerminal(null, true));
            _keyboardCommandService.RegisterCommandHandler(Command.CloseTab, CloseCurrentTab);
            _keyboardCommandService.RegisterCommandHandler(Command.NextTab, SelectNextTab);
            _keyboardCommandService.RegisterCommandHandler(Command.PreviousTab, SelectPreviousTab);
            _keyboardCommandService.RegisterCommandHandler(Command.NewWindow, NewWindow);
            _keyboardCommandService.RegisterCommandHandler(Command.ShowSettings, ShowSettings);
            _keyboardCommandService.RegisterCommandHandler(Command.ToggleFullScreen, ToggleFullScreen);
            var currentTheme = _settingsService.GetCurrentTheme();
            var options      = _settingsService.GetTerminalOptions();

            Background           = currentTheme.Colors.Background;
            BackgroundOpacity    = options.BackgroundOpacity;
            _applicationSettings = _settingsService.GetApplicationSettings();
            TabsPosition         = _applicationSettings.TabsPosition;

            AddTerminalCommand  = new RelayCommand(() => AddTerminal(null, false));
            ShowSettingsCommand = new RelayCommand(ShowSettings);

            _applicationView.CloseRequested += OnCloseRequest;
            Terminals.CollectionChanged     += OnTerminalsCollectionChanged;
        }
コード例 #10
0
        public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService)
        {
            _settingsService = settingsService;
            _settingsService.CurrentThemeChanged        += OnCurrentThemeChanged;
            _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
            _trayProcessCommunicationService             = trayProcessCommunicationService;
            _dialogService          = dialogService;
            _keyboardCommandService = keyboardCommandService;
            _keyboardCommandService.RegisterCommandHandler(Command.NewTab, () => AddTerminal(null));
            _keyboardCommandService.RegisterCommandHandler(Command.CloseTab, CloseCurrentTab);
            _keyboardCommandService.RegisterCommandHandler(Command.NextTab, SelectNextTab);
            _keyboardCommandService.RegisterCommandHandler(Command.PreviousTab, SelectPreviousTab);
            _keyboardCommandService.RegisterCommandHandler(Command.NewWindow, NewWindow);
            _keyboardCommandService.RegisterCommandHandler(Command.ShowSettings, ShowSettings);
            var currentTheme = _settingsService.GetCurrentTheme();

            Background           = currentTheme.Colors.Background;
            BackgroundOpacity    = currentTheme.BackgroundOpacity;
            _applicationSettings = _settingsService.GetApplicationSettings();

            AddTerminalCommand  = new RelayCommand(() => AddTerminal(null));
            ShowSettingsCommand = new RelayCommand(ShowSettings);

            Terminals.CollectionChanged += OnTerminalsCollectionChanged;

            Title = "Fluent Terminal";

            _dispatcher = CoreApplication.GetCurrentView().Dispatcher;
            SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += OnCloseRequest;
        }
コード例 #11
0
        public App()
        {
            _mainViewModels = new List <MainViewModel>();

            InitializeComponent();

            UnhandledException += OnUnhandledException;

            var applicationDataContainers = new ApplicationDataContainers
            {
                LocalSettings   = new ApplicationDataContainerAdapter(ApplicationData.Current.LocalSettings),
                RoamingSettings = new ApplicationDataContainerAdapter(ApplicationData.Current.RoamingSettings),
                KeyBindings     = new ApplicationDataContainerAdapter(ApplicationData.Current.RoamingSettings.CreateContainer(Constants.KeyBindingsContainerName, ApplicationDataCreateDisposition.Always)),
                ShellProfiles   = new ApplicationDataContainerAdapter(ApplicationData.Current.LocalSettings.CreateContainer(Constants.ShellProfilesContainerName, ApplicationDataCreateDisposition.Always)),
                Themes          = new ApplicationDataContainerAdapter(ApplicationData.Current.RoamingSettings.CreateContainer(Constants.ThemesContainerName, ApplicationDataCreateDisposition.Always))
            };

            var builder = new ContainerBuilder();

            builder.RegisterType <SettingsService>().As <ISettingsService>().SingleInstance();
            builder.RegisterType <DefaultValueProvider>().As <IDefaultValueProvider>().SingleInstance();
            builder.RegisterType <TrayProcessCommunicationService>().As <ITrayProcessCommunicationService>().SingleInstance();
            builder.RegisterType <DialogService>().As <IDialogService>().SingleInstance();
            builder.RegisterType <KeyboardCommandService>().As <IKeyboardCommandService>().InstancePerDependency();
            builder.RegisterType <NotificationService>().As <INotificationService>().InstancePerDependency();
            builder.RegisterType <UpdateService>().As <IUpdateService>().InstancePerDependency();
            builder.RegisterType <MainViewModel>().InstancePerDependency();
            builder.RegisterType <SettingsViewModel>().InstancePerDependency();
            builder.RegisterType <ThemeParserFactory>().As <IThemeParserFactory>().SingleInstance();
            builder.RegisterType <ITermThemeParser>().As <IThemeParser>().SingleInstance();
            builder.RegisterType <FluentTerminalThemeParser>().As <IThemeParser>().SingleInstance();
            builder.RegisterType <ClipboardService>().As <IClipboardService>().SingleInstance();
            builder.RegisterType <FileSystemService>().As <IFileSystemService>().SingleInstance();
            builder.RegisterType <SystemFontService>().As <ISystemFontService>().SingleInstance();
            builder.RegisterType <ShellProfileSelectionDialog>().As <IShellProfileSelectionDialog>().InstancePerDependency();
            builder.RegisterType <CreateKeyBindingDialog>().As <ICreateKeyBindingDialog>().InstancePerDependency();
            builder.RegisterType <InputDialog>().As <IInputDialog>().InstancePerDependency();
            builder.RegisterType <MessageDialogAdapter>().As <IMessageDialog>().InstancePerDependency();
            builder.RegisterType <ApplicationViewAdapter>().As <IApplicationView>().InstancePerDependency();
            builder.RegisterType <DispatcherTimerAdapter>().As <IDispatcherTimer>().InstancePerDependency();
            builder.RegisterType <StartupTaskService>().As <IStartupTaskService>().SingleInstance();
            builder.RegisterInstance(applicationDataContainers);

            _container = builder.Build();

            _settingsService = _container.Resolve <ISettingsService>();
            _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;

            _trayProcessCommunicationService = _container.Resolve <ITrayProcessCommunicationService>();

            _applicationSettings = _settingsService.GetApplicationSettings();

            _commandLineParser = new Parser(settings =>
            {
                settings.CaseSensitive             = false;
                settings.CaseInsensitiveEnumValues = true;
            });
        }
コード例 #12
0
 public SshProfileViewModel(SshProfile sshProfile, ISettingsService settingsService,
                            IDialogService dialogService, IFileSystemService fileSystemService, IApplicationView applicationView,
                            ITrayProcessCommunicationService trayProcessCommunicationService,
                            IApplicationDataContainer historyContainer, bool isNew) : base(sshProfile, settingsService, dialogService,
                                                                                           isNew)
 {
     ProfileVm = new SshConnectViewModel(settingsService, applicationView, trayProcessCommunicationService,
                                         fileSystemService, sshProfile);
 }
コード例 #13
0
 public SshHelperService(ISettingsService settingsService, IDialogService dialogService,
                         IFileSystemService fileSystemService, IApplicationView applicationView, ITrayProcessCommunicationService trayProcessCommunicationService)
 {
     _settingsService   = settingsService;
     _dialogService     = dialogService;
     _fileSystemService = fileSystemService;
     _applicationView   = applicationView;
     _trayProcessCommunicationService = trayProcessCommunicationService;
 }
コード例 #14
0
 public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService,
                          ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService, IFileSystemService fileSystemService)
 {
     KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService);
     General     = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider);
     Shell       = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService);
     Terminal    = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService);
     Themes      = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService);
 }
コード例 #15
0
        public KeyBindingsPageViewModel(ISettingsService settingsService, IDialogService dialogService, ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _settingsService = settingsService;
            _dialogService   = dialogService;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            RestoreDefaultsCommand           = new RelayCommand(async() => await RestoreDefaults().ConfigureAwait(false));
            AddCommand = new RelayCommand <string>(async command => await Add(command).ConfigureAwait(false));

            Initialize(_settingsService.GetCommandKeyBindings());
        }
コード例 #16
0
        public KeyBindingsPageViewModel(ISettingsService settingsService, IDialogService dialogService, ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _settingsService = settingsService;
            _dialogService   = dialogService;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            RestoreDefaultsCommand           = new AsyncRelayCommand(RestoreDefaultsAsync);
            AddCommand = new AsyncRelayCommand <string>(AddAsync);

            Initialize(_settingsService.GetCommandKeyBindings());
        }
コード例 #17
0
 public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService,
                          ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService,
                          IFileSystemService fileSystemService, IStartupTaskService startupTaskService, IUpdateService updateService, IApplicationView applicationView)
 {
     About       = new AboutPageViewModel(settingsService, updateService, applicationView);
     KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService);
     General     = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider, startupTaskService);
     Shell       = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService);
     Terminal    = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService);
     Themes      = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService);
     Mouse       = new MousePageViewModel(settingsService, dialogService, defaultValueProvider);
 }
コード例 #18
0
        public SshInfoDialog(ISettingsService settingsService, ISshHelperService sshHelperService,
                             ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _sshHelperService = sshHelperService;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            InitializeComponent();
            PrimaryButtonText   = I18N.Translate("OK");
            SecondaryButtonText = I18N.Translate("Cancel");
            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);
        }
コード例 #19
0
        public TerminalViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService,
                                 IKeyboardCommandService keyboardCommandService, ApplicationSettings applicationSettings, ShellProfile shellProfile,
                                 IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService, string terminalState = null)
        {
            SettingsService = settingsService;
            SettingsService.CurrentThemeChanged        += OnCurrentThemeChanged;
            SettingsService.TerminalOptionsChanged     += OnTerminalOptionsChanged;
            SettingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
            SettingsService.KeyBindingsChanged         += OnKeyBindingsChanged;

            _terminalOptions = SettingsService.GetTerminalOptions();

            TrayProcessCommunicationService = trayProcessCommunicationService;

            DialogService           = dialogService;
            _keyboardCommandService = keyboardCommandService;
            ApplicationSettings     = applicationSettings;
            ApplicationView         = applicationView;
            ClipboardService        = clipboardService;

            ShellProfile  = shellProfile;
            TerminalTheme = shellProfile.TerminalThemeId == Guid.Empty ? SettingsService.GetCurrentTheme() : SettingsService.GetTheme(shellProfile.TerminalThemeId);

            TabThemes = new ObservableCollection <TabTheme>(SettingsService.GetTabThemes());
            TabTheme  = TabThemes.FirstOrDefault(t => t.Id == ShellProfile.TabThemeId);

            CloseCommand            = new RelayCommand(async() => await TryClose().ConfigureAwait(false));
            CloseLeftTabsCommand    = new RelayCommand(CloseLeftTabs);
            CloseRightTabsCommand   = new RelayCommand(CloseRightTabs);
            CloseOtherTabsCommand   = new RelayCommand(CloseOtherTabs);
            FindNextCommand         = new RelayCommand(FindNext);
            FindPreviousCommand     = new RelayCommand(FindPrevious);
            CloseSearchPanelCommand = new RelayCommand(CloseSearchPanel);
            SelectTabThemeCommand   = new RelayCommand <string>(SelectTabTheme);
            EditTitleCommand        = new AsyncCommand(EditTitle);
            DuplicateTabCommand     = new RelayCommand(DuplicateTab);

            if (!String.IsNullOrEmpty(terminalState))
            {
                Restore(terminalState);
            }

            Terminal = new Terminal(TrayProcessCommunicationService, _terminalId);
            Terminal.KeyboardCommandReceived += Terminal_KeyboardCommandReceived;
            Terminal.OutputReceived          += Terminal_OutputReceived;
            Terminal.SizeChanged             += Terminal_SizeChanged;
            Terminal.TitleChanged            += Terminal_TitleChanged;
            Terminal.Exited += Terminal_Exited;
            Terminal.Closed += Terminal_Closed;

            Overlay = new OverlayViewModel(dispatcherTimer);
        }
コード例 #20
0
        public GeneralPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider,
                                    IStartupTaskService startupTaskService, IApplicationLanguageService applicationLanguageService, ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _settingsService                 = settingsService;
            _dialogService                   = dialogService;
            _defaultValueProvider            = defaultValueProvider;
            _startupTaskService              = startupTaskService;
            _applicationLanguageService      = applicationLanguageService;
            _trayProcessCommunicationService = trayProcessCommunicationService;

            _applicationSettings = _settingsService.GetApplicationSettings();

            RestoreDefaultsCommand = new RelayCommand(async() => await RestoreDefaults().ConfigureAwait(false));
        }
コード例 #21
0
 public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService,
                          ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService,
                          IFileSystemService fileSystemService, IStartupTaskService startupTaskService, IApplicationView applicationView,
                          IApplicationLanguageService applicationLanguageService, ApplicationDataContainers containers)
 {
     KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, trayProcessCommunicationService);
     General     = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider, startupTaskService, applicationLanguageService, trayProcessCommunicationService, fileSystemService);
     Profiles    = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService, applicationView);
     Terminal    = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService);
     Themes      = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService);
     Mouse       = new MousePageViewModel(settingsService, dialogService, defaultValueProvider);
     SshProfiles = new SshProfilesPageViewModel(settingsService, dialogService, fileSystemService,
                                                applicationView, trayProcessCommunicationService, containers.HistoryContainer);
 }
コード例 #22
0
        public TerminalViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService,
                                 IKeyboardCommandService keyboardCommandService, ApplicationSettings applicationSettings, ShellProfile shellProfile,
                                 IApplicationView applicationView, IClipboardService clipboardService, string terminalState = null)
        {
            MessengerInstance.Register <ApplicationSettingsChangedMessage>(this, OnApplicationSettingsChanged);
            MessengerInstance.Register <CurrentThemeChangedMessage>(this, OnCurrentThemeChanged);
            MessengerInstance.Register <TerminalOptionsChangedMessage>(this, OnTerminalOptionsChanged);

            SettingsService = settingsService;

            _terminalOptions = SettingsService.GetTerminalOptions();

            TrayProcessCommunicationService = trayProcessCommunicationService;

            DialogService           = dialogService;
            _keyboardCommandService = keyboardCommandService;
            ApplicationSettings     = applicationSettings;
            ApplicationView         = applicationView;
            ClipboardService        = clipboardService;

            ShellProfile  = shellProfile;
            TerminalTheme = shellProfile.TerminalThemeId == Guid.Empty ? SettingsService.GetCurrentTheme() : SettingsService.GetTheme(shellProfile.TerminalThemeId);

            TabThemes = new ObservableCollection <TabTheme>(SettingsService.GetTabThemes());
            TabTheme  = TabThemes.FirstOrDefault(t => t.Id == ShellProfile.TabThemeId);

            CloseCommand            = new AsyncCommand(CloseTab, CanExecuteCommand);
            CloseLeftTabsCommand    = new RelayCommand(CloseLeftTabs, CanExecuteCommand);
            CloseRightTabsCommand   = new RelayCommand(CloseRightTabs, CanExecuteCommand);
            CloseOtherTabsCommand   = new RelayCommand(CloseOtherTabs, CanExecuteCommand);
            FindNextCommand         = new RelayCommand(FindNext, CanExecuteCommand);
            FindPreviousCommand     = new RelayCommand(FindPrevious, CanExecuteCommand);
            CloseSearchPanelCommand = new RelayCommand(CloseSearchPanel, CanExecuteCommand);
            SelectTabThemeCommand   = new RelayCommand <string>(SelectTabTheme, CanExecuteCommand);
            EditTitleCommand        = new AsyncCommand(EditTitle, CanExecuteCommand);
            DuplicateTabCommand     = new RelayCommand(DuplicateTab, CanExecuteCommand);

            if (!String.IsNullOrEmpty(terminalState))
            {
                Restore(terminalState);
            }

            Terminal = new Terminal(TrayProcessCommunicationService, _terminalId);
            Terminal.KeyboardCommandReceived += Terminal_KeyboardCommandReceived;
            Terminal.OutputReceived          += Terminal_OutputReceived;
            Terminal.SizeChanged             += Terminal_SizeChanged;
            Terminal.TitleChanged            += Terminal_TitleChanged;
            Terminal.Exited += Terminal_Exited;
            Terminal.Closed += Terminal_Closed;
        }
コード例 #23
0
        public TerminalViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService,
                                 IKeyboardCommandService keyboardCommandService, ApplicationSettings applicationSettings, string startupDirectory, ShellProfile shellProfile,
                                 IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService)
        {
            SettingsService = settingsService;
            SettingsService.CurrentThemeChanged        += OnCurrentThemeChanged;
            SettingsService.TerminalOptionsChanged     += OnTerminalOptionsChanged;
            SettingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
            SettingsService.KeyBindingsChanged         += OnKeyBindingsChanged;

            TrayProcessCommunicationService = trayProcessCommunicationService;

            DialogService           = dialogService;
            _keyboardCommandService = keyboardCommandService;
            ApplicationSettings     = applicationSettings;
            StartupDirectory        = startupDirectory;
            ApplicationView         = applicationView;
            ClipboardService        = clipboardService;

            ShellProfile  = shellProfile;
            TerminalTheme = shellProfile.TerminalThemeId == Guid.Empty ? SettingsService.GetCurrentTheme() : SettingsService.GetTheme(shellProfile.TerminalThemeId);

            TabThemes = new ObservableCollection <TabTheme>(SettingsService.GetTabThemes());
            TabTheme  = TabThemes.FirstOrDefault(t => t.Id == ShellProfile.TabThemeId);

            _resizeOverlayTimer          = dispatcherTimer;
            _resizeOverlayTimer.Interval = new TimeSpan(0, 0, 2);
            _resizeOverlayTimer.Tick    += OnResizeOverlayTimerFinished;

            CloseCommand            = new RelayCommand(async() => await TryClose().ConfigureAwait(false));
            FindNextCommand         = new RelayCommand(FindNext);
            FindPreviousCommand     = new RelayCommand(FindPrevious);
            CloseSearchPanelCommand = new RelayCommand(CloseSearchPanel);
            SelectTabThemeCommand   = new RelayCommand <string>(SelectTabTheme);
            EditTitleCommand        = new AsyncCommand(EditTitle);

            if (!string.IsNullOrWhiteSpace(StartupDirectory))
            {
                ShellProfile.WorkingDirectory = StartupDirectory;
            }

            Terminal = new Terminal(TrayProcessCommunicationService);
            Terminal.KeyboardCommandReceived += Terminal_KeyboardCommandReceived;
            Terminal.OutputReceived          += Terminal_OutputReceived;
            Terminal.SizeChanged             += Terminal_SizeChanged;
            Terminal.TitleChanged            += Terminal_TitleChanged;
            Terminal.Closed += Terminal_Closed;
        }
コード例 #24
0
        public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService,
                             IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService)
        {
            _settingsService = settingsService;
            _settingsService.CurrentThemeChanged        += OnCurrentThemeChanged;
            _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
            _settingsService.TerminalOptionsChanged     += OnTerminalOptionsChanged;
            _trayProcessCommunicationService             = trayProcessCommunicationService;
            _dialogService          = dialogService;
            _applicationView        = applicationView;
            _dispatcherTimer        = dispatcherTimer;
            _clipboardService       = clipboardService;
            _keyboardCommandService = keyboardCommandService;
            _keyboardCommandService.RegisterCommandHandler(Command.NewTab, () => AddTerminal(null, false));
            _keyboardCommandService.RegisterCommandHandler(Command.ConfigurableNewTab, () => AddTerminal(null, true));
            _keyboardCommandService.RegisterCommandHandler(Command.CloseTab, CloseCurrentTab);

            // Add all of the commands for switching to a tab of a given ID, if there's one open there
            for (int i = 0; i < 9; i++)
            {
                Command switchCmd = Command.SwitchToTerm1 + i;
                int     tabNumber = i;
                Action  handler   = () => SelectTabNumber(tabNumber);
                _keyboardCommandService.RegisterCommandHandler(switchCmd, handler);
            }
            _keyboardCommandService.RegisterCommandHandler(Command.NextTab, SelectNextTab);
            _keyboardCommandService.RegisterCommandHandler(Command.PreviousTab, SelectPreviousTab);

            _keyboardCommandService.RegisterCommandHandler(Command.NewWindow, NewWindow);
            _keyboardCommandService.RegisterCommandHandler(Command.ShowSettings, ShowSettings);
            _keyboardCommandService.RegisterCommandHandler(Command.ToggleFullScreen, ToggleFullScreen);
            var currentTheme = _settingsService.GetCurrentTheme();
            var options      = _settingsService.GetTerminalOptions();

            Background           = currentTheme.Colors.Background;
            BackgroundOpacity    = options.BackgroundOpacity;
            _applicationSettings = _settingsService.GetApplicationSettings();
            TabsPosition         = _applicationSettings.TabsPosition;

            AddTerminalCommand  = new RelayCommand(() => AddTerminal(null, false));
            ShowAboutCommand    = new RelayCommand(ShowAbout);
            ShowSettingsCommand = new RelayCommand(ShowSettings);

            _applicationView.CloseRequested += OnCloseRequest;
            Terminals.CollectionChanged     += OnTerminalsCollectionChanged;
        }
コード例 #25
0
        public CustomCommandDialog(ISettingsService settingsService, IApplicationView applicationView,
                                   ITrayProcessCommunicationService trayProcessCommunicationService, ApplicationDataContainers containers)
        {
            _settingsService = settingsService;
            _applicationView = applicationView;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            _historyContainer = containers.HistoryContainer;

            InitializeComponent();

            PrimaryButtonText   = I18N.Translate("OK");
            SecondaryButtonText = I18N.Translate("Cancel");

            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);
        }
コード例 #26
0
        public GeneralPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider,
                                    IStartupTaskService startupTaskService, IApplicationLanguageService applicationLanguageService,
                                    ITrayProcessCommunicationService trayProcessCommunicationService, IFileSystemService fileSystemService)
        {
            _settingsService                 = settingsService;
            _dialogService                   = dialogService;
            _defaultValueProvider            = defaultValueProvider;
            _startupTaskService              = startupTaskService;
            _applicationLanguageService      = applicationLanguageService;
            _trayProcessCommunicationService = trayProcessCommunicationService;
            _fileSystemService               = fileSystemService;

            _applicationSettings = _settingsService.GetApplicationSettings();

            RestoreDefaultsCommand    = new AsyncCommand(RestoreDefaults);
            BrowseLogDirectoryCommand = new AsyncCommand(BrowseLogDirectory);
        }
コード例 #27
0
        public SshInfoDialog(ISettingsService settingsService, IApplicationView applicationView,
                             IFileSystemService fileSystemService, ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _settingsService   = settingsService;
            _applicationView   = applicationView;
            _fileSystemService = fileSystemService;
            _trayProcessCommunicationService = trayProcessCommunicationService;

            InitializeComponent();

            BrowseIdentityFileCommand = new AsyncCommand(BrowseIdentityFile);
            SaveLinkCommand           = new AsyncCommand(SaveLink);

            PrimaryButtonText   = I18N.Translate("OK");
            SecondaryButtonText = I18N.Translate("Cancel");

            var currentTheme = settingsService.GetCurrentTheme();

            RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background);
        }
コード例 #28
0
        public SshProfilesPageViewModel(ISettingsService settingsService, IDialogService dialogService,
                                        IFileSystemService fileSystemService, IApplicationView applicationView,
                                        ITrayProcessCommunicationService trayProcessCommunicationService)
        {
            _settingsService   = settingsService;
            _dialogService     = dialogService;
            _fileSystemService = fileSystemService;
            _applicationView   = applicationView;
            _trayProcessCommunicationService = trayProcessCommunicationService;

            CreateSshProfileCommand = new RelayCommand(CreateSshProfile);
            CloneCommand            = new RelayCommand <SshProfileViewModel>(Clone);

            var defaultSshProfileId = _settingsService.GetDefaultSshProfileId();

            foreach (var sshProfile in _settingsService.GetSshProfiles())
            {
                var viewModel = new SshProfileViewModel(sshProfile, settingsService, dialogService,
                                                        fileSystemService, applicationView, _trayProcessCommunicationService, false);
                viewModel.Deleted      += OnSshProfileDeleted;
                viewModel.SetAsDefault += OnSshProfileSetAsDefault;

                if (sshProfile.Id == defaultSshProfileId)
                {
                    viewModel.IsDefault = true;
                }

                SshProfiles.Add(viewModel);
            }

            if (SshProfiles.Count == 0)
            {
                CreateSshProfile();
            }
            SelectedSshProfile = SshProfiles.FirstOrDefault(p => p.IsDefault);
            if (SelectedSshProfile == null)
            {
                SelectedSshProfile = SshProfiles.First();
            }
        }
コード例 #29
0
        public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService,
                             IApplicationView applicationView, IClipboardService clipboardService, ICommandHistoryService commandHistoryService, IAcceleratorKeyValidator acceleratorKeyValidator)
        {
            MessengerInstance.Register <ApplicationSettingsChangedMessage>(this, OnApplicationSettingsChanged);
            MessengerInstance.Register <CurrentThemeChangedMessage>(this, OnCurrentThemeChanged);
            MessengerInstance.Register <ShellProfileAddedMessage>(this, OnShellProfileAdded);
            MessengerInstance.Register <ShellProfileDeletedMessage>(this, OnShellProfileDeleted);
            MessengerInstance.Register <ShellProfileChangedMessage>(this, OnShellProfileChanged);
            MessengerInstance.Register <DefaultShellProfileChangedMessage>(this, OnDefaultShellProfileChanged);
            MessengerInstance.Register <TerminalOptionsChangedMessage>(this, OnTerminalOptionsChanged);
            MessengerInstance.Register <CommandHistoryChangedMessage>(this, OnCommandHistoryChanged);
            MessengerInstance.Register <KeyBindingsChangedMessage>(this, OnKeyBindingChanged);

            _settingsService = settingsService;

            _trayProcessCommunicationService = trayProcessCommunicationService;
            _dialogService           = dialogService;
            ApplicationView          = applicationView;
            _clipboardService        = clipboardService;
            _keyboardCommandService  = keyboardCommandService;
            _commandHistoryService   = commandHistoryService;
            _acceleratorKeyValidator = acceleratorKeyValidator;

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewTab), async() => await AddDefaultProfileAsync(NewTerminalLocation.Tab));
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewWindow), async() => await AddDefaultProfileAsync(NewTerminalLocation.Window));

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewSshTab), async() => await AddSshProfileAsync(NewTerminalLocation.Tab));
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewSshWindow), async() => await AddSshProfileAsync(NewTerminalLocation.Window));

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewCustomCommandTab), async() => await AddQuickLaunchProfileAsync(NewTerminalLocation.Tab));
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewCustomCommandWindow), async() => await AddQuickLaunchProfileAsync(NewTerminalLocation.Window));

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ConfigurableNewTab), async() => await AddSelectedProfileAsync(NewTerminalLocation.Tab));
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ConfigurableNewWindow), async() => await AddSelectedProfileAsync(NewTerminalLocation.Window));

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ChangeTabTitle), async() => await SelectedTerminal.EditTitleAsync());
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.CloseTab), CloseCurrentTab);
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.DuplicateTab), async() => await AddTabAsync(SelectedTerminal.ShellProfile.Clone()));

            // Add all of the commands for switching to a tab of a given ID, if there's one open there
            for (int i = 0; i < 9; i++)
            {
                var switchCmd = Command.SwitchToTerm1 + i;
                int tabNumber = i;
                // ReSharper disable once InconsistentNaming
                void handler() => SelectTabNumber(tabNumber);

                _keyboardCommandService.RegisterCommandHandler(switchCmd.ToString(), handler);
            }

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.NextTab), SelectNextTab);
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.PreviousTab), SelectPreviousTab);

            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ShowSettings), ShowSettings);
            _keyboardCommandService.RegisterCommandHandler(nameof(Command.ToggleFullScreen), ToggleFullScreen);

            foreach (ShellProfile profile in _settingsService.GetShellProfiles())
            {
                _keyboardCommandService.RegisterCommandHandler(profile.Id.ToString(), async() => await AddProfileByGuidAsync(profile.Id));
            }

            foreach (SshProfile profile in _settingsService.GetSshProfiles())
            {
                _keyboardCommandService.RegisterCommandHandler(profile.Id.ToString(), async() => await AddProfileByGuidAsync(profile.Id));
            }

            var currentTheme = _settingsService.GetCurrentTheme();
            var options      = _settingsService.GetTerminalOptions();

            Background           = currentTheme.Colors.Background;
            BackgroundOpacity    = options.BackgroundOpacity;
            _applicationSettings = _settingsService.GetApplicationSettings();
            TabsPosition         = _applicationSettings.TabsPosition;

            AddDefaultTabCommand = new RelayCommand(async() => await AddDefaultProfileAsync(NewTerminalLocation.Tab));

            ApplicationView.CloseRequested += OnCloseRequest;
            ApplicationView.Closed         += OnClosed;
            Terminals.CollectionChanged    += OnTerminalsCollectionChanged;

            LoadKeyBindings();

            _newDefaultTabCommand        = new RelayCommand(async() => await AddDefaultProfileAsync(NewTerminalLocation.Tab));
            _newDefaultWindowCommand     = new RelayCommand(async() => await AddDefaultProfileAsync(NewTerminalLocation.Window));
            _newRemoteTabCommand         = new RelayCommand(async() => await AddSshProfileAsync(NewTerminalLocation.Tab));
            _newRemoteWindowCommand      = new RelayCommand(async() => await AddSshProfileAsync(NewTerminalLocation.Window));
            _newQuickLaunchTabCommand    = new RelayCommand(async() => await AddQuickLaunchProfileAsync(NewTerminalLocation.Tab));
            _newQuickLaunchWindowCommand = new RelayCommand(async() => await AddQuickLaunchProfileAsync(NewTerminalLocation.Window));

            _settingsCommand = new RelayCommand(ShowSettings);
            _aboutCommand    = new RelayCommand(async() => await _dialogService.ShowAboutDialogAsync());
            _quitCommand     = new AsyncCommand(() => _trayProcessCommunicationService.QuitApplicationAsync());

            _defaultProfile = _settingsService.GetDefaultShellProfile();

            CreateMenuViewModel();
        }
コード例 #30
0
ファイル: App.xaml.cs プロジェクト: qinfengzhu/FluentTerminal
        public App()
        {
            _mainViewModels = new List <MainViewModel>();

            InitializeComponent();

            UnhandledException += OnUnhandledException;

            var applicationDataContainers = new ApplicationDataContainers
            {
                LocalSettings    = new ApplicationDataContainerAdapter(ApplicationData.Current.LocalSettings),
                RoamingSettings  = new ApplicationDataContainerAdapter(ApplicationData.Current.RoamingSettings),
                KeyBindings      = new ApplicationDataContainerAdapter(ApplicationData.Current.RoamingSettings.CreateContainer(Constants.KeyBindingsContainerName, ApplicationDataCreateDisposition.Always)),
                ShellProfiles    = new ApplicationDataContainerAdapter(ApplicationData.Current.LocalSettings.CreateContainer(Constants.ShellProfilesContainerName, ApplicationDataCreateDisposition.Always)),
                Themes           = new ApplicationDataContainerAdapter(ApplicationData.Current.RoamingSettings.CreateContainer(Constants.ThemesContainerName, ApplicationDataCreateDisposition.Always)),
                SshProfiles      = new ApplicationDataContainerAdapter(ApplicationData.Current.RoamingSettings.CreateContainer(Constants.SshProfilesContainerName, ApplicationDataCreateDisposition.Always)),
                HistoryContainer = new ApplicationDataContainerAdapter(ApplicationData.Current.RoamingSettings.CreateContainer(Constants.ExecutedCommandsContainerName, ApplicationDataCreateDisposition.Always))
            };
            var builder = new ContainerBuilder();

            builder.RegisterType <SettingsService>().As <ISettingsService>().SingleInstance();
            builder.RegisterType <DefaultValueProvider>().As <IDefaultValueProvider>().SingleInstance();
            builder.RegisterType <TrayProcessCommunicationService>().As <ITrayProcessCommunicationService>().SingleInstance();
            builder.RegisterType <DialogService>().As <IDialogService>().SingleInstance();
            builder.RegisterType <KeyboardCommandService>().As <IKeyboardCommandService>().InstancePerDependency();
            builder.RegisterType <NotificationService>().As <INotificationService>().InstancePerDependency();
            builder.RegisterType <UpdateService>().As <IUpdateService>().InstancePerDependency();
            builder.RegisterType <MainViewModel>().InstancePerDependency();
            builder.RegisterType <SettingsViewModel>().InstancePerDependency();
            builder.RegisterType <ThemeParserFactory>().As <IThemeParserFactory>().SingleInstance();
            builder.RegisterType <ITermThemeParser>().As <IThemeParser>().SingleInstance();
            builder.RegisterType <FluentTerminalThemeParser>().As <IThemeParser>().SingleInstance();
            builder.RegisterType <ClipboardService>().As <IClipboardService>().SingleInstance();
            builder.RegisterType <FileSystemService>().As <IFileSystemService>().SingleInstance();
            builder.RegisterType <SystemFontService>().As <ISystemFontService>().SingleInstance();
            builder.RegisterType <ShellProfileSelectionDialog>().As <IShellProfileSelectionDialog>().InstancePerDependency();
            builder.RegisterType <SshProfileSelectionDialog>().As <ISshProfileSelectionDialog>().InstancePerDependency();
            builder.RegisterType <CreateKeyBindingDialog>().As <ICreateKeyBindingDialog>().InstancePerDependency();
            builder.RegisterType <InputDialog>().As <IInputDialog>().InstancePerDependency();
            builder.RegisterType <AboutDialog>().As <IAboutDialog>().InstancePerDependency();
            builder.RegisterType <MessageDialogAdapter>().As <IMessageDialog>().InstancePerDependency();
            builder.RegisterType <SshInfoDialog>().As <ISshConnectionInfoDialog>().InstancePerDependency();
            builder.RegisterType <CustomCommandDialog>().As <ICustomCommandDialog>().InstancePerDependency();
            builder.RegisterType <ApplicationViewAdapter>().As <IApplicationView>().InstancePerDependency();
            builder.RegisterType <DispatcherTimerAdapter>().As <IDispatcherTimer>().InstancePerDependency();
            builder.RegisterType <StartupTaskService>().As <IStartupTaskService>().SingleInstance();
            builder.RegisterType <ApplicationLanguageService>().As <IApplicationLanguageService>().SingleInstance();
            builder.RegisterType <ShellProfileMigrationService>().As <IShellProfileMigrationService>().SingleInstance();
            builder.RegisterInstance(applicationDataContainers);

            _container = builder.Build();

            Messenger.Default.Register <ApplicationSettingsChangedMessage>(this, OnApplicationSettingsChanged);

            _settingsService = _container.Resolve <ISettingsService>();

            var shellProfileMigrationService = _container.Resolve <IShellProfileMigrationService>();

            foreach (var profile in _settingsService.GetShellProfiles())
            {
                shellProfileMigrationService.Migrate(profile);
                _settingsService.SaveShellProfile(profile);
            }

            foreach (var profile in _settingsService.GetSshProfiles())
            {
                shellProfileMigrationService.Migrate(profile);
                _settingsService.SaveSshProfile(profile);
            }

            _trayProcessCommunicationService = _container.Resolve <ITrayProcessCommunicationService>();

            _dialogService = _container.Resolve <IDialogService>();

            _applicationSettings = _settingsService.GetApplicationSettings();

            JsonConvert.DefaultSettings = () =>
            {
                var settings = new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver(),
                };
                settings.Converters.Add(new StringEnumConverter(typeof(CamelCaseNamingStrategy)));

                return(settings);
            };

            _commandLineParser = new Parser(settings =>
            {
                settings.CaseSensitive             = false;
                settings.CaseInsensitiveEnumValues = true;
            });
        }