Esempio n. 1
1
File: Program.cs Progetto: jariz/jZm
        public static void PluginExc(Exception z,   jZmPlugin plug)
        {
            TaskDialog diag = new TaskDialog();
            diag.InstructionText = "'" + plug.Name + "' by '" + plug.Author + "' has thrown a exception.";
            diag.Text = "One of your plugins has thrown an unhandled exception.\nThis means that one of your plugin may be unstable.";
            diag.Caption = "WTF?";
            diag.Icon = TaskDialogStandardIcon.Error;
            diag.DetailsExpandedText = z.ToString();
            TaskDialogCommandLink linkz = new TaskDialogCommandLink("r", "Restart jZm");
            linkz.ShowElevationIcon = true;
            linkz.Click += delegate(object sender, EventArgs argz)
            {
                diag.Close();
                Application.Restart();
            };
            diag.Controls.Add(linkz);
            linkz = new TaskDialogCommandLink("r", "Exit jZm");
            linkz.Click += delegate(object sender, EventArgs argz)
            {
                diag.Close();
                Environment.Exit(-1);
            };
            diag.Controls.Add(linkz);

            linkz = new TaskDialogCommandLink("r", "Ignore error", "Warning: Plugin might throw more errors, You'll probably be better off contacting the owner and/or removing the plugin.");
            linkz.Click += delegate(object sender, EventArgs argz)
            {
                diag.Close();
            };
            diag.Controls.Add(linkz);
            diag.Show();
        }
Esempio n. 2
1
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        public static TaskDialogResult Show(IntPtr owner)
        {
            TaskDialog td = new TaskDialog();

            TaskDialogCommandLink cusButton = new TaskDialogCommandLink("cusButton", U.T("AssociationsChoose"), U.T("AssociationsChooseText"));
            TaskDialogCommandLink skipButton = new TaskDialogCommandLink("skipButton", U.T("AssociationsSkip"), U.T("AssociationsSkipText"));
            TaskDialogCommandLink defButton = new TaskDialogCommandLink("defButton", U.T("AssociationsYes"), U.T("AssociationsYesText"));

            defButton.Click += new EventHandler(defButton_Click);
            skipButton.Click += new EventHandler(skipButton_Click);

            td.Controls.Add(defButton);
            td.Controls.Add(cusButton);
            td.Controls.Add(skipButton);

            td.Caption = U.T("AssociationsCaption");
            td.InstructionText = U.T("AssociationsInstruction");
            td.Text = U.T("AssociationsText");
            td.StartupLocation = TaskDialogStartupLocation.CenterOwner;
            td.OwnerWindowHandle = owner;
            return td.Show();
        }
        public static void HandleException(Window window, DirectoryNotFoundException ex)
        {
            try
            {
                string message = string.Format(Properties.Resources.MessageDirectoryNotFoundException);

                TaskDialog dialog = new TaskDialog();

                dialog.InstructionText = message;
                //dialog.Text
                dialog.Icon = TaskDialogStandardIcon.Error;
                dialog.StandardButtons = TaskDialogStandardButtons.Ok;

                dialog.DetailsExpandedText = ex.Message;

                dialog.Caption = App.Current.ApplicationTitle;
                if (window != null)
                {
                    dialog.OwnerWindowHandle = new WindowInteropHelper(window).Handle;
                }

                dialog.Show();
            }
            catch (PlatformNotSupportedException)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public static void HandleException(Window window, FileNotFoundException ex)
 {
     try
     {
         var fileName = Path.GetFileName(ex.FileName);
         var message = string.Format(Properties.Resources.MessageFileNotFoundException, fileName);
         var dialog = new TaskDialog
                          {
                              InstructionText = message,
                              Icon = TaskDialogStandardIcon.Error,
                              StandardButtons = TaskDialogStandardButtons.Ok,
                              DetailsExpandedText = ex.Message,
                              Caption = App.Current.ApplicationTitle
                          };
         if (window != null)
         {
             dialog.OwnerWindowHandle = new WindowInteropHelper(window).Handle;
         }
         dialog.Show();
     }
     catch (PlatformNotSupportedException)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 5
0
        private void ExecuteStart(object sender, RoutedEventArgs e)
        {
            if (!_viewModel.DoNotShowWarning)
            {
                using (TaskDialog dlg = new TaskDialog())
                {
                    dlg.Caption = "Подтвердите операцию";
                    dlg.Text = "Во время своей работы приложение создаст временные базы данных на указанном вами сервере. Они будут удалены сразу после окончания тестирования.\r\n\r\nНе используйте данное приложение с рабочим SQL Server!";
                    dlg.Cancelable = true;
                    var okLink = new TaskDialogCommandLink("ok", "Согласен. Продолжаем!");
                    okLink.Click += (sender2, e2) => ((TaskDialog)((TaskDialogCommandLink)sender2).HostingDialog).Close(TaskDialogResult.Ok);
                    var cancelLink = new TaskDialogCommandLink("cancel", "Я передумал") {Default = true};
                    cancelLink.Click += (sender2, e2) => ((TaskDialog)((TaskDialogCommandLink)sender2).HostingDialog).Close(TaskDialogResult.Cancel);
                    dlg.Controls.Add(okLink);
                    dlg.Controls.Add(cancelLink);
                    dlg.FooterCheckBoxText = "Больше не спрашивать";

                    var result = dlg.Show();
                    _viewModel.DoNotShowWarning = dlg.FooterCheckBoxChecked.Value;
                    if (result != TaskDialogResult.Ok) return;
                }
            }

            _viewModel.PoolTestRunning = true;
            _viewModel.Server = tbServer.Text.Trim();
            _viewModel.UseSqlAuthentication = cbUseSqlAuth.IsChecked.Value;
            _viewModel.UserName = tbUserName.Text.Trim();
            _viewModel.Password = tbPassword.Password;
            _viewModel.LogLines.Clear();

            Thread t = new Thread(_presenter.RunPoolTest);
            t.Start();
        }
Esempio n. 6
0
        public static void Show(Window owner = null, string text = "", string instructionText = "", string caption = "Information")
        {
            IntPtr windowHandle = IntPtr.Zero;

            if (owner == null)
                windowHandle = new WindowInteropHelper(Application.Current.MainWindow).Handle;
            else
                windowHandle = new WindowInteropHelper(owner).Handle;

            try
            {
                using (TaskDialog taskDialog = new TaskDialog())
                {
                    taskDialog.OwnerWindowHandle = windowHandle;
                    taskDialog.StandardButtons = TaskDialogStandardButtons.Ok;
                    taskDialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
                    taskDialog.Icon = TaskDialogStandardIcon.Information;
                    taskDialog.Text = text;
                    taskDialog.InstructionText = instructionText;
                    taskDialog.Caption = caption;
                    taskDialog.Show();
                }
            }
            catch (Exception)
            {
                if (owner != null)
                    MessageBox.Show(owner, text, caption, MessageBoxButton.OK, MessageBoxImage.Information);
                else
                    MessageBox.Show(text, caption, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void ButtonTaskDialogCustomButtonClose_Click(object sender, RoutedEventArgs e)
        {
            var helper = new WindowInteropHelper(this);
            var td = new TaskDialog {OwnerWindowHandle = helper.Handle};

            var closeLink = new TaskDialogCommandLink("close", "Close", "Closes the task dialog");
            closeLink.Click += (o, ev) => td.Close(TaskDialogResult.CustomButtonClicked);
            var closeButton = new TaskDialogButton("closeButton", "Close");
            closeButton.Click += (o, ev) => td.Close(TaskDialogResult.CustomButtonClicked);

            // Enable one or the other; can't have both at the same time
            td.Controls.Add(closeLink);
            //td.Controls.Add(closeButton);

            // needed since none of the buttons currently closes the TaskDialog
            td.Cancelable = true;

            switch (td.Show())
            {
                case TaskDialogResult.CustomButtonClicked:
                    MessageBox.Show("The task dialog was closed by a custom button");
                    break;
                case TaskDialogResult.Cancel:
                    MessageBox.Show("The task dialog was canceled");
                    break;
                default:
                    MessageBox.Show("The task dialog was closed by other means");
                    break;
            }
        }
 private void ButtonTaskDialogIconFix_Click(object sender, RoutedEventArgs e)
 {
     using (var dialog = new TaskDialog
     {
         Caption = "Caption",
         DetailsCollapsedLabel = "DetailsCollapsedLabel",
         DetailsExpanded = true,
         DetailsExpandedLabel = "DetailsExpandedLabel",
         DetailsExpandedText = "DetailsExpandedText",
         ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandContent,
         FooterCheckBoxChecked = true,
         FooterCheckBoxText = "FooterCheckBoxText",
         FooterIcon = TaskDialogStandardIcon.Information,
         FooterText = "FooterText",
         HyperlinksEnabled = true,
         Icon = TaskDialogStandardIcon.Shield,
         InstructionText = "InstructionText",
         ProgressBar = new TaskDialogProgressBar {Value = 100},
         StandardButtons =
             TaskDialogStandardButtons.Ok | TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No |
             TaskDialogStandardButtons.Cancel | TaskDialogStandardButtons.Close | TaskDialogStandardButtons.Retry,
         StartupLocation = TaskDialogStartupLocation.CenterScreen,
         Text = "Text"
     })
     {
         dialog.Show();
     }
 }
Esempio n. 9
0
        // OMG, http://www.roblox.com/Game/PlaceLauncher.ashx?request=RequestGame&placeId=1818

        private void button1_Click(object sender, EventArgs e)
        {
            Console.WriteLine("f");
            TaskDialog dialog = new TaskDialog();
            dialog.Opened += dialog_Opened;
            TaskDialogProgressBar bar = new TaskDialogProgressBar(0, 100, 2);
            bar.State = TaskDialogProgressBarState.Marquee;
            dialog.Controls.Add(bar);

            dialog.StandardButtons = TaskDialogStandardButtons.None;

            backgroundWorker1.RunWorkerCompleted += (s, ev) =>
            {
                if (ev.Result == (object)true)
                {
                    try
                    {
                        dialog.Close(TaskDialogResult.Ok);
                    }
                    catch { }
                }
            };

            dialog.InstructionText = "Launching Roblox...";
            dialog.Text = "Getting Authentication Url, Ticket, and Join Script.";
            dialog.Closing += dialog_Closing;
            dialog.Show();
        }
Esempio n. 10
0
        /*
         * Continue button click event handler.
         */
        private void continueButton_Click(object sender, EventArgs e) {
            // Save team domain if valid otherwise show team not found information dialog
            if(IsTeamDomainValid()) {
                SlackTeamDomain = teamDomainTextBox.Text.ToLowerInvariant();
                DialogResult = DialogResult.OK;
                Close();
            } else {
                TaskDialog noTeamDialog = new TaskDialog() {
                    Caption = Application.ProductName,
                    HyperlinksEnabled = true,
                    Icon = TaskDialogStandardIcon.Information,
                    InstructionText = "We couldn't find your team.",
                    OwnerWindowHandle = Handle,
                    StandardButtons = TaskDialogStandardButtons.Ok,
                    Text = "If you can't remember your team's address, Slack can <a href=\"#\">send you a reminder</a>."
                };

                noTeamDialog.HyperlinkClick += delegate { Process.Start(FindYourTeamUrl); };

                // Workaround for a bug in the Windows TaskDialog API
                noTeamDialog.Opened += (td, ev) => {
                    TaskDialog taskDialog = td as TaskDialog;
                    taskDialog.Icon = noTeamDialog.Icon;
                    taskDialog.InstructionText = noTeamDialog.InstructionText;
                };

                noTeamDialog.Show();
            }
        }
Esempio n. 11
0
File: Program.cs Progetto: jariz/jZm
 public static void Crash(Exception z)
 {
     TaskDialog diag = new TaskDialog();
     diag.InstructionText = "An unhandled exception was caught";
     diag.Text = "jZm has crashed because of a unhandled exception, this means something happend that shouldn't happen.";
     diag.Caption = "WTF?";
     diag.Icon = TaskDialogStandardIcon.Error;
     diag.DetailsExpandedText = z.ToString();
     TaskDialogCommandLink linkz = new TaskDialogCommandLink("r", "Restart jZm");
     linkz.ShowElevationIcon = true;
     linkz.Click += delegate(object sender, EventArgs argz)
     {
         diag.Close();
         Application.Restart();
     };
     diag.Controls.Add(linkz);
     linkz = new TaskDialogCommandLink("r", "Exit jZm");
     linkz.Click += delegate(object sender, EventArgs argz)
     {
         diag.Close();
         Environment.Exit(-1);
     };
     diag.Controls.Add(linkz);
     diag.Show();
     Environment.Exit(-1);
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem != null)
            {
                ParentalControlsCredential cred = new ParentalControlsCredential(textBox1.Text, textBox2.Text, false);
                if(!file.Remove((ParentalControlsCredential)comboBox1.SelectedItem))
                {
                    TaskDialog dialog = new TaskDialog();

                    dialog.Caption = this.Text;
                    dialog.InstructionText = "Failed to Change Credential";
                    dialog.Text = "An unknown error occured while changing \""+((ParentalControlsCredential)comboBox1.SelectedItem).Username+"\"";
                    dialog.Opened += (a, b) =>
                    {
                        dialog.Icon = TaskDialogStandardIcon.Error;
                    };

                    dialog.Show();
                }
                else
                {
                    file.Add(cred);
                    RefreshItems(false);
                    comboBox1.SelectedItem = cred;
                }
            }
        }
        private void cmdShow_Click(object sender, EventArgs e)
        {
            TaskDialog td = new TaskDialog();

            #region Button(s)

            TaskDialogStandardButtons button = TaskDialogStandardButtons.None;

            if (chkOK.Checked) button |= TaskDialogStandardButtons.Ok; 
            if (chkCancel.Checked) button |= TaskDialogStandardButtons.Cancel;

            if (chkYes.Checked) button |= TaskDialogStandardButtons.Yes;
            if (chkNo.Checked) button |= TaskDialogStandardButtons.No;

            if (chkClose.Checked) button |= TaskDialogStandardButtons.Close;
            if (chkRetry.Checked) button |= TaskDialogStandardButtons.Retry;

            #endregion

            #region Icon

            if (rdoError.Checked)
            {
                td.Icon = TaskDialogStandardIcon.Error;
            }
            else if (rdoInformation.Checked)
            {
                td.Icon = TaskDialogStandardIcon.Information;
            }
            else if (rdoShield.Checked)
            {
                td.Icon = TaskDialogStandardIcon.Shield;
            }
            else if (rdoWarning.Checked)
            {
                td.Icon = TaskDialogStandardIcon.Warning;
            }

            #endregion

            #region Prompts

            string title = txtTitle.Text;
            string instruction  = txtInstruction.Text;
            string content = txtContent.Text;

            #endregion

            td.StandardButtons = button;
            td.InstructionText = instruction;
            td.Caption = title;
            td.Text = content;
            td.OwnerWindowHandle = this.Handle;
            
            TaskDialogResult res = td.Show();

            this.resultLbl.Text = "Result = " + res.ToString();
        }
Esempio n. 14
0
        public DialogResult ShowDialog(IWin32Window owner)
        {
            var isLogicError = !IsID10TError(_exception);

            var editReportLinkHref = "edit_report";

            var dialog = new TaskDialog
                         {
                             Cancelable = true,
                             DetailsExpanded = false,
                             HyperlinksEnabled = true,
                             ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter,
                             StartupLocation = TaskDialogStartupLocation.CenterOwner,

                             Icon = TaskDialogStandardIcon.Error,
                             Caption = _title,
                             InstructionText = "An unexpected error occured.",
                             Text = _exception.Message,
                             DetailsExpandedText = _exception.ToString(),

                             DetailsCollapsedLabel = "Show &details",
                             DetailsExpandedLabel = "Hide &details",

                             FooterText = string.Format("<a href=\"{0}\">Edit report contents</a>", editReportLinkHref),

                             OwnerWindowHandle = owner.Handle
                         };

            var sendButton = new TaskDialogCommandLink("sendButton", "&Report This Error\nFast and painless - I promise!");
            sendButton.Click += delegate
                                {
                                    new TaskBuilder()
                                        .OnCurrentThread()
                                        .DoWork((invoker, token) => ErrorReporter.Report(_exception))
                                        .Fail(args => ReportExceptionFail(owner, args))
                                        .Succeed(() => ReportExceptionSucceed(owner))
                                        .Build()
                                        .Start();
                                    dialog.Close(TaskDialogResult.Yes);
                                };

            var dontSendButton = new TaskDialogCommandLink("dontSendButton", "&No Thanks\nI don't feel like being helpful");
            dontSendButton.Click += delegate
                                    {
                                        dialog.Close(TaskDialogResult.No);
                                    };

            dialog.HyperlinkClick += (sender, args) => MessageBox.Show(owner, args.LinkText);

            if (true || isLogicError)
            {
                dialog.Controls.Add(sendButton);
                dialog.Controls.Add(dontSendButton);
            }

            return dialog.Show().ToDialogResult();
        }
        // Configuration is applied at dialog creation time.
        internal NativeTaskDialog(NativeTaskDialogSettings settings, TaskDialog outerDialog)
        {
            nativeDialogConfig = settings.NativeConfiguration;
            this.settings = settings;

            // Wireup dialog proc message loop for this instance.
            nativeDialogConfig.callback = new TaskDialogNativeMethods.TaskDialogCallback(DialogProc);

            ShowState = DialogShowState.PreShow;

            // Keep a reference to the outer shell, so we can notify.
            this.outerDialog = outerDialog;
        }
Esempio n. 16
0
        // Configuration is applied at dialog creation time.
        internal NativeTaskDialog( 
            NativeTaskDialogSettings settings,
            TaskDialog outerDialog)
        {
            nativeDialogConfig = settings.NativeConfiguration;
            this.settings = settings;

            // Wireup dialog proc message loop for this instance.
            nativeDialogConfig.pfCallback =
                new TaskDialogNativeMethods.PFTASKDIALOGCALLBACK(DialogProc);

            // Keep a reference to the outer shell, so we can notify.
            this.outerDialog = outerDialog;
        }
Esempio n. 17
0
        /// <summary>
        /// Ask a new replays folder to the user and return it.
        /// </summary>
        /// <param name="oldPath">The old Path to show in the message box</param>
        /// <returns>return a string for the new path with the replay</returns>
        public static bool GetNewReplayFolder( string oldPath, out string newPath )
        {
            // Select a new folder command link
            var anotherReplayFolderCMDLink = new TaskDialogCommandLink("anotherFolder", "Select another replay folder\nThe folder must have .wargamerpl2 files");
            anotherReplayFolderCMDLink.Click += AnotherReplayFolderCMDLink_Click;


            // Exit Application command link
            var exitApplicationCMDLink = new TaskDialogCommandLink("exitApplication", "Exit the application");
            exitApplicationCMDLink.Click += ( s, d ) =>
            {
                _buttonPressed = "exitApplication";
                var s2 = (TaskDialogCommandLink)s;
                var taskDialog = (TaskDialog)(s2.HostingDialog);
                //taskDialog.Close(TaskDialogResult.CustomButtonClicked);
            };

            // Task Dialog settings
            var td = new TaskDialog();
            td.Caption = "Empty Replay Folder";
            td.Controls.Add(anotherReplayFolderCMDLink);
            td.Controls.Add(exitApplicationCMDLink);
            td.Icon = TaskDialogStandardIcon.Error;
            td.InstructionText = String.Format("The Replay folder is empty.");
            td.Text = String.Format("The folder {0} doesn't contains any .wargamerpl2 files.", oldPath);

            td.Closing += Td_Closing;
            TaskDialogResult tdResult = td.Show();

            if ( tdResult == TaskDialogResult.CustomButtonClicked )
            {
                if( _buttonPressed == "anotherFolder" && !String.IsNullOrEmpty(_newPath))
                {
                    newPath = _newPath;
                    return true;
                }
                else
                {
                    newPath = null;
                    return false;
                }
            }
            else
            {
                newPath = null;
                return false;
            }

        }
Esempio n. 18
0
		void Open(string fileName)
		{
			TaskDialogResult result;
			do
			{
				Activate();
				prevMain.ViewPane.Select();
				using (TaskDialog dialog = new TaskDialog())
				{
					dialog.Cancelable = false;
					dialog.Controls.Add(new TaskDialogButton("btnCancel", Properties.Resources.Cancel));
					dialog.Caption = Application.ProductName;
					dialog.Icon = TaskDialogStandardIcon.None;
					dialog.InstructionText = Properties.Resources.OpeningFile;
					dialog.OwnerWindowHandle = Handle;
					dialog.ProgressBar = new TaskDialogProgressBar(0, 100, 0);
					dialog.Opened += async (s, ev) =>
					{
						((TaskDialogButtonBase)dialog.Controls["btnCancel"]).Enabled = false;
						try
						{
							await icd.OpenAsync(fileName, new Progress<int>(value => dialog.ProgressBar.Value = value));
							dialog.Close(TaskDialogResult.Ok);
						}
						catch (OperationCanceledException)
						{
							dialog.Close(TaskDialogResult.Close);
						}
					};
					dialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
					result = dialog.Show();
				}
			} while (result == TaskDialogResult.Retry);
			if (result == TaskDialogResult.Close)
			{
				Close();
				return;
			}
			conBookmarks.Items.AddRange(icd.Bookmarks.Select(b => new ToolStripMenuItem(b.Name, null, (sen, eve) =>
			{
				current = spreads.FindIndex(sp => sp.Left == b.Target || sp.Right == b.Target);
				ViewCurrentPage();
			})).ToArray());
			spreads = new List<Spread>(icd.ConstructSpreads(false));
			openingFileName = "";
			ViewCurrentPage();
		}
Esempio n. 19
0
 private void Form1_Shown( object sender, EventArgs e )
 {
     try
     {
         SensorList<Sensor> sl = SensorManager.GetAllSensors();
         SensorManager.RequestPermission( this.Handle, true, sl ); 
     }
     catch( SensorPlatformException spe )
     {
         TaskDialog dialog = new TaskDialog( );
         dialog.InstructionText = spe.Message;
         dialog.Text = "This application will now exit.";
         dialog.StandardButtons = TaskDialogStandardButtons.Close;
         dialog.Show();
         Application.Exit( );
     }
 }
Esempio n. 20
0
        public void Error(Exception e, string TaskName)
        {
            // Error dialog
            TaskDialog tdError = new TaskDialog();
            TaskDialogStandardButtons button = TaskDialogStandardButtons.Ok;
            tdError.StandardButtons = button;
            tdError.DetailsExpanded = false;
            tdError.Cancelable = true;
            tdError.Icon = TaskDialogStandardIcon.Error;

            tdError.Caption = TaskName;
            tdError.InstructionText = Properties.Resources.ErrorMsg;
            tdError.DetailsExpandedText = e.ToString();

            tdError.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter;

            TaskDialogResult res = tdError.Show();
        }
Esempio n. 21
0
		private static void Main(string[] commands) {
			bool pobjIOwnMutex;
			using (new Mutex(true, "PathDefence", out pobjIOwnMutex)) {
				if (pobjIOwnMutex || (commands.Length > 0 && commands[0] == "-r")) {
					//LogFramework.Initialize("PathDefence",Settings.Default.LogServer, Settings.Default.LogAccount,Settings.Default.LogPw,"1.0.0.0",1,"abc");
					//LogFramework.AddLog("Starting PathDefence...",false,LogType.StartLog);
					using (var game = new PathDefenceGame()) {
						game.Run();
					}
					//LogFramework.FinalizeLogger();
				} else {
					if (TaskDialog.IsPlatformSupported) {
						var dlg = new TaskDialog {
							Cancelable = true,
							Caption = "Fehler",
							DetailsCollapsedLabel = "Hilfe anzeigen",
							DetailsExpandedText =
								"Sollten Sie das Programm soeben beendet haben, so warten Sie ein paar Sekunden und versuchen Sie es erneut.",
							DetailsExpandedLabel = "Hilfe ausblenden",
							ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandContent,
							InstructionText = "Es wird bereits eine Instanz dieses Programms ausgeführt!",
							Text =
								"Bitte schließen Sie diese Instanz bevor Sie das Programm erneut öffnen!",
							StandardButtons = TaskDialogStandardButtons.Close,
							Icon = TaskDialogStandardIcon.Error
						};

						var killProcess = new TaskDialogCommandLink("killprocess", "Andere Instanz beenden",
																	"Die andere laufende Instanz wird beendet.\nDaten des Spiels könnten möglicherweise verloren gehen.");
						killProcess.Click += killProcess_Click;
						dlg.Controls.Add(killProcess);

						dlg.Show();
					} else {
						MessageBox.Show(
							"Es wird bereits eine Instanz dieses Programms ausgeführt!\n" +
							"Bitte schließen Sie diese Instanz bevor Sie das Programm erneut öffnen!\n" +
							"Sollten Sie das Programm soeben beendet haben, so warten Sie ein paar Sekunden und versuchen Sie es erneut.",
							"Fehler beim Starten des Programms", MessageBoxButtons.OK, MessageBoxIcon.Error);
					}
				}
			}
		}
Esempio n. 22
0
		private void button1_Click(object sender, EventArgs e)
		{
			DirtyMem();
			try
			{

				var tdError = new TaskDialog
				{
					DetailsExpanded = false,
					Cancelable = false,
					Icon = TaskDialogStandardIcon.Error,
					Caption = "This dialog works",
					InstructionText = "A good news for you - this dialog works!",
					Text = "It might be possible to continue by pressing Ignore button. This error has been reported to Credit Master Support.",
					DetailsExpandedLabel = "Hide details",
					DetailsCollapsedLabel = "Show details",
					ExpansionMode = TaskDialogExpandedDetailsLocation.Hide
				};

				tdError.DetailsExpandedText = "Exception Text";
				tdError.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter;

				var ignoreButton = new TaskDialogCommandLink("ignore", "Ignore\nDo not close the application.");
				ignoreButton.Click += (s, e1) => tdError.Close(TaskDialogResult.Retry);
				tdError.Controls.Add(ignoreButton);

				var closeButton = new TaskDialogCommandLink("close", "Close\nClose the application and exit.");
				closeButton.Click += (s, e1) => tdError.Close(TaskDialogResult.Cancel);
				tdError.Controls.Add(closeButton);

				var copyButton = new TaskDialogCommandLink("copy", "Copy Details to Clipboard\nCopy error details to clipboard for further investigation.");
				copyButton.Click += (s, e1) => MessageBox.Show("");
				tdError.Controls.Add(copyButton);

				tdError.OwnerWindowHandle = Handle;
				Text = tdError.Show().ToString();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.ToString());
			}
		}
Esempio n. 23
0
        private void CheckUpdate()
        {
            System.Net.WebClient client = new System.Net.WebClient();
            string xml = client.DownloadString(new Uri(Define.NewVersionUrl));

            string v = "";

            var a = from b in XElement.Parse(xml).Elements()
                    select new
                    {
                        Version = b.Element("McMDK").Value
                    };
            foreach(var item in a)
            {
                v = item.Version;
            }
            int r = int.Parse(v.Substring(v.LastIndexOf(".") + 1));
            if(Define.Release < r)
            {
                //New version
                var taskDialog = new TaskDialog();
                taskDialog.Caption = "更新";
                taskDialog.InstructionText = "McMDKの最新版がリリースされています!";
                taskDialog.Text = "McMDKの最新版\"" + v + "\"がリリースされています。\n更新しますか?";
                taskDialog.Icon = TaskDialogStandardIcon.Information;
                taskDialog.StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No;
                taskDialog.Opened += (sender, e) =>
                    {
                        var dialog = (TaskDialog)sender;
                        dialog.Icon = dialog.Icon;
                    };
                if(taskDialog.Show() == TaskDialogResult.Yes)
                {
                    //Update
                }
            }
            this.DownloadResources();
        }
 private void Button_Click_3(object sender, RoutedEventArgs e)
 {
     TaskDialog td = new TaskDialog();
     td.Caption = "Reset Library";
     td.Icon = TaskDialogStandardIcon.Warning;
     td.Text = "Click \"OK\" to reset currently selected library properties";
     td.InstructionText = "Reset Library Properties?";
     td.FooterIcon = TaskDialogStandardIcon.Information;
     //td.FooterText = "This will reset all the properties to default properties for library type";
     td.DetailsCollapsedLabel = "More info";
     td.DetailsExpandedLabel = "More Info";
     td.DetailsExpandedText = "This will reset all the properties to default properties for library type";
     td.DetailsExpanded = false;
     td.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter;
     td.StandardButtons = TaskDialogStandardButtons.Ok | TaskDialogStandardButtons.Cancel;
     td.OwnerWindowHandle = this.Handle;
     if (td.Show() == TaskDialogResult.Ok)
     {
         if (Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default).ToLowerInvariant() != "documents" &&
             Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default).ToLowerInvariant() != "music" &&
             Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default).ToLowerInvariant() != "videos" &&
             Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default).ToLowerInvariant() != "pictures")
         {
             ShellLibrary lib = ShellLibrary.Load(Explorer.SelectedItems[0].GetDisplayName(DisplayNameType.Default),
                         false);
             lib.IsPinnedToNavigationPane = true;
             lib.LibraryType = LibraryFolderType.Generic;
             lib.IconResourceId = new IconReference(@"C:\Windows\System32\imageres.dll", 187);
             lib.Close();
         }
     }
 }
        //private void CreateArchive_Show(OutArchiveFormat format) 
        //{
        //    var selectedItems = new List<string>();
        //    foreach(ShellObject item in Explorer.SelectedItems)
        //    {
        //        if (Directory.Exists(item.ParsingName))
        //        {
        //            DirectoryInfo di = new DirectoryInfo(item.ParsingName);
        //            FileInfo[] Files = di.GetFiles("*", SearchOption.AllDirectories);
        //            foreach (FileInfo fi in Files)
        //            {
        //                selectedItems.Add(fi.FullName);
        //            }

        //        }
        //        else
        //        {
        //            selectedItems.Add(item.ParsingName);
        //        }

        //    }
        //    if (selectedItems.Count > 0)
        //    {
        //        try
        //        {
        //            var CAI = new CreateArchive(selectedItems,
        //                                        true,
        //                                        Path.GetDirectoryName(selectedItems[0]),
        //                                        format);

        //            CAI.Show(this.GetWin32Window());


        //        }
        //        catch (Exception exception)
        //        {
        //            var dialog = new TaskDialog();
        //            dialog.StandardButtons = TaskDialogStandardButtons.Ok;
        //            dialog.Text = exception.Message;
        //            dialog.Show();
        //        }
        //    }
        // }

        private void ExtractFiles()
        {
            var selectedItems = new List<string>();
            foreach (ShellObject item in Explorer.SelectedItems)
            {
                selectedItems.Add(item.ParsingName);
            }
            try
            {
                var CAI = new CreateArchive(selectedItems,
                                            false,
                                            Explorer.SelectedItems[0].ParsingName);

                CAI.Show(this.GetWin32Window());


            }
            catch (Exception exception)
            {
                var dialog = new TaskDialog();
                dialog.StandardButtons = TaskDialogStandardButtons.Ok;
                dialog.Text = exception.Message;
                dialog.Show();
            }
        }
Esempio n. 26
0
        void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            // If the user is closing the app, ask them if they wish to close the current tab
            // or all the tabs

            if (tabControl1 != null && tabControl1.TabPages.Count > 0)
            {
                if (tabControl1.TabPages.Count <= 1)
                {
                    // close the tab and the application
                    cancelFormClosing = false;
                }
                else
                {
                    // More than 1 tab.... show the user the TaskDialog
                    TaskDialog tdClose = new TaskDialog();
                    tdClose.Caption = "Tabbed Thumbnail demo (Winforms)";
                    tdClose.InstructionText = "Do you want to close all the tabs or the current tab?";
                    tdClose.Cancelable = true;
                    tdClose.OwnerWindowHandle = this.Handle;

                    TaskDialogButton closeAllTabsButton = new TaskDialogButton("closeAllTabsButton", "Close all tabs");
                    closeAllTabsButton.Default = true;
                    closeAllTabsButton.Click += new EventHandler(closeAllTabsButton_Click);
                    tdClose.Controls.Add(closeAllTabsButton);

                    TaskDialogButton closeCurrentTabButton = new TaskDialogButton("closeCurrentTabButton", "Close current tab");
                    closeCurrentTabButton.Click += new EventHandler(closeCurrentTabButton_Click);
                    tdClose.Controls.Add(closeCurrentTabButton);

                    tdClose.Show();
                }
            }

            e.Cancel = cancelFormClosing;
        }
Esempio n. 27
0
        private void _ButtonRemove_Click(object sender, EventArgs e)
        {
            TaskDialog dialog = new TaskDialog();
            dialog.Caption = Resources.WindowTitle;
            dialog.InstructionText = Locale.Current.Labels.RemoveConfirmation;
            dialog.Cancelable = true;
            dialog.OwnerWindowHandle = base.Handle;

            TaskDialogButton buttonYes = new TaskDialogButton("yesButton", Locale.Current.Labels.Yes);
            buttonYes.Default = true;
            buttonYes.Click += _TaskButtonYes_Click;

            TaskDialogButton buttonNo = new TaskDialogButton("noButton", Locale.Current.Labels.No);
            buttonNo.Click += _TaskButtonNo_Click;

            dialog.Controls.Add(buttonYes);
            dialog.Controls.Add(buttonNo);
            dialog.Show();
        }
Esempio n. 28
0
        public ThumbnailBrowser()
        {
            InitializeComponent();

            // Set some ExplorerBrowser properties
            explorerBrowser1.ContentOptions.SingleSelection = true;
            explorerBrowser1.ContentOptions.ViewMode = ExplorerBrowserViewMode.List;
            explorerBrowser1.NavigationOptions.PaneVisibility.Navigation = PaneVisibilityState.Hide;
            explorerBrowser1.NavigationOptions.PaneVisibility.CommandsView = PaneVisibilityState.Hide;
            explorerBrowser1.NavigationOptions.PaneVisibility.CommandsOrganize = PaneVisibilityState.Hide;
            explorerBrowser1.NavigationOptions.PaneVisibility.Commands = PaneVisibilityState.Hide;

            // set our initial state CurrentView == large
            toolStripSplitButton1.Image = Microsoft.WindowsAPICodePack.Samples.ThumbnailBrowserDemo.Properties.Resources.large;
            smallToolStripMenuItem.Checked = false;
            mediumToolStripMenuItem.Checked = false;
            largeToolStripMenuItem.Checked = true;
            extraLargeToolStripMenuItem.Checked = false;

            //
            comboBox1.SelectedIndex = 0;

            //
            explorerBrowser1.SelectionChanged += new ExplorerBrowserSelectionChangedEventHandler(explorerBrowser1_SelectionChanged);

            // Create our Task Dialog for displaying the error to the user
            // when they are asking for Thumbnail Only and the selected item doesn't have a thumbnail.
            td = new TaskDialog();
            td.OwnerWindowHandle = this.Handle;
            td.InstructionText = "Error displaying thumbnail";
            td.Text = "The selected item does not have a thumbnail and you have selected the viewing mode to be thumbnail only. Please select one of the following options:";
            td.StartupLocation = TaskDialogStartupLocation.CenterOwner;
            td.Icon = TaskDialogStandardIcon.Error;
            td.Cancelable = true;
            td.FooterCheckBoxText = "Do not show this dialog again";
            td.FooterCheckBoxChecked = false;

            TaskDialogCommandLink button1 = new TaskDialogCommandLink("changeModeButton", "Change mode to Thumbnail Or Icon",
                "Change the viewing mode to Thumbnail or Icon. If the selected item does not have a thumbnail, it's associated icon will be displayed.");
            button1.Click += new EventHandler(button1_Click);

            TaskDialogCommandLink button2 = new TaskDialogCommandLink("noChangeButton", "Keep the current mode",
                                    "Keep the currently selected mode (Thumbnail Only). If the current mode is Thumbnail Only and the selected item does not have a thumbnail, nothing will be shown in the preview panel.");
            button2.Click += new EventHandler(button2_Click);

            td.Controls.Add(button1);
            td.Controls.Add(button2);

        }
Esempio n. 29
0
        /// <summary>
        /// Updates the thumbnail preview for currently selected item and current view
        /// </summary>
        private void UpdatePreview()
        {
            if (currentItem != null)
            {
                // Set the appropiate FormatOption
                if (currentMode == Mode.ThumbnailOrIcon)
                    currentItem.Thumbnail.FormatOption = ShellThumbnailFormatOptions.Default;
                else if (currentMode == Mode.ThumbnailOnly)
                    currentItem.Thumbnail.FormatOption = ShellThumbnailFormatOptions.ThumbnailOnly;
                else
                    currentItem.Thumbnail.FormatOption = ShellThumbnailFormatOptions.IconOnly;

                // Get the correct bitmap
                try
                {
                    if (currentView == Views.Small)
                        pictureBox1.Image = currentItem.Thumbnail.SmallBitmap;
                    else if (currentView == Views.Medium)
                        pictureBox1.Image = currentItem.Thumbnail.MediumBitmap;
                    else if (currentView == Views.Large)
                        pictureBox1.Image = currentItem.Thumbnail.LargeBitmap;
                    else if (currentView == Views.ExtraLarge)
                        pictureBox1.Image = currentItem.Thumbnail.ExtraLargeBitmap;
                }
                catch (NotSupportedException)
                {
                    TaskDialog tdThumbnailHandlerError = new TaskDialog();
                    tdThumbnailHandlerError.Caption = "Error getting the thumbnail";
                    tdThumbnailHandlerError.InstructionText = "The selected file does not have a valid thumbnail or thumbnail handler.";
                    tdThumbnailHandlerError.Icon = TaskDialogStandardIcon.Error;
                    tdThumbnailHandlerError.StandardButtons = TaskDialogStandardButtons.Ok;
                    tdThumbnailHandlerError.Show();
                }
                catch (InvalidOperationException)
                {
                    if (currentMode == Mode.ThumbnailOnly)
                    {
                        // If we get an InvalidOperationException and our mode is Mode.ThumbnailOnly,
                        // then we have a ShellItem that doesn't have a thumbnail (icon only).
                        // Let the user know this and if they want, change the mode.
                        if (showErrorTaskDialog)
                        {
                            TaskDialogResult tdr = td.Show();

                            showErrorTaskDialog = !td.FooterCheckBoxChecked.Value;
                        }

                        // If the user picked the first option, change the mode...
                        if (onErrorChangeMode)
                        {
                            // Change the mode to ThumbnailOrIcon
                            comboBox1.SelectedIndex = 0;
                            UpdatePreview();
                        }
                        else // else, ignore and display nothing.
                            pictureBox1.Image = null;
                    }
                    else
                        pictureBox1.Image = null;
                }
            }
            else
                pictureBox1.Image = null;
        }
Esempio n. 30
0
        private void CheckFileRegistration()
        {
            bool registered = false;

            try
            {
                RegistryKey openWithKey = Registry.ClassesRoot.OpenSubKey(Path.Combine(".txt", "OpenWithProgIds"));
                string value = openWithKey.GetValue(progId, null) as string;

                if (value == null)
                    registered = false;
                else
                    registered = true;
            }
            finally
            {
                // Let the user know
                if (!registered)
                {
                    td = new TaskDialog();

                    td.Text = "File type is not registered";
                    td.InstructionText = "This demo application needs to register .txt files as associated files to properly execute the Taskbar related features.";
                    td.Icon = TaskDialogStandardIcon.Information;
                    td.Cancelable = true;

                    TaskDialogCommandLink button1 = new TaskDialogCommandLink("registerButton", "Register file type for this application",
                        "Register .txt files with this application to run this demo application correctly.");

                    button1.Click += new EventHandler(button1_Click);
                    // Show UAC shield as this task requires elevation
                    button1.UseElevationIcon = true;

                    td.Controls.Add(button1);

                    TaskDialogResult tdr = td.Show();
                }
            }
        }