Exemplo n.º 1
0
        public ShellViewModel(
            IFileManagerEventSource fileManagerEventSource,
            IFileManager fileManager,
            IStateService stateService,
            IClipboardService clipboardService)
        {
            _clipboardService = clipboardService;
            _stateService = stateService;
            _stateService.SavingEvent.Subscribe(this.SaveState);
            _fileManager = fileManager;
            fileManagerEventSource.OpenFileEventStream.Subscribe(this.OpenFile);

            this.DisplayName = "Eagle";

            this.FollowTail = true;

            if (Execute.InDesignMode)
            {
                this.IsFileOpen = true;
                this.File = new FileViewModel("Test File");
            }
            else
            {
                //this.FilePicker.Items.Add(new FileLocationViewModel("Documents") { SubLocations = { new FileLocationViewModel("File1"), new FileLocationViewModel("File2"), new FileLocationViewModel("File3") } });
                //this.FilePicker.Items.Add(new FileLocationViewModel("Projects"));
                //this.FilePicker.Items.Add(new FileLocationViewModel("Logs"));
            }
        }
        public PasswordEditorViewModel( IPasswordEditorModel model,
                                        DerivedPasswordViewModel.Factory derivedPasswordFactory,
                                        IExclusiveDelayedScheduler scheduler,
                                        IClipboardService clipboardService,
                                        IDialogService dialogService,
                                        IGuidToColorConverter guidToColor )
        {
            _model = model;
            _scheduler = scheduler;
            _clipboardService = clipboardService;
            _dialogService = dialogService;
            _guidToColor = guidToColor;
            _derivedPasswords = new ObservableCollection<DerivedPasswordViewModel>(
                _model.DerivedPasswords.Select( dp => derivedPasswordFactory( dp, _model ) ) );

            foreach ( DerivedPasswordViewModel passwordSlotViewModel in DerivedPasswords )
                passwordSlotViewModel.PropertyChanged += OnDerivedPasswordPropertyChanged;

            _saveCommand = new RelayCommand( ExecuteSave, CanExecuteSave );
            _copyCommand = new RelayCommand( ExecuteCopy, CanExecuteCopy );
            _deleteCommand = new RelayCommand( ExecuteDelete, CanExecuteDelete );

            _closeSelfCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.Self ) );
            _closeAllCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.All ) );
            _closeAllButSelfCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.AllButSelf ) );
            _closeToTheRightCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.RightOfSelf ) );
            _closeInsecureCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.Insecure ) );

            Refresh( );
        }
Exemplo n.º 3
0
        public SystemInfoViewModel(ISystemInfoService systemInfoService, IDispatcherService dispatcherService, IClipboardService clipboardService)
        {
            Argument.IsNotNull(() => systemInfoService);
            Argument.IsNotNull(() => dispatcherService);
            Argument.IsNotNull(() => clipboardService);

            _systemInfoService = systemInfoService;
            _dispatcherService = dispatcherService;
            _clipboardService = clipboardService;

            SystemInfo = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>(string.Empty, string.Empty) };

            CopyToClipboard = new Command(OnCopyToClipboardExecute);
        }
Exemplo n.º 4
0
        public ItemFilterScriptViewModel(IItemFilterBlockBaseViewModelFactory itemFilterBlockBaseViewModelFactory,
                                         IItemFilterBlockTranslator blockTranslator,
                                         IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
                                         IItemFilterPersistenceService persistenceService,
                                         IMessageBoxService messageBoxService,
                                         IClipboardService clipboardService,
                                         IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
        {
            _itemFilterBlockBaseViewModelFactory = itemFilterBlockBaseViewModelFactory;
            _blockTranslator = blockTranslator;
            _avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
            _avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
            _persistenceService         = persistenceService;
            _messageBoxService          = messageBoxService;
            _clipboardService           = clipboardService;
            _blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
            _itemFilterBlockViewModels  = new ObservableCollection <IItemFilterBlockViewModelBase>();

            _avalonDockWorkspaceViewModel.ActiveDocumentChanged += (s, e) =>
            {
                RaisePropertyChanged(nameof(IsActiveDocument));
            };

            ToggleShowAdvancedCommand = new RelayCommand <bool>(OnToggleShowAdvancedCommand);
            ClearFilterCommand        = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
            CloseCommand             = new RelayCommand(async() => await OnCloseCommand());
            DeleteBlockCommand       = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null);
            MoveBlockToTopCommand    = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null && ItemFilterBlockViewModels.IndexOf(SelectedBlockViewModel) > 0);
            MoveBlockUpCommand       = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null && ItemFilterBlockViewModels.IndexOf(SelectedBlockViewModel) > 0);
            MoveBlockDownCommand     = new RelayCommand(OnMoveBlockDownCommand, () => SelectedBlockViewModel != null && ItemFilterBlockViewModels.IndexOf(SelectedBlockViewModel) < ItemFilterBlockViewModels.Count);
            MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null && ItemFilterBlockViewModels.IndexOf(SelectedBlockViewModel) < ItemFilterBlockViewModels.Count);
            AddBlockCommand          = new RelayCommand(OnAddBlockCommand);
            AddSectionCommand        = new RelayCommand(OnAddCommentBlockCommand, () => SelectedBlockViewModel != null);
            DisableBlockCommand      = new RelayCommand(OnDisableBlockCommand, HasSelectedEnabledBlock);
            EnableBlockCommand       = new RelayCommand(OnEnableBlockCommand, HasSelectedDisabledBlock);
            CopyBlockCommand         = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
            CopyBlockStyleCommand    = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null);
            PasteBlockCommand        = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
            PasteBlockStyleCommand   = new RelayCommand(OnPasteBlockStyleCommand, () => SelectedBlockViewModel != null);
            ExpandAllBlocksCommand   = new RelayCommand(OnExpandAllBlocksCommand);
            CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand);

            var icon = new BitmapImage();

            icon.BeginInit();
            icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/script_icon.png");
            icon.EndInit();
            IconSource = icon;
        }
