示例#1
0
    public void Select(DungeonCharacter dc, ReturnFunction rf, CancelFunction cf)
    {
        rfunc = rf;
        cfunc = cf;
        dchar = dc;

        options = OptionsFor(dc);
        selIndex = 0;

        screenPos = Camera.mainCamera.WorldToScreenPoint(dc.entity.tile.worldPos);
        screenPos.y = Screen.height - screenPos.y;

        selecting = true;
    }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WizardControlViewModel"/> class.
        /// </summary>
        public WizardControlViewModel()
        {
            this.Pages = new ObservableCollection <IWizardPage>();

            PreviousCommand = new DelegateCommand(() =>
            {
                Navigate(NavigationDirection.Backwards);

                //if (SelectedIndex == Pages.IndexOf(ErrorPage))
                //{
                //    SetPage(LastActivePageIndex);
                //}
                //else
                //{
                //    var cuItem = this.Pages[SelectedIndex];

                //    if (CanNavigate(NavigationDirection.Backwards, cuItem))
                //        SetPage(GetPreviousPageIndex(SelectedIndex));
                //}
            });

            NextCommand = new DelegateCommand(() =>
            {
                Navigate(NavigationDirection.Forward);
            });

            ProcessButtonCommand = new DelegateCommand(() =>
            {
                var cuItem = this.Pages[SelectedIndex];

                if (cuItem.Validate())
                {
                    if (CanNavigate(NavigationDirection.Forward, cuItem))
                    {
                        IsBusy = true;
                    }

                    Task.Run(async() =>
                    {
                        SetPage(Pages.IndexOf(ProgressPage));

                        try
                        {
                            if (ProcessFunction != null)
                            {
                                var result = await ProcessFunction();

                                switch (result)
                                {
                                case WizardProcessResult.Complete:
                                    {
                                        SetPage(Pages.IndexOf(CompletePage));
                                    }
                                    break;

                                default:
                                    {
                                        SetPage(Pages.IndexOf(ErrorPage));
                                    }
                                    break;
                                }
                            }
                            else
                            {
                                SetPage(Pages.IndexOf(CompletePage));
                            }
                        }
                        catch (Exception)
                        {
                        }
                    });

                    //

                    IsBusy = false;
                }
            });

            CompleteCommand = new DelegateCommand(() =>
            {
                CloseFunction?.Invoke();
            });

            CancelCommand = new DelegateCommand(() =>
            {
                CancelFunction?.Invoke();
            });
        }