Exemplo 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;
            }
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
        void dlg_Tick(object sender, TimerEventArgs e)
        {
            WindowsFormsAero.TaskDialog.TaskDialog dlg = (WindowsFormsAero.TaskDialog.TaskDialog)sender;

            cTicks    += (int)e.Ticks;
            dlg.Footer = "Elapsed time: " + cTicks / 1000 + "s.";

            if (dlg.ProgressBarState == WindowsFormsAero.ProgressBar.States.Normal)
            {
                dlg.ProgressBarPosition += (int)e.Ticks / 100;
                e.ResetCount             = true;
            }

            if (dlg.ProgressBarPosition >= 90)
            {
                WindowsFormsAero.TaskDialog.TaskDialog newDlg = new TaskDialog("Upload complete.", "Upload", "Thank you!");
                newDlg.CustomButtons = new CustomButton[] {
                    new CustomButton(Result.Cancel, "Close")
                };
                dlg.Navigate(newDlg);

                dlg.Tick -= tickHandler;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Opens a confirmation dialog to confirm whether to reset the main form or not.
        /// </summary>
        public void ResetMainFormWithConfirmation()
        {
            var dlg = new TaskDialog(Strings.AskReset, Strings.AskResetTitle, Strings.AskResetContent);
            dlg.UseCommandLinks = true;
            dlg.CustomButtons = new CustomButton[] {
                new CustomButton(Result.OK, Strings.AskResetButtonOk),
                new CustomButton(Result.Cancel, Strings.ButtonCancel)
            };
            dlg.CommonIcon = TaskDialogIcon.Information;

            if (dlg.Show(this).CommonButton == Result.OK) {
                ResetMainForm();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Displays an error task dialog.
        /// </summary>
        /// <param name="mainInstruction">Main instruction of the error dialog.</param>
        /// <param name="explanation">Detailed informations about the error.</param>
        /// <param name="errorMessage">Expanded error codes/messages.</param>
        private void ShowErrorDialog(string mainInstruction, string explanation, string errorMessage)
        {
            TaskDialog dlg = new TaskDialog(mainInstruction, Strings.ErrorGenericTitle, explanation) {
                CommonIcon = TaskDialogIcon.Stop,
                IsExpanded = false
            };

            if (!string.IsNullOrEmpty(errorMessage)) {
                dlg.ExpandedInformation = Strings.ErrorGenericInfoText + errorMessage;
                dlg.ExpandedControlText = Strings.ErrorGenericInfoButton;
            }

            dlg.Show(this);
        }
Exemplo n.º 6
0
        /// <summary>Creates a new Task Dialog setup and replaces the existing one. Note that the window will not be
        /// destroyed and that you should keep the existing TaskDialog reference (event handlers will still be
        /// registered). The existing Task Dialog will simply reset and use the options of the new one.</summary>
        /// <param name="nextDialog">An instance of Task Dialog, whose settings will be copied into the existing dialog.
        /// You may safely destroy the nextDialog instance after use (do not register to events on it).</param>
        public void Navigate(TaskDialog nextDialog)
        {
            //Prepare config structure of target dialog
            nextDialog.PreConfig(IntPtr.Zero);
            //Keep callback reference to the current dialog, since the nextDialog instance will eventually be destroyed
            nextDialog.config.pfCallback = config.pfCallback;
            //Copy queued messages
            while (nextDialog._msgQueue.Count > 0)
                _msgQueue.Enqueue(nextDialog._msgQueue.Dequeue());

            //Navigate
            PostMessage(new Message(NativeMethods.TaskDialogMessages.TDM_NAVIGATE_PAGE, 0, nextDialog.config));

            //Clean up
            nextDialog.PostConfig();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles background downloading.
        /// </summary>
        private void DownloadAsyncCallback(IAsyncResult result)
        {
            if (_downloadRequest == null || _updateDialog == null)
                return;

            try {
                var response = _downloadRequest.EndGetResponse(result);
                var responseStream = response.GetResponseStream();
                long total = response.ContentLength;

                byte[] buffer = new byte[1024];

                using (var stream = new FileStream(UpdateInstallerPath, FileMode.Create)) {
                    int readTotal = 0;
                    while (true) {
                        int read = responseStream.Read(buffer, 0, buffer.Length);
                        readTotal += read;

                        if (read <= 0) //EOF
                            break;

                        stream.Write(buffer, 0, read);

                        _updateDialog.Content = string.Format(Strings.UpdateDownloadingContent, readTotal, total);
                        _updateDialog.ProgressBarPosition = (int)((readTotal * 100.0) / total);
                    }
                }
            }
            catch (Exception ex) {
                DownloadShowError(ex.Message);
                return;
            }

            _updateDownloaded = true;

            var okDlg = new TaskDialog {
                Title = Strings.UpdateTitle,
                Instruction = Strings.UpdateReadyInstruction,
                Content = string.Format(Strings.UpdateReadyContent, LastInformation.LatestVersion),
                UseCommandLinks = true,
                CommonButtons = TaskDialogButton.Cancel,
                CustomButtons = new CustomButton[] {
                    new CustomButton(Result.OK, Strings.UpdateReadyCommandOk)
                }
            };
            _updateDialog.Navigate(okDlg);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Displays info. Called from GUI thread.
 /// </summary>
 private void DisplayInfoCore()
 {
     //No updates, but need to inform the user
     var dlg = new TaskDialog {
         Title = Strings.UpdateTitle,
         Instruction = Strings.UpdateInfoInstruction,
         Content = Strings.UpdateInfoContent,
         EnableHyperlinks = true,
         CommonButtons = TaskDialogButton.Close,
         AllowDialogCancellation = true,
         CommonIcon = TaskDialogIcon.Information,
         Footer = string.Format(Strings.UpdateInfoFooter, LastInformation.LatestVersionRelease.ToLongDateString())
     };
     dlg.HyperlinkClick += delegate(object sender, HyperlinkEventArgs args) {
         Process.Start("http://ontopreplica.codeplex.com");
     };
     dlg.Show(AttachedForm);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Core delegate that asks for update confirmation and installs. Must be called from GUI thread.
        /// </summary>
        private void ConfirmAndInstallCore()
        {
            _updateDialog = new TaskDialog {
                Title = Strings.UpdateTitle,
                Instruction = string.Format(Strings.UpdateAvailableInstruction, LastInformation.LatestVersion),
                Content = Strings.UpdateAvailableContent,
                CustomButtons = new CustomButton[] {
                    new CustomButton(Result.OK, string.Format(Strings.UpdateAvailableCommandOk, LastInformation.LatestVersion)),
                    new CustomButton(Result.Cancel, Strings.UpdateAvailableCommandCancel)
                },
                UseCommandLinks = true,
                CommonIcon = TaskDialogIcon.Information,
                ExpandedInformation = string.Format(Strings.UpdateAvailableExpanded, LastInformation.CurrentVersion, LastInformation.LatestVersion),
            };
            _updateDialog.ButtonClick += delegate(object sender, ClickEventArgs args) {
                if (args.ButtonID == (int)Result.OK) {
                    args.PreventClosing = true;

                    if (_updateDownloaded) {
                        //Terminate application
                        AttachedForm.Close();

                        //Launch updater
                        Process.Start(UpdateInstallerPath);
                    }
                    else {
                        var downDlg = new TaskDialog {
                            Title = Strings.UpdateTitle,
                            Instruction = Strings.UpdateDownloadingInstruction,
                            ShowProgressBar = true,
                            ProgressBarMinRange = 0,
                            ProgressBarMaxRange = 100,
                            ProgressBarPosition = 0,
                            CommonButtons = TaskDialogButton.Cancel
                        };
                        _updateDialog.Navigate(downDlg);

                        _downloadRequest = (HttpWebRequest)HttpWebRequest.Create(LastInformation.DownloadInstaller);
                        _downloadRequest.BeginGetResponse(DownloadAsyncCallback, null);
                    }
                }
            };

            _updateDialog.Show(AttachedForm);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Core delegate that asks for update confirmation and installs. Must be called from GUI thread.
 /// </summary>
 private void ConfirmAndInstallCore()
 {
     var updateDialog = new TaskDialog {
         Title = Strings.UpdateTitle,
         Instruction = string.Format(Strings.UpdateAvailableInstruction, LastInformation.LatestVersion),
         Content = Strings.UpdateAvailableContent,
         CustomButtons = new CustomButton[] {
             new CustomButton(Result.OK, string.Format(Strings.UpdateAvailableCommandOk, LastInformation.LatestVersion)),
             new CustomButton(Result.Cancel, Strings.UpdateAvailableCommandCancel)
         },
         UseCommandLinks = true,
         CommonIcon = TaskDialogIcon.Information,
         ExpandedInformation = string.Format(Strings.UpdateAvailableExpanded, LastInformation.CurrentVersion, LastInformation.LatestVersion),
     };
     if (updateDialog.Show(AttachedForm).CommonButton == Result.OK) {
         Shell.Execute(LastInformation.DownloadPage);
     }
 }
Exemplo n.º 11
0
        void dlg_Tick(object sender, TimerEventArgs e)
        {
            WindowsFormsAero.TaskDialog.TaskDialog dlg = (WindowsFormsAero.TaskDialog.TaskDialog)sender;

            cTicks += (int)e.Ticks;
            dlg.Footer = "Elapsed time: " + cTicks / 1000 + "s.";

            if (dlg.ProgressBarState == WindowsFormsAero.ProgressBar.States.Normal)
            {
                dlg.ProgressBarPosition += (int)e.Ticks / 100;
                e.ResetCount = true;
            }

            if (dlg.ProgressBarPosition >= 90)
            {
                WindowsFormsAero.TaskDialog.TaskDialog newDlg = new TaskDialog("Upload complete.", "Upload", "Thank you!");
                newDlg.CustomButtons = new CustomButton[] {
                    new CustomButton(Result.Cancel, "Close")
                };
                dlg.Navigate(newDlg);

                dlg.Tick -= tickHandler;
            }
        }
Exemplo n.º 12
0
        private void tskDlgMarquee(object sender, EventArgs e)
        {
            TaskDialog dlg = new TaskDialog("This dialog displays a progress bar", "Marquee Progress Bar", "The progress bar below is in 'marquee' mode, that is it will not show the exact percentage of the work done, but it will show that some work is being done.", TaskDialogButton.Close);
            dlg.SetMarqueeProgressBar(true, 30);

            dlg.Show(this);
        }
Exemplo n.º 13
0
        private void tskDlgComplex(object sender, EventArgs e)
        {
            TaskDialog dlg = new TaskDialog("This is the main instruction", "Complex Task Dialog");
            dlg.CommonIcon = TaskDialogIcon.SecurityShieldBlue;
            dlg.Content = "You may write long and informative messages, with <a href=\"http://www.google.com\">hyperlinks</a> and linebreaks.\nButtons can also be shaped as Command Link buttons instead of standard buttons. You may also use radio buttons or add a progress bar.";
            dlg.UseCommandLinks = true;
            dlg.EnableHyperlinks = true;
            dlg.CustomButtons = new CustomButton[] {
                new CustomButton(9, "Upload\nShows a fake upload task dialog."),
                new CustomButton(Result.Cancel, "Close")
            };
            dlg.RadioButtons = new CustomButton[] {
                new CustomButton(1, "First radio button"),
                new CustomButton(2, "Second radio button"),
                new CustomButton(3, "Third radio button")
            };
            dlg.ExpandedControlText = "Details";
            dlg.ExpandedInformation = "Place some \"expanded information\" here...";

            dlg.EnableRadioButton(3, false);

            //Evt registration
            dlg.ButtonClick += new EventHandler<ClickEventArgs>(dlg_ButtonClick);

            Results results = dlg.Show(this.Handle);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Opens a confirmation dialog to confirm whether to reset the main form or not.
        /// </summary>
        public void ResetMainFormWithConfirmation()
        {
            var dlg = new TaskDialog("Reset the mainform?", "reset preseria-preview dialog", "Do you want to reset the mainform to default values?");
            dlg.UseCommandLinks = true;
            dlg.CustomButtons = new CustomButton[] {
                new CustomButton(Result.OK, "OK"),
                new CustomButton(Result.Cancel, "Cancel")
            };
            dlg.CommonIcon = TaskDialogIcon.Information;

            if (dlg.Show(this).CommonButton == Result.OK) {
                ResetMainForm();
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Displays an error task dialog.
        /// </summary>
        /// <param name="mainInstruction">Main instruction of the error dialog.</param>
        /// <param name="explanation">Detailed informations about the error.</param>
        /// <param name="errorMessage">Expanded error codes/messages.</param>
        private void ShowErrorDialog(string mainInstruction, string explanation, string errorMessage)
        {
            TaskDialog dlg = new TaskDialog(mainInstruction, "Error Preseria-Preview", explanation) {
                CommonIcon = TaskDialogIcon.Stop,
                IsExpanded = false
            };

            if (!string.IsNullOrEmpty(errorMessage)) {
                dlg.ExpandedInformation = "Error: " + errorMessage;
                dlg.ExpandedControlText = "OK";
            }

            dlg.Show(this);
        }