Exemplo n.º 5
0
        public FileExplorerViewModel(
            IClipboardService clipboard,
            IFileIconProvider fileIconProvider,
            IMessageDialogService messageDialogService,
            bool allowMultipleSelection,
            IObservable <IFilter <FileSystemEntry> >?filter = null)
        {
            _currentFolder = new Folder(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)));

            AddressBar = new FileExplorerAddressBarViewModel();

            FileExplorerTree = new FileExplorerTreeViewModel();

            filter ??= DefaultFilterObservable;

            var searchTextFilter =
                from searchText in this.WhenAnyValue(vm => vm.SearchText)
                select Filter.String.Contains(searchText, StringComparison.OrdinalIgnoreCase)
                .Cast <string, FileSystemEntry>(e => e.Name);

            filter = Observable.CombineLatest(filter, searchTextFilter, (f, s) => f.And(s));

            FileExplorerFolder = new FileExplorerFolderViewModel(
                clipboard, fileIconProvider, messageDialogService, allowMultipleSelection, filter);

            FileOpened = _fileOpened.AsObservable();

            NavigateBackCommand = ReactiveCommand.Create(
                NavigateBack,
                this.WhenAnyValue(vm => vm.CanNavigateBack));

            NavigateForwardCommand = ReactiveCommand.Create(
                NavigateForward,
                this.WhenAnyValue(vm => vm.CanNavigateForward));

            NavigateUpCommand = ReactiveCommand.Create(
                NavigateUp,
                this.WhenAnyValue(vm => vm.CurrentFolder).Select(x => x.Parent != null));

            AddressBar.AddressChanged.Subscribe(address => NavigateToAddress(address));

            FileExplorerTree.SelectedFolderChanged.Subscribe(folder => NavigateTo(folder));
            FileExplorerFolder.FolderOpened.Subscribe(folder => NavigateTo(folder));

            FileOpened = FileExplorerFolder.FileOpened;

            this.WhenAnyValue(vm => vm.CurrentFolder)
            .Subscribe(CurrentFolderChanged);
        }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(SettingsService settings,
                             ScanningService scanning,
                             IIconCacheService iconCache,
                             IUIService ui,
                             IBitmapFactory bitmapFactory,
                             ImagesServiceBase images,
                             IClipboardService clipboard,
                             IOSService os,
                             IWindowDialogService dialogs,
                             TreemapRendererFactory treemapFactory,
                             IShortcutsService shortcuts,
                             RelayCommandService relayFactory)
        {
            Settings      = settings;
            Scanning      = scanning;
            IconCache     = iconCache;
            UI            = ui;
            BitmapFactory = bitmapFactory;
            Images        = images;
            Clipboard     = clipboard;
            OS            = os;
            Dialogs       = dialogs;
            Shortcuts     = shortcuts;
            Treemap       = treemapFactory.Create();

            Settings.PropertyChanged += OnSettingsPropertyChanged;
            Scanning.PropertyChanged += OnScanningPropertyChanged;

            Extensions = new ExtensionItemViewModelCollection(this);

            SelectedFiles = new ObservableCollection <FileItemViewModel>();
            SelectedFiles.CollectionChanged += OnSelectedFilesChanged;

            FileComparer      = new FileComparer();
            ExtensionComparer = new ExtensionComparer();
            UpdateEmptyRecycleBin();

            GCRAMUsage = GC.GetTotalMemory(false);
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                // Code runs "for real"
                ramTimer    = UI.StartTimer(Settings.RAMInterval, true, OnRAMUsageTick);
                statusTimer = UI.CreateTimer(Settings.StatusInterval, true, OnStatusTick);
            }
        }
Exemplo n.º 7
0
 public ExplorerComponent(
     IQueryHistory state,
     IQueryFactory queryFactory,
     IFileSystemErrorView dialogView,
     IFileSystem fileSystem,
     IExplorer explorer,
     IClipboardService clipboard)
 {
     _state        = state;
     _queryFactory = queryFactory;
     _fileSystem   = fileSystem;
     _clipboard    = clipboard;
     _dialogView   = dialogView;
     _explorer     = explorer;
 }
Exemplo n.º 8
0
        public void Initialize()
        {
            _windowService              = A.Fake <IWindowService>();
            _dataTransferService        = A.Fake <IDataTransferService>();
            _clipboardService           = A.Fake <IClipboardService>();
            _httpService                = A.Fake <IHttpService>();
            _schedulerProvider          = A.Fake <ISchedulerProvider>();
            _textToSpeechService        = A.Fake <ITextToSpeechService>();
            _applicationSettingsService = new ApplicationSettingsService(new MockApplicationDataContainer());
            _uiSettingsService          = A.Fake <ISettingsService>();
            _shareDataRepository        = A.Fake <IShareDataRepository>();
            _navigationService          = A.Fake <INavigationService>();

            A.CallTo(() => _schedulerProvider.Default).Returns(_testScheduler);
        }
