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; }
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; }
/// <summary> /// Called after the GUI toolkit message loop terminates, to clean up the application. Override /// this method to perform custom clean-up. Be sure to call the base class method. /// </summary> protected virtual void CleanUp() { _synchronizationContext = null; if (_view != null && _view is IDisposable) { (_view as IDisposable).Dispose(); _view = null; } if (_toolSet != null) { _toolSet.Dispose(); _toolSet = null; } if (_windows != null) { (_windows as IDisposable).Dispose(); } if (_guiToolkit != null && _guiToolkit is IDisposable) { (_guiToolkit as IDisposable).Dispose(); } }
public ProfilesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider, IFileSystemService fileSystemService, IApplicationView applicationView) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _fileSystemService = fileSystemService; _applicationView = applicationView; CreateShellProfileCommand = new RelayCommand(CreateShellProfile); CloneCommand = new RelayCommand <ShellProfileViewModel>(Clone); var defaultShellProfileId = _settingsService.GetDefaultShellProfileId(); foreach (var shellProfile in _settingsService.GetShellProfiles()) { var viewModel = new ShellProfileViewModel(shellProfile, settingsService, dialogService, fileSystemService, applicationView, defaultValueProvider, false); viewModel.Deleted += OnShellProfileDeleted; viewModel.SetAsDefault += OnShellProfileSetAsDefault; if (shellProfile.Id == defaultShellProfileId) { viewModel.IsDefault = true; } ShellProfiles.Add(viewModel); } SelectedShellProfile = ShellProfiles.First(p => p.IsDefault); }
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(); }
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(); }
public ApplicationViewBase(IApplicationController controller) { _controller = controller; _model = controller.Model; _view = CreateConcreteView(); // otherwise would be this... _controller.View = _view; }
public AboutPageViewModel(IUpdateService updateService, IApplicationView applicationView) { _updateService = updateService; _applicationView = applicationView; CheckForUpdatesCommand = new AsyncRelayCommand(() => CheckForUpdateAsync(true)); }
/// <summary> /// <summary> /// This is the main constructor used by the application. It takes all the application views and /// initialises the dependencies between them. Many of the MVP triads are dependent on events /// and properties of other Views. The approach we have taken here is treating the triads as /// essentially being sub-triads of the main ApplicationView. While this breaks somewhat from the /// MVP pattern it simplifies inter-triad communication while still preserving the ability to /// test them. /// </summary> /// <param name="view"></param> public ApplicationPresenter(IApplicationView view) { // Hook in to the View's events. View = view; View.SelectPanel += View_SelectPanel; View.LoadZipPackage += View_LoadZipPackage; View.BookChanged += View_BookChanged; View.LoadPackage += View_LoadPackage; View.BookDisplayed += View_BookDisplayed; View.BookLoadFailed += View_BookLoadFailed; View.BookLoadStarted += View_BookLoadStarted; View.SpeakableElementSelected += AllViews_SpeakableElementSelected; View.SelfVoicingSpeakText += AllViews_SelfVoicingSpeakText; View.SpeakableElementSelectedHelpText += AllViews_SpeakableElementSelectedHelpText; // Configure the application's global state. ConfigureApplicationState(); // It is the responsibility of the ApplicationPresenter to configure all the dependent // presenters. ConfigurePlayerPresenter(); ConfigureNavigationPresenter(); ConfigureDisplaySettingsPresenter(); ConfigureSearchPresenter(); // Perform any business logic related initialisation steps Init(); }
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); }
/// <summary> /// Implements the logic to start up the desktop by running the GUI toolkit and creating the application view. /// </summary> private void Run(string[] args) { // load gui toolkit try { _guiToolkit = (IGuiToolkit)(new GuiToolkitExtensionPoint()).CreateExtension(); } catch (Exception ex) { ExceptionHandler.ReportUnhandled(ex); return; } _guiToolkit.Started += delegate { // load application view try { _synchronizationContext = SynchronizationContext.Current; _view = (IApplicationView)ViewFactory.CreateAssociatedView(this.GetType()); } catch (Exception ex) { ExceptionHandler.ReportUnhandled(ex); TerminateGuiToolkit(); return; } // initialize if (!Initialize(args)) { TerminateGuiToolkit(); return; } _initialized = true; PhoneHome.Startup(); // now that the desktop is fully initialized, take advantage of idle time to // load any outstanding plugins Platform.PluginManager.EnableBackgroundAssemblyLoading(true); }; // init windows collection _windows = new DesktopWindowCollection(this); _windows.ItemClosed += delegate { // terminate the app when the window count goes to 0 if the app isn't already quitting if (_windows.Count == 0 && !IsQuitting) { Quit(false); } }; // start message pump - this will block until _guiToolkit.Terminate() is called _guiToolkit.Run(); }
public ApplicationPresenter(IApplicationView aView, ISpyManager aSpyManager, HookingSettings hookingSettings, int platformBits) { _processModulesDisplayer = new ProcessModulesDisplayer(this, aView); _hookingSettings = hookingSettings; _platformBits = platformBits; InitializePresenter(aView, aSpyManager); InitializeView(); }
/// <summary> Constructor. </summary> /// <param name="view"> The view for the controller. </param> public ApplicationController(IApplicationView view) { _view = view; _input = new InputController(view.InputView); _processing = new ProcessingController(view.ProcessingView); _output = new OutputController(this, view.OutputView); }
public AboutPageViewModel(ISettingsService settingsService, IUpdateService updateService, IApplicationView applicationView) { _settingsService = settingsService; _updateService = updateService; _applicationView = applicationView; CheckForUpdatesCommand = new AsyncCommand(() => CheckForUpdate(true)); }
public SshHelperService(ISettingsService settingsService, IDialogService dialogService, IFileSystemService fileSystemService, IApplicationView applicationView, ITrayProcessCommunicationService trayProcessCommunicationService) { _settingsService = settingsService; _dialogService = dialogService; _fileSystemService = fileSystemService; _applicationView = applicationView; _trayProcessCommunicationService = trayProcessCommunicationService; }
public ApplicationPresenter(IApplicationView view, Dispatcher dispatcher) { View = view; RestClient = RestClientFactory.GetDefault(); Dispatcher = dispatcher; view.FindRegionPressed += FindRegion; View.Compare += Compare; View.HasGasChanged += HasGasChanged; }
internal ProcessModulesDisplayer(ApplicationPresenter presenter, IApplicationView view) { _presenter = presenter; _view = view; _modulesShownByWorker = new Dictionary <BackgroundWorker, IEnumerable <Module> >(); _newModulesToShowByWorker = new Dictionary <BackgroundWorker, IEnumerable <Module> >(); _moduleToKeepSelected = new Dictionary <BackgroundWorker, Module>(); _workers = new List <BackgroundWorker>(); }
internal ProcessModulesDisplayer(ApplicationPresenter presenter, IApplicationView view) { _presenter = presenter; _view = view; _modulesShownByWorker = new Dictionary<BackgroundWorker, IEnumerable<Module>>(); _newModulesToShowByWorker = new Dictionary<BackgroundWorker, IEnumerable<Module>>(); _moduleToKeepSelected = new Dictionary<BackgroundWorker, Module>(); _workers = new List<BackgroundWorker>(); }
public void ViewVirtualDesktopChanged(IApplicationView pView) { if (_viewChangedEventListeners.TryGetValue(IntPtr.Zero, out var all)) { all.Call(); } if (_viewChangedEventListeners.TryGetValue(pView.GetThumbnailWindow(), out var listener)) { listener.Call(); } }
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); }
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; }
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; }
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; }
public SshInfoDialog(ISettingsService settingsService, IApplicationView applicationView, IFileSystemService fileSystemService, ITrayProcessCommunicationService trayProcessCommunicationService) { _settingsService = settingsService; _applicationView = applicationView; _fileSystemService = fileSystemService; _trayProcessCommunicationService = trayProcessCommunicationService; InitializeComponent(); PrimaryButtonText = I18N.Translate("OK"); SecondaryButtonText = I18N.Translate("Cancel"); var currentTheme = settingsService.GetCurrentTheme(); RequestedTheme = ContrastHelper.GetIdealThemeForBackgroundColor(currentTheme.Colors.Background); }
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); }
private void InitializePresenter(IApplicationView aView, ISpyManager aSpyManager) { _selectedProcesses = Enumerable.Empty <IProcess>(); _selectedFunctions = Enumerable.Empty <Function>(); _view = aView; _spyManager = aSpyManager; _hookLoader = new HookLoader(_hookingSettings, FilterProcessesToApplyHookingSettingsOn, AddHookForRunningProcess); InitializeProcessHandlers(); _spyManager.ProcessStartedHandler = ProcessStartedHandler; _spyManager.ProcessTerminatedHandler = ProcessTerminatedHandler; _spyManager.FunctionCalledHandler = FunctionCalledHandler; _spyManager.HookStateChangedHandler = HookStateChangedHandler; _spyManager.AgentLoadHandler = AgentLoadHandler; }
protected IApplicationView LaunchView(string viewClassName) { try { // TODO: obter o nome da class do concrete view do ficheiro de configuracao //string viewClassName = "eFinancesWF.frmDashboard, eFinancesWF"; if (string.IsNullOrEmpty(viewClassName)) { throw new ArgumentNullException("ViewClassName nao 'e valida"); } IApplicationView frm = ReflectionHelper <IApplicationView> .GetInstanceOf(viewClassName, new object[] { _controller }); return(frm); } catch (Exception ex) { throw ex; } }
public bool CanViewMoveDesktops(IApplicationView pView) { if (this._manager14328 != null) { return(this._manager14328.CanViewMoveDesktops(pView)); } if (this._manager10240 != null) { return(this._manager10240.CanViewMoveDesktops(pView)); } if (this._manager10130 != null) { return(this._manager10130.CanViewMoveDesktops(pView)); } throw new NotSupportedException(); }
public ShellProfileViewModel(ShellProfile shellProfile, ISettingsService settingsService, IDialogService dialogService, IFileSystemService fileSystemService, IApplicationView applicationView, IDefaultValueProvider defaultValueProvider, Boolean isNew) { Model = shellProfile; _settingsService = settingsService; _dialogService = dialogService; _fileSystemService = fileSystemService; _applicationView = applicationView; _defaultValueProvider = defaultValueProvider; _isNew = isNew; _settingsService.ThemeAdded += OnThemeAdded; _settingsService.ThemeDeleted += OnThemeDeleted; 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); } KeyBindings = new KeyBindingsViewModel(shellProfile.Id.ToString(), _dialogService, string.Empty, false); InitializeViewModelProperties(shellProfile); SetDefaultCommand = new RelayCommand(SetDefault); DeleteCommand = new AsyncCommand(Delete, CanDelete); EditCommand = new RelayCommand(Edit); CancelEditCommand = new AsyncCommand(CancelEdit); SaveChangesCommand = new RelayCommand(SaveChanges); AddKeyboardShortcutCommand = new AsyncCommand(AddKeyboardShortcut); BrowseForCustomShellCommand = new AsyncCommand(BrowseForCustomShell); BrowseForWorkingDirectoryCommand = new AsyncCommand(BrowseForWorkingDirectory); RestoreDefaultsCommand = new AsyncCommand(RestoreDefaults); }
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(); } }
public void MoveViewToDesktop(IApplicationView pView, IVirtualDesktop desktop) { if (this._manager14328 != null) { this._manager14328?.MoveViewToDesktop(pView, desktop); return; } if (this._manager10240 != null) { this._manager10240?.MoveViewToDesktop(pView, desktop); return; } if (this._manager10130 != null) { this._manager10130.MoveViewToDesktop(pView, desktop); return; } throw new NotSupportedException(); }
public ApplicationController(IApplicationView applicationView) { this.applicationView = applicationView; }
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(); }
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); }
// オブザーバーパターン関連のメソッド // Attach, Detach, StateChange, MoveForward void IApplicationLogic.Attach(IApplicationView view) { m_ApplicationViews.Add(view); }
private void InitializePresenter(IApplicationView aView, ISpyManager aSpyManager) { _selectedProcesses = Enumerable.Empty<IProcess>(); _selectedFunctions = Enumerable.Empty<Function>(); _view = aView; _spyManager = aSpyManager; _hookLoader = new HookLoader(_hookingSettings, FilterProcessesToApplyHookingSettingsOn, AddHookForRunningProcess); InitializeProcessHandlers(); _spyManager.ProcessStartedHandler = ProcessStartedHandler; _spyManager.ProcessTerminatedHandler = ProcessTerminatedHandler; _spyManager.FunctionCalledHandler = FunctionCalledHandler; _spyManager.HookStateChangedHandler = HookStateChangedHandler; _spyManager.AgentLoadHandler = AgentLoadHandler; }
//static public readonly Mutex ProcessDisplayerMutex = new Mutex(false); #endregion #region Instance Creation & Initialization public static ApplicationPresenter For(IApplicationView aView) { return new ApplicationPresenter(aView, new SpyManager(), new HookingSettings(), (IntPtr.Size == 8 ? 64 : 32)); }
void IApplicationLogic.Detach(IApplicationView view) { m_ApplicationViews.Remove(view); }