コード例 #1
0
        public PhaseChooserDialog()
        {
            this.InitializeComponent();

            if (GalaSoft.MvvmLight.ViewModelBase.IsInDesignModeStatic)
            {
                var wrapPhase = ItemPhaseDefinition.FindPhase("Wrap", ItemPhaseDefinition.ButtsPhases);
                this.Choices = wrapPhase.NextPhases;
            }
        }
コード例 #2
0
        public async Task <ItemPhaseDefinition> ChooseNextPhaseAsync(ItemDefinition definition, ItemPhaseDefinition currentPhase)
        {
            // Special case for first phase
            if (currentPhase == null)
            {
                return(definition.Phases);
            }

            if (!currentPhase.NextPhases.Any())
            {
                throw new InvalidOperationException("Phase has no next phases!");
            }

            if (currentPhase.NextPhases.Count == 1)
            {
                return(currentPhase.NextPhases.First());
            }

            // Show dialog for more than one next phase
            var dialog = new Dialogs.PhaseChooserDialog();

            dialog.Choices = currentPhase.NextPhases;

            var result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                return(dialog.SelectedChoice);
            }

            return(null);
        }