Ejemplo n.º 1
0
 private async Task ShowTaskCancelledError()
 {
     await dialogManager.ShowDialogAsync(new ErrorDialogViewModel
     {
         Title   = "Błąd połączenia",
         Message =
             "Połączenie zostało zerwane. Upewnij się, że wprowadzone zmiany zostały zapisane.",
     });
 }
Ejemplo n.º 2
0
        public Task ShowAsync()
        {
            var commands = new List <IDialogUICommand <DialogResult> >();

            _loginCommand          = new DialogUICommand <DialogResult>("Login", DialogResult.Ok, true);
            _loginCommand.Invoked += async(sender, args) =>
            {
                args.Cancel();     // Cancel command, we'll take it from here.

                await LoginAsync();

                if (_authenticationService.IsLoggedIn)
                {
                    args.DialogHost.TryClose(_loginCommand.DialogResult);
                }
            };
            commands.Add(_loginCommand);

#if !SILVERLIGHT
            var closeCommand = new DialogUICommand <DialogResult>("Close", DialogResult.Cancel, false, true);
            commands.Add(closeCommand);
#endif

            UpdateCommands();
            return(_dialogManager.ShowDialogAsync(commands, this));
        }
Ejemplo n.º 3
0
        private async Task OnShowSampleDialogAsync()
        {
            var text = await _dialogManager.ShowDialogAsync <SampleDialogViewModel, string>();

            if (text != null)
            {
                await _dialogManager.ShowMessageBox(Title, "You entered: " + text);
            }
        }
        public async void Add()
        {
            var rateTypes        = UnitOfWork.RateTypes;
            var rateTypeSelector = _rateTypeSelectorFactory.CreateExport().Value
                                   .Start("Select type:", "DisplayName", () => rateTypes.AllAsync(q => q.OrderBy(t => t.DisplayName)));

            await _dialogManager.ShowDialogAsync(rateTypeSelector, DialogButtons.OkCancel);

            StaffingResource.AddRate((RateType)rateTypeSelector.SelectedItem);
        }
Ejemplo n.º 5
0
        public Task <DialogResult> ShowDialogAsync()
        {
            _okCommand = new DialogUICommand <DialogResult>(DialogResult.Ok, true)
            {
                Enabled = IsComplete
            };
            var cancelCommand = new DialogUICommand <DialogResult>(DialogResult.Cancel, false, true);

            return(_dialogManager.ShowDialogAsync(new[] { _okCommand, cancelCommand }, this));
        }
Ejemplo n.º 6
0
        private async void ButtonOnClick(object sender, RoutedEventArgs e)
        {
            var dialogViewModel = new ChoiceDialogViewModel();

            dialogViewModel.Title   = "What's your choice?";
            dialogViewModel.Message = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt?";

            var result = await _dialogManager.ShowDialogAsync(dialogViewModel);

            await this.ShowMessageAsync("Result", $"Your choice was: {result}");
        }
        public async void Add()
        {
            var addressTypes        = UnitOfWork.AddressTypes;
            var addressTypeSelector = _addressTypeSelectorFactory.CreateExport().Value
                                      .Start("Select type:", "DisplayName", () => addressTypes.AllAsync(q => q.OrderBy(t => t.DisplayName)));

            await _dialogManager.ShowDialogAsync(addressTypeSelector, DialogButtons.OkCancel);

            StaffingResource.AddAddress((AddressType)addressTypeSelector.SelectedItem);

            EnsureDelete();
        }
        public async void Add()
        {
            var phoneTypes        = UnitOfWork.PhoneNumberTypes;
            var phoneTypeSelector = _phoneTypeSelectorFactory.CreateExport().Value
                                    .Start("Select type:", "Name", () => phoneTypes.AllAsync(q => q.OrderBy(t => t.Name)));

            await _dialogManager.ShowDialogAsync(phoneTypeSelector, DialogButtons.OkCancel);

            StaffingResource.AddPhoneNumber((PhoneNumberType)phoneTypeSelector.SelectedItem);

            EnsureDelete();
        }
Ejemplo n.º 9
0
        public UpdateViewModel(IUpdateManager updateManager, ISettings settings, IDialogManager dialogManager, UpdateDownloadViewModel.Factory updateDownloadViewModelFactory, bool checkForUpdates) {
            _updateManager = updateManager;
            _settings = settings;
            _checkForUpdates = checkForUpdates;
            _releases = new ObservableCollection<ReleaseInfo>();

            _updateCommand = new AsyncRelayCommand(async () => {
                Close();
                await dialogManager.ShowDialogAsync(updateDownloadViewModelFactory.Invoke(_releases.First()));
            }, () => CanUpdate);
            _cancelCommand = new RelayCommand(Close);

            var collectionView = CollectionViewSource.GetDefaultView(Releases);
            collectionView.Filter = item => ((ReleaseInfo)item).IsNew;

            BindingOperations.EnableCollectionSynchronization(_releases, _releases);
        }
Ejemplo n.º 10
0
        public UpdateViewModel(IUpdateManager updateManager, ISettings settings, IDialogManager dialogManager, UpdateDownloadViewModel.Factory updateDownloadViewModelFactory, bool checkForUpdates)
        {
            _updateManager   = updateManager;
            _settings        = settings;
            _checkForUpdates = checkForUpdates;
            _releases        = new ObservableCollection <ReleaseInfo>();

            _updateCommand = new AsyncRelayCommand(async() => {
                Close();
                await dialogManager.ShowDialogAsync(updateDownloadViewModelFactory.Invoke(_releases.First()));
            }, () => CanUpdate);
            _cancelCommand = new RelayCommand(Close);

            var collectionView = CollectionViewSource.GetDefaultView(Releases);

            collectionView.Filter = item => ((ReleaseInfo)item).IsNew;

            BindingOperations.EnableCollectionSynchronization(_releases, _releases);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Show dialog.
        /// </summary>
        /// <param name="initializer">Dialog initializer</param>
        /// <param name="dialogType">Alert type</param>
        /// <param name="selections">Selections</param>
        /// <returns></returns>
        public static async Task <string> ShowDialogAsync(
            this IDialogManager dialogManager,
            Action <IDialogConfig <DialogSelection> > initializer,
            EDialogType dialogType,
            Action <string> onResult,
            params string[] selections)
        {
            var ret = await dialogManager.ShowDialogAsync(
                initializer,
                dialogType,
                selection => onResult(selection.Content as string),
                selections?.Any() == true
                ?selections?.Select((x, i) => new DialogSelection {
                Id = i,
                Content = x,
                IsDefault = (i == 0)
            }).ToArray()
                    : new DialogSelection[] { OkSelection(0, true) }
                );

            return(ret?.Content as string);
        }
Ejemplo n.º 12
0
        private async Task LoadProjectsAsync(string path)
        {
            var oldRootPath = RootPath;

            RootPath = path;

            var fileScanningViewModel = _viewModelFactory.CreateFileScanningViewModel(path);
            var result = await _dialogManager.ShowDialogAsync(fileScanningViewModel);

            if (result != null)
            {
                _settings.RootPath            = path;
                _projectRepository.RootPath   = path;
                _projectRepository.RootFolder = result.ProjectFolder;
                _mostRecentUsedFoldersRepository.SetCurrentFolder(path);
                Solution = _viewModelFactory.CreateSolutionViewModel(path, result.Projects);
                Show(String.Format("{0} projects loaded.", result.Projects.Count));
            }
            else
            {
                RootPath = oldRootPath;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Loguje użytkownika.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool Login(string username, string password)
        {
            var response = GetToken(username, password);

            try
            {
                dynamic responseJson = JObject.Parse(response);
                string  token        = responseJson["access_token"];
                if (token != null)
                {
                    client = CreateClient(token);
                    return(true);
                }
            }
            catch (JsonReaderException)
            {
                dialogManager.ShowDialogAsync(new ErrorDialogViewModel
                {
                    Title   = "Błąd",
                    Message = "Wystąpił błąd podczas logowania. Spróbuj ponownie za chwilę."
                }).ConfigureAwait(false);
            }
            return(false);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Provides compatibility for legacy code.
 /// </summary>
 public static OperationResult <DialogResult> ShowDialogAsync(
     this IDialogManager source, object content, IEnumerable <DialogResult> dialogButtons, string title)
 {
     return(source.ShowDialogAsync(content, dialogButtons, title));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Provides compatibility for legacy code.
 /// </summary>
 public static OperationResult <T> ShowDialogAsync <T>(
     this IDialogManager source, object content, T defaultButton, T cancelButton, IEnumerable <T> dialogButtons,
     string title)
 {
     return(source.ShowDialogAsync(content, defaultButton, cancelButton, dialogButtons, title));
 }
Ejemplo n.º 16
0
        public override void Handle(ValidationErrorMessage message)
        {
            var content = _viewModelFactory.CreateExport().Value.Start(message.VerifierResults);

            _dialogManager.ShowDialogAsync(content, DialogButtons.Ok);
        }