Esempio n. 1
0
 private uint TaskDialogCallback(IntPtr hwnd, uint uNotification, IntPtr wParam, IntPtr lParam, IntPtr dwRefData)
 {
     Interlocked.Increment(ref _inEventHandler);
     try
     {
         switch( (NativeMethods.TaskDialogNotifications)uNotification )
         {
         case NativeMethods.TaskDialogNotifications.Created:
             _handle = hwnd;
             DialogCreated();
             OnCreated(EventArgs.Empty);
             break;
         case NativeMethods.TaskDialogNotifications.Destroyed:
             _handle = IntPtr.Zero;
             OnDestroyed(EventArgs.Empty);
             break;
         case NativeMethods.TaskDialogNotifications.Navigated:
             DialogCreated();
             break;
         case NativeMethods.TaskDialogNotifications.HyperlinkClicked:
             string url = Marshal.PtrToStringUni(lParam);
             OnHyperlinkClicked(new HyperlinkClickedEventArgs(url));
             break;
         case NativeMethods.TaskDialogNotifications.ButtonClicked:
             TaskDialogButton button;
             if( _buttonsById.TryGetValue((int)wParam, out button) )
             {
                 TaskDialogItemClickedEventArgs e = new TaskDialogItemClickedEventArgs(button);
                 OnButtonClicked(e);
                 if( e.Cancel )
                     return 1;
             }
             break;
         case NativeMethods.TaskDialogNotifications.VerificationClicked:
             IsVerificationChecked = ((int)wParam) == 1;
             OnVerificationClicked(EventArgs.Empty);
             break;
         case NativeMethods.TaskDialogNotifications.RadioButtonClicked:
             TaskDialogRadioButton radioButton;
             if( _radioButtonsById.TryGetValue((int)wParam, out radioButton) )
             {
                 radioButton.Checked = true; // there's no way to click a radio button without checking it, is there?
                 TaskDialogItemClickedEventArgs e = new TaskDialogItemClickedEventArgs(radioButton);
                 OnRadioButtonClicked(e);
             }
             break;
         case NativeMethods.TaskDialogNotifications.Timer:
             TimerEventArgs timerEventArgs = new TimerEventArgs(wParam.ToInt32());
             OnTimer(timerEventArgs);
             return (uint)(timerEventArgs.ResetTickCount ? 1 : 0);
         case NativeMethods.TaskDialogNotifications.ExpandoButtonClicked:
             OnExpandButtonClicked(new ExpandButtonClickedEventArgs(wParam.ToInt32() != 0));
             break;
         case NativeMethods.TaskDialogNotifications.Help:
             OnHelpRequested(EventArgs.Empty);
             break;
         }
         return 0;
     }
     finally
     {
         Interlocked.Decrement(ref _inEventHandler);
         if( _updatePending )
             UpdateDialog();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Raises the <see cref="Timer"/> event.
 /// </summary>
 /// <param name="e">The <see cref="TimerEventArgs"/> containing the data for the event.</param>
 protected virtual void OnTimer(TimerEventArgs e)
 {
     if( Timer != null )
         Timer(this, e);
 }