Пример #1
0
        private async Task Export()
        {
            try
            {
                _loggingService.Info($"Exporting channels");

                var chs = await _channelService.LoadChannels();

                if (chs.Count == 0)
                {
                    await _dialogService.Information("Channel list is empty");

                    return;
                }

                if (File.Exists(AndroidChannelsListPath))
                {
                    if (!await _dialogService.Confirm($"File {AndroidChannelsListPath} exists. Overwite?"))
                    {
                        return;
                    }

                    File.Delete(AndroidChannelsListPath);
                }

                File.WriteAllText(AndroidChannelsListPath, JsonConvert.SerializeObject(chs));

                MessagingCenter.Send($"File exported.", BaseViewModel.MSG_ToastMessage);
            }
            catch (Exception ex)
            {
                _loggingService.Error(ex, "Export failed");
                await _dialogService.Error($"Export failed");
            }
        }
Пример #2
0
        public override void CanClose(Action <bool> callback)
        {
            if (AccountViewModels.Any(vm => vm.HasChanges))
            {
                callback(DialogService.Confirm("You have unsaved changes. Are you sure you want to exit?"));

                return;
            }

            callback(true);
        }
Пример #3
0
        private async Task maybeLogout()
        {
            if (await isSynced())
            {
                await logout();

                return;
            }

            var(title, message) = IsRunningSync
                ? (Resources.SettingsSyncInProgressTitle, Resources.SettingsSyncInProgressMessage)
                : (Resources.SettingsUnsyncedTitle, Resources.SettingsUnsyncedMessage);

            var shouldLogout = await dialogService.Confirm(
                title,
                message,
                Resources.SettingsDialogButtonSignOut,
                Resources.Cancel
                );

            if (!shouldLogout)
            {
                return;
            }

            await logout();
        }
Пример #4
0
        private async Task selectProject(AutocompleteSuggestion suggestion)
        {
            if (suggestion is CreateEntitySuggestion createEntitySuggestion)
            {
                await createProject(createEntitySuggestion.EntityName);

                return;
            }

            if (suggestion.WorkspaceId == workspaceId || suggestion.WorkspaceId == 0)
            {
                setProject(suggestion);
                return;
            }

            var shouldSetProject = await dialogService.Confirm(
                Resources.DifferentWorkspaceAlertTitle,
                Resources.DifferentWorkspaceAlertMessage,
                Resources.Ok,
                Resources.Cancel
                );

            if (!shouldSetProject)
            {
                return;
            }

            setProject(suggestion);
        }
Пример #5
0
 private async void ToolConnect_Clicked(object sender, EventArgs e)
 {
     if (_driver.Started)
     {
         if (!(await _dialogService.Confirm($"Connected device: {_driver.Configuration.DeviceName}.", $"Device status", "Back", "Disconnect")))
         {
             await _viewModel.DisconnectDriver();
         }
     }
     else
     {
         if (await _dialogService.Confirm($"Disconnected.", $"Device status", "Connect", "Back"))
         {
             MessagingCenter.Send("", BaseViewModel.MSG_Init);
         }
     }
 }
Пример #6
0
 private void CancelCommandExecute(DownloadItem param)
 {
     if (_dialogService.Confirm("Are you sure you want to cancel download?", "Part of the ship, part of the crew"))
     {
         param.CancelDownload();
         Downloads.Remove(param);
     }
 }
Пример #7
0
        private async void ExitApplication()
        {
            var confirmed = await _dialogService.Confirm("Exit the application?");

            if (confirmed)
            {
                Application.Current.Shutdown();
            }
        }
Пример #8
0
        private async Task DeleteAsync(ScriptNodeViewModel <TScript> scriptVm)
        {
            if (!_dialogService.Confirm($"Are you sure you want to delete {scriptVm.Description} '{scriptVm.Script.Id}'?"))
            {
                return;
            }

            await scriptVm.DeleteAsync();

            scriptVm.Parent?.ReloadChildren();
        }
        private async Task DeleteScriptService(ScriptService scriptService)
        {
            if (!await _dialogService.Confirm(Novaroma.Properties.Resources.MontyNi, Novaroma.Properties.Resources.AreYouSure))
            {
                return;
            }

            await _engine.DeleteEntity(scriptService);

            _scriptServices.Remove(scriptService);
            IsModified = true;
        }
Пример #10
0
        private async void OnClosing(object sender, CancelEventArgs e)
        {
            if (_shouldBeClosed)
            {
                return;
            }

            e.Cancel = true;
            if (await _dialogService.Confirm(Resx.MontyNi, Resx.AreYouSure))
            {
                _shouldBeClosed = true;
                Close();
            }
        }
Пример #11
0
        private void Remove(AccountNodeViewModel accountVm)
        {
            if (!_dialogService.Confirm($"Are you sure you want to remove account '{accountVm.Name}'?"))
            {
                return;
            }

            if (!_accountDirectory.TryGetById(accountVm.Id, out var account))
            {
                return;
            }

            _accountDirectory.Remove(accountVm.Id);
            _accountDirectory.Save();

            _messenger.Publish(new AccountRemovedMessage(account));
        }
Пример #12
0
        private async Task signout()
        {
            var shouldLogout = !needsSync || await dialogService.Confirm(
                Resources.AreYouSure,
                Resources.SettingsUnsyncedMessage,
                Resources.SettingsDialogButtonSignOut,
                Resources.Cancel
                );

            if (!shouldLogout)
            {
                return;
            }

            await dataSource.Logout();

            await navigationService.Navigate <OnboardingViewModel>();
        }
Пример #13
0
        public SettingsPage(ILoggingService loggingService, IDialogService dialogService, DVBTTelevizorConfiguration config, ChannelService channelService)
        {
            InitializeComponent();

            _loggingService = loggingService;
            _dialogService  = dialogService;

            BindingContext = _viewModel = new SettingsPageViewModel(_loggingService, _dialogService, config, channelService);

            PlayOnBackgroundSwitch.Toggled += PlayOnBackgroundSwitch_Toggled;

            MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_RequestBatterySettings, async(sender) =>
            {
                if (await _dialogService.Confirm("You should manually turn battery optimization off for DVBT Televizor. Open settings?"))
                {
                    MessagingCenter.Send <SettingsPage>(this, BaseViewModel.MSG_SetBatterySettings);
                }
            });
        }
        public void Handle(DeleteShortCodeCommand command)
        {
            if (command.ShortCode == null)
            {
                return;
            }

            _uiThreadInvoker.Invoke(() =>
            {
                if (!_dialogService.Confirm(String.Format("Are you sure you want to delete {0}?", command.ShortCode.Code)))
                {
                    return;
                }

                var existingCode = _applicationState.ShortCodes.SingleOrDefault(s => s.ShortCodeId == command.ShortCode.ShortCodeId);
                _applicationState.ShortCodes.Remove(existingCode);
                _storageManager.SaveData();
            });
        }
Пример #15
0
        public async Task TryLogout()
        {
            var synced = !isSyncing && await isSynced();

            if (synced)
            {
                await logout();

                return;
            }

            var(title, message) = isSyncing
                ? (Resources.SettingsSyncInProgressTitle, Resources.SettingsSyncInProgressMessage)
                : (Resources.SettingsUnsyncedTitle, Resources.SettingsUnsyncedMessage);

            await dialogService
            .Confirm(title, message, Resources.SettingsDialogButtonSignOut, Resources.Cancel)
            .SelectMany(shouldLogout
                        => shouldLogout ? logout() : Observable.Return(Unit.Default));
        }
Пример #16
0
        private async Task signout()
        {
            var shouldLogout = !needsSync || await dialogService.Confirm(
                Resources.AreYouSure,
                Resources.SettingsUnsyncedMessage,
                Resources.SettingsDialogButtonSignOut,
                Resources.Cancel
                );

            if (!shouldLogout)
            {
                return;
            }

            analyticsService.Logout.Track(LogoutSource.TokenReset);
            userPreferences.Reset();
            await dataSource.Logout();

            await navigationService.Navigate <LoginViewModel>();
        }
Пример #17
0
        public SettingsPage(ILoggingService loggingService, IOnlineTelevizorConfiguration config, IDialogService dialogService, TVService service)
        {
            InitializeComponent();

            _config         = config;
            _loggingService = loggingService;
            _dialogService  = dialogService;

            BindingContext = _viewModel = new SettingsViewModel(loggingService, config, dialogService, service);

            PlayOnBackgroundSwitch.Toggled  += PlayOnBackgroundSwitch_Toggled;
            UseInternalPlayerSwitch.Toggled += PlayOnBackgroundSwitch_Toggled;

            if (Device.RuntimePlatform == Device.UWP)
            {
                UsernameEntry.TextColor       = Color.Black;
                UsernameEntry.BackgroundColor = Color.Gray;
                PasswordEntry.TextColor       = Color.Black;
                PasswordEntry.BackgroundColor = Color.Gray;
                PinEntry.TextColor            = Color.Black;
                PinEntry.BackgroundColor      = Color.Gray;

                FontSizeLabel.IsVisible  = false;
                FontSizePicker.IsVisible = false;
            }

            MessagingCenter.Subscribe <string>(this, BaseViewModel.RequestBatterySettings, async(sender) =>
            {
                if (await _dialogService.Confirm("Při běhu na pozadí je nutné zajistit, aby se aplikace kvůli optimalizaci baterie neukončovala. Přejít do nastavení?"))
                {
                    MessagingCenter.Send <SettingsPage>(this, BaseViewModel.SetBatterySettings);
                }
            });

            TVAPIPicker.Unfocused += TVAPIPicker_Unfocused;
            LastChannelAutoPlayPicker.Unfocused += LastChannelAutoPlayPicker_Unfocused;
            FontSizePicker.Unfocused            += FontSizePicker_Unfocused;

            PasswordEntry.Unfocused += PasswordEntry_Unfocused;
        }
Пример #18
0
        public void Handle(AddNewShortCodeCommand command)
        {
            _uiThreadInvoker.Invoke(() =>
            {
                if (_trialService.IsTrial() && _applicationState.ShortCodes.Count > 0)
                {
                    var result = _dialogService.Confirm("The trial version is limited to storing 1 short code only.  Click Okay to buy the full version.");
                    if (result)
                    {
                        _trialService.SendUserToMarketplace();
                    }
                    return;
                }

                var addPageViewModel = _container.GetInstance <IAddPageViewModel>();

                addPageViewModel.ActiveShortCode = new ShortCode();
                addPageViewModel.Errors.Clear();
                addPageViewModel.PageTitle = "add code";

                _navigationService.Navigate("/Views/AddPage.xaml");
            });
        }
Пример #19
0
        private async Task done()
        {
            if (!SaveEnabled)
            {
                return;
            }

            if (initialWorkspaceId != workspaceId)
            {
                var shouldContinue = await dialogService.Confirm(
                    Resources.WorkspaceChangedAlertTitle,
                    Resources.WorkspaceChangedAlertMessage,
                    Resources.Ok,
                    Resources.Cancel
                    );

                if (!shouldContinue)
                {
                    return;
                }
            }

            var billable = await interactorFactory.AreProjectsBillableByDefault(workspaceId).Execute();

            var createdProject = await dataSource.Projects.Create(new CreateProjectDTO
            {
                Name        = TrimmedName,
                Color       = Color.ToHexString(),
                IsPrivate   = IsPrivate,
                ClientId    = clientId,
                Billable    = billable,
                WorkspaceId = workspaceId
            });

            await navigationService.Close(this, createdProject.Id);
        }
Пример #20
0
        private void StopImpl()
        {
            switch (timerState)
            {
            case TimerState.Running:
                stopWatch.Stop();
                TimerState = TimerState.Stopped;
                break;

            case TimerState.Stopped:
                if (!dialogService.Confirm("Are you sure you want to start new?", "Confirm"))
                {
                    return;
                }
                stopWatch.Reset();
                LapTimes.Clear();
                TimerState = TimerState.Initial;
                break;

            case TimerState.Initial:
            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #21
0
 public Task <bool> Confirm(string title, string message)
 {
     return(DialogService.Confirm(title, message));
 }
Пример #22
0
        private async Task selectSuggestion(AutocompleteSuggestion suggestion)
        {
            switch (suggestion)
            {
            case QuerySymbolSuggestion querySymbolSuggestion:
                TextFieldInfo = TextFieldInfo.WithTextAndCursor(querySymbolSuggestion.Symbol, 1);
                break;

            case TimeEntrySuggestion timeEntrySuggestion:

                TextFieldInfo = TextFieldInfo.WithTextAndCursor(
                    timeEntrySuggestion.Description,
                    timeEntrySuggestion.Description.Length);

                if (!timeEntrySuggestion.ProjectId.HasValue)
                {
                    TextFieldInfo = TextFieldInfo.RemoveProjectInfo();
                    return;
                }

                if (timeEntrySuggestion.TaskId == null)
                {
                    TextFieldInfo = TextFieldInfo.WithProjectInfo(
                        timeEntrySuggestion.WorkspaceId,
                        timeEntrySuggestion.ProjectId.Value,
                        timeEntrySuggestion.ProjectName,
                        timeEntrySuggestion.ProjectColor);
                    break;
                }

                TextFieldInfo = TextFieldInfo.WithProjectAndTaskInfo(
                    timeEntrySuggestion.WorkspaceId,
                    timeEntrySuggestion.ProjectId.Value,
                    timeEntrySuggestion.ProjectName,
                    timeEntrySuggestion.ProjectColor,
                    timeEntrySuggestion.TaskId.Value,
                    timeEntrySuggestion.TaskName);
                break;

            case ProjectSuggestion projectSuggestion:

                if (TextFieldInfo.WorkspaceId == projectSuggestion.WorkspaceId)
                {
                    setProject(projectSuggestion);
                    break;
                }

                var shouldChangeProject = await dialogService.Confirm(
                    Resources.DifferentWorkspaceAlertTitle,
                    Resources.DifferentWorkspaceAlertMessage,
                    Resources.Ok,
                    Resources.Cancel);

                if (!shouldChangeProject)
                {
                    break;
                }

                setProject(projectSuggestion);

                break;

            case TaskSuggestion taskSuggestion:

                if (TextFieldInfo.WorkspaceId == taskSuggestion.WorkspaceId)
                {
                    setTask(taskSuggestion);
                    break;
                }

                var shouldChangeTask = await dialogService.Confirm(
                    Resources.DifferentWorkspaceAlertTitle,
                    Resources.DifferentWorkspaceAlertMessage,
                    Resources.Ok,
                    Resources.Cancel);

                if (!shouldChangeTask)
                {
                    break;
                }

                setTask(taskSuggestion);

                break;

            case TagSuggestion tagSuggestion:

                TextFieldInfo = TextFieldInfo
                                .RemoveTagQueryFromDescriptionIfNeeded()
                                .AddTag(tagSuggestion);
                break;
            }
        }
Пример #23
0
        private IObservable <Unit> done()
        {
            var nameIsAlreadyTaken = currentWorkspace
                                     .SelectMany(workspace => dataSource.Projects.GetAll(project => project.WorkspaceId == workspace.Id))
                                     .Select(existingProjectsDictionary)
                                     .CombineLatest(currentClient, Name, checkNameIsTaken);

            var projectCreation = currentWorkspace.FirstAsync()
                                  .SelectMany(workspace => checkIfCanContinue(workspace)
                                              .SelectMany(shouldContinue => !shouldContinue
                        ? Observable.Empty <Unit>()
                        : getDto(workspace)
                                                          .SelectMany(dto => interactorFactory.CreateProject(dto).Execute())
                                                          .SelectMany(createdProject =>
                                                                      navigationService.Close(this, createdProject.Id).ToObservable())
                                                          .SelectUnit()
                                                          )
                                              );

            return(nameIsAlreadyTaken.SelectMany(taken =>
            {
                if (taken)
                {
                    throw new Exception(Resources.ProjectNameTakenError);
                }

                return projectCreation;
            }));

            IObservable <bool> checkIfCanContinue(IThreadSafeWorkspace workspace)
            {
                if (initialWorkspaceId == workspace.Id)
                {
                    return(Observable.Return(true));
                }

                return(dialogService.Confirm(
                           Resources.WorkspaceChangedAlertTitle,
                           Resources.WorkspaceChangedAlertMessage,
                           Resources.Ok,
                           Resources.Cancel
                           ));
            }

            IObservable <CreateProjectDTO> getDto(IThreadSafeWorkspace workspace)
            => Observable.CombineLatest(
                Name.FirstAsync(),
                Color.FirstAsync(),
                currentClient.FirstAsync(),
                interactorFactory.AreProjectsBillableByDefault(workspace.Id).Execute(),
                IsPrivate.FirstAsync(),
                (name, color, client, billable, isPrivate) => new CreateProjectDTO
            {
                Name        = name.Trim(),
                Color       = color.ToHexString(),
                IsPrivate   = isPrivate,
                ClientId    = client?.Id,
                Billable    = billable,
                WorkspaceId = workspace.Id
            }
                );

            Dictionary <long, HashSet <string> > existingProjectsDictionary(IEnumerable <IThreadSafeProject> projectsInWorkspace)
            => projectsInWorkspace.Aggregate(new Dictionary <long, HashSet <string> >(), (dict, project) =>
            {
                var key = project.ClientId ?? noClientId;
                if (dict.ContainsKey(key))
                {
                    dict[key].Add(project.Name);
                    return(dict);
                }

                dict[key] = new HashSet <string> {
                    project.Name
                };
                return(dict);
            });

            bool checkNameIsTaken(Dictionary <long, HashSet <string> > projectNameDictionary, IThreadSafeClient client, string name)
            {
                var key = client?.Id ?? noClientId;

                if (projectNameDictionary.TryGetValue(key, out var projectNames))
                {
                    return(projectNames.Contains(name.Trim()));
                }

                return(false);
            }
        }
        private async Task selectSuggestion(AutocompleteSuggestion suggestion)
        {
            switch (suggestion)
            {
            case QuerySymbolSuggestion querySymbolSuggestion:

                if (querySymbolSuggestion.Symbol == QuerySymbols.ProjectsString)
                {
                    analyticsService.StartViewTapped.Track(StartViewTapSource.PickEmptyStateProjectSuggestion);
                    analyticsService.StartEntrySelectProject.Track(ProjectTagSuggestionSource.TableCellButton);
                }
                else if (querySymbolSuggestion.Symbol == QuerySymbols.TagsString)
                {
                    analyticsService.StartViewTapped.Track(StartViewTapSource.PickEmptyStateTagSuggestion);
                    analyticsService.StartEntrySelectTag.Track(ProjectTagSuggestionSource.TableCellButton);
                }

                textFieldInfo.Accept(textFieldInfo.Value.FromQuerySymbolSuggestion(querySymbolSuggestion));
                break;

            case TimeEntrySuggestion timeEntrySuggestion:
                analyticsService.StartViewTapped.Track(StartViewTapSource.PickTimeEntrySuggestion);
                textFieldInfo.Accept(textFieldInfo.Value.FromTimeEntrySuggestion(timeEntrySuggestion));
                break;

            case ProjectSuggestion projectSuggestion:
                analyticsService.StartViewTapped.Track(StartViewTapSource.PickProjectSuggestion);

                if (textFieldInfo.Value.WorkspaceId != projectSuggestion.WorkspaceId &&
                    await workspaceChangeDenied())
                {
                    return;
                }

                isSuggestingProjects.Accept(false);
                textFieldInfo.Accept(textFieldInfo.Value.FromProjectSuggestion(projectSuggestion));
                queryByTypeSubject.OnNext(AutocompleteSuggestionType.None);

                break;

            case TaskSuggestion taskSuggestion:
                analyticsService.StartViewTapped.Track(StartViewTapSource.PickTaskSuggestion);

                if (textFieldInfo.Value.WorkspaceId != taskSuggestion.WorkspaceId &&
                    await workspaceChangeDenied())
                {
                    return;
                }

                isSuggestingProjects.Accept(false);
                textFieldInfo.Accept(textFieldInfo.Value.FromTaskSuggestion(taskSuggestion));
                queryByTypeSubject.OnNext(AutocompleteSuggestionType.None);
                break;

            case TagSuggestion tagSuggestion:
                analyticsService.StartViewTapped.Track(StartViewTapSource.PickTagSuggestion);
                textFieldInfo.Accept(textFieldInfo.Value.FromTagSuggestion(tagSuggestion));
                break;

            case CreateEntitySuggestion createEntitySuggestion:
                if (isSuggestingProjects.Value)
                {
                    createProject();
                }
                else
                {
                    createTag();
                }
                break;

            default:
                return;
            }

            IObservable <bool> workspaceChangeDenied()
            => dialogService.Confirm(
                Resources.DifferentWorkspaceAlertTitle,
                Resources.DifferentWorkspaceAlertMessage,
                Resources.Ok,
                Resources.Cancel
                ).Select(Invert);
        }
Пример #25
0
 private IObservable <bool> askToLogOut()
 => dialogService.Confirm(
     Resources.AreYouSure,
     Resources.SettingsUnsyncedMessage,
     Resources.SettingsDialogButtonSignOut,
     Resources.Cancel);