Exemplo n.º 9
0
        internal BindableGuild(
            IMessenger messenger,
            IDiscordService discordService,
            QuarrelClient quarrelClient,
            IDispatcherService dispatcherService,
            IClipboardService clipboardService,
            ILocalizationService localizationService,
            Guild guild) :
            base(messenger, discordService, quarrelClient, dispatcherService)
        {
            _clipboardService    = clipboardService;
            _localizationService = localizationService;

            _guild = guild;
        }
Exemplo n.º 10
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;
        }
        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));
            FindNextCommand         = new RelayCommand(FindNext);
            FindPreviousCommand     = new RelayCommand(FindPrevious);
            CloseSearchPanelCommand = new RelayCommand(CloseSearchPanel);
            SelectTabThemeCommand   = new RelayCommand <string>(SelectTabTheme);
            EditTitleCommand        = new AsyncCommand(EditTitle);

            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);
        }
Exemplo n.º 12
0
 public Viewer(CasterSocket casterSocket,
               IScreenCapturer screenCapturer,
               IClipboardService clipboardService,
               IWebRtcSessionFactory webRtcSessionFactory,
               IAudioCapturer audioCapturer)
 {
     Capturer             = screenCapturer;
     CasterSocket         = casterSocket;
     WebRtcSessionFactory = webRtcSessionFactory;
     EncoderParams        = new EncoderParameters();
     ImageQuality         = defaultImageQuality;
     ClipboardService     = clipboardService;
     ClipboardService.ClipboardTextChanged += ClipboardService_ClipboardTextChanged;
     AudioCapturer = audioCapturer;
     AudioCapturer.AudioSampleReady += AudioCapturer_AudioSampleReady;
 }
Exemplo n.º 13
0
        public SystemInfoViewModel(ISystemInfoService systemInfoService, IDispatcherService dispatcherService, IClipboardService clipboardService)
        {
            Argument.IsNotNull(() => systemInfoService);
            Argument.IsNotNull(() => dispatcherService);
            Argument.IsNotNull(() => clipboardService);

            _systemInfoService = systemInfoService;
            _dispatcherService = dispatcherService;
            _clipboardService  = clipboardService;

            SystemInfo = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>(string.Empty, string.Empty)
            };

            CopyToClipboard = new Command(OnCopyToClipboardExecute);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainViewModel(IPluginService pluginService, IClipboardService clipboardService, IPortableNavigationService navigationService,
                             IDialogService dialogService)
        {
            this.pluginService     = pluginService;
            this.clipboardService  = clipboardService;
            this.navigationService = navigationService;
            this.dialogService     = dialogService;

            var version = AppVersion.Get().ProductVersion.Split('+')[0];

            Title    = $"Timesheet Parser {version}";
            JobsDate = DateTime.Now;

            GenerateCommand   = new RelayCommand(GenerateCommand_Executed);
            SubmitJobsCommand = new RelayCommand(SubmitJobs_Executed, SubmitJobs_CanExecute);
            HelpCommand       = new RelayCommand(HelpCommand_Executed);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommonServices" /> class.
 /// </summary>
 /// <param name="busyService">The busy service.</param>
 /// <param name="messageService"></param>
 /// <param name="languageService">The language service.</param>
 /// <param name="telemetryService">The telemetry service.</param>
 /// <param name="dialogService">The dialog service.</param>
 /// <param name="navigationService">The navigation service.</param>
 /// <param name="infoService">The information service.</param>
 /// <param name="converterService">The converter service.</param>
 /// <param name="dispatcherService"></param>
 /// <param name="fileService"></param>
 /// <param name="clipboardService">The clipboard service.</param>
 public CommonServices(
     IBusyService busyService,
     IMessageService messageService,
     ILanguageService languageService,
     ITelemetryService telemetryService,
     IDialogService dialogService,
     INavigationService navigationService,
     IInfoService infoService,
     IConverterService converterService,
     IDispatcherService dispatcherService,
     IFileService fileService,
     IClipboardService clipboardService)
     : base(busyService, messageService, languageService, telemetryService, dialogService, navigationService, infoService, converterService, dispatcherService)
 {
     FileService      = fileService;
     ClipboardService = clipboardService;
 }
Exemplo n.º 16
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;
        }
Exemplo n.º 17
0
        public OpenRepoCommand(
            IFileService directoryService,
            IPromptCommandService promptCommandService,
            IClipboardService clipboardService)
            : base(typeof(OpenRepoCommand).Namespace, nameof(OpenRepoCommand), HelpDefinition)
        {
            NameParameter = new CommandParameterDefinition(
                "name",
                CommandParameterDefinition.TypeValue.String,
                "Indicates the name or part of it for search and open this folder",
                "n");

            CommandParametersDefinition.Add(NameParameter);
            DirectoryService     = directoryService ?? throw new ArgumentNullException(nameof(directoryService));
            PromptCommandService = promptCommandService ?? throw new ArgumentNullException(nameof(promptCommandService));
            ClipboardService     = clipboardService ?? throw new ArgumentNullException(nameof(clipboardService));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DiscordService"/> class.
        /// </summary>
        public DiscordService(
            ILoggingService loggingService,
            IClipboardService clipboardService,
            ILocalizationService localizationService,
            IDispatcherService dispatcherService,
            IMessenger messenger,
            QuarrelClient quarrelClient)
        {
            _loggingService      = loggingService;
            _clipboardService    = clipboardService;
            _localizationService = localizationService;
            _dispatcherService   = dispatcherService;
            _messenger           = messenger;

            _quarrelClient = quarrelClient;
            RegisterEvents();
        }
Exemplo n.º 19
0
        public SaveFileDialogViewModel(
            IDialogView <SaveFileDialogResult> view,
            IClipboardService clipboard,
            IFileIconProvider fileIconProvider,
            IMessageDialogService messageDialogService)
        {
            _view = view;
            _messageDialogService = messageDialogService;

            FileExplorer = new FileExplorerViewModel(clipboard, fileIconProvider, messageDialogService, allowMultipleSelection: false);

            SaveCommand   = ReactiveCommand.Create(SaveAsync);
            CancelCommand = ReactiveCommand.Create(Cancel);

            FileExplorer.FileOpened.Subscribe(async file => await SaveAsync());

            FileExplorer.FileExplorerFolder.WhenAnyValue(vm => vm.SelectedItem).Subscribe(SelectedItemChanged);
        }
Exemplo n.º 20
0
        public MessageBoxViewModel(IMessageService messageService, IClipboardService clipboardService)
        {
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => clipboardService);

            _messageService = messageService;
            _clipboardService = clipboardService;

            CopyToClipboard = new Command(OnCopyToClipboardExecute);

            OkCommand = new TaskCommand(OnOkCommandExecuteAsync);
            YesCommand = new TaskCommand(OnYesCommandExecuteAsync);
            NoCommand = new TaskCommand(OnNoCommandExecuteAsync);
            CancelCommand = new TaskCommand(OnCancelCommandExecuteAsync);
            EscapeCommand = new TaskCommand(OnEscapeCommandExecuteAsync);

            Result = MessageResult.None;
        }
Exemplo n.º 21
0
        public MessageBoxViewModel(IMessageService messageService, IClipboardService clipboardService)
        {
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => clipboardService);

            _messageService   = messageService;
            _clipboardService = clipboardService;

            CopyToClipboard = new Command(OnCopyToClipboardExecute);

            OkCommand     = new TaskCommand(OnOkCommandExecuteAsync);
            YesCommand    = new TaskCommand(OnYesCommandExecuteAsync);
            NoCommand     = new TaskCommand(OnNoCommandExecuteAsync);
            CancelCommand = new TaskCommand(OnCancelCommandExecuteAsync);
            EscapeCommand = new TaskCommand(OnEscapeCommandExecuteAsync);

            Result = MessageResult.None;
        }
Exemplo n.º 22
0
        public void ShouldCopyDataToClipboard()
        {
            //Given
            DictionaryBase doc1 = new Document()
            {
                { "first_name", "Bill" }, { "middle_initial", "Q" }, { "last_name", "Jackson" }, { "address", "744 Nottingham St." }
            };
            DictionaryBase doc3 = new Document()
            {
                { "first_name", "Ronald" }, { "middle_initial", "Q" }, { "last_name", "Weasly" }, { "city", "Santa Rosa" }
            };
            IList <DictionaryBase> documents = new List <DictionaryBase>()
            {
                doc1, doc3
            };
            IMongoQuery query = MockRepository.GenerateStub <IMongoQuery>();

            query.Stub(q => q.RunQuery("localhost", "test", "27017", "folks:this.middle_initial == 'Q'")).Return(documents);
            IMongoQueryFactory queryFactory = MockRepository.GenerateStub <IMongoQueryFactory>();

            queryFactory.Stub(factory => factory.BuildQuery()).Return(query);
            IClipboardService   clipboardService = MockRepository.GenerateMock <IClipboardService>();
            IUserMessageService messageService   = MockRepository.GenerateMock <IUserMessageService>();

            MainViewModel viewModel = new MainViewModel()
            {
                Server             = "localhost",
                Database           = "test",
                Port               = "27017",
                Query              = "folks:this.middle_initial == 'Q'",
                MongoQueryFactory  = queryFactory,
                ClipboardService   = clipboardService,
                UserMessageService = messageService
            };

            //When
            viewModel.RunQueryCommand.Execute(null);
            viewModel.CopyToClipboardCommand.Execute(null);

            //Then
            clipboardService.AssertWasCalled(clipboard => clipboard.SetText(
                                                 "last_name\tfirst_name\tmiddle_initial\taddress\tcity\t\r\nJackson\tBill\tQ\t744 Nottingham St.\t\t\r\nWeasly\tRonald\tQ\t\tSanta Rosa\t\r\n"));
            messageService.AssertWasCalled(service => service.ShowMessage("Results copied to clipboard"));
        }
        public VaultListSitesPage(bool favorites)
            : base(true)
        {
            _favorites        = favorites;
            _folderService    = Resolver.Resolve <IFolderService>();
            _siteService      = Resolver.Resolve <ISiteService>();
            _connectivity     = Resolver.Resolve <IConnectivity>();
            _userDialogs      = Resolver.Resolve <IUserDialogs>();
            _clipboardService = Resolver.Resolve <IClipboardService>();
            _syncService      = Resolver.Resolve <ISyncService>();
            _pushNotification = Resolver.Resolve <IPushNotification>();
            _settings         = Resolver.Resolve <ISettings>();

            var cryptoService = Resolver.Resolve <ICryptoService>();

            _loadExistingData = !_settings.GetValueOrDefault(Constants.FirstVaultLoad, true) || !cryptoService.KeyChanged;

            Init();
        }
Exemplo n.º 24
0
        public MainPageViewModel(IWindowService windowService,
                                 IDataTransferService dataTransferService,
                                 IClipboardService clipboardService,
                                 IHttpService httpService,
                                 ISchedulerProvider schedulerProvider,
                                 ITextToSpeechService textToSpeechService,
                                 ApplicationSettingsService settingsService,
                                 ISettingsService settingsUiService,
                                 INavigationService navigationService)
        {
            Text = DefineClipboardObservable(windowService.IsVisibleObservable, clipboardService).ToReactiveProperty();

            SelectAllTextTrigger = DefineSelectAllTextTriggerObservable(windowService.IsVisibleObservable, schedulerProvider.Default)
                                   .ToReadonlyReactiveProperty(mode: ReactivePropertyMode.None);

            var formattedStringObservable = DefineFormattedStringObservable(Text);

            var validLinkObservable = DefineValidUriObservable(formattedStringObservable);

            ShareCommand      = validLinkObservable.ToReactiveCommand();
            KeyPressedCommand = validLinkObservable.ToReactiveCommand <object>();

            var enterPressedObservable = DefineEnterPressedObservable(KeyPressedCommand);

            var shareTrigger = DefineShareTrigger(formattedStringObservable, ShareCommand, enterPressedObservable);

            var urlTitleResolveObservable = DefineUrlTitleResolveObservable(shareTrigger, httpService);

            IsInProgress = DefineInProgressObservable(shareTrigger, urlTitleResolveObservable)
                           .ToReadonlyReactiveProperty();

            ErrorMessage = DefineErrorMessageObservable(shareTrigger, urlTitleResolveObservable)
                           .ToReadonlyReactiveProperty();

            _textToSpeechSubscription = DefineTextToSpeachObservable(urlTitleResolveObservable, settingsService, textToSpeechService)
                                        .Subscribe();

            _shareLinkSubscription = urlTitleResolveObservable.ObserveOnUI()
                                     .Subscribe(shareData => ShareLink(dataTransferService, shareData.Title, shareData.Uri));

            SettingsCommand = new DelegateCommand(settingsUiService.ShowSettings);
            HistoryCommand  = new DelegateCommand(() => navigationService.Navigate("History", null));
        }
Exemplo n.º 25
0
        public SettingsPageViewModel()
        {
            _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _cryptoService        = ServiceContainer.Resolve <ICryptoService>("cryptoService");
            _stateService         = ServiceContainer.Resolve <IStateService>("stateService");
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _environmentService   = ServiceContainer.Resolve <IEnvironmentService>("environmentService");
            _messagingService     = ServiceContainer.Resolve <IMessagingService>("messagingService");
            _vaultTimeoutService  = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService");
            _syncService          = ServiceContainer.Resolve <ISyncService>("syncService");
            _biometricService     = ServiceContainer.Resolve <IBiometricService>("biometricService");
            _policyService        = ServiceContainer.Resolve <IPolicyService>("policyService");
            _localizeService      = ServiceContainer.Resolve <ILocalizeService>("localizeService");
            _keyConnectorService  = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService");
            _clipboardService     = ServiceContainer.Resolve <IClipboardService>("clipboardService");

            GroupedItems = new ObservableRangeCollection <ISettingsPageListItem>();
            PageTitle    = AppResources.Settings;
        }
Exemplo n.º 26
0
        public ConsoleViewModel(
            IConsoleService consoleService,
            ISerialPortService serialPortService,
            ISettingsService settingsService,
            IClipboardService clipboardService,
            IDialogService dialogService,
            IApplicationServices applicationServices,
            IWindowService windowService,
            IPrinterService printerService,
            ITaskHelpers taskHelpers)
        {
            // Services

            ConsoleService      = consoleService;
            SerialPortService   = serialPortService;
            SettingsService     = settingsService;
            ClipboardService    = clipboardService;
            DialogService       = dialogService;
            ApplicationServices = applicationServices;
            WindowService       = windowService;
            PrinterService      = printerService;
            TaskHelpers         = taskHelpers;


            // Commands

            NewSessionCommand        = new AsyncRelayCommand(NewSessionCommandImpl);
            EndSessionCommand        = new RelayCommand(EndSessionCommandImpl);
            SaveCommand              = new AsyncRelayCommand(SaveCommandImpl);
            PrintCommand             = new RelayCommand(PrintCommandImpl);
            ClearCommand             = new RelayCommand(ClearCommandImpl);
            CopyCommand              = new RelayCommand(CopyCommandImpl);
            PasteCommand             = new AsyncRelayCommand(PasteCommandImpl);
            PasteAndSendCommand      = new AsyncRelayCommand(PasteAndSendCommandImpl);
            PasteAndSendLinesCommand = new AsyncRelayCommand(PasteAndSendLinesCommandImpl);
            CutCommand       = new AsyncRelayCommand(CutCommandImpl);
            SelectAllCommand = new RelayCommand(SelectAllCommandImpl);
            QuitCommand      = new RelayCommand(QuitCommandImpl);
            SettingsCommand  = new RelayCommand(SettingsCommandImpl);

            Title = "Serial Port Utility";
        }
Exemplo n.º 27
0
        internal BindableGuildFolder(
            IMessenger messenger,
            IDiscordService discordService,
            QuarrelClient quarrelClient,
            IDispatcherService dispatcherService,
            IClipboardService clipboardService,
            ILocalizationService localizationService,
            GuildFolder folder) :
            base(messenger, discordService, quarrelClient, dispatcherService)
        {
            _folder = folder;

            var guilds = _folder.GetGuilds();

            Children = new ObservableCollection <BindableGuild>();
            foreach (var guild in guilds)
            {
                Children.Add(new BindableGuild(messenger, discordService, quarrelClient, dispatcherService, clipboardService, localizationService, guild));
            }
        }
Exemplo n.º 28
0
    public QuickCommands(Lazy <IQuickAccessService> service,
                         Lazy <IQuickAccessViewModel> viewModel,
                         IClipboardService clipboardService,
                         IStatusBar statusBar)
    {
        CopyCommand = new DelegateCommand <object>(o =>
        {
            var text = o.ToString() ?? "";
            clipboardService.SetText(text);
            statusBar.PublishNotification(new PlainNotification(NotificationType.Info, "Copied " + text));
            viewModel.Value.CloseSearch();
        });

        SetSearchCommand = new DelegateCommand <object>(o =>
        {
            viewModel.Value.OpenSearch(o.ToString());
        });

        NoCommand = new DelegateCommand(() => { });
    }
        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;

            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(async() => await FindNext().ConfigureAwait(false));
            FindPreviousCommand     = new RelayCommand(async() => await FindPrevious().ConfigureAwait(false));
            CloseSearchPanelCommand = new RelayCommand(CloseSearchPanel);
            SelectTabThemeCommand   = new RelayCommand <string>(SelectTabTheme);
            EditTitleCommand        = new AsyncCommand(EditTitle);
        }
Exemplo n.º 30
0
        public FFmpegLogViewModel(IClipboardService ClipboardService,
                                  FFmpegLog FFmpegLog)
        {
            LogItems = FFmpegLog
                       .LogItems
                       .ToReadOnlyReactiveCollection();

            LogItems
            .ObserveAddChanged()
            .Subscribe(M => SelectedLogItem = M);

            LogItems
            .ObserveRemoveChanged()
            .Subscribe(M =>
            {
                if (LogItems.Count > 0)
                {
                    SelectedLogItem = LogItems[0];
                }
            });

            if (LogItems.Count > 0)
            {
                SelectedLogItem = LogItems[0];
            }

            CopyToClipboardCommand = this
                                     .ObserveProperty(M => M.SelectedLogItem)
                                     .Select(M => M != null)
                                     .ToReactiveCommand()
                                     .WithSubscribe(() =>
            {
                ClipboardService.SetText(SelectedLogItem.GetCompleteLog());
            });

            RemoveCommand = this
                            .ObserveProperty(M => M.SelectedLogItem)
                            .Select(M => M != null)
                            .ToReactiveCommand()
                            .WithSubscribe(() => FFmpegLog.Remove(SelectedLogItem));
        }
Exemplo n.º 31
0
        public DeviceActionService(
            IClipboardService clipboardService,
            IStateService stateService,
            IMessagingService messagingService,
            IBroadcasterService broadcasterService,
            Func <IEventService> eventServiceFunc)
        {
            _clipboardService   = clipboardService;
            _stateService       = stateService;
            _messagingService   = messagingService;
            _broadcasterService = broadcasterService;
            _eventServiceFunc   = eventServiceFunc;

            _broadcasterService.Subscribe(nameof(DeviceActionService), (message) =>
            {
                if (message.Command == "selectFileCameraPermissionDenied")
                {
                    _cameraPermissionsDenied = true;
                }
            });
        }
Exemplo n.º 32
0
 public ViewModelService(IDialogService dialogService, IThemeService themeService, INotificationService notificationService, IProgressBarService progressBarService, IConfigurationService configurationService, IInstallService installService, IProductService productService, IMsiService msiService, IInstallerFileBundleProviderFactory installerFileBundleProviderFactory, IUriService uriService, IClipboardService clipboardService, IIOService ioService, string tmpFolderPath)
 {
     _dialogService        = dialogService ?? throw new ArgumentNullException(nameof(dialogService));
     _themeService         = themeService ?? throw new ArgumentNullException(nameof(themeService));
     _notificationService  = notificationService ?? throw new ArgumentNullException(nameof(notificationService));
     _progressBarService   = progressBarService ?? throw new ArgumentNullException(nameof(progressBarService));
     _configurationService = configurationService ?? throw new ArgumentNullException(nameof(configurationService));
     _installService       = installService ?? throw new ArgumentNullException(nameof(installService));
     _productService       = productService ?? throw new ArgumentNullException(nameof(productService));
     _msiService           = msiService ?? throw new ArgumentNullException(nameof(msiService));
     _installerFileBundleProviderFactory = installerFileBundleProviderFactory ?? throw new ArgumentNullException(nameof(installerFileBundleProviderFactory));
     _uriService       = uriService ?? throw new ArgumentNullException(nameof(uriService));
     _clipboardService = clipboardService ?? throw new ArgumentNullException(nameof(clipboardService));
     _ioService        = ioService ?? throw new ArgumentNullException(nameof(ioService));
     if (String.IsNullOrEmpty(tmpFolderPath))
     {
         throw new ArgumentNullException(nameof(tmpFolderPath));
     }
     _downloadFolderPath = GetDownloadFolderPath(tmpFolderPath);
     _logFolderPath      = GetLogFolderPath(tmpFolderPath);
 }
Exemplo n.º 33
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="translationService"></param>
        /// <param name="iconsService"></param>
        /// <param name="clipboardService"></param>
        public EntryListViewModel(ITranslationService translationService,
                                  IIconsService iconsService,
                                  IClipboardService clipboardService)
            : base(translationService)
        {
            this.iconsService     = iconsService;
            this.clipboardService = clipboardService;

            iconsService.IconDownloadedEvent += IconDownloadedEventHandler;

            basePasswordEntries = new List <PasswordEntryModel>();

            Messenger.Default.Register <DatabaseLoadedMessage>(this, DatabaseLoadedHandler);
            Messenger.Default.Register <DatabaseUnloadedMessage>(this, DatabaseUnloadedHandler);
            Messenger.Default.Register <EntryEditedMessage>(this, EntryEditedHandler);
            Messenger.Default.Register <EntryAddedMessage>(this, EntryAddedHandler);
            Messenger.Default.Register <EntryDeletedMessage>(this, EntryDeletedHandler);
            Messenger.Default.Register <CategorySelectedMessage>(this, CategorySelectedHandler);
            Messenger.Default.Register <CategoryDeletedMessage>(this, CategoryDeletedHandler);
            Messenger.Default.Register <CategoryEditedMessage>(this, CategoryEditedHandler);
        }
Exemplo n.º 34
0
        public FFmpegLogItem(string Name,
                             string Args,
                             IClipboardService ClipboardService)
        {
            this.Name = Name;
            this.Args = Args;

            _complete.AppendLine("ARGS:");
            _complete.AppendLine("-------------");
            _complete.AppendLine(Args);
            _complete.AppendLine();
            _complete.AppendLine("OUTPUT:");
            _complete.AppendLine("-------------");

            CopyToClipboardCommand = new DelegateCommand(() =>
            {
                ClipboardService.SetText(_complete.ToString());
            });

            RemoveCommand = new DelegateCommand(() => RemoveRequested?.Invoke());
        }
Exemplo n.º 35
0
        public FileController(IMessageService messageService, IFileDialogService fileDialogService, IShellService shellService, IEnvironmentService environmentService, 
            IClipboardService clipboardService, FileService fileService, ExportFactory<SaveChangesViewModel> saveChangesViewModelFactory)
        {
            this.messageService = messageService;
            this.fileDialogService = fileDialogService;
            this.shellService = shellService;
            this.environmentService = environmentService;
            this.clipboardService = clipboardService;
            this.fileService = fileService;
            this.saveChangesViewModelFactory = saveChangesViewModelFactory;
            this.newCSharpCommand = new DelegateCommand(NewCSharpFile);
            this.newVisualBasicCommand = new DelegateCommand(NewVisualBasicFile);
            this.newCSharpFromClipboardCommand = new DelegateCommand(NewCSharpFromClipboard, CanNewFromClipboard);
            this.newVisualBasicFromClipboardCommand = new DelegateCommand(NewVisualBasicFromClipboard, CanNewFromClipboard);
            this.openCommand = new DelegateCommand(OpenFile);
            this.closeCommand = new DelegateCommand(CloseFile, CanCloseFile);
            this.closeAllCommand = new DelegateCommand(CloseAll, CanCloseAll);
            this.saveCommand = new DelegateCommand(SaveFile, CanSaveFile);
            this.saveAsCommand = new DelegateCommand(SaveAsFile, CanSaveAsFile);

            this.fileService.NewCSharpCommand = newCSharpCommand;
            this.fileService.NewVisualBasicCommand = newVisualBasicCommand;
            this.fileService.NewCSharpFromClipboardCommand = newCSharpFromClipboardCommand;
            this.fileService.NewVisualBasicFromClipboardCommand = newVisualBasicFromClipboardCommand;
            this.fileService.OpenCommand = openCommand;
            this.fileService.CloseCommand = closeCommand;
            this.fileService.CloseAllCommand = closeAllCommand;
            this.fileService.SaveCommand = saveCommand;
            this.fileService.SaveAsCommand = saveAsCommand;

            this.cSharpFileType = new FileType(Resources.CSharpFile, ".cs");
            this.visualBasicFileType = new FileType(Resources.VisualBasicFile, ".vb");
            this.allFilesType = new FileType(Resources.CodeFile, ".cs;*.vb");
            this.observedDocumentFiles = new List<DocumentFile>();
            PropertyChangedEventManager.AddHandler(fileService, FileServicePropertyChanged, "");
            shellService.Closing += ShellServiceClosing;
        }
Exemplo n.º 36
0
 public ClipboardObject(IClipboardService service)
 {
     this.ClipboardService = service;
 }
        public ItemFilterScriptViewModel(IItemFilterBlockViewModelFactory itemFilterBlockViewModelFactory,
                                         IItemFilterBlockTranslator blockTranslator,
                                         IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
                                         IItemFilterPersistenceService persistenceService,
                                         IMessageBoxService messageBoxService,
                                         IClipboardService clipboardService,
                                         IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
        {
            _itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory;
            _blockTranslator = blockTranslator;
            _avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
            _avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
            _persistenceService = persistenceService;
            _messageBoxService = messageBoxService;
            _clipboardService = clipboardService;
            _blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
            _itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
            
            ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
            ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
            CloseCommand = new RelayCommand(async () => await OnCloseCommand());
            DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null);
            MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null);
            MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null);
            MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => SelectedBlockViewModel != null);
            MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null);
            AddBlockCommand = new RelayCommand(OnAddBlockCommand);
            AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null);
            DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, HasSelectedEnabledBlock);
            EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, HasSelectedDisabledBlock);
            CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
            CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null);
            PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
            PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => SelectedBlockViewModel != null);
            ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand);
            CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand);

            var icon = new BitmapImage();
            icon.BeginInit();
            icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/script_icon.png");
            icon.EndInit();
            IconSource = icon;
        }
Exemplo n.º 38
0
        public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
                                   IItemFilterScriptTranslator itemFilterScriptTranslator,
                                   IReplaceColorsViewModel replaceColorsViewModel,
                                   IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
                                   ISettingsPageViewModel settingsPageViewModel,
                                   IThemeProvider themeProvider,
                                   IThemeService themeService,
                                   IMessageBoxService messageBoxService,
                                   IClipboardService clipboardService)
        {
            _itemFilterScriptRepository = itemFilterScriptRepository;
            _itemFilterScriptTranslator = itemFilterScriptTranslator;
            _replaceColorsViewModel = replaceColorsViewModel;
            _avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
            SettingsPageViewModel = settingsPageViewModel;
            _themeProvider = themeProvider;
            _themeService = themeService;
            _messageBoxService = messageBoxService;
            _clipboardService = clipboardService;

            NewScriptCommand = new RelayCommand(OnNewScriptCommand);
            CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
            OpenScriptCommand = new RelayCommand(async () => await OnOpenScriptCommand());
            OpenThemeCommand = new RelayCommand(async () => await OnOpenThemeCommandAsync());

            SaveCommand = new RelayCommand(async () => await OnSaveDocumentCommandAsync(), ActiveDocumentIsEditable);
            SaveAsCommand = new RelayCommand(async () => await OnSaveAsCommandAsync(), ActiveDocumentIsEditable);
            CloseCommand = new RelayCommand(OnCloseDocumentCommand, ActiveDocumentIsEditable);

            CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
            CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
            PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
            PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);

            MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
            MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
            MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
            MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);

            AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
            AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
            DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
            DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
            EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
            OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
            ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);

            CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript);
            ApplyThemeToScriptCommand = new RelayCommand(async () => await OnApplyThemeToScriptCommandAsync(), () => ActiveDocumentIsScript);
            EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript);

            AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
            AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
            AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
            DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable && _avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);

            ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
            CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);

            ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript);
            ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript);

            if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
            {
                SetItemFilterScriptDirectory();
            }

            var icon = new BitmapImage();
            icon.BeginInit();
            icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/filtration_icon.png");
            icon.EndInit();
            Icon = icon;

            Messenger.Default.Register<ThemeClosedMessage>(this, message =>
            {
                if (message.ClosedViewModel == null) return;
                AvalonDockWorkspaceViewModel.CloseDocument(message.ClosedViewModel);
            });

            Messenger.Default.Register<NotificationMessage>(this, message =>
            {
                switch (message.Notification)
                {
                    case "ActiveDocumentChanged":
                    {
                        CopyScriptCommand.RaiseCanExecuteChanged();
                        SaveCommand.RaiseCanExecuteChanged();
                        SaveAsCommand.RaiseCanExecuteChanged();
                        CloseCommand.RaiseCanExecuteChanged();
                        CopyBlockCommand.RaiseCanExecuteChanged();
                        PasteCommand.RaiseCanExecuteChanged();
                        ReplaceColorsCommand.RaiseCanExecuteChanged();
                        ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
                        EditMasterThemeCommand.RaiseCanExecuteChanged();
                        CreateThemeCommand.RaiseCanExecuteChanged();
                        RaisePropertyChanged("ActiveDocumentIsScript");
                        RaisePropertyChanged("ActiveDocumentIsTheme");
                        RaisePropertyChanged("ShowAdvancedStatus");
                        break;
                    }
                    case "NewScript":
                    {
                        OnNewScriptCommand();
                        break;
                    }
                    case "OpenScript":
                    {
#pragma warning disable 4014
                        OnOpenScriptCommand();
#pragma warning restore 4014
                        break;
                    }
                    case "ShowLoadingBanner":
                    {
                        ShowLoadingBanner = true;
                        break;
                    }
                    case "HideLoadingBanner":
                    {
                        ShowLoadingBanner = false;
                        break;
                    }
                }
            });
        }
Exemplo n.º 39
0
 public CopyTweetUrlCommand(string urlFormat, ISelection selection, IClipboardService clipboardService)
 {
     _urlFormat = urlFormat;
     _selection = selection;
     _clipboardService = clipboardService;
 }