Exemplo n.º 1
0
        private void SelectLanguageHandler(InteractionContext <Unit, Language> interaction)
        {
            var viewModel = new LanguageSelectionViewModel(_context);
            var view      = viewModel.GetView();
            var confirm   = view.ShowDialog();

            if (confirm != null && confirm.Value)
            {
                interaction.SetOutput(viewModel.SelectedLanguage);
            }
            else
            {
                interaction.SetOutput(null);
            }
        }
Exemplo n.º 2
0
        private void SelectWeaponHandler(InteractionContext <Unit, Weapon> interaction)
        {
            var viewModel = new WeaponSelectionViewModel(_context);
            var view      = viewModel.GetView();
            var confirm   = view.ShowDialog();

            if (confirm != null && confirm.Value)
            {
                interaction.SetOutput(viewModel.SelectedWeapon);
            }
            else
            {
                interaction.SetOutput(null);
            }
        }
Exemplo n.º 3
0
        private async Task ShowOpenImageDialog(InteractionContext <Unit, string> interaction)
        {
            var dialog = new OpenFileDialog
            {
                AllowMultiple = false,
                Filters       = new List <FileDialogFilter>
                {
                    new FileDialogFilter
                    {
                        Name       = "Obrazy",
                        Extensions = new List <string>
                        {
                            "bmp",
                            "png",
                            "jpg",
                            "jpeg",
                        },
                    },
                },
            };

            var fileNames = await dialog.ShowAsync(this);

            interaction.SetOutput(fileNames?.FirstOrDefault());
        }
Exemplo n.º 4
0
        private async Task HandleDiscardChangesConfirmationAsync(InteractionContext <Unit, bool> interactionContext)
        {
            var dialog = DialogHelper.CreateAlertDialog(new AlertDialogBuilderParams()
            {
                ContentHeader    = "Confirm action",
                SupportingText   = "Are you sure to discard the changes?",
                DialogHeaderIcon = DialogIconKind.Help,
                StartupLocation  = WindowStartupLocation.CenterOwner,
                NegativeResult   = new DialogResult("no"),
                Borderless       = true,
                DialogButtons    = new[]
                {
                    new DialogResultButton
                    {
                        Content = "Yes",
                        Result  = "yes",
                    },
                    new DialogResultButton
                    {
                        Content = "No",
                        Result  = "no",
                    },
                },
            });

            var result = await dialog.ShowDialog(Host)
                         .ConfigureAwait(false);

            interactionContext.SetOutput(result.GetResult == "yes");
        }
Exemplo n.º 5
0
        private async Task HandleNewNodePointRequest(InteractionContext <Unit, Point?> interaction)
        {
            try
            {
                Nodes.Cursor = Cursors.Cross;

                var sequence = Observable.Merge(
                    Nodes.Events()
                    .MouseLeftButtonDown      // left button picks a point
                    .Select(e => new Point?(e.GetPosition(Nodes))),
                    Nodes.Events()
                    .MouseRightButtonDown      // right button cancels addition
                    .Select(e => default(Point?)),
                    ViewModel.MainWindowKeyDown
                    .Where(e => e.Key == Key.Escape)          // Esc cancels addition
                    .Select(e => default(Point?)));

                var point = await sequence.FirstAsync(); // whichever comes first

                interaction.SetOutput(point);
            }
            finally
            {
                Nodes.Cursor = Cursors.Arrow;
            }
        }
Exemplo n.º 6
0
        private async Task ShowSaveImageDialog(InteractionContext <Unit, string> interaction)
        {
            var dialog = new SaveFileDialog
            {
                DefaultExtension = "png",
                Filters          = new List <FileDialogFilter>
                {
                    new FileDialogFilter
                    {
                        Name       = "Obrazy",
                        Extensions = new List <string>
                        {
                            "bmp",
                            "png",
                            "jpg",
                            "jpeg",
                        },
                    },
                },
            };

            var fileName = await dialog.ShowAsync(this);

            interaction.SetOutput(fileName);
        }
Exemplo n.º 7
0
        private void GetDirectoryHandler(InteractionContext <string, string?> interaction)
        {
            using var folderDialog = new FolderBrowserDialog
                  {
                      RootFolder = System.Environment.SpecialFolder.ProgramFilesX86
                  };
            switch (folderDialog.ShowDialog())
            {
            case DialogResult.OK:
                interaction.SetOutput(folderDialog.SelectedPath);
                break;

            default:
                interaction.SetOutput(null);
                break;
            }
        }
Exemplo n.º 8
0
        /// <summary>Handles the folder prompt.</summary>
        /// <param name="context">The context of the interaction.</param>
        private void HandleFolderPrompt(InteractionContext <string, string> context)
        {
            var dialog = new CommonOpenFileDialog {
                IsFolderPicker = true, Title = context.Input
            };

            context.SetOutput(dialog.ShowDialog() != CommonFileDialogResult.Ok ? null : dialog.FileName);
        }
        private async Task DoShowConfirmationDialogAsync(InteractionContext <ConfirmationViewModel, ResultViewModel?> interaction)
        {
            var dialog = new ConfirmationWindow();

            dialog.DataContext = interaction.Input;

            var result = await dialog.ShowDialog <ResultViewModel?>(this);

            interaction.SetOutput(result);
        }
        private async Task DoShowNewCharacterDialogAsync(InteractionContext <NewCharacterViewModel, CharacterViewModel?> interaction)
        {
            var dialog = new NewCharacterWindow();

            dialog.DataContext = interaction.Input;

            var result = await dialog.ShowDialog <CharacterViewModel?>(this);

            interaction.SetOutput(result);
        }
Exemplo n.º 11
0
        /* This method creates the AvaloniaStoreWindow,
         * it sets its DataContext to interaction.Input,
         * which is the instance of the ViewModel */
        private async Task DoShowDialogAsync(InteractionContext <AvaloniaStoreViewModel, StackViewModel?> interaction)
        {
            var dialog = new AvaloniaStoreWindow();

            dialog.DataContext = interaction.Input;

            var result = await dialog.ShowDialog <StackViewModel?>(this);

            interaction.SetOutput(result);
        }
Exemplo n.º 12
0
        private async Task DoShowDialogAsync(InteractionContext <PrintCodesViewModel, PrintCodesViewModel> interaction)
        {
            var dialog = new PrintCodesWindow();

            dialog.DataContext = interaction.Input;

            var result = await dialog.ShowDialog <PrintCodesViewModel>(this);

            interaction.SetOutput(result);
        }
Exemplo n.º 13
0
        private async Task DoShowDialogAsync(InteractionContext <MusicStoreViewModel, AlbumViewModel?> interaction)
        {
            var dialog = new MusicStoreWindow {
                DataContext = interaction.Input
            };

            var result = await dialog.ShowDialog <AlbumViewModel?>(this);

            interaction.SetOutput(result);
        }
        private async Task DoShowMsgDialogAsync(InteractionContext <MessageDialogViewModel, MessageDialogViewModel> interaction)
        {
            var msgDialog = new MessageDialogView();

            msgDialog.DataContext = interaction.Input;

            var result = await msgDialog.ShowDialog <MessageDialogViewModel>(this);

            interaction.SetOutput(result);
        }
        private async Task DoShowAppDialogAsync(InteractionContext <AppStoreViewModel, AppViewModel?> interaction)
        {
            var appStoreDialog = new AppStoreWindow();

            appStoreDialog.DataContext = interaction.Input;

            var result = await appStoreDialog.ShowDialog <AppViewModel?>(this);

            interaction.SetOutput(result);
        }
Exemplo n.º 16
0
        private async Task DoShowDialogAsync(InteractionContext <MessageWindowViewModel, DialogResultViewModel?> interaction)
        {
            var dialog = new MessageWindow();

            dialog.DataContext = interaction.Input;

            var result = await dialog.ShowDialog <DialogResultViewModel?>(this);

            interaction.SetOutput(result);
        }
        private async Task DoShowRemoveDialogAsync(InteractionContext <ConfirmationViewModel, ResultViewModel?> interaction)
        {
            var dialog = new ConfirmationWindow();

            dialog.DataContext = interaction.Input;

            //var result = await dialog.ShowDialog<ItemViewModel?>(((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime).MainWindow);
            var result = await dialog.ShowDialog <ResultViewModel?>(((IVisual)this).FindAncestorOfType <Window>());

            interaction.SetOutput(result);
        }
Exemplo n.º 18
0
        private async Task DoShowDialogAsync(InteractionContext <EndpointsDialogViewModel, EndpointsListModel> interaction)
        {
            var dialog = new EndpointsDialog
            {
                DataContext = interaction.Input
            };

            var result = await dialog.ShowDialog <EndpointsListModel>(this);

            interaction.SetOutput(result);
        }
Exemplo n.º 19
0
        private async Task DoShowEventChangeDialogAsync(InteractionContext <SessionChangeViewModel, SessionViewModel?> interaction)
        {
            var dialog = new SessionChangeView
            {
                DataContext = interaction.Input
            };

            var result = await dialog.ShowDialog <SessionViewModel?>(WindowParent);

            interaction.SetOutput(result);
        }
Exemplo n.º 20
0
        private async Task DoShowInformationDisplayDialogAsync
            (InteractionContext <InformationDisplayViewModel, ResultViewModel> interaction)
        {
            var dialog = new InformationDisplayWindow();

            dialog.DataContext = interaction.Input;

            var result = await dialog.ShowDialog <ResultViewModel?>(((IVisual)this).FindAncestorOfType <Window>());

            interaction.SetOutput(result);
        }
Exemplo n.º 21
0
        private async Task DoShowInfoBoxAsync(InteractionContext <InfoBoxViewModel, Unit> interaction)
        {
            var dialog = new InfoBox
            {
                DataContext = interaction.Input
            };

            var output = await dialog.ShowDialog <Unit>(this);

            interaction.SetOutput(output);
        }
Exemplo n.º 22
0
        private async Task DoShowCloseWindowBoxDialogAsync(InteractionContext <CloseWindowBoxViewModel, Unit> interaction)
        {
            var dialog = new CloseWindowBox
            {
                DataContext = interaction.Input
            };

            await dialog.ShowDialog(WindowParent);

            interaction.SetOutput(Unit.Default);
        }
Exemplo n.º 23
0
        private async Task DoShowRegisterDialogAsync(InteractionContext <RegisterViewModel, Unit> interaction)
        {
            var dialog = new RegisterView
            {
                DataContext = interaction.Input
            };

            var output = await dialog.ShowDialog <Unit>(this);

            interaction.SetOutput(output);
        }
Exemplo n.º 24
0
        private async Task DoShowShutdownBoxDialogAsync(InteractionContext <ShutdownBoxViewModel, Unit> interaction)
        {
            var dialog = new ShutdownBox
            {
                DataContext = interaction.Input
            };

            await dialog.ShowDialog(this);

            interaction.SetOutput(Unit.Default);
        }
Exemplo n.º 25
0
        private Task DoShowMainWindowDialogAsync(InteractionContext <MainWindowViewModel, Unit> interaction)
        {
            var dialog = new MainWindow
            {
                DataContext = interaction.Input
            };

            dialog.Show();
            interaction.SetOutput(Unit.Default);

            return(Task.CompletedTask);
        }
Exemplo n.º 26
0
        /// <summary>
        /// ダイアログを表示する。
        /// </summary>
        /// <param name="interaction">インタラクション</param>
        /// <remarks>
        /// 以下を参考にして作成。
        /// https://docs.avaloniaui.net/tutorials/music-store-app/opening-a-dialog
        /// </remarks>
        /// <returns></returns>
        private async Task DoShowDialogAsync(InteractionContext <Unit, AddPlaylistDialogViewModel> interaction)
        {
            // ダイアログを表示
            var dialog = new AddPlaylistDialog();
            var vm     = new AddPlaylistDialogViewModel();

            dialog.DataContext = vm;
            await dialog.ShowDialog <Unit>(this);

            // 表示結果を設定
            interaction.SetOutput(vm);
        }
Exemplo n.º 27
0
        /// <summary>
        /// 公開されているプレイリストアイテムを自分のプレイリストアイテムとして追加するダイアログを表示する。
        /// </summary>
        /// <param name="interaction">インタラクション</param>
        /// <returns></returns>
        private async Task DoShowShowClonePlaylistItemsDialogAsync(InteractionContext <Unit, ClonePlaylistItemsDialogViewModel> interaction)
        {
            // ダイアログを表示
            var dialog = new ClonePlaylistItemsDialog();
            // TODO うまく注入するような実装にしたいが、できていない
            var vm = new ClonePlaylistItemsDialogViewModel(Locator.Current.GetService <IYouTubeService>(), Locator.Current.GetService <IWebClientService>());

            dialog.DataContext = vm;
            await dialog.ShowDialog <Unit>(this);

            // 表示結果を設定
            interaction.SetOutput(vm);
        }
        private async Task ShowDialogAsync(
            InteractionContext <TextBoxDialogViewModel, string?> interaction
            )
        {
            var dialog = new TextBoxDialogWindow
            {
                DataContext = interaction.Input
            };

            var owner  = this.FindAncestorOfType <Window>();
            var result = await dialog.ShowDialog <string?>(owner);

            interaction.SetOutput(result);
        }
Exemplo n.º 29
0
        private void HandleDeletionRequest(InteractionContext <INode, Unit> interaction)
        {
            var node      = interaction.Input;
            var connected = connections.Where(c => c.To.Node == node || c.From.Node == node);

            foreach (var connection in connected)
            {
                connection.To.ConnectedTo   = null;
                connection.From.ConnectedTo = null;
            }

            connections.RemoveAll(connected.ToArray());
            nodes.Remove(node);

            interaction.SetOutput(Unit.Default);
        }
Exemplo n.º 30
0
        private async Task DoShowJsonFileDialogAsync(InteractionContext <Unit, string[]> interaction)
        {
            var dialog = new OpenFileDialog
            {
                AllowMultiple = false,
                Title         = "Wybierz plik do importu",
                Filters       = new List <FileDialogFilter>
                {
                    new FileDialogFilter {
                        Name = "Json files", Extensions = new List <string> {
                            "json"
                        }
                    }
                }
            };

            var output = await dialog.ShowAsync(this);

            interaction.SetOutput(output);
        }