Beispiel #1
0
        public async Task RunAsync(GeneratorTabViewModel generator)
        {
            var savedHighlights = Tree.HighlightedNodes.ToList();

            var solver = await generator.CreateSolverAsync();

            if (solver == null)
            {
                return;
            }

            var controllerResult = await _dialogCoordinator
                                   .ShowControllerDialogAsync(_dialogContext, solver, generator.DisplayName, Tree);

            if (controllerResult != null)
            {
                Tree.SkilledNodes.Clear();
                Tree.AllocateSkillNodes(controllerResult.Select(n => SkillTree.Skillnodes[n]));
            }
            Tree.HighlightedNodes.Clear();
            Tree.HighlightedNodes.UnionWith(savedHighlights);
            Tree.DrawHighlights();

            RunFinished?.Invoke(this, EventArgs.Empty);
        }
        /// <summary>
        /// Constructs a new SettingsViewModel that operates on the given skill tree.
        /// </summary>
        /// <param name="tree">The skill tree to operate on. (not null)</param>
        /// <param name="generator">Optional <see cref="GeneratorTabViewModel"/> initialize
        /// <see cref="Tabs"/> with. If non is provided, <see cref="AdvancedTabViewModel"/>,
        /// <see cref="AutomatedTabViewModel"/> and <see cref="SteinerTabViewModel"/> will be
        /// added to <see cref="Tabs"/>.</param>
        public SettingsViewModel(SkillTree tree, GeneratorTabViewModel generator = null)
        {
            if (tree == null)
            {
                throw new ArgumentNullException("tree");
            }

            DisplayName = L10n.Message("Skill tree Generator");

            _tree            = tree;
            AdditionalPoints = CalculateAdditionalPointsNeeded(tree);

            tree.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Level")
                {
                    TotalPoints = _tree.Level - 1 + _additionalPoints;
                }
            };

            if (generator == null)
            {
                CreateTabs();
            }
            else
            {
                Tabs = new ObservableCollection <GeneratorTabViewModel> {
                    generator
                };
            }
        }
        public async Task RunAsync(GeneratorTabViewModel generator)
        {
            var savedHighlights = Tree.HighlightedNodes.ToList();

            var solver = await generator.CreateSolverAsync();
            if (solver == null)
                return;

            var controllerResult = await _dialogCoordinator
                .ShowControllerDialogAsync(this, solver, generator.DisplayName, Tree);
            if (controllerResult != null)
            {
                Tree.SkilledNodes.Clear();
                Tree.AllocateSkillNodes(controllerResult.Select(n => SkillTree.Skillnodes[n]));
            }
            Tree.HighlightedNodes.Clear();
            Tree.HighlightedNodes.UnionWith(savedHighlights);
            Tree.DrawHighlights();

            RunFinished?.Invoke(this, EventArgs.Empty);
        }
        /// <summary>
        /// Constructs a new SettingsViewModel that operates on the given skill tree.
        /// </summary>
        /// <param name="tree">The skill tree to operate on. (not null)</param>
        /// <param name="generator">Optional <see cref="GeneratorTabViewModel"/> initialize
        /// <see cref="Tabs"/> with. If non is provided, <see cref="AdvancedTabViewModel"/>,
        /// <see cref="AutomatedTabViewModel"/> and <see cref="SteinerTabViewModel"/> will be
        /// added to <see cref="Tabs"/>.</param>
        public SettingsViewModel(SkillTree tree, GeneratorTabViewModel generator = null)
        {
            if (tree == null) throw new ArgumentNullException("tree");

            DisplayName = L10n.Message("Skill tree Generator");

            _tree = tree;
            AdditionalPoints = CalculateAdditionalPointsNeeded(tree);
            
            tree.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Level")
                {
                    TotalPoints = _tree.Level - 1 + _additionalPoints;
                }
            };

            if (generator == null)
            {
                CreateTabs();
            }
            else
            {
                Tabs = new ObservableCollection<GeneratorTabViewModel> { generator };
            }
        }