Пример #1
0
        private async void btnPinOutcomeCreate_Click(object sender, RoutedEventArgs e)
        {
            IKey   categoryKey  = KeyFactory.Empty(typeof(Category));
            Color? background   = null;
            string categoryName = null;

            // Select a category.
            CategoryPicker categoryPicker = new CategoryPicker();

            categoryPicker.SelectedKey = categoryKey;

            ContentDialogResult categoryResult = await categoryPicker.ShowAsync();

            if (categoryResult == ContentDialogResult.None)
            {
                return;
            }

            if (categoryResult == ContentDialogResult.Primary)
            {
                categoryKey = categoryPicker.SelectedKey;
            }
            else if (categoryResult == ContentDialogResult.Secondary)
            {
                categoryKey = KeyFactory.Empty(typeof(Category));
            }

            if (!categoryKey.IsEmpty)
            {
                categoryName = await queryDispatcher.QueryAsync(new GetCategoryName(categoryKey));

                background = await queryDispatcher.QueryAsync(new GetCategoryColor(categoryKey));
            }

            // Select a background color.
            ColorPicker backgroundPicker = new ColorPicker();

            backgroundPicker.Title             = "Pick a tile background color";
            backgroundPicker.PrimaryButtonText = "Create";

            if (background != null)
            {
                backgroundPicker.Value = background.Value;
            }

            ContentDialogResult backgroundResult = await backgroundPicker.ShowAsync();

            if (backgroundResult == ContentDialogResult.None)
            {
                return;
            }

            // Create a tile.
            await tileService.PinOutcomeCreate(categoryKey, categoryName, backgroundPicker.Value);

            string message = "Tile created";

            if (categoryName != null)
            {
                message += $" for category '{categoryName}'";
            }

            navigator
            .Message(message)
            .Show();
        }
Пример #2
0
        private async void abbPin_Click(object sender, RoutedEventArgs e)
        {
            IKey   categoryKey  = ViewModel.SelectedCategories.FirstOrDefault() ?? KeyFactory.Empty(typeof(Category));
            Color? background   = null;
            string categoryName = null;

            // Select a category.
            CategoryPicker categoryPicker = new CategoryPicker();

            categoryPicker.SelectedKey = categoryKey;

            ContentDialogResult categoryResult = await categoryPicker.ShowAsync();

            if (categoryResult == ContentDialogResult.None)
            {
                return;
            }

            if (categoryResult == ContentDialogResult.Primary)
            {
                categoryKey = categoryPicker.SelectedKey;
            }
            else if (categoryResult == ContentDialogResult.Secondary)
            {
                categoryKey = KeyFactory.Empty(typeof(Category));
            }

            if (!categoryKey.IsEmpty)
            {
                CategoryModel category = ViewModel.Categories.FirstOrDefault(c => c.Key.Equals(categoryKey));
                if (category != null)
                {
                    categoryName = category.Name;
                    background   = category.Color;
                }
            }

            // Select a background color.
            ColorPicker backgroundPicker = new ColorPicker();

            backgroundPicker.Title             = "Pick a tile background color";
            backgroundPicker.PrimaryButtonText = "Create";

            if (background != null)
            {
                backgroundPicker.Value = background.Value;
            }

            ContentDialogResult backgroundResult = await backgroundPicker.ShowAsync();

            if (backgroundResult == ContentDialogResult.None)
            {
                return;
            }

            // Create a tile.
            await tileService.PinOutcomeCreate(categoryKey, categoryName, backgroundPicker.Value);

            string message = "Tile created";

            if (categoryName != null)
            {
                message += $" for category '{categoryName}'";
            }

            navigator
            .Message(message)
            .Show();
        }