Пример #1
0
        private bool taskDialog_Callback2(IActiveTaskDialog dialog, VistaTaskDialogNotificationArgs args, object callbackData)
        {
            bool result = false;

            switch (args.Notification)
            {
            case VistaTaskDialogNotification.Created:
                _downloadedPercent = 0;
                dialog.SetProgressBarRange(0, 100);
                break;

            case VistaTaskDialogNotification.ButtonClicked:
                if (args.ButtonIndex == 0)
                {
                    _downloadTimerReset = true;
                    result = true;                             // prevent dialog from closing
                }
                break;

            case VistaTaskDialogNotification.Timer:
                if (_downloadedPercent < 100 && _downloadRandomizer.Next(0, 3) == 0)
                {
                    _downloadedPercent++;

                    dialog.SetProgressBarPosition(_downloadedPercent);
                    dialog.SetWindowTitle(
                        String.Format(
                            "{0:P0} Complete Downloading File...",
                            (Convert.ToDouble(_downloadedPercent) / 100d)));
                }
                else if (_downloadedPercent >= 100)
                {
                    // Download finished
                    // Close the dialog by simulating a click on the cancel button
                    dialog.ClickCustomButton(1);

                    // Alternative method:
                    //dialog.ClickButton(TaskDialog.GetButtonIdForCustomButton(1));
                }

                // 131072 = 1 MB in bytes
                dialog.SetContent(
                    String.Format(
                        "Time elapsed: {0} | Download rate: {1}/s",
                        TimeSpan.FromMilliseconds(args.TimerTickCount).ToString(@"h\:mm\:ss"),
                        GetByteScaleSizeBinary(_downloadRandomizer.Next(0, 131072))));

                if (_downloadTimerReset)
                {
                    // TRUE: reset tick count (args.TimerTickCount)
                    result = true;
                    _downloadTimerReset = false;
                }
                break;
            }

            return(result);
        }
Пример #2
0
 private bool taskDialog_Callback1(IActiveTaskDialog dialog, VistaTaskDialogNotificationArgs args, object callbackData)
 {
     if (args.Notification == VistaTaskDialogNotification.HyperlinkClicked)
     {
         try
         {
             Process.Start(args.Hyperlink);
         }
         catch
         {
         }
     }
     return(false);
 }
Пример #3
0
        private bool taskDialog_Callback1(IActiveTaskDialog dialog, VistaTaskDialogNotificationArgs args, object callbackData)
        {
            bool result = false;

            switch (args.Notification)
            {
            case VistaTaskDialogNotification.HyperlinkClicked:
                //result = true; // prevents HREF from being processed automatically by ShellExecute
                MessageBox.Show("Hyperlink clicked: " + args.Hyperlink);
                break;
            }

            return(result);
        }
        public static void MakeTopMost(this IActiveTaskDialog taskDialog)
        {
            if (!(taskDialog is ActiveTaskDialog activeTaskDialog))
            {
                return;
            }
            // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos
            // HWND_TOPMOST (HWND) - 1
            // Places the window above all non-topmost windows.The window maintains its topmost position even when it is deactivated.

            NativeMethods.SetWindowPos(
                activeTaskDialog.Handle, HWND_TOPMOST,
                0, 0, 0, 0,
                Win32Constants.SWP_NOSIZE | Win32Constants.SWP_NOMOVE);
        }
Пример #5
0
        public static void AwaitBackgroundAction(CountDownLatch signal, Host bookmark, string title, string message, Icon icon)
        {
            IActiveTaskDialog taskDialog = default;

            CancellationTokenSource cancelToken = new CancellationTokenSource();
            Task task = Wrap(signal, cancelToken.Token).ContinueWith(_ =>
            {
                taskDialog.ClickButton((int)TaskDialogSimpleResult.Ok);
            });

            var result = TaskDialog.TaskDialog.Show(allowDialogCancellation: true,
                                                    customMainIcon: icon,
                                                    commonButtons: TaskDialogCommonButtons.Cancel,
                                                    content: message,
                                                    mainInstruction: title,
                                                    title: BookmarkNameProvider.toString(bookmark),
                                                    showMarqueeProgressBar: true,
                                                    callback: (d, a, o) =>
            {
                switch (a.Notification)
                {
                case TaskDialogNotification.DialogConstructed:
                    taskDialog = d;

                    d.SetProgressBarMarquee(true, 0);
                    break;

                case TaskDialogNotification.ButtonClicked:
                    return(false);
                }

                return(true);
            });

            cancelToken.Cancel();

            if (result.Result == TaskDialogSimpleResult.Cancel)
            {
                throw new ConnectionCanceledException();
            }
        }
Пример #6
0
        private bool taskDialog_Callback2(IActiveTaskDialog dialog, VistaTaskDialogNotificationArgs args, object callbackData)
        {
            bool result = false;

            switch (args.Notification)
            {
                case VistaTaskDialogNotification.Created:
                    _downloadedPercent = 0;
                    dialog.SetProgressBarRange(0, 100);
                    break;
                case VistaTaskDialogNotification.ButtonClicked:
                    if (args.ButtonId == 500)
                    {
                        _downloadTimerReset = true;
                        result = true; // prevent dialog from closing
                    }
                    break;
                case VistaTaskDialogNotification.Timer:
                    if (_downloadedPercent < 100 && _downloadRandomizer.Next(0, 10) == 0)
                    {
                        _downloadedPercent++;

                        dialog.SetProgressBarPosition(_downloadedPercent);
                        dialog.SetWindowTitle(
                            String.Format(
                                "{0:P0} Complete Downloading File...",
                                (Convert.ToDouble(_downloadedPercent) / 100d)));
                    }
                    else if (_downloadedPercent >= 100)
                    {
                        // Download finished
                        // Close the dialog by simulating a click on the cancel button
                        dialog.ClickButton(TaskDialog.GetButtonIdForCustomButton(1));
                    }

                    // 131072 = 1 MB in bytes
                    dialog.SetContent(
                        String.Format(
                            "Time elapsed: {0} | Download rate: {1}/s",
                            TimeSpan.FromMilliseconds(args.TimerTickCount).ToString(@"h\:mm\:ss"),
                            GetByteScaleSizeBinary(_downloadRandomizer.Next(0, 131072))));

                    if (_downloadTimerReset)
                    {
                        // TRUE: reset tick count (args.TimerTickCount)
                        result = true;
                        _downloadTimerReset = false;
                    }
                    break;
            }

            return result;
        }
Пример #7
0
        private bool taskDialog_Callback1(IActiveTaskDialog dialog, VistaTaskDialogNotificationArgs args, object callbackData)
        {
            bool result = false;

            switch (args.Notification)
            {
                case VistaTaskDialogNotification.HyperlinkClicked:
                    //result = true; // prevents HREF from being processed automatically by ShellExecute
                    MessageBox.Show("Hyperlink clicked: " + args.Hyperlink);
                    break;
            }

            return result;
        }
Пример #8
0
    private bool taskDialog_Callback(IActiveTaskDialog dialog, VistaTaskDialogNotificationArgs args, object callbackData) {
      bool result = false;

      switch (args.Notification) {
        case VistaTaskDialogNotification.ButtonClicked:
          if (args.ButtonId == 500) {
            this.autoUpdater.ReadyToBeInstalled += AutoUpdater_ReadyToBeInstalled;
            this.autoUpdater.InstallNow();
          } else if (args.ButtonId == 501) {
          }
          break;
      }

      return result;
    }