public void TestInitialize() { _logger = Substitute.For <ILogger>(); _appConfig = new Common.Configuration.Config(); _blockedTraffic = Substitute.For <IBlockedTraffic>(); _forwardedTraffic = Substitute.For <IForwardedTraffic>(); _scheduler = Substitute.For <IScheduler>(); _modals = Substitute.For <IModals>(); _dialogs = Substitute.For <IDialogs>(); _timer = Substitute.For <ISchedulerTimer>(); _timer.When(x => x.Start()).Do(x => _timerIsEnabled = true); _timer.When(x => x.Stop()).Do(x => _timerIsEnabled = false); _timer.When(x => x.IsEnabled = Arg.Do <bool>(value => _timerIsEnabled = value)); _timer.IsEnabled.Returns(_ => _timerIsEnabled); _scheduler.Timer().Returns(_timer); }
public TagsViewModel(IPushManager pushManager, IDialogs dialogs) { var tags = pushManager as IPushTagSupport; this.Add = ReactiveCommand.CreateFromTask(async() => { var result = await dialogs.Input("Name of tag?"); if (!result.IsEmpty()) { await tags.AddTag(result); this.Load.Execute(null); } }); this.Clear = ReactiveCommand.CreateFromTask(async() => { var result = await dialogs.Confirm("Are you sure you wish to clear all tags?"); if (result) { await tags.ClearTags(); this.Load.Execute(null); } }); this.Load = ReactiveCommand.Create(() => { this.Tags = tags .RegisteredTags .Select(tag => new CommandItem { Text = tag, PrimaryCommand = ReactiveCommand.CreateFromTask(async() => { var result = await dialogs.Confirm($"Are you sure you wish to remove tag '{tag}'?"); if (result) { await tags.RemoveTag(tag); this.Load.Execute(null); } }) }) .ToList(); this.RaisePropertyChanged(nameof(this.Tags)); }); }
private static MenuViewModel CreateSut(out ProjectData projectData, out IDialogs dialogs, out IReportFactory reportFactory) { var windowManager = Substitute.For <IWindowManager>(); var fileSystem = Substitute.For <IFileSystem>(); var processApi = Substitute.For <IProcess>(); dialogs = Substitute.For <IDialogs>(); var busy = Substitute.For <IBusy>(); reportFactory = Substitute.For <IReportFactory>(); var settings = new Settings(); projectData = new ProjectData(settings, windowManager, dialogs, fileSystem, processApi); var sut = new MenuViewModel(projectData, busy, reportFactory, processApi, dialogs); return(sut); }
public SettingsViewModel(ITripTrackerManager manager, IDialogs dialogs) { this.IsEnabled = manager.TrackingType == null; this.UseAutomotive = manager.TrackingType == TripTrackingType.Automotive; this.UseCycling = manager.TrackingType == TripTrackingType.Cycling; this.UseRunning = manager.TrackingType == TripTrackingType.Running; this.UseWalking = manager.TrackingType == TripTrackingType.Walking; this.UseOnFoot = manager.TrackingType == TripTrackingType.OnFoot; this.UseExercise = manager.TrackingType == TripTrackingType.Exercise; this.ToggleMonitoring = ReactiveCommand.CreateFromTask ( async() => { var access = await manager.RequestAccess(); if (access != AccessState.Available) { await dialogs.Alert("Invalid Access - " + access); } else { if (!this.IsEnabled) { await manager.StopTracking(); } else { var type = this.GetTrackingType().Value; await manager.StartTracking(type); } this.IsEnabled = !this.IsEnabled; this.RaisePropertyChanged(nameof(this.MonitoringText)); } }, this.WhenAny( x => x.UseAutomotive, x => x.UseRunning, x => x.UseWalking, x => x.UseCycling, x => x.UseOnFoot, x => x.UseExercise, (auto, run, walk, cycle, foot, ex) => this.GetTrackingType() != null ) ); }
// CONSTRUCTOR public ScreenDX(IAppWindow Parent, IDialogs Dialogs, ISettings Settings, uint MessageDisplayDuration) { dialogs = Dialogs; settings = Settings; advancedView = Settings.AdvancedView; isGreenScreen = Settings.GreenScreen; messageDisplayDuration = MessageDisplayDuration; cellsNormal = new RawRectangleF[ScreenMetrics.NUM_SCREEN_CHARS]; cellsWide = new RawRectangleF[ScreenMetrics.NUM_SCREEN_CHARS]; shadowScreen = new byte[ScreenMetrics.NUM_SCREEN_CHARS]; Views.View.OnUserCommand += UserCommandHandler; Initialize(Parent); }
protected AbstractLogViewModel(IDialogs dialogs) { this.Dialogs = dialogs; this.Logs = new ObservableList <TItem>(); this.Load = ReactiveCommand.CreateFromTask(async() => { var logs = await this.LoadLogs(); this.Logs.ReplaceAll(logs); }); this.Clear = ReactiveCommand.CreateFromTask(this.DoClear); this.BindBusyCommand(this.Load); this.WhenAnyValue(x => x.SelectedItem) .WhereNotNull() .SubscribeAsync(x => this.OnSelected(x)) .DisposedBy(this.DestroyWith); }
public static async Task <bool> AlertAccess(this IDialogs dialogs, AccessState access) { switch (access) { case AccessState.Available: return(true); case AccessState.Restricted: await dialogs.Alert("WARNING: Access is restricted"); return(true); default: await dialogs.Alert("Invalid Access State: " + access); return(false); } }
public NfcReadViewModel(IDialogs dialogs, INfcManager?nfcManager = null) { this.dialogs = dialogs; this.CheckPermission = ReactiveCommand.CreateFromTask( () => this.DoCheckPermission(nfcManager) ); this.Clear = ReactiveCommand.Create(() => this.NDefRecords.Clear() ); this.Read = ReactiveCommand.CreateFromTask( async() => { await this.DoCheckPermission(nfcManager); if (this.Access == AccessState.Available) { this.ManageObservable(nfcManager.SingleRead()); } }, this.WhenAny( x => x.IsListening, x => !x.GetValue() ) ); this.Continuous = ReactiveCommand.CreateFromTask(async() => { await this.DoCheckPermission(nfcManager); if (this.Access == AccessState.Available) { if (this.IsListening) { this.IsListening = false; this.Deactivate(); } else { this.ManageObservable(nfcManager.ContinuousRead()); } } }); }
public MainViewModel( UserAuth userAuth, IVpnManager vpnManager, IActiveUrls urls, IEventAggregator eventAggregator, AppExitHandler appExitHandler, IModals modals, IDialogs dialogs, IPopupWindows popups, MapViewModel mapViewModel, ConnectingViewModel connectingViewModel, OnboardingViewModel onboardingViewModel, FlashNotificationViewModel flashNotificationViewModel, TrayNotificationViewModel trayNotificationViewModel) { _eventAggregator = eventAggregator; _vpnManager = vpnManager; _urls = urls; _userAuth = userAuth; _appExitHandler = appExitHandler; _modals = modals; _dialogs = dialogs; _popups = popups; Map = mapViewModel; Connection = connectingViewModel; Onboarding = onboardingViewModel; TrayNotification = trayNotificationViewModel; FlashNotification = flashNotificationViewModel; eventAggregator.Subscribe(this); AboutCommand = new RelayCommand(AboutAction, CanClick); AccountCommand = new RelayCommand(AccountAction, CanClick); ProfilesCommand = new RelayCommand(ProfilesAction, CanClick); SettingsCommand = new RelayCommand(SettingsAction, CanClick); HelpCommand = new RelayCommand(HelpAction); ReportBugCommand = new RelayCommand(ReportBugAction, CanClick); DeveloperToolsCommand = new RelayCommand(DeveloperToolsAction); LogoutCommand = new RelayCommand(LogoutAction); ExitCommand = new RelayCommand(ExitAction); SetDeveloperToolsVisibility(); }
public PendingViewModel(INavigationService navigation, IHttpTransferManager httpTransfers, IDialogs dialogs) { this.httpTransfers = httpTransfers; this.dialogs = dialogs; this.Create = navigation.NavigateCommand("CreateTransfer"); this.Load = ReactiveCommand.CreateFromTask(async() => { var transfers = await httpTransfers.GetTransfers(); this.Transfers = transfers .Select(transfer => { var vm = new HttpTransferViewModel { Identifier = transfer.Identifier, Uri = transfer.Uri, IsUpload = transfer.IsUpload, Cancel = ReactiveCommand.CreateFromTask(async() => { var confirm = await dialogs.Confirm("Are you sure you want to cancel all transfers?", "Confirm", "Yes", "No"); if (confirm) { await this.httpTransfers.Cancel(transfer.Identifier); this.Load.Execute(null); } }) }; ToViewModel(vm, transfer); return(vm); }) .ToList(); }); this.CancelAll = ReactiveCommand.CreateFromTask(async() => { await httpTransfers.Cancel(); this.Load.Execute(null); }); this.BindBusyCommand(this.Load); }
protected AbstractForm( Common.Configuration.Config appConfig, ColorProvider colorProvider, IUserStorage userStorage, ProfileManager profileManager, IDialogs dialogs, IModals modals, ServerManager serverManager) { _appConfig = appConfig; _profileManager = profileManager; UserStorage = userStorage; _colorProvider = colorProvider; _dialogs = dialogs; _modals = modals; ServerManager = serverManager; SelectColorCommand = new RelayCommand <string>(SelectColorAction); }
public EventsViewModel(IDialogs dialogs) : base(dialogs) { Log .WhenEventLogged() .Select(x => new CommandItem { Text = $"{x.EventName} ({DateTime.Now:hh:mm:ss tt})", Detail = x.Description, PrimaryCommand = ReactiveCommand.CreateFromTask(async() => { var s = $"{x.EventName} ({DateTime.Now:hh:mm:ss tt}){Environment.NewLine}{x.Description}"; foreach (var p in x.Parameters) { s += $"{Environment.NewLine}{p.Key}: {p.Value}"; } await this.Dialogs.Alert(s); }) })
private P2PDetector( ILogger logger, IBlockedTraffic blockedTraffic, IForwardedTraffic forwardedTraffic, ISchedulerTimer timer, IModals modals, IDialogs dialogs, TimeSpan checkInterval) { _logger = logger; _blockedTraffic = blockedTraffic; _forwardedTraffic = forwardedTraffic; _timer = timer; _modals = modals; _dialogs = dialogs; _timer.Interval = checkInterval; _timer.Tick += OnTimerTick; }
public UpdateViewModel( IDialogs dialogs, IOsProcesses osProcesses, IModals modals, IAppSettings appSettings, IVpnServiceManager vpnServiceManager, ISystemState systemState, ISettingsServiceClientManager settingsServiceClientManager) { _dialogs = dialogs; _osProcesses = osProcesses; _modals = modals; _appSettings = appSettings; _vpnServiceManager = vpnServiceManager; _systemState = systemState; _settingsServiceClientManager = settingsServiceClientManager; OpenAboutCommand = new RelayCommand(OpenAbout); }
public ChannelCreateViewModel(INavigationService navigator, INotificationManager manager, IDialogs dialogs) { this.Create = ReactiveCommand.CreateFromTask ( async() => { await manager.AddChannel(this.ToChannel()); await navigator.GoBack(); }, this.WhenAny( x => x.Identifier, x => x.Description, (id, desc) => !id.GetValue().IsEmpty() && !desc.GetValue().IsEmpty() ) ); this.PickImportance = dialogs.PickEnumValueCommand <ChannelImportance>( "Importance", x => this.Importance = x.ToString() ); this.PickActionType1 = dialogs.PickEnumValueCommand <ChannelActionType>( "Action Type", x => this.Action1ActionType = x.ToString(), this.WhenAny( x => x.UseAction1, x => x.GetValue() ) ); this.PickActionType2 = dialogs.PickEnumValueCommand <ChannelActionType>( "Action Type", x => this.Action2ActionType = x.ToString(), this.WhenAny( x => x.UseAction2, x => x.GetValue() ) ); }
public ProfileListModalViewModel( ProfileManager profileManager, ProfileViewModelFactory profileHelper, IModals modals, IDialogs dialogs, VpnManager vpnManager, ProfileSyncViewModel profileSync) { ProfileSync = profileSync; _profileHelper = profileHelper; _profileManager = profileManager; _modals = modals; _dialogs = dialogs; _vpnManager = vpnManager; ConnectCommand = new RelayCommand <ProfileViewModel>(ConnectAction); RemoveCommand = new RelayCommand <ProfileViewModel>(RemoveAction); EditCommand = new RelayCommand <ProfileViewModel>(EditProfileAction); CreateProfileCommand = new RelayCommand(CreateProfileAction); }
public ListViewModel(INavigationService navigator, IGeofenceManager geofenceManager, IDialogs dialogs) { this.geofenceManager = geofenceManager; this.dialogs = dialogs; this.Create = navigator.NavigateCommand("CreateGeofence"); this.DropAllFences = ReactiveCommand.CreateFromTask( async _ => { var confirm = await this.dialogs.Confirm("Are you sure you wish to drop all geofences?"); if (confirm) { await this.geofenceManager.StopAllMonitoring(); await this.LoadRegions(); } } ); }
public ViewNavigator(p.IRegionManager regionManager, IDialogs dialogs, IFormsManager formsManager, IInfrastructureEventAggregator eventAggregator) { _RegionManager = regionManager; _Dialogs = dialogs; _FormsManager = formsManager; _EventAggregator = eventAggregator; _RegionActiveViewModels = new Dictionary<string, HashSet<INavigationAware>>(); _DisposableViewStates = new Dictionary<object, IDisposable>(); KeptAliveRegions = new HashSet<string>(); _EventAggregator.Subscribe<IApplicationExitRequestEvent>(ApplicationExitRequested); _EventAggregator.Subscribe<IStartupNotificationsRequestEvent>(args => _IsProcessingNotifications = true); _EventAggregator.Subscribe<IStartupNotificationsProcessedEvent>(args => { _IsProcessingNotifications = false; _NotificationsProcessed = true; ProcessUIWorkQueue(); }); }
protected AbstractLogViewModel(IDialogs dialogs) { this.Dialogs = dialogs; this.Logs = new ObservableList <TItem>(); this.Logs .WhenCollectionChanged() .Synchronize(this.syncLock) .Select(_ => this.Logs.Any()) .Subscribe(x => this.HasLogs = x) .DisposedBy(this.DestroyWith); this.Load = ReactiveCommand.CreateFromTask(async() => { var logs = await this.LoadLogs(); this.Logs.ReplaceAll(logs); }); this.Clear = ReactiveCommand.CreateFromTask(this.DoClear); this.BindBusyCommand(this.Load); }
public MediaScannerViewModel(IDialogs dialogs, IMediaGalleryScanner?scanner = null) { this.RunQuery = ReactiveCommand.CreateFromTask(async() => { this.IsSearchExpanded = false; this.IsBusy = true; if (scanner == null) { await dialogs.Alert("Media scanner not supported"); return; } var result = await scanner.RequestAccess(); if (result != AccessState.Available) { await dialogs.Alert("Invalid Status - " + result); return; } var mediaTypes = MediaTypes.None; if (this.IncludeAudio) { mediaTypes |= MediaTypes.Audio; } if (this.IncludeImages) { mediaTypes |= MediaTypes.Image; } if (this.IncludeVideos) { mediaTypes |= MediaTypes.Video; } var list = await scanner.Query(mediaTypes, this.SyncFrom); this.List.ReplaceAll(list.Select(x => new CommandItem { Text = $"{x.Type} - {x.FilePath}", ImageUri = x.Type == MediaTypes.Audio ? null : x.FilePath })); this.IsBusy = false; }); this.BindBusyCommand(this.RunQuery); }
public MonitoringViewModel(INavigationService navigator, IDialogs dialogs, IBeaconMonitoringManager?beaconManager = null) { this.Add = navigator.NavigateCommand("CreateBeacon"); this.Load = ReactiveCommand.CreateFromTask(async() => { if (beaconManager == null) { await dialogs.Alert("Beacon monitoring is not supported on this platform"); return; } var regions = await beaconManager.GetMonitoredRegions(); this.Regions = regions .Select(x => new CommandItem { Text = $"{x.Identifier}", Detail = $"{x.Uuid}/{x.Major ?? 0}/{x.Minor ?? 0}", PrimaryCommand = ReactiveCommand.CreateFromTask(async() => { await beaconManager.StopMonitoring(x.Identifier); this.Load.Execute(null); }) }) .ToList(); }); this.StopAllMonitoring = ReactiveCommand.CreateFromTask( async() => { var result = await dialogs.Confirm("Are you sure you wish to stop all monitoring"); if (result) { await beaconManager.StopAllMonitoring(); this.Load.Execute(null); } }, Observable.Return(beaconManager != null) ); }
public CountriesViewModel( IAppSettings appSettings, ServerListFactory serverListFactory, App app, IDialogs dialogs, ServerConnector serverConnector, CountryConnector countryConnector) { _appSettings = appSettings; _serverListFactory = serverListFactory; _app = app; _dialogs = dialogs; _serverConnector = serverConnector; _countryConnector = countryConnector; Connect = new RelayCommand <ServerItemViewModel>(ConnectAction); ConnectCountry = new RelayCommand <IServerCollection>(ConnectCountryAction); Expand = new RelayCommand <IServerCollection>(ExpandAction); ToggleSecureCoreCommand = new RelayCommand(ToggleSecureCoreAction); ClearSearchCommand = new RelayCommand(ClearSearchAction); }
public ProfileConnector( ILogger logger, IUserStorage userStorage, IAppSettings appSettings, ServerManager serverManager, ServerCandidatesFactory serverCandidatesFactory, IVpnServiceManager vpnServiceManager, IModals modals, IDialogs dialogs, VpnCredentialProvider vpnCredentialProvider) { _logger = logger; _vpnCredentialProvider = vpnCredentialProvider; _modals = modals; _dialogs = dialogs; _userStorage = userStorage; _serverManager = serverManager; _serverCandidatesFactory = serverCandidatesFactory; _appSettings = appSettings; _vpnServiceManager = vpnServiceManager; }
public ListViewModel(IDialogs dialogs, IMotionActivityManager?activityManager = null) { this.activityManager = activityManager; this.Load = ReactiveCommand.CreateFromTask(async() => { if (this.activityManager == null) { await dialogs.Alert("MotionActivity is not supported on this platform"); return; } var result = await this.activityManager.RequestAccess(); if (result != Shiny.AccessState.Available) { await dialogs.Alert("Motion Activity is not available - " + result); return; } var activities = await this.activityManager.QueryByDate(this.Date); this.Events = activities .OrderByDescending(x => x.Timestamp) .Select(x => new CommandItem { Text = $"({x.Confidence}) {x.Types}", Detail = $"{x.Timestamp.LocalDateTime}" }) .ToList(); this.EventCount = this.Events.Count; }); this.BindBusyCommand(this.Load); this.WhenAnyValue(x => x.Date) .DistinctUntilChanged() .Select(_ => Unit.Default) .InvokeCommand((ICommand)this.Load) .DisposeWith(this.DestroyWith); }
public NewProjectPanel() { this.Build(); this.mtoolkit = App.Current.MultimediaToolkit; dialogs = App.Current.Dialogs; capturemediafilechooser.FileChooserMode = FileChooserMode.File; capturemediafilechooser.ProposedFileName = String.Format("Live-LongoMatch-{0}.mp4", DateTime.Now.ToShortDateString()); notebook1.ShowTabs = false; notebook1.ShowBorder = false; LoadIcons(); GroupLabels(); ConnectSignals(); FillDahsboards(); FillFormats(); Gdk.Color.Parse("red", ref red); outputfilelabel.ModifyFg(StateType.Normal, red); urilabel.ModifyFg(StateType.Normal, red); ApplyStyle(); }
public DictationViewModel(ISpeechRecognizer speech, IDialogs dialogs) { speech .WhenListeningStatusChanged() .SubOnMainThread(x => this.IsListening = x); this.ToggleListen = ReactiveCommand.Create(() => { if (this.IsListening) { this.Deactivate(); } else { if (this.UseContinuous) { speech .ContinuousDictation() .SubOnMainThread( x => this.Text += " " + x, ex => dialogs.Alert(ex.ToString()) ) .DisposedBy(this.DeactivateWith); } else { speech .ListenUntilPause() .SubOnMainThread( x => this.Text = x, ex => dialogs.Alert(ex.ToString()) ) .DisposedBy(this.DeactivateWith); } } }); }
public MainForm() { instance = this; settings = new Settings(); productInfo = new ProductInfo(); dialogs = new WinDialogs(this, productInfo, BeforeDialog, AfterDialog); uiThread = Thread.CurrentThread; KeyPreview = true; Text = productInfo.ProductName + " - TRS-80 Model III Emulator"; BackColor = Color.Black; keyboard = new KeyboardDX(); screen = new ScreenDX(this, dialogs, settings, DISPLAY_MESSAGE_CYCLE_DURATION); InitializeComponent(); SetupClientArea(); }
public SettingsModalViewModel( IAppSettings appSettings, VpnManager vpnManager, ProfileViewModelFactory profileViewModelFactory, SplitTunnelingViewModel splitTunnelingViewModel, CustomDnsListViewModel customDnsListViewModel, IUserStorage userStorage, IDialogs dialogs, IActiveUrls urls) { _dialogs = dialogs; _appSettings = appSettings; _vpnManager = vpnManager; _profileViewModelFactory = profileViewModelFactory; _userStorage = userStorage; _urls = urls; SplitTunnelingViewModel = splitTunnelingViewModel; Ips = customDnsListViewModel; ReconnectCommand = new RelayCommand(ReconnectAction); UpgradeCommand = new RelayCommand(UpgradeAction); }
public RangingViewModel(INavigationService navigator, IDialogs dialogs, IBeaconRangingManager beaconManager) { this.dialogs = dialogs; this.beaconManager = beaconManager; this.WhenAnyValue(x => x.Uuid) .Select(x => !x.IsEmpty()) .ToPropertyEx(this, x => x.IsRegionSet); this.WhenAnyValue(x => x.Major) .Select(x => !x.IsEmpty()) .ToPropertyEx(this, x => x.IsMajorSet); this.WhenAnyValue(x => x.Minor) .Select(x => !x.IsEmpty()) .ToPropertyEx(this, x => x.IsMinorSet); this.SetRegion = navigator.NavigateCommand( "CreateBeacon", p => p .Set(nameof(BeaconRegion), this.region) .Set("IsRanging", true) ); this.ScanToggle = ReactiveCommand.Create(() => { if (this.scanner == null) { this.StartScan(); } else { this.StopScan(); } }); }
public PendingViewModel(INotificationManager notifications, IDialogs dialogs) { this.Load = ReactiveCommand.CreateFromTask(async() => { var pending = await notifications.GetPending(); this.PendingList = pending .Select(x => new CommandItem { Text = $"[{x.Id}] {x.Title}", Detail = $"[{x.ScheduleDate.Value}] {x.Message}", PrimaryCommand = ReactiveCommand.CreateFromTask(async() => { await notifications.Cancel(x.Id); ((ICommand)this.Load).Execute(null); }) }) .ToList(); }); this.BindBusyCommand(this.Load); this.Clear = ReactiveCommand.CreateFromTask( async() => { var confirm = await dialogs.Confirm("Clear All Pending Notifications?"); if (confirm) { await notifications.Clear(); ((ICommand)this.Load).Execute(null); } } //this.WhenAny( // x => x.PendingList, // x => x.GetValue()?.Any() ?? false //) ); }
/// <summary> /// Initializes a new instance of the <see cref="StoreDetailViewModel"/> class. /// </summary> /// <param name="popupViewStackService">The popup view stack service.</param> /// <param name="storeService">The store service.</param> /// <param name="queueService">The queue service.</param> /// <param name="dialogs">The dialogs.</param> public StoreDetailViewModel( IPopupViewStackService popupViewStackService, IStoreService storeService, IQueueService queueService, IDialogs dialogs) : base(popupViewStackService) { _popupViewStackService = popupViewStackService; _storeService = storeService; _queueService = queueService; _dialogs = dialogs; var getStore = ReactiveCommand.CreateFromObservable <Guid, Unit>(ExecuteGetStore); this.WhenPropertyValueChanges(x => x.StoreId) .Where(x => x != Guid.Empty) .DistinctUntilChanged() .InvokeCommand(getStore) .DisposeWith(Subscriptions); InitializeData = ReactiveCommand.CreateFromObservable <Guid, Unit>(ExecuteInitializeData); Add = ReactiveCommand.CreateFromObservable(ExecuteAdd); }
public void SetUp() { _sut = NullDialogs<Window>.Default; _testWindow = new Window(); }