Esempio n. 1
0
        void dlg_ButtonClick(object sender, ClickEventArgs e)
        {
            if (e.ButtonID == 9)
            {
                e.PreventClosing = true;

                WindowsFormsAero.TaskDialog.TaskDialog newDlg = new TaskDialog("Uploading...", "Upload");
                newDlg.ShowProgressBar = true;
                newDlg.EnableCallbackTimer = true;
                newDlg.ProgressBarMaxRange = 90;
                newDlg.CustomButtons = new CustomButton[] {
                    new CustomButton(Result.Cancel, "Abort transfer")
                };
                newDlg.Footer = "Elapsed time: 0s.";
                newDlg.FooterCommonIcon = TaskDialogIcon.Information;

                WindowsFormsAero.TaskDialog.TaskDialog dlg = (WindowsFormsAero.TaskDialog.TaskDialog)sender;
                dlg.Navigate(newDlg);

                tickHandler = new EventHandler<TimerEventArgs>(dlg_Tick);
                dlg.Tick += tickHandler;
            }
        }
Esempio n. 2
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);
        }
Esempio n. 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)
        {
            //Store window handle
            _hwnd = hWnd;

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

                    if (Created != null)
                        Created(this, new EventArgs());
                    break;

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

                    if (Navigating != null)
                        Navigating(this, new EventArgs());
                    break;

                case NativeMethods.TaskDialogNotification.TDN_BUTTON_CLICKED:
                    if (ButtonClick != null) {
                        ClickEventArgs args = new ClickEventArgs((int)wParam);
                        ButtonClick(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:
                    if (HyperlinkClick != null)
                        HyperlinkClick(this, new HyperlinkEventArgs(Marshal.PtrToStringUni(lParam)));
                    break;

                case NativeMethods.TaskDialogNotification.TDN_TIMER:
                    if (Tick != null) {
                        TimerEventArgs args = new TimerEventArgs((long)wParam);
                        Tick(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;

                    if (Destroyed != null)
                        Destroyed(this, new EventArgs());
                    break;

                case NativeMethods.TaskDialogNotification.TDN_RADIO_BUTTON_CLICKED:
                    if (RadioButtonClick != null)
                        RadioButtonClick(this, new ClickEventArgs((int)wParam));
                    break;

                case NativeMethods.TaskDialogNotification.TDN_DIALOG_CONSTRUCTED:
                    if (Constructed != null)
                        Constructed(this, new EventArgs());
                    break;

                case NativeMethods.TaskDialogNotification.TDN_VERIFICATION_CLICKED:
                    if (VerificationClick != null)
                        VerificationClick(this, new CheckEventArgs((uint)wParam == 1));
                    break;

                case NativeMethods.TaskDialogNotification.TDN_HELP:
                    if (Help != null)
                        Help(this, new EventArgs());
                    break;

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

            return IntPtr.Zero;
        }