Beispiel #1
0
    private void CraftMaterialButton_OnInitialized(object sender, EventArgs e)
    {
        var button = sender as Button;

        if (button?.ToolTip == null)
        {
            var toolTipBlock = new TextBlock
            {
                Style = (Style)FindResource("ToolTipTextBlockBase")
            };

            toolTipBlock.Inlines.Add(new Run("Craft with:"));
            toolTipBlock.Inlines.Add(new LineBreak());

            var listOfInlines = ItemToolTipHelper.GenerateRecipeIngredientsInlines(button.CommandParameter as Recipe);

            foreach (var run in listOfInlines)
            {
                run.FontFamily = (FontFamily)FindResource("FontRegularDemiBold");
                run.FontSize   = (double)FindResource("FontSizeToolTipBase");
                toolTipBlock.Inlines.Add(run);
            }

            var toolTip = new ToolTip
            {
                Style = (Style)FindResource("ToolTipSimple")
            };

            toolTip.Content = toolTipBlock;

            button.ToolTip = toolTip;
        }
    }
Beispiel #2
0
    private bool CheckAndRemoveMaterials(Recipe recipe)
    {
        if (!CheckIfHeroHasEnoughMaterials(recipe))
        {
            var notEnoughMaterialsInlines = new List <Inline>
            {
                new Run("You don't have enough materials to craft "),
                new Run($"{recipe.Name}")
                {
                    FontFamily = (FontFamily)FindResource("FontRegularDemiBold")
                },
                new Run(".\n")
            };
            notEnoughMaterialsInlines.AddRange(ItemToolTipHelper.GenerateRecipeIngredientsInlines(recipe));
            notEnoughMaterialsInlines.Add(new Run("\n\nGet more materials by completing quests and killing monsters and bosses or try to craft this artifact using ingots."));

            AlertBox.Show(notEnoughMaterialsInlines, MessageBoxButton.OK);
            return(false);
        }

        var enoughMaterialsInlines = new List <Inline>
        {
            new Run("Are you sure you want to craft "),
            new Run($"{recipe.Name}")
            {
                FontFamily = (FontFamily)FindResource("FontRegularDemiBold")
            },
            new Run(" using materials?\n")
        };

        enoughMaterialsInlines.AddRange(ItemToolTipHelper.GenerateRecipeIngredientsInlines(recipe));
        enoughMaterialsInlines.Add(new Run("\n\nThis action will destroy all materials and this recipe."));

        var result = AlertBox.Show(enoughMaterialsInlines);

        if (result == MessageBoxResult.No)
        {
            return(false);
        }

        RemoveMaterials(recipe);
        return(true);
    }