public LayoutConverter([NotNull] IWindowFactory windowFactory, [NotNull] IViewFactoryProvider viewFactoryProvider, [NotNull] ISchedulerProvider schedulerProvider, [NotNull] GeneralOptionsViewModel generalOptionsViewModel) { if (windowFactory == null) { throw new ArgumentNullException(nameof(windowFactory)); } if (viewFactoryProvider == null) { throw new ArgumentNullException(nameof(viewFactoryProvider)); } if (schedulerProvider == null) { throw new ArgumentNullException(nameof(schedulerProvider)); } if (generalOptionsViewModel == null) { throw new ArgumentNullException(nameof(generalOptionsViewModel)); } _windowFactory = windowFactory; _viewFactoryProvider = viewFactoryProvider; _schedulerProvider = schedulerProvider; _generalOptionsViewModel = generalOptionsViewModel; }
void ShowErrorMessage() { if (MessageBox.Show(Strings.Get($"CalDav Synchronizer failed to load due to the following exception: {Environment.NewLine}{_loadExceptionAsString}{Environment.NewLine}{Environment.NewLine}Do you want to open the log file ?"), ComponentContainer.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { GeneralOptionsViewModel.ShowLogFileWithouWarning(); } }
public void WhenLastCheckIsZero_ThenLastUpdateCheckReturnsNever() { var viewModel = new GeneralOptionsViewModel( this.settingsRepository, this.protocolRegistryMock.Object, new HelpService()); Assert.AreEqual("never", viewModel.LastUpdateCheck); }
public WinFormOptionsPage() { InitializeComponent(); _optionsVm = new GeneralOptionsViewModel(); _page = Repository.Instance.ViewManager.CreateViewFor(_optionsVm).View; wpfControl.Child = _page; this.MonitorVisibility(); }
public bool ShowGeneralOptions(GeneralOptionsViewModel generalOptionsViewModel) { var window = new GeneralOptionsWindow(); window.DataContext = generalOptionsViewModel; window.Icon = BitmapFrame.Create(new Uri("pack://application:,,,/CalDavSynchronizer;component/Resources/ApplicationIcon.ico")); ElementHost.EnableModelessKeyboardInterop(window); return(window.ShowDialog().GetValueOrDefault(false)); }
public void SetUp() { hkcu.DeleteSubKeyTree(TestKeyPath, false); var baseKey = hkcu.CreateSubKey(TestKeyPath); this.settingsRepository = new ApplicationSettingsRepository(baseKey); this.protocolRegistryMock = new Mock <IAppProtocolRegistry>(); this.viewModel = new GeneralOptionsViewModel( this.settingsRepository, this.protocolRegistryMock.Object, new HelpService()); }
public WindowViewModel(IObjectProvider objectProvider, IWindowFactory windowFactory, ILogger logger, IWindowsController windowsController, RecentFilesViewModel recentFilesViewModel, GeneralOptionsViewModel generalOptionsViewModel, ISchedulerProvider schedulerProvider) { _logger = logger; _windowsController = windowsController; RecentFiles = recentFilesViewModel; GeneralOptions = generalOptionsViewModel; _schedulerProvider = schedulerProvider; _objectProvider = objectProvider; InterTabClient = new InterTabClient(windowFactory); OpenFileCommand = new Command(OpenFile); ShowInGitHubCommand = new Command(() => Process.Start("https://github.com/RolandPheasant")); ZoomOutCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale + 5; }); ZoomInCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale - 5; }); SaveLayoutCommand = new Command(WalkTheLayout); ExitCommmand = new Command(() => Application.Current.Shutdown()); Version = $"v{Assembly.GetEntryAssembly().GetName().Version.ToString(3)}"; var fileDropped = DropMonitor.Dropped.Subscribe(OpenFile); var isEmptyChecker = Views.ToObservableChangeSet() .ToCollection() .Select(items => items.Count) .StartWith(0) .Select(count => count == 0) .Subscribe(isEmpty => IsEmpty = isEmpty); var openRecent = recentFilesViewModel.OpenFileRequest .Subscribe(file => { MenuIsOpen = false; OpenFile(file); }); _cleanUp = new CompositeDisposable(recentFilesViewModel, isEmptyChecker, fileDropped, DropMonitor, openRecent, Disposable.Create(() => { Views.Select(vc => vc.Content) .OfType <IDisposable>() .ForEach(d => d.Dispose()); })); }
public void WhenBrowserIntegrationChanged_ThenIsDirtyIsTrueUntilApplied() { var viewModel = new GeneralOptionsViewModel( this.settingsRepository, this.protocolRegistryMock.Object, new HelpService()); Assert.IsFalse(viewModel.IsDirty); viewModel.IsBrowserIntegrationEnabled = !viewModel.IsBrowserIntegrationEnabled; Assert.IsTrue(viewModel.IsDirty); }
public void WhenSettingDisabled_ThenIsUpdateCheckEnabledIsTrue() { var settings = this.settingsRepository.GetSettings(); settings.IsUpdateCheckEnabled.BoolValue = false; this.settingsRepository.SetSettings(settings); var viewModel = new GeneralOptionsViewModel( this.settingsRepository, this.protocolRegistryMock.Object, new HelpService()); Assert.IsFalse(viewModel.IsUpdateCheckEnabled); }
public void WhenBrowserIntegrationDisabled_ThenApplyChangesUnregistersProtocol() { var viewModel = new GeneralOptionsViewModel( this.settingsRepository, this.protocolRegistryMock.Object, new HelpService()); viewModel.IsBrowserIntegrationEnabled = false; viewModel.ApplyChanges(); this.protocolRegistryMock.Verify(r => r.Unregister( It.Is <string>(s => s == IapRdpUrl.Scheme)), Times.Once); }
public void WhenSettingEnabled_ThenIsDeviceCertificateAuthenticationEnabledIsTrue() { var settings = this.settingsRepository.GetSettings(); settings.IsDeviceCertificateAuthenticationEnabled.BoolValue = true; this.settingsRepository.SetSettings(settings); var viewModel = new GeneralOptionsViewModel( this.settingsRepository, this.protocolRegistryMock.Object, new HelpService()); Assert.IsTrue(viewModel.IsDeviceCertificateAuthenticationEnabled); }
public void WhenLastCheckIsNonZero_ThenLastUpdateCheckReturnsNever() { var settings = this.settingsRepository.GetSettings(); settings.LastUpdateCheck.LongValue = 1234567L; this.settingsRepository.SetSettings(settings); var viewModelWithCustomSettings = new GeneralOptionsViewModel( this.settingsRepository, this.protocolRegistryMock.Object, new HelpService()); Assert.AreNotEqual("never", viewModelWithCustomSettings.LastUpdateCheck); }
public void WhenDisablingUpdateCheck_ThenChangeIsApplied() { var settings = this.settingsRepository.GetSettings(); settings.IsUpdateCheckEnabled.BoolValue = true; this.settingsRepository.SetSettings(settings); var viewModel = new GeneralOptionsViewModel( this.settingsRepository, this.protocolRegistryMock.Object, new HelpService()); viewModel.IsUpdateCheckEnabled = false; viewModel.ApplyChanges(); settings = this.settingsRepository.GetSettings(); Assert.IsFalse(settings.IsUpdateCheckEnabled.BoolValue); }
public async Task ShowGeneralOptionsAsync() { await EditGeneralOptionsAsync( o => { var generalOptionsViewModel = new GeneralOptionsViewModel { Options = o.Clone() }; if (_uiService.ShowGeneralOptions(generalOptionsViewModel)) { return(Tuple.Create(true, generalOptionsViewModel.Options)); } else { return(Tuple.Create(false, (GeneralOptions)null)); } }); }
public WindowViewModel(IObjectProvider objectProvider, IWindowFactory windowFactory, ILogger logger, IWindowsController windowsController, RecentFilesViewModel recentFilesViewModel, GeneralOptionsViewModel generalOptionsViewModel, ISchedulerProvider schedulerProvider, IApplicationStatePublisher applicationStatePublisher) { _logger = logger; _windowsController = windowsController; RecentFiles = recentFilesViewModel; GeneralOptions = generalOptionsViewModel; _schedulerProvider = schedulerProvider; _objectProvider = objectProvider; InterTabClient = new InterTabClient(windowFactory); OpenFileCommand = new Command(OpenFile); ShowInGitHubCommand = new Command(() => Process.Start("https://github.com/RolandPheasant")); ZoomOutCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale + 5; }); ZoomInCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale - 5; }); CollectMemoryCommand = new Command(() => { //Diagnostics [useful for memory testing] GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }); ExitCommmand = new Command(() => { applicationStatePublisher.Publish(ApplicationState.ShuttingDown); Application.Current.Shutdown(); }); WindowExiting = () => { applicationStatePublisher.Publish(ApplicationState.ShuttingDown); }; Version = $"v{Assembly.GetEntryAssembly().GetName().Version.ToString(3)}"; var fileDropped = DropMonitor.Dropped.Subscribe(OpenFile); var isEmptyChecker = Views.ToObservableChangeSet() .ToCollection() .Select(items => items.Count) .StartWith(0) .Select(count => count == 0) .LogErrors(logger) .Subscribe(isEmpty => IsEmpty = isEmpty); var openRecent = recentFilesViewModel.OpenFileRequest .LogErrors(logger) .Subscribe(file => { MenuIsOpen = false; OpenFile(file); }); var selectedChange = this.WhenValueChanged(vm => vm.Selected) .Subscribe(selected => { var currentSelection = selected?.Content as ISelectedAware; Views.Where(hv => !hv.Equals(selected)) .Select(hv => hv.Content) .OfType <ISelectedAware>() .ForEach(selectedAware => selectedAware.IsSelected = false); if (currentSelection != null) { currentSelection.IsSelected = true; } }); _cleanUp = new CompositeDisposable(recentFilesViewModel, isEmptyChecker, fileDropped, DropMonitor, openRecent, selectedChange, Disposable.Create(() => { Views.Select(vc => vc.Content) .OfType <IDisposable>() .ForEach(d => d.Dispose()); })); }
public void Reset() { _optionsVm = new GeneralOptionsViewModel(); _page.DataContext = _optionsVm; }
public bool ShowGeneralOptions(GeneralOptionsViewModel generalOptionsViewModel) { return(false); }
public WindowViewModel(IObjectProvider objectProvider, IWindowFactory windowFactory, ILogger logger, IWindowsController windowsController, RecentFilesViewModel recentFilesViewModel, GeneralOptionsViewModel generalOptionsViewModel, ISchedulerProvider schedulerProvider, DialogViewModel dialogviewmodel, FileOpenViewModel fileopenviewmodel) { //This function handles the pinning //If the user decides to pin a tab the function will lock that tab and reorder the effected tabs Pinning = new ActionCommand(o => { var viewsarray = Views.ToList(); var pinnedone = Views.FirstOrDefault(c => c.Header.Equals(o)); var pinnedindex = Views.IndexOf(pinnedone); bool actualpinned = false; ViewContainer oldtab = null; if (o.GetType().IsEquivalentTo(typeof(FilesHeader))) { ((FilesHeader)pinnedone.Header).IsPinned = !((FilesHeader)pinnedone.Header).IsPinned; actualpinned = ((FilesHeader)pinnedone.Header).IsPinned; } else { ((FileHeader)pinnedone.Header).IsPinned = !((FileHeader)pinnedone.Header).IsPinned; actualpinned = ((FileHeader)pinnedone.Header).IsPinned; } if (actualpinned) { PinnedNumber += 1; PinnedNumber2 += 1; oldtab = Views[pinnedindex]; viewsarray.Remove(viewsarray[pinnedindex]); viewsarray.Insert(PinnedNumber, oldtab); } else { PinnedNumber -= 1; PinnedNumber2 -= 1; oldtab = Views[pinnedindex]; viewsarray.Remove(viewsarray[pinnedindex]); viewsarray.Insert(PinnedNumber2, oldtab); } Views = new ObservableCollection <ViewContainer>(viewsarray); OnPropertyChanged("Views"); OnPropertyChanged("PinnedNumber2"); }); _logger = logger; _windowsController = windowsController; RecentFiles = recentFilesViewModel; GeneralOptions = generalOptionsViewModel; Dialog = dialogviewmodel; _schedulerProvider = schedulerProvider; _objectProvider = objectProvider; InterTabClient = new InterTabClient(windowFactory); FileOpenDialogCommand = new Command(OpenFileDialog); FileOpen = new FileOpenViewModel(OpenFile); ShowInGitHubCommand = new Command(() => Process.Start("https://github.com/RolandPheasant")); Views.CollectionChanged += Views_CollectionChanged; ZoomOutCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale + 5; }); ZoomInCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale - 5; }); SaveLayoutCommand = new Command(WalkTheLayout); ExitCommmand = new Command(() => Application.Current.Shutdown()); Version = $"v{Assembly.GetEntryAssembly().GetName().Version.ToString(3)}"; var fileDropped = DropMonitor.Dropped.Subscribe(async t => await OpenFile(t)); var isEmptyChecker = Views.ToObservableChangeSet() .ToCollection() .Select(items => items.Count) .StartWith(0) .Select(count => count == 0) .Subscribe(isEmpty => IsEmpty = isEmpty); var openRecent = recentFilesViewModel.OpenFileRequest .Subscribe(file => { MenuIsOpen = false; OpenFile(file); }); _cleanUp = new CompositeDisposable(recentFilesViewModel, isEmptyChecker, fileDropped, DropMonitor, openRecent, Disposable.Create(() => { Views.Select(vc => vc.Content) .OfType <IDisposable>() .ForEach(d => d.Dispose()); })); }
internal GeneralOptionsView(GeneralOptionsViewModel viewModel) { InitializeComponent(); DataContext = viewModel; }
public GeneralOptions(GeneralOptionsViewModel viewModel) { _viewModel = Preconditions.CheckNotNull(viewModel, nameof(viewModel)); _view = new GeneralOptionsView(viewModel); }
public void SetUp() { _uut = new GeneralOptionsViewModel(); _notificationHelper = _uut.ErrorNotificationRequest.NewTestHelper(); }