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();
        }
        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;
            }
        }
Esempio n. 3
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);
 }
Esempio n. 4
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();
        }
Esempio n. 5
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. 6
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. 7
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. 8
0
        public static void Init()
        {
            Console.WindowWidth = Console.LargestWindowWidth - 25;
            Console.WindowHeight = Console.LargestWindowHeight - 25;
            Console.Title = "SkypeStats - Debug Console";

            Out.WritePlain("SkypeStats by JariZ");
            Out.WriteBlank();

            AddStats();

            Out.WriteLine("Searching for skype databases...");
            string[] Accounts = GetAccounts();

            TaskDialog chooser = new TaskDialog();
            chooser.InstructionText = "The following accounts were found on this computer";
            chooser.Text = "SkypeStats has found several accounts, which one do you want to analyse?";
            chooser.FooterCheckBoxText = "Load entire DB into memory and max out cache";

            string Account = "";
            foreach (string account in Accounts)
            {
                TaskDialogCommandLink link = new TaskDialogCommandLink(Path.GetFileName(account), Path.GetFileName(account));
                link.Click += delegate(object send, EventArgs args) {
                    Account = ((TaskDialogCommandLink)send).Name;
                    chooser.Close();
                };
                chooser.Controls.Add(link);
            }

            chooser.FooterText = "Loading everything into memory might be faster but requires a lot of RAM, only choose this if you know what you're doing";
            chooser.FooterIcon = TaskDialogStandardIcon.Information;

            chooser.Show();

            MaxedOutMode = chooser.FooterCheckBoxChecked;

            Core.Account = Account;
            DatabasePath = SkypeAppData + "\\" + Account + "\\main.db";
            if (!File.Exists(DatabasePath))
                Failure("Database file not found, restart SkypeStats");

            Out.WriteDebug("DB path is " + DatabasePath + " and exists");

            Out.WriteDebug("Connecting to DB...");
            try
            {
                Database = new DB(DatabasePath);
            }
            catch(Exception z)
            {
                Out.WriteDebug("UNABLE TO CONNECT TO DB:");
                Out.WriteError(z.ToString(), z);
                Failure("Unable to connect to database file: " + z.Message);
            }
            Out.WriteLine("Successfully connected to DB!");

            ProgressDialog progress = null;
            if (ProgDiag)
            {
                Out.WriteDebug("Init progressdialog...");
                progress = new ProgressDialog(IntPtr.Zero);
                progress.Title = "SkypeStats";
                progress.Line1 = "Initializing...";
                progress.Line2 = " ";
                progress.Line3 = " ";
                progress.ShowDialog();

                //wait for progdiag to show up
                Thread.Sleep(1000);
            }
            else
            {
                Thread splash = new Thread(SplashThread);
                splash.SetApartmentState(ApartmentState.STA);
                splash.Start();

                while (Splash == null) { }
            }

            Out.WriteDebug("Counting messages....");
            if (ProgDiag)
            {
                progress.Line1 = "Counting messages...";
                progress.Value = 1337;
            }
            else
            {
                Splash.Status = "Counting messages...";
                Splash.Value = 1337;
            }
            MessageCount = Convert.ToInt32(Database.ExecuteScalar("SELECT COUNT(*) FROM Messages"));
            Out.WriteLine(MessageCount + " messages found!");

            Out.WriteDebug("Counting conversations....");
            if (ProgDiag)
            {
                progress.Line1 = "Counting conversations...";
                progress.Value = 1337;
            }
            else
            {
                Splash.Status = "Counting conversations...";
                Splash.Value = 1337;
            }
            ConvoCount = Convert.ToInt32(Database.ExecuteScalar("SELECT COUNT(*) FROM Conversations"));
            Out.WriteLine(ConvoCount + " conversations found!");

            Out.WriteDebug("Counting contacts....");
            if (ProgDiag)
            {
                progress.Line1 = "Counting contacts...";
                progress.Value = 1337;
            }
            else
            {
                Splash.Status = "Counting contacts...";
                Splash.Value = 1337;
            }
            ContactCount = Convert.ToInt32(Database.ExecuteScalar("SELECT COUNT(*) FROM Contacts"));
            Out.WriteLine(ContactCount + " contacts found!");

            AnalysisStart = DateTime.Now;
            Out.WriteLine("Analysis started @ " + AnalysisStart.ToLongTimeString());

            Out.WriteLine("Analysing contacts...");
            if (ProgDiag)
            {
                progress.Line1 = "Analysing contacts...";
                progress.Maximum = Convert.ToUInt32(ContactCount);
                progress.Value = 0;
            }
            else
            {
                Splash.Status = "Analysing contacts...";
                Splash.Maximum = ContactCount;
                Splash.Value = 0;
            }

            int limit = 0;
            int step = 1000;
            if (MaxedOutMode == true)
                step = int.MaxValue;

            string columns = Columns(ColumnType.Contact);
            Out.WriteDebug("Using " + columns + " columns.");

            while (limit < ContactCount)
            {
                string query = string.Format("SELECT {0} FROM Contacts LIMIT {1},{2}", columns, limit, limit + step);
                DataTable dt = Database.GetDataTable(query);

                foreach (DataRow row in dt.Rows)
                {
                    foreach (Stat stat in Stats)
                    {
                        stat.RunContactStep(row);
                    }
                }

                limit += step;
                if (ProgDiag) progress.Value += Convert.ToUInt32(step);
                else Splash.AddValue(step);
            }

            Out.WriteLine("Analysing conversations...");
            if (ProgDiag)
            {
                progress.Line1 = "Analysing conversations...";
                progress.Maximum = Convert.ToUInt32(ConvoCount);
                progress.Value = 0;
            }
            else
            {
                Splash.Status = "Analysing conversations...";
                Splash.Maximum = ConvoCount;
                Splash.Value = 0;
            }

            limit = 0;
            step = 1000;
            if (MaxedOutMode == true)
                step = int.MaxValue;

            columns = Columns(ColumnType.Convo);
            Out.WriteDebug("Using " + columns + " columns.");

            while (limit < ConvoCount)
            {
                string query = string.Format("SELECT {0} FROM Conversations WHERE type = 1 LIMIT {1},{2}", columns, limit, limit + step);
                DataTable dt = Database.GetDataTable(query);

                foreach (DataRow row in dt.Rows)
                {
                    foreach (Stat stat in Stats)
                    {
                        stat.RunConversationStep(row);
                    }
                }

                limit += step;
                if (ProgDiag) progress.Value += Convert.ToUInt32(step);
                else Splash.AddValue(step);
            }

            Out.WriteLine("Analysing messages...");
            if (ProgDiag)
            {
                progress.Line1 = "Analysing messages...";
                progress.Maximum = Convert.ToUInt32(MessageCount);
                progress.Value = 0;
            }
            else
            {
                Splash.Status = "Analysing messages...";
                Splash.Maximum = MessageCount;
                Splash.Value = 0;
            }

            limit = 0;
            step = 10000;
            if (MaxedOutMode == true)
                step = int.MaxValue;
            columns = Columns(ColumnType.Message);
            Out.WriteDebug("Using " + columns + " columns.");
            while (limit < MessageCount)
            {
                string query = string.Format("SELECT {0} FROM Messages LIMIT {1},{2}", columns, limit, limit + step);
                DataTable dt = Database.GetDataTable(query);

                foreach (DataRow row in dt.Rows)
                {
                    foreach (Stat stat in Stats)
                    {
                        stat.RunMessageStep(row);
                    }
                }

                limit += step;
                if (ProgDiag) progress.Value += Convert.ToUInt32(step);
                else Splash.AddValue(step);
            }

            AnalysisFinish = DateTime.Now;
            DateTime difference = new DateTime(AnalysisFinish.Ticks -  AnalysisStart.Ticks);

            Out.WriteLine(string.Format("Analysis finished in {0}s {1}ms", difference.Second, difference.Millisecond));

            if (ProgDiag) progress.CloseDialog();
            else Splash.Kill();

            System.Windows.Forms.Application.Run(new SkypeStats());
        }
        /// <summary>
        /// Handles the unexpected exception.
        /// </summary>
        /// <param name="ex">The exception.</param>
        /// <param name="isTerminating">if set to <c>true</c> the exception will terminate the execution.</param>
        public void HandleUnexpectedException(Exception ex, bool isTerminating = false)
        {
            if (ex is ThreadAbortException)
            {
                return;
            }

            var show = Settings.Get<bool>("Show Unhandled Errors");
            var sb   = new StringBuilder();

            parseException:
            sb.AppendLine(ex.GetType() + ": " + ex.Message);
            sb.AppendLine(ex.StackTrace);

            if (ex.InnerException != null)
            {
                ex = ex.InnerException;
                goto parseException;
            }

            if (show)
            {
                var mc  = Regex.Matches(sb.ToString(), @"\\(?<file>[^\\]+\.cs)(?::lig?ne|, sor:) (?<ln>[0-9]+)");
                var loc = "at a location where it was not expected";

                if (mc.Count != 0)
                {
                    loc = "in file {0} at line {1}".FormatWith(mc[0].Groups["file"].Value, mc[0].Groups["ln"].Value);
                }

                var td = new TaskDialog
                    {
                        Icon                  = TaskDialogStandardIcon.Error,
                        Caption               = "An unexpected error occurred",
                        InstructionText       = "An unexpected error occurred",
                        Text                  = "An exception of type {0} was thrown {1}.".FormatWith(ex.GetType().ToString().Replace("System.", string.Empty), loc) + (isTerminating ? "\r\n\r\nUnfortunately this exception occured at a crucial part of the code and the execution of the software will be terminated." : string.Empty),
                        DetailsExpandedText   = sb.ToString(),
                        DetailsExpandedLabel  = "Hide stacktrace",
                        DetailsCollapsedLabel = "Show stacktrace",
                        Cancelable            = true,
                        StandardButtons       = TaskDialogStandardButtons.None
                    };

                if ((bool)Dispatcher.Invoke((Func<bool>)(() => IsVisible)))
                {
                    td.Opened  += (s, r) => Utils.Win7Taskbar(100, TaskbarProgressBarState.Error);
                    td.Closing += (s, r) => Utils.Win7Taskbar(state: TaskbarProgressBarState.NoProgress);
                }

                var fd = new TaskDialogCommandLink { Text = "Submit bug report" };
                fd.Click += (s, r) =>
                    {
                        td.Close();
                        ReportException(sb.ToString());
                    };

                var ig = new TaskDialogCommandLink { Text = "Ignore exception" };
                ig.Click += (s, r) => td.Close();

                td.Controls.Add(fd);
                td.Controls.Add(ig);
                td.Show();
            }
            else
            {
                ReportException(sb.ToString());
            }
        }
Esempio n. 10
0
        private static void ShowResponseDialog(IWin32Window owner, string error)
        {
            TaskDialog td = new TaskDialog()
            {
                OwnerWindowHandle = owner == null ? IntPtr.Zero : owner.Handle,
                Caption = "Exception Explorer",
                Cancelable = true
            };

            td.Opened += (sender, args) => td.Icon = td.Icon;

            VersionCheckResponse response = Options.Current.Update.LastResponse.Value;
            if (AppVersion.UpgradeRequired)
            {
                response = VersionCheckResponse.NewVersion;
            }

            switch (response)
            {
                case VersionCheckResponse.Failed:
                    td.Icon = TaskDialogStandardIcon.Warning;
                    td.InstructionText = "Could not find the latest version.";
                    td.DetailsExpandedText = error;
                    break;

                case VersionCheckResponse.OK:
                    td.Icon = TaskDialogStandardIcon.Information;
                    td.InstructionText = "You are already running the latest version.";
                    break;

                case VersionCheckResponse.NewVersion:
                    td.Icon = TaskDialogStandardIcon.Information;
                    td.InstructionText = "A new version is available.";
                    td.DetailsExpandedText = string.Format("Version {0} is available.\nYou are running {1}.", AppVersion.Latest, AppVersion.Current);

                    TaskDialogCommandLink download = new TaskDialogCommandLink("name", "Download now");
                    download.Click += (sender, args) =>
                    {
                        Web.OpenSite(SiteLink.NewVersion);
                        td.Close();
                    };

                    TaskDialogCommandLink later = new TaskDialogCommandLink("name", "Remind me later");
                    later.Click += (sender, args) =>
                    {
                        td.Close();
                    };

                    //td.FooterCheckBoxText = "Don't remind me of this version";

                    td.Controls.Add(download);
                    td.Controls.Add(later);

                    break;
            }

            td.Show();
        }
Esempio n. 11
0
        public static void Report(Exception exception, bool isTerminating)
        {
            if (isTerminating)
            {
                // TODO: this is not very efficient
                SerializableException serializableException = new(exception);
                string xml     = serializableException.ToXmlString();
                string encoded = Base64Encode(xml);
                Process.Start("BugReporter.exe", encoded);

                return;
            }

            bool isUserExternalOperation = exception is UserExternalOperationException;
            bool isExternalOperation     = exception is ExternalOperationException;

            StringBuilder text      = new();
            string        rootError = Append(text, exception);

            using var taskDialog = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialog
                  {
                      OwnerWindowHandle = OwnerFormHandle,
                      Icon            = TaskDialogStandardIcon.Error,
                      Caption         = TranslatedStrings.Error,
                      InstructionText = rootError,
                      Cancelable      = true,
                  };

            // prefer to ignore failed external operations
            if (isExternalOperation)
            {
                AddIgnoreOrCloseButton();
            }

            // no bug reports for user configured operations
            if (!isUserExternalOperation)
            {
                // directions and button to raise a bug
                text.AppendLine().AppendLine(TranslatedStrings.ReportBug);
            }

            string buttonText = isUserExternalOperation ? TranslatedStrings.ButtonViewDetails : TranslatedStrings.ButtonReportBug;
            TaskDialogCommandLink taskDialogCommandLink = new(buttonText, buttonText);

            taskDialogCommandLink.Click += (s, e) =>
            {
                taskDialog.Close();
                ShowNBug(OwnerForm, exception, isTerminating);
            };
            taskDialog.Controls.Add(taskDialogCommandLink);

            // let the user decide whether to report the bug
            if (!isExternalOperation)
            {
                AddIgnoreOrCloseButton();
            }

            taskDialog.Text = text.ToString().Trim();
            taskDialog.Show();
            return;

            void AddIgnoreOrCloseButton()
            {
                string buttonText = isTerminating ? TranslatedStrings.ButtonCloseApp : TranslatedStrings.ButtonIgnore;
                TaskDialogCommandLink taskDialogCommandLink = new(buttonText, buttonText);

                taskDialogCommandLink.Click += (s, e) => taskDialog.Close();
                taskDialog.Controls.Add(taskDialogCommandLink);
            }
        }
Esempio n. 12
0
        private void t_NewFolder_Click(object sender, EventArgs e)
        {
            try
            {
                ((Folder)rightClickedNode.Tag).CreateNewFolder(GetNewFolderName((Folder)rightClickedNode.Tag));
            }
            catch (Exception x)
            {
                if (!Aero)
                {
                    MessageBox.Show("An exception was thrown: " + x.Message + "\r\n\r\nIf this appears to be a bug, press CTRL + C to copy the stack trace, then please email it to me at [email protected]:\r\n" + x.StackTrace);
                }
                else
                {
                    TaskDialog td = new TaskDialog();
                    td.Caption = "Unhandled Exception";
                    td.InstructionText = "An Unhandled Exception was Thrown";
                    td.Text = string.Format("An exception was thrown: {0}\r\n\r\nIf this appears to be a bug, please email me at [email protected] with the details below", x.Message);
                    td.DetailsCollapsedLabel = "Details";
                    td.DetailsExpandedLabel = "Details";
                    td.DetailsExpandedText = x.StackTrace;

                    TaskDialogButton Copy = new TaskDialogButton("Copy", "Copy Details to Clipboard");
                    Copy.Click += (o, f) => { Clipboard.SetDataObject(x.Message + "\r\n\r\n" + x.StackTrace, true, 10, 200); };

                    TaskDialogButton Close = new TaskDialogButton("Close", "Close");
                    Close.Click += (o, f) => { td.Close(); };

                    td.Controls.Add(Copy);
                    td.Controls.Add(Close);
                    td.ShowDialog(this.Handle);
                }
            }
        }
Esempio n. 13
0
        private void m_CheckForUpdates_Click(object sender, EventArgs e)
        {
            #region Update Shit

            Party_Buffalo.Update u = new Update();
            #if TRACE
            Party_Buffalo.Update.UpdateInfo ud = u.CheckForUpdates(new Uri("http://clkxu5.com/drivexplore/coolapplicationstuff.xml"));
            #endif
            #if DEBUG
            Party_Buffalo.Update.UpdateInfo ud = new Update.UpdateInfo();
            if (UpdateDebug)
            {
                if (!UpdateDebugForce)
                {
                    ud = u.CheckForUpdates(new Uri("http://clkxu5.com/drivexplore/dev/coolapplicationstuff.xml"));
                }
                else
                {
                    ud.Update = true;
                    ud.UpdateText = "This`Is`A`Test";
                    ud.UpdateVersion = "9000";
                }
            }
            #endif
            if (ud.Update)
            {
                if (!Aero)
                {
                    Forms.UpdateForm uf = new Party_Buffalo.Forms.UpdateForm(ud);
                    uf.ShowDialog();
                }
                else
                {
                    TaskDialog td = new TaskDialog();
                    td.Caption = "Update Available";
                    td.InstructionText = "Version " + ud.UpdateVersion + " is Available";
                    td.Text = "An update is available for Party Buffalo";
                    td.DetailsCollapsedLabel = "Change Log";
                    td.DetailsExpandedLabel = "Change Log";
                    td.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter;
                    string[] Split = ud.UpdateText.Split('`');
                    string UpdateText = "";
                    for (int i = 0; i < Split.Length; i++)
                    {
                        if (i != 0)
                        {
                            UpdateText += "\r\n";
                        }
                        if (Split[i] == "")
                        {
                            continue;
                        }
                        UpdateText += "-" + Split[i];
                    }
                    td.DetailsExpandedText = UpdateText;
                    TaskDialogCommandLink Download = new TaskDialogCommandLink("Download", "Download Party Buffalo version " + ud.UpdateVersion, "");
                    Download.Click += (o, f) =>
                    {
                        Forms.UpdateDownloadForm udf = new Party_Buffalo.Forms.UpdateDownloadForm(ud);
                        udf.ShowDialog();
                    };

                    TaskDialogCommandLink DontDownload = new TaskDialogCommandLink("DontDownload", "Let me go about my business and I'll download this stuff later...", "");
                    DontDownload.Click += (o, f) =>
                    {
                        td.Close();
                    };
                    td.Controls.Add(Download);
                    td.Controls.Add(DontDownload);
                    td.Show();
                }
            }
            else
            {
                MessageBox.Show("Party Buffalo is up to date!");
            }
            if (ud.QuickMessage != null && ud.QuickMessage != "")
            {
                quickMessage.Text = ud.QuickMessage;
            }
            else
            {
                quickMessage.Text = "Could not load quick message";
            }

            #endregion
        }
Esempio n. 14
0
File: Program.cs Progetto: jariz/jZm
        static void Main(string[] args)
        {
            string gameName;
            if (args.Length > 0)
                gameName = args[0];
            else gameName = "t6zm";

            Process[] games = Process.GetProcessesByName(gameName);
            Process gameProcess = null;
            if (games.Length > 1)
            {
                TaskDialog diag = new TaskDialog();
                diag.Caption = "Woops!";
                diag.InstructionText = "I found more than 2 running games!";
                diag.Icon = TaskDialogStandardIcon.Warning;
                diag.Text = "jZm has found more than just one game.\r\nWhat would you like to do?";
                foreach (Process game in games)
                {
                    TaskDialogCommandLink link = new TaskDialogCommandLink(game.ProcessName, game.ProcessName, "PID " + game.Id);
                    link.Click += delegate(object sender, EventArgs argz)
                    {
                        gameProcess = game;
                        diag.Close();
                    };
                    diag.Controls.Add(link);
                }
                TaskDialogCommandLink linkz = new TaskDialogCommandLink("r", "Restart", "Restart jZm");
                linkz.ShowElevationIcon = true;
                linkz.Click += delegate(object sender, EventArgs argz)
                {
                    diag.Close();
                    Application.Restart();
                    //mare sure we're dead
                    Environment.Exit(-1);
                };
                diag.Controls.Add(linkz);
                linkz = new TaskDialogCommandLink("r", "Exit", "Exit jZm");
                linkz.ShowElevationIcon = true;
                linkz.Click += delegate(object sender, EventArgs argz)
                {
                    diag.Close();
                    Environment.Exit(-1);
                };
                diag.Controls.Add(linkz);

                diag.Show();
            }
            else if (games.Length == 0)
            {
                TaskDialog diag = new TaskDialog();
                diag.Caption = "Woops!";
                diag.InstructionText = "I was unable to find any games";
                diag.Icon = TaskDialogStandardIcon.Error;
                diag.Text = "jZm was unable to find any processes matching the name '" + gameName + "'.\r\nWhat would you like to do?";
                TaskDialogCommandLink linkz = new TaskDialogCommandLink("r", "Restart jZm", "Restart and look for the game again");
                linkz.ShowElevationIcon = true;
                linkz.Click += delegate(object sender, EventArgs argz)
                {
                    diag.Close();
                    Application.Restart();
                    //mare sure we're dead
                    Environment.Exit(-1);
                };
                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();
            }
            else gameProcess = games[0];

            API = new ZombieAPI.ZombieAPI();

            MainForm = new Main();
            MainForm.Show();

            try
            {
                API.Bootstrap(gameProcess);
            }
            catch (Exception z)
            {
                Crash(z);
            }

            Application.Run();
        }
Esempio n. 15
0
        //タスクダイアログ
        private TaskDialogResult TaskDialogShow(Exception ex, bool isUnhandledException)
        {
            var dialog = new TaskDialog();
            dialog.Caption = "Manage your Life";
            dialog.InstructionText = "エラーが発生しました";
            dialog.Text = "Manage your Lifeを終了します。";
            dialog.DetailsCollapsedLabel = "エラー情報";
            dialog.DetailsExpandedLabel = "エラー情報を非表示";
            dialog.DetailsExpandedText = ex.GetType().ToString() + "\n" + ex.Message;
            dialog.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandContent;
            dialog.DetailsExpanded = false;
            dialog.Icon = TaskDialogStandardIcon.Error;
            dialog.Opened += dialog_Opened;

            /*
            var link2 = new TaskDialogCommandLink("link2", "プログラムを終了します");
            link2.Default = true;
            link2.Click += (sender, e) => dialog.Close(TaskDialogResult.Cancel);
            dialog.Controls.Add(link2);

            var link1 = new TaskDialogCommandLink("link1", "プログラムを再起動します");
            link1.Click += (sender, e) => dialog.Close(TaskDialogResult.Ok);
            dialog.Controls.Add(link1);

            var link3 = new TaskDialogCommandLink("link3", "無視します");
            link3.Click += (sender, e) => dialog.Close(TaskDialogResult.None);
            dialog.Controls.Add(link3);
            */

            var shutButton = new TaskDialogButton();
            shutButton.Text = "終了";
            shutButton.Default = true;
            shutButton.Click += (sender, e) => dialog.Close(TaskDialogResult.Cancel);
            dialog.Controls.Add(shutButton);

            var rebootButton = new TaskDialogButton();
            rebootButton.Text = "再起動";
            rebootButton.Click += (sender, e) => dialog.Close(TaskDialogResult.Ok);
            dialog.Controls.Add(rebootButton);

            if (!isUnhandledException)
            {
                var continueButton = new TaskDialogButton();
                continueButton.Text = "続行";
                continueButton.Click += (sender, e) => dialog.Close(TaskDialogResult.None);
                dialog.Controls.Add(continueButton);
            }

            return dialog.Show();
        }
Esempio n. 16
0
        private void BuyWall(string wallName, Wall wall, int price)
        {
            if (!this.CheckMoney(price)) return;

            if (this.vm.Field.Walls.All(w => w != null))
            {
                MessageBox.Show("設置できる場所がありません。", "壁を買う");
                return;
            }

            var dialog = new TaskDialog();
            dialog.Caption = "壁を買う";
            dialog.InstructionText = wallName;
            dialog.Text = "設置場所を選択してください。";
            dialog.Cancelable = true;
            dialog.OwnerWindowHandle = new WindowInteropHelper(Window.GetWindow(this)).Handle;

            if (this.vm.Field.Walls[2] == null)
            {
                var left = new TaskDialogButton();
                left.Text = "左";
                left.Click += (_, __) =>
                {
                    for (var i = 0; i < 3; i++)
                    {
                        if (this.vm.Field.Walls[i] == null)
                        {
                            this.vm.Field.SetWall(wall, i);
                            break;
                        }
                    }
                    dialog.Close(TaskDialogResult.Ok);
                };
                dialog.Controls.Add(left);
            }

            if (this.vm.Field.Walls[5] == null)
            {
                var center = new TaskDialogButton();
                center.Text = "中央";
                center.Click += (_, __) =>
                {
                    for (var i = 3; i < 6; i++)
                    {
                        if (this.vm.Field.Walls[i] == null)
                        {
                            this.vm.Field.SetWall(wall, i);
                            break;
                        }
                    }
                    dialog.Close(TaskDialogResult.Ok);
                };
                dialog.Controls.Add(center);
            }

            if (this.vm.Field.Walls[8] == null)
            {
                var right = new TaskDialogButton();
                right.Text = "右";
                right.Click += (_, __) =>
                {
                    for (var i = 6; i < 9; i++)
                    {
                        if (this.vm.Field.Walls[i] == null)
                        {
                            this.vm.Field.SetWall(wall, i);
                            break;
                        }
                    }
                    dialog.Close(TaskDialogResult.Ok);
                };
                dialog.Controls.Add(right);
            }

            if (dialog.Show() == TaskDialogResult.Ok)
                this.vm.Field.Money -= price;
        }
Esempio n. 17
0
 public static void FatalError(Exception z)
 {
     Out.WritePlain("A unhandled exception was acquired. Below is the information (possibly repeated) of the exception which made EZCap crash.");
     Out.WriteError("\r\n----------- EZCAP FATALERROR -----------\r\n" + z.ToString() + "\r\n----------------------------------------");
     TaskDialog diag = new TaskDialog();
     diag.InstructionText = "EasyCapture has failed you, master.";
     diag.Text = "EasyCapture has encountered an fatal error.";
     diag.Icon = TaskDialogStandardIcon.Error;
     diag.DetailsExpandedText = z.ToString();
     TaskDialogCommandLink cmd1 = new TaskDialogCommandLink("exit", "Exit the application");
     TaskDialogCommandLink cmd2 = new TaskDialogCommandLink("continue", "Continue and ignore error");
     TaskDialogCommandLink cmd3 = new TaskDialogCommandLink("debug", "Debug the program", "Show the console and try to find out what happend");
     cmd1.Click += delegate(object a, EventArgs b) { Environment.Exit(1); };
     cmd2.Click += delegate(object a, EventArgs b) { diag.Close(); };
     cmd3.Click += delegate(object a, EventArgs b) {
         diag.Close();
         startConsole();
         Out.WritePlain("EZCap debug mode entered");
         Out.WritePlain("EZCap was forced to stop executing. Press enter to resume.");
         Console.Title = "EasyCapture Debug Session";
         Console.ReadLine();
         WINAPI.FreeConsole();
     };
     diag.Controls.Add(cmd1);
     diag.Controls.Add(cmd2);
     diag.Controls.Add(cmd3);
     diag.Caption = "Oops!";
     diag.DetailsExpandedLabel = "Hide error";
     diag.DetailsCollapsedLabel = "Show error";
     diag.Show();
 }
Esempio n. 18
0
 static TaskDialog Step2(TaskDialog d)
 {
     d.Text = "Do you want to follow a quick tutorial to get started with EasyCapture?";
     d.FooterText = "Question 2/2";
     TaskDialogCommandLink cmd1 = new TaskDialogCommandLink("cmd1", "Yes, I'll follow the - really short - tutorial", "Recommended for people who have never used EasyCapture before");
     TaskDialogCommandLink cmd2 = new TaskDialogCommandLink("cmd2", "No, I already know how the program works");
     cmd1.Click += delegate(object sender, EventArgs argz) { d.Close(); ThreadPool.QueueUserWorkItem(new WaitCallback(DemoThread)); };
     cmd2.Click += delegate(object sender, EventArgs argz) { d.Close(); };
     d.Controls.Add(cmd1);
     d.Controls.Add(cmd2);
     return d;
 }
Esempio n. 19
0
 static void SettingsThread(object zz)
 {
     if (!SettingsShowing)
     {
         SettingsShowing = true;
         SettingsV3 v3 = null;
         try
         {
             v3 = new SettingsV3();
         }
         catch (Exception z)
         {
             TaskDialog d = new TaskDialog();
             d.InstructionText = "Unable to load settings";
             d.Text = "The configuration file might be corrupt, do you want to reset it?";
             TaskDialogCommandLink l1 = new TaskDialogCommandLink("l1", "Reset the configuration file", "This will delete your current settings, but then you'll be able to open the settings again");
             TaskDialogCommandLink l2 = new TaskDialogCommandLink("l2", "Don't reset the configuration file", "Settings screen won't load anymore, but you'll keep your settings");
             l1.Click += delegate(object a, EventArgs b) { File.Delete(Core.Settings.path); File.Copy(Path.GetDirectoryName(Application.ExecutablePath) + "\\example.ini", Core.Settings.path); Core_Click(null, null); };
             l2.Click += delegate(object a, EventArgs b) { d.Close(); };
             d.Controls.Add(l1);
             d.Controls.Add(l2);
             d.Icon = TaskDialogStandardIcon.Error;
             d.Caption = d.InstructionText;
             d.DetailsCollapsedLabel = "Show error";
             d.DetailsExpandedLabel = "Hide error";
             d.DetailsExpandedText = z.ToString();
             d.Show();
         }
         finally
         {
             try
             {
                 if (v3 != null)
                 {
                     v3.ShowDialog();
                     v3.Dispose();
                     GC.Collect();
                 }
             }
             catch (Exception z)
             {
                 FatalError(z);
             }
         }
         SettingsShowing = false;
     }
 }
Esempio n. 20
0
        public static void LicenceMessage(IWin32Window owner)
        {
            Licence lic = Options.Current.Licence;

            if (lic.IsValid)
            {
                return;
            }

            string caption = null;
            string message = null;
            bool die = false;

            if (lic.TrialInfo.LevelChanged)
            {
                switch (lic.TrialLevel)
                {
                    case TrialLevel.Remind:
                        caption = "Reminder";
                        message = "Don't forget, this is the trial version of Exception Explorer - but it wont last forever.\n\nConsider purchasing a licence if you would like to continue using Exception Explorer.";
                        break;
                    case TrialLevel.Warn:
                        caption = "Your trial will end soon!";
                        message = "Your time to use Exception Explorer will soon run out, so purchase a licence this week to avoid disappointment!";
                        break;
                    case TrialLevel.Stop:
                        caption = "Final chance...";
                        message = "This is your final chance to try out Exception Explorer.\n\nAfter this session, you will no longer be able to use this software without purchasing a licence.";
                        break;
                }
            }
            else if (lic.TrialLevel == TrialLevel.Stop)
            {
                caption = "Purchase a licence today.";
                message = "Unfortunately, your time to try Exception Explorer has now come to an end.\n\nFor this to happen, you must have been using this software enough to find it useful...\n\nFeel free to purchace a licence if you would like to continue using Exception Explorer.";
                die = true;
            }

            if (message != null)
            {
                TaskDialog td = new TaskDialog()
                {
                    InstructionText = caption.Fix(),
                    Text = message.Fix(),
                    StandardButtons = TaskDialogStandardButtons.Close,
                    Cancelable = true,
                    DetailsExpandedText = string.Format("Installed for {0} days.\nRan {1} times, over {2} distinct days.\n", lic.TrialInfo.DaysInstalled, lic.TrialInfo.RunCount, lic.TrialInfo.DayCount).Fix(),
                };

                TaskDialogCommandLink purchase = new TaskDialogCommandLink("purchase", "Purchase Licence".Fix());
                purchase.Click += (sender, e) =>
                {
                    Web.OpenSite(SiteLink.Buy);
                    td.Close();
                };

                td.Controls.Add(purchase);

                if (!die)
                {
                    TaskDialogCommandLink later = new TaskDialogCommandLink("later", "Maybe later");
                    later.Click += (sender, e) =>
                    {
                        td.Close();
                    };
                }

                td.Show(owner);

                if (die)
                {
                    Application.Exit();
                }
            }
        }
Esempio n. 21
0
        void ExceptionHandler(Exception x)
        {
            if (!Aero)
            {
                MessageBox.Show("An exception was thrown: " + x.Message + "\r\n\r\nPress CTRL + C to copy the stack trace:\r\n" + x.StackTrace);
            }
            else
            {
                tm.SetProgressState(TaskbarProgressBarState.Error);
                this.Invoke((MethodInvoker)delegate
                {
                    TaskDialog td = new TaskDialog();
                    td.Caption = "Unhandled Exception";
                    td.InstructionText = "An Unhandled Exception was Thrown";
                    td.Text = string.Format("An exception was thrown: {0}\r\n\r\nIf this appears to be a bug, please email me at [email protected] with the details below", x.Message);
                    td.DetailsCollapsedLabel = "Details";
                    td.DetailsExpandedLabel = "Details";
                    td.DetailsExpandedText = x.StackTrace;

                    TaskDialogButton Copy = new TaskDialogButton("Copy", "Copy Details to Clipboard");
                    Copy.Click += (o, f) => { this.Invoke((MethodInvoker)delegate { Clipboard.SetDataObject(x.Message + "\r\n\r\n" + x.StackTrace, true, 10, 200); }); };

                    TaskDialogButton Close = new TaskDialogButton("Close", "Close");
                    Close.Click += (o, f) => { td.Close(); };

                    td.Controls.Add(Copy);
                    td.Controls.Add(Close);
                    td.ShowDialog(this.Handle);
                });
            }
        }
Esempio n. 22
0
        private void menuItem7_Click(object sender, EventArgs e)
        {
            string Text = "Party Buffalo was created by CLK Rebellion (Lander Griffith) with help from gabe_k.  You may contact me at [email protected]\r\n\r\nThis application is not affiliated with Microsoft Corp. \"Microsoft\", \"Xbox\", \"Xbox 360\" and \"Xbox LIVE\" are registered trademarks of Microsoft Corp.";
            string Thanks = "skitzo, gabe_k, Cody, hippie, Rickshaw, Cheater912, unknown_v2, sonic-iso, XeNoN.7\r\n\r\nCaboose (Nyan Cat progress bar), Mathieulh (stealing credit cards), idc \"Looks like a list of attendees for a furry convention to me\", roofus & angerwound for the first Xbox 360 FATX explorer which still keeps people satisfied...";
            string Version = "Version: " + Application.ProductVersion.ToString();

            if (Aero)
            {
                Microsoft.WindowsAPICodePack.Dialogs.TaskDialog td = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialog();
                td.Caption = "About Party Buffalo";
                td.Text = Text;
                td.InstructionText = "About Party Buffalo";
                td.DetailsCollapsedLabel = "Special Thanks To...";
                td.DetailsExpandedText = Thanks;
                Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton Donate = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton("Donate", "Donate");
                Donate.Click += (o, f) => { MessageBox.Show("Thank you for your contribution!"); System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JWATGN6RETA5Y&lc=US&item_name=Party%20Buffalo%20Drive%20Explorer&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"); };

                //Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton Visit = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton("Visit", "Visit CLKXU5.com");
                //Visit.Click += (o, f) => { System.Diagnostics.Process.Start("http://clkxu5.com"); };

                Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton Close = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton("Close", "Close");
                Close.Click += (o, f) => { td.Close(); };

                td.HyperlinksEnabled = true;
                td.HyperlinkClick += (o, f) => { switch (f.LinkText)
                {
                    case "Visit the Development Blog":
                        System.Diagnostics.Process.Start("http://clkxu5.com");
                        break;
                    default:
                        System.Diagnostics.Process.Start("http://free60.org/FATX");
                        break;
                }};
                td.FooterText = "Thank you for using Party Buffalo Drive Explorer\r\n" + Version + "\r\n<a href=\"http://clkxu5.com\">Visit the Development Blog</a> - <a href=\"http://free60.org/FATX\">FATX Research</a>";

                td.Controls.Add(Donate);
                //td.Controls.Add(Visit);
                td.Controls.Add(Close);
                td.Show();
            }
            else
            {
                if (MessageBox.Show(Text + "\r\n" + Thanks + "\r\n" + Version + "\r\nWould you like to donate?", "About Party Buffalo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    MessageBox.Show("Thank you for your contribution!"); System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JWATGN6RETA5Y&lc=US&item_name=Party%20Buffalo%20Drive%20Explorer&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted");
                }
            }
        }
Esempio n. 23
0
        private static void CheckForUpdates()
        {
            StartupLog.Debug ("Checking for updates..");

            Updater.CheckAsync (UpdateChannel.Nightly).ContinueWith (t => {
                if (t.IsCanceled) {
                    StartupLog.Debug ("Update check was canceled.");
                    return;
                } else if (t.IsFaulted) {
                    StartupLog.Debug ("Update check failed", t.Exception.Flatten());
                    return;
                }

                Version currentVersion = typeof (Program).Assembly.GetName().Version;
                StartupLog.DebugFormat ("Update check: Current {0} vs. {1}", currentVersion, t.Result.Version);

                if (t.Result.Version <= currentVersion)
                    return;

                TaskDialog update = new TaskDialog {
                    InstructionText = "Would you like to update?",
                    Text = String.Format ("You're using version {0}, version {1} is available.", currentVersion, t.Result.Version),
                    Icon = TaskDialogStandardIcon.Information,
                    Caption = "Gablarski",
                    StartupLocation = TaskDialogStartupLocation.CenterScreen,
                    StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No
                };

                //update.Controls.Add (new TaskDialogButton ("update", "Yes") { UseElevationIcon = true });
                //update.Controls.Add (new TaskDialogButton ("dontupdate", "No"));

                update.Closing += (sender, args) => {
                    //if (args.CustomButton != "update")
                        //return;
                    if (args.TaskDialogResult != TaskDialogResult.Yes)
                        return;

                    Task.Run (() => {
                        var cancelSource = new CancellationTokenSource();

                        TaskDialog downloadUpdate = new TaskDialog {
                            InstructionText = "Downloading update...",
                            StandardButtons = TaskDialogStandardButtons.Cancel,
                            ProgressBar = new TaskDialogProgressBar (0, 100, 0)
                        };

                        var progress = new Progress<int> (p => {
                            downloadUpdate.ProgressBar.Value = p;
                        });

                        Updater.DownloadAsync (t.Result, progress, cancelSource.Token).ContinueWith (dt => {
                            downloadUpdate.Close (TaskDialogResult.Ok);

                            Process.Start (dt.Result);
                            Environment.Exit (0);
                        }, TaskContinuationOptions.OnlyOnRanToCompletion);

                        if (downloadUpdate.Show() == TaskDialogResult.Cancel)
                            cancelSource.Cancel();
                    });
                };

                update.Show();
            });
        }
Esempio n. 24
0
        private void tCached_Click(object sender, EventArgs e)
        {
            Forms.NewKnownFolder n = new Forms.NewKnownFolder();
            if (n.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Folder f = (Folder)rightClickedNode.Tag;
                    if (!f.IsDeleted)
                    {
                        foreach (Folder Fol in f.Folders())
                        {
                            if (Fol.Name.ToLower() == (n.Selected.ToLower()))
                            {
                                MessageBox.Show("Folder already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                        f.CreateNewFolder(n.Selected);
                        rightClickedNode.Tag = f;
                    }
                }
                catch(Exception x)
                {
                    if (!Aero)
                    {
                        MessageBox.Show("An exception was thrown: " + x.Message + "\r\n\r\nIf this appears to be a bug, press CTRL + C to copy the stack trace, then please email it to me at [email protected]:\r\n" + x.StackTrace);
                    }
                    else
                    {
                        TaskDialog td = new TaskDialog();
                        td.Caption = "Unhandled Exception";
                        td.InstructionText = "An Unhandled Exception was Thrown";
                        td.Text = string.Format("An exception was thrown: {0}\r\n\r\nIf this appears to be a bug, please email me at [email protected] with the details below", x.Message);
                        td.DetailsCollapsedLabel = "Details";
                        td.DetailsExpandedLabel = "Details";
                        td.DetailsExpandedText = x.StackTrace;

                        TaskDialogButton Copy = new TaskDialogButton("Copy", "Copy Details to Clipboard");
                        Copy.Click += (o, f) => { Clipboard.SetDataObject(x.StackTrace, true, 10, 200); };

                        TaskDialogButton Close = new TaskDialogButton("Close", "Close");
                        Close.Click += (o, f) => { td.Close(); };

                        td.Controls.Add(Copy);
                        td.Controls.Add(Close);
                    }
                    Clear();
                }
            }
        }
Esempio n. 25
0
        private static bool ShowKeyProgress(CancellationTokenSource keyCancelSource)
        {
            if (Key.IsCompleted)
                return true;

            StartupLog.Debug ("Key retrieval not complete in time, showing dialog.");

            bool showing = false;
            TaskDialog progress = new TaskDialog {
                Caption = "Gablarski",
                InstructionText = "Setting up personal key...",
                ProgressBar = new TaskDialogProgressBar { State = TaskDialogProgressBarState.Marquee },
                StandardButtons = TaskDialogStandardButtons.Cancel,
                StartupLocation = TaskDialogStartupLocation.CenterScreen
            };

            progress.Opened += (s, e) => showing = true;

            Key.ContinueWith (t => {
                while (!showing)
                    Thread.Sleep (1);

                progress.Close (TaskDialogResult.Ok);
            }, TaskContinuationOptions.NotOnCanceled);

            if (progress.Show() == TaskDialogResult.Cancel) {
                keyCancelSource.Cancel();
                return false;
            }

            return true;
        }
Esempio n. 26
0
        void DoStartup()
        {
            if (Properties.Settings.Default.checkForUpdates)
            {
                #region Update Shit

                Party_Buffalo.Update u = new Update();
            #if TRACE
                Party_Buffalo.Update.UpdateInfo ud = u.CheckForUpdates(new Uri("http://clkxu5.com/drivexplore/coolapplicationstuff.xml"));
            #endif
            #if DEBUG
                Party_Buffalo.Update.UpdateInfo ud = new Update.UpdateInfo();
                if (UpdateDebug)
                {
                    if (!UpdateDebugForce)
                    {
                        ud = u.CheckForUpdates(new Uri("http://clkxu5.com/drivexplore/dev/coolapplicationstuff.xml"));
                    }
                    else
                    {
                        ud.Update = true;
                        ud.UpdateText = "This`Is`A`Test";
                        ud.UpdateVersion = "9000";
                    }
                }
            #endif
                if (ud.Update)
                {
                    if (!Aero)
                    {
                        Forms.UpdateForm uf = new Party_Buffalo.Forms.UpdateForm(ud);
                        uf.ShowDialog();
                    }
                    else
                    {
                        TaskDialog td = new TaskDialog();
                        td.Caption = "Update Available";
                        td.InstructionText = "Version " + ud.UpdateVersion + " is Available";
                        td.Text = "An update is available for Party Buffalo";
                        td.DetailsCollapsedLabel = "Change Log";
                        td.DetailsExpandedLabel = "Change Log";
                        td.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter;
                        string[] Split = ud.UpdateText.Split('`');
                        string UpdateText = "";
                        for (int i = 0; i < Split.Length; i++)
                        {
                            if (i != 0)
                            {
                                UpdateText += "\r\n";
                            }
                            if (Split[i] == "")
                            {
                                continue;
                            }
                            UpdateText += "-" + Split[i];
                        }
                        td.DetailsExpandedText = UpdateText;
                        TaskDialogCommandLink Download = new TaskDialogCommandLink("Download", "Download Party Buffalo version " + ud.UpdateVersion, "");
                        Download.Click += (o, f) =>
                        {
                            Forms.UpdateDownloadForm udf = new Party_Buffalo.Forms.UpdateDownloadForm(ud);
                            udf.ShowDialog();
                        };

                        TaskDialogCommandLink DontDownload = new TaskDialogCommandLink("DontDownload", "Let me go about my business and I'll download this stuff later...", "");
                        DontDownload.Click += (o, f) =>
                        {
                            td.Close();
                        };
                        td.Controls.Add(Download);
                        td.Controls.Add(DontDownload);
                        td.Show();
                    }
                }
                if (ud.QuickMessage != null && ud.QuickMessage != "")
                {
                    quickMessage.Text = ud.QuickMessage;
                }
                else
                {
                    quickMessage.Text = "Could not load quick message";
                }

                #endregion
            }
            else
            {
                m_DisableUpdates.Checked = true;
            }

            if (!Properties.Settings.Default.Upgraded)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.Upgraded = true;
                Properties.Settings.Default.Save();
            }
            if (Properties.Settings.Default.width > 50 && Properties.Settings.Default.height > 50)
            {
                this.Height = Properties.Settings.Default.height;
                this.Width = Properties.Settings.Default.width;
            }
            quickAddMode.Checked = Properties.Settings.Default.quickAddMode;
            SaveIcons.Checked = Properties.Settings.Default.SaveIcons;
            m_loadEntireDrive.Checked = Properties.Settings.Default.loadEntireDrive;
            m_LoadSTFS.Checked = Properties.Settings.Default.loadSTFS;
            m_retrieveGameNames.Checked = Properties.Settings.Default.loadTIDNames;
            cacheContentIcons.Checked = Properties.Settings.Default.cacheContentIcons;
            if (Properties.Settings.Default.hideToolBar)
            {
                m_hideToolBar.PerformClick();
            }
            if (Properties.Settings.Default.hideAddressBar)
            {
                m_hideAddressBar.PerformClick();
            }
            if (Properties.Settings.Default.hideStatusBar)
            {
                m_hideStatusBar.PerformClick();
            }
            switch (Properties.Settings.Default.view)
            {
                case View.Details:
                    c_Details.Checked = true;
                    listView1.View = View.Details;
                    break;
                case View.LargeIcon:
                    c_largeIcon.Checked = true;
                    listView1.View = View.LargeIcon;
                    break;
                case View.List:
                    c_List.Checked = true;
                    listView1.View = View.List;
                    break;
                case View.SmallIcon:
                    c_SmallIcon.Checked = true;
                    listView1.View = View.SmallIcon;
                    break;
                case View.Tile:
                    c_Tile.Checked = true;
                    listView1.View = View.Tile;
                    break;

            }

            if (Properties.Settings.Default.recentFiles != null)
            {
                List<string> Remove = new List<string>();
                foreach (string s in Properties.Settings.Default.recentFiles)
                {
                    if (System.IO.File.Exists(s))
                    {
                        MenuItem i = new MenuItem(s);
                        i.Click += new EventHandler(RecentFileHandler);
                        m_Open.MenuItems.Add(i);
                    }
                    else
                    {
                        Remove.Add(s);
                    }
                }

                for (int i = 0; i < Remove.Count; )
                {
                    Properties.Settings.Default.recentFiles.Remove(Remove[i]);
                    Remove.RemoveAt(i);
                }
            }

            List<MenuItem> mil = new List<MenuItem>();
            List<MenuItem> mit = new List<MenuItem>();

            // Add the "new known folder" (cached) items
            for (int i = 0; i < CLKsFATXLib.VariousFunctions.Known.Length; i++)
            {
                string ss = CLKsFATXLib.VariousFunctions.Known[i];
                string s = CLKsFATXLib.VariousFunctions.KnownEquivilent[i];
                // Create our listview menu item...
                MenuItem mu = new MenuItem(s + " (" + ss + ")");
                // Set its tag
                mu.Tag = ss;
                // Set its event handler
                mu.Click += new EventHandler(mu_Click);

                // Create our treeview menu item...
                MenuItem mut = new MenuItem(s + " (" + ss + ")");
                // Set its tag
                mut.Tag = ss;
                // Create its event handler
                mut.Click += new EventHandler(mut_Click);

                // Add it to the cached menu items
                mil.Add(mu);
                mit.Add(mut);
                //lCached.MenuItems.Add(mu);
                //tCached.MenuItems.Add(mut);
            }

            // Cast those as arrays
            MenuItem[] ArrayL = mil.ToArray();
            Array.Sort(ArrayL, new Extensions.MenuItemComparer());

            MenuItem[] ArrayT = mit.ToArray();
            Array.Sort(ArrayT, new Extensions.MenuItemComparer());

            // Add ranges
            lStatic.MenuItems.AddRange(ArrayL);
            tStatic.MenuItems.AddRange(ArrayT);

            // For treeview icon size
            switch (Properties.Settings.Default.treeViewIconWidthHeight)
            {
                case 16:
                    size16.Checked = true;
                    break;
                case 24:
                    size24.Checked = true;
                    break;
                case 32:
                    size32.Checked = true;
                    break;
                case 64:
                    size64.Checked = true;
                    break;
            }
            treeView1.ImageList.ImageSize = new Size(Properties.Settings.Default.treeViewIconWidthHeight, Properties.Settings.Default.treeViewIconWidthHeight);
        }
Esempio n. 27
0
        private static bool LocateMissingGit()
        {
            int dialogResult = -1;

            using var dialog1 = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialog
                  {
                      InstructionText = ResourceManager.TranslatedStrings.GitExecutableNotFound,
                      Icon            = TaskDialogStandardIcon.Error,
                      StandardButtons = TaskDialogStandardButtons.Cancel,
                      Cancelable      = true,
                  };
            var btnFindGitExecutable = new TaskDialogCommandLink("FindGitExecutable", null, ResourceManager.TranslatedStrings.FindGitExecutable);

            btnFindGitExecutable.Click += (s, e) =>
            {
                dialogResult = 0;
                dialog1.Close();
            };
            var btnInstallGitInstructions = new TaskDialogCommandLink("InstallGitInstructions", null, ResourceManager.TranslatedStrings.InstallGitInstructions);

            btnInstallGitInstructions.Click += (s, e) =>
            {
                dialogResult = 1;
                dialog1.Close();
            };
            dialog1.Controls.Add(btnFindGitExecutable);
            dialog1.Controls.Add(btnInstallGitInstructions);

            dialog1.Show();
            switch (dialogResult)
            {
            case 0:
            {
                using var dialog = new System.Windows.Forms.OpenFileDialog
                      {
                          Filter = @"git.exe|git.exe|git.cmd|git.cmd",
                      };
                if (dialog.ShowDialog(null) == DialogResult.OK)
                {
                    AppSettings.GitCommandValue = dialog.FileName;
                }

                if (CheckSettingsLogic.SolveGitCommand())
                {
                    return(true);
                }

                return(false);
            }

            case 1:
            {
                OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/Application-Dependencies#git");
                return(false);
            }

            default:
            {
                return(false);
            }
            }
        }