private async UniTask ConstructBuildingAsync(PlaceArgs args)
        {
            var building = await buildingConstructor.Build(args.Building, args.Position);

            if (building == null)
            {
                return;
            }

            var goal = new GoalConstructor(building, db, service, progressConstructor);

            args.Building.Accept(goal);

            Constructed?.Invoke(new BuildingArgs(building, args.Position));
        }
示例#2
0
        public TaskDialog()
        {
            config.StructSize = ( uint )Marshal.SizeOf(config);
            config.Callback   = (IntPtr hwnd, TaskDialogNotification msg, IntPtr wParam, IntPtr lParam, IntPtr lpRefData) =>
            {
                TaskDialogEventArgs commonEventArgs;
                switch (msg)
                {
                case TaskDialogNotification.Created:
                {
                    var eventArgs = new TaskDialogEventArgs()
                    {
                        TaskDialogHandle = hwnd
                    };
                    Created?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.Destroyed:
                {
                    var eventArgs = new TaskDialogEventArgs()
                    {
                        TaskDialogHandle = hwnd
                    };
                    Destroyed?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.DialogConstructed:
                {
                    var eventArgs = new TaskDialogEventArgs()
                    {
                        TaskDialogHandle = hwnd
                    };
                    Constructed?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.Help:
                {
                    var eventArgs = new TaskDialogEventArgs()
                    {
                        TaskDialogHandle = hwnd
                    };
                    Help?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.ButtonClicked:
                {
                    var eventArgs = new ButtonClickedEventArgs(( int )wParam)
                    {
                        TaskDialogHandle = hwnd
                    };
                    ButtonClicked?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.RadioButtonClicked:
                {
                    var eventArgs = new ButtonClickedEventArgs(( int )wParam)
                    {
                        TaskDialogHandle = hwnd
                    };
                    RadioButtonClicked?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.HyperlinkClicked:
                {
                    string url = null;
                    unsafe { url = new string (( char * )lParam ); }
                    var eventArgs = new HyperLinkClickedEventArgs(url)
                    {
                        TaskDialogHandle = hwnd
                    };
                    HyperlinkClicked?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.ExpendOButtonClicked:
                {
                    var eventArgs = new ExpandButtonClickedEventArgs(wParam.ToInt32() == 0 ? false : true)
                    {
                        TaskDialogHandle = hwnd
                    };
                    ExpandButtonClicked?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.VerificationClicked:
                {
                    var eventArgs = new VerificationClickedEventArgs(wParam.ToInt32() == 0 ? false : true)
                    {
                        TaskDialogHandle = hwnd
                    };
                    VerificationClicked?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.Navigated:
                {
                    var eventArgs = new TaskDialogEventArgs()
                    {
                        TaskDialogHandle = hwnd
                    };
                    Navigated?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                case TaskDialogNotification.Timer:
                {
                    var eventArgs = new TimerEventArgs(TimeSpan.FromMilliseconds(( uint )wParam))
                    {
                        TaskDialogHandle = hwnd
                    };
                    Timer?.Invoke(this, eventArgs);
                    commonEventArgs = eventArgs;
                }
                break;

                default:
                    return(0);
                }
                return(commonEventArgs.ReturnValue);
            };
        }
示例#3
0
        /// <summary>
        /// Common native callback for Task Dialogs.
        /// Will route events to the user event handler.
        /// </summary>
        /// <param name="refData">TODO: Currently unused, would need complex marshaling of data.</param>
        internal IntPtr CommonCallbackProc(IntPtr hWnd, uint uEvent, UIntPtr wParam, IntPtr lParam, IntPtr refData)
        {
            _hwnd = hWnd;

            //Handle event
            switch ((NativeMethods.TaskDialogNotification)uEvent)
            {
            case NativeMethods.TaskDialogNotification.TDN_CREATED:
                //Dispatch buffered messages
                DispatchMessageQueue();

                Created?.Invoke(this, EventArgs.Empty);
                break;

            case NativeMethods.TaskDialogNotification.TDN_NAVIGATED:
                //Dispatch buffered messages (copied in from the new task dialog we are navigating to)
                DispatchMessageQueue();

                Navigating?.Invoke(this, EventArgs.Empty);
                break;

            case NativeMethods.TaskDialogNotification.TDN_BUTTON_CLICKED:
                var evtButtonClick = ButtonClick;
                if (evtButtonClick != null)
                {
                    ClickEventArgs args = new ClickEventArgs((int)wParam);
                    evtButtonClick(this, args);

                    //Return value given by user to prevent closing (false will close)
                    return((IntPtr)((args.PreventClosing) ? 1 : 0));
                }
                break;

            case NativeMethods.TaskDialogNotification.TDN_HYPERLINK_CLICKED:
                HyperlinkClick?.Invoke(this, new HyperlinkEventArgs(Marshal.PtrToStringUni(lParam)));
                break;

            case NativeMethods.TaskDialogNotification.TDN_TIMER:
                var evtTick = Tick;
                if (evtTick != null)
                {
                    var args = new TimerEventArgs((long)wParam);
                    evtTick(this, args);

                    //Return value given by user to reset timer ticks
                    return((IntPtr)((args.ResetCount) ? 1 : 0));
                }
                break;

            case NativeMethods.TaskDialogNotification.TDN_DESTROYED:
                //Set dialog as not "showing" and drop handle to window
                _hwnd = IntPtr.Zero;

                Destroyed?.Invoke(this, EventArgs.Empty);
                break;

            case NativeMethods.TaskDialogNotification.TDN_RADIO_BUTTON_CLICKED:
                RadioButtonClick?.Invoke(this, new ClickEventArgs((int)wParam));
                break;

            case NativeMethods.TaskDialogNotification.TDN_DIALOG_CONSTRUCTED:
                Constructed?.Invoke(this, EventArgs.Empty);
                break;

            case NativeMethods.TaskDialogNotification.TDN_VERIFICATION_CLICKED:
                VerificationClick?.Invoke(this, new CheckEventArgs((uint)wParam == 1));
                break;

            case NativeMethods.TaskDialogNotification.TDN_HELP:
                Help?.Invoke(this, EventArgs.Empty);
                break;

            case NativeMethods.TaskDialogNotification.TDN_EXPANDO_BUTTON_CLICKED:
                Expanding?.Invoke(this, new ExpandEventArgs((uint)wParam != 0));
                break;
            }

            return(IntPtr.Zero);
        }