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); } }
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); }
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 <SshInfoDialog>().As <ISshConnectionInfoDialog>().InstancePerDependency(); builder.RegisterType <ApplicationViewAdapter>().As <IApplicationView>().InstancePerDependency(); builder.RegisterType <DispatcherTimerAdapter>().As <IDispatcherTimer>().InstancePerDependency(); builder.RegisterType <StartupTaskService>().As <IStartupTaskService>().SingleInstance(); builder.RegisterType <SshHelperService>().As <ISshHelperService>().SingleInstance(); builder.RegisterType <ApplicationLanguageService>().As <IApplicationLanguageService>().SingleInstance(); builder.RegisterInstance(applicationDataContainers); _container = builder.Build(); _settingsService = _container.Resolve <ISettingsService>(); _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged; _trayProcessCommunicationService = _container.Resolve <ITrayProcessCommunicationService>(); _sshHelperService = _container.Resolve <ISshHelperService>(); _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; }); }
public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService, IApplicationView applicationView, IDispatcherTimer dispatcherTimer, IClipboardService clipboardService, ISshHelperService sshHelperService) { _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; _sshHelperService = sshHelperService; _keyboardCommandService = keyboardCommandService; _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewTab), () => AddTerminal()); _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewSshTab), () => AddRemoteTerminal()); _keyboardCommandService.RegisterCommandHandler(nameof(Command.ConfigurableNewTab), () => AddConfigurableTerminal()); _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.Id)); } var currentTheme = _settingsService.GetCurrentTheme(); var options = _settingsService.GetTerminalOptions(); Background = currentTheme.Colors.Background; BackgroundOpacity = options.BackgroundOpacity; _applicationSettings = _settingsService.GetApplicationSettings(); TabsPosition = _applicationSettings.TabsPosition; AddLocalShellCommand = new RelayCommand(() => AddTerminal()); AddRemoteShellCommand = new RelayCommand(() => AddRemoteTerminal()); ShowAboutCommand = new RelayCommand(ShowAbout); ShowSettingsCommand = new RelayCommand(ShowSettings); ApplicationView.CloseRequested += OnCloseRequest; ApplicationView.Closed += OnClosed; Terminals.CollectionChanged += OnTerminalsCollectionChanged; }