OSDN Git Service

RAD-498: Ability to confirm the program exit 19/head
authornooperation <madbrahmin@gmail.com>
Wed, 15 Jul 2015 23:46:23 +0000 (19:46 -0400)
committernooperation <madbrahmin@gmail.com>
Wed, 15 Jul 2015 23:46:23 +0000 (19:46 -0400)
* Added setting to enable confirm exit whenever application attempts to
exit.

Radegast/GUI/Dialogs/MainForm.cs
Radegast/GUI/Dialogs/Settings.Designer.cs
Radegast/GUI/Dialogs/Settings.cs

index 7641948..dbaa599 100644 (file)
@@ -390,6 +390,15 @@ namespace Radegast
 
         private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
         {
+            if (instance.GlobalSettings["confirm_exit"].AsBoolean())
+            {
+                if (MessageBox.Show("Are you sure you want to exit Radegast?", "Confirm Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
+                {
+                    e.Cancel = true;
+                    return;
+                }
+            }
+
             if (statusTimer != null)
             {
                 statusTimer.Stop();
index 6c43e3f..eeb6c2e 100644 (file)
@@ -98,6 +98,8 @@ namespace Radegast
             this.rbDNSmart = new System.Windows.Forms.RadioButton();
             this.rbDNOff = new System.Windows.Forms.RadioButton();
             this.tbpAutoResponse = new System.Windows.Forms.TabPage();
+            this.gnAutoScriptPermission = new System.Windows.Forms.GroupBox();
+            this.cbAutoScriptPermission = new System.Windows.Forms.ComboBox();
             this.gnAutoInventory = new System.Windows.Forms.GroupBox();
             this.cbOnInvOffer = new System.Windows.Forms.ComboBox();
             this.txtAutoResponse = new System.Windows.Forms.TextBox();
@@ -129,8 +131,7 @@ namespace Radegast
             this.autoSitUUID = new System.Windows.Forms.TextBox();
             this.autoSitName = new System.Windows.Forms.TextBox();
             this.autoSitNameLabel = new System.Windows.Forms.Label();
-            this.gnAutoScriptPermission = new System.Windows.Forms.GroupBox();
-            this.cbAutoScriptPermission = new System.Windows.Forms.ComboBox();
+            this.cbConfirmExit = new System.Windows.Forms.CheckBox();
             this.tcGraphics.SuspendLayout();
             this.tbpGeneral.SuspendLayout();
             this.cbHighLight.SuspendLayout();
@@ -138,6 +139,7 @@ namespace Radegast
             this.Chat.SuspendLayout();
             this.gbDisplayNames.SuspendLayout();
             this.tbpAutoResponse.SuspendLayout();
+            this.gnAutoScriptPermission.SuspendLayout();
             this.gnAutoInventory.SuspendLayout();
             this.gbAutoResponse.SuspendLayout();
             this.tbpBot.SuspendLayout();
@@ -145,7 +147,6 @@ namespace Radegast
             this.pseudoHome.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pseudoHomeTolerance)).BeginInit();
             this.autoSit.SuspendLayout();
-            this.gnAutoScriptPermission.SuspendLayout();
             this.SuspendLayout();
             // 
             // tcGraphics
@@ -243,6 +244,7 @@ namespace Radegast
             // 
             // cbMisc
             // 
+            this.cbMisc.Controls.Add(this.cbConfirmExit);
             this.cbMisc.Controls.Add(this.cbShowScriptErrors);
             this.cbMisc.Controls.Add(this.cbDisableHTTPInventory);
             this.cbMisc.Controls.Add(this.cbHideLoginGraphics);
@@ -260,7 +262,7 @@ namespace Radegast
             this.cbMisc.Controls.Add(this.cbSyntaxHighlight);
             this.cbMisc.Location = new System.Drawing.Point(270, 6);
             this.cbMisc.Name = "cbMisc";
-            this.cbMisc.Size = new System.Drawing.Size(236, 310);
+            this.cbMisc.Size = new System.Drawing.Size(236, 328);
             this.cbMisc.TabIndex = 2;
             this.cbMisc.TabStop = false;
             // 
@@ -604,6 +606,30 @@ namespace Radegast
             this.tbpAutoResponse.Text = "Auto Response";
             this.tbpAutoResponse.UseVisualStyleBackColor = true;
             // 
+            // gnAutoScriptPermission
+            // 
+            this.gnAutoScriptPermission.Controls.Add(this.cbAutoScriptPermission);
+            this.gnAutoScriptPermission.Location = new System.Drawing.Point(9, 216);
+            this.gnAutoScriptPermission.Name = "gnAutoScriptPermission";
+            this.gnAutoScriptPermission.Size = new System.Drawing.Size(281, 54);
+            this.gnAutoScriptPermission.TabIndex = 3;
+            this.gnAutoScriptPermission.TabStop = false;
+            this.gnAutoScriptPermission.Text = "On script permission questions";
+            // 
+            // cbAutoScriptPermission
+            // 
+            this.cbAutoScriptPermission.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.cbAutoScriptPermission.FormattingEnabled = true;
+            this.cbAutoScriptPermission.Items.AddRange(new object[] {
+            "Ask",
+            "Auto Accept",
+            "Auto Decline"});
+            this.cbAutoScriptPermission.Location = new System.Drawing.Point(6, 19);
+            this.cbAutoScriptPermission.Name = "cbAutoScriptPermission";
+            this.cbAutoScriptPermission.Size = new System.Drawing.Size(121, 21);
+            this.cbAutoScriptPermission.TabIndex = 0;
+            this.cbAutoScriptPermission.SelectedIndexChanged += new System.EventHandler(this.cbAutoScriptPermission_SelectedIndexChanged);
+            // 
             // gnAutoInventory
             // 
             this.gnAutoInventory.Controls.Add(this.cbOnInvOffer);
@@ -950,29 +976,16 @@ namespace Radegast
             this.autoSitNameLabel.Text = "Name";
             this.autoSitNameLabel.Click += new System.EventHandler(this.autoSitNameLabel_Click);
             // 
-            // gnAutoScriptPermission
-            // 
-            this.gnAutoScriptPermission.Controls.Add(this.cbAutoScriptPermission);
-            this.gnAutoScriptPermission.Location = new System.Drawing.Point(9, 216);
-            this.gnAutoScriptPermission.Name = "gnAutoScriptPermission";
-            this.gnAutoScriptPermission.Size = new System.Drawing.Size(281, 54);
-            this.gnAutoScriptPermission.TabIndex = 3;
-            this.gnAutoScriptPermission.TabStop = false;
-            this.gnAutoScriptPermission.Text = "On script permission questions";
+            // cbConfirmExit
             // 
-            // cbAutoScriptPermission
-            // 
-            this.cbAutoScriptPermission.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.cbAutoScriptPermission.FormattingEnabled = true;
-            this.cbAutoScriptPermission.Items.AddRange(new object[] {
-            "Ask",
-            "Auto Accept",
-            "Auto Decline"});
-            this.cbAutoScriptPermission.Location = new System.Drawing.Point(6, 19);
-            this.cbAutoScriptPermission.Name = "cbAutoScriptPermission";
-            this.cbAutoScriptPermission.Size = new System.Drawing.Size(121, 21);
-            this.cbAutoScriptPermission.TabIndex = 0;
-            this.cbAutoScriptPermission.SelectedIndexChanged += new System.EventHandler(this.cbAutoScriptPermission_SelectedIndexChanged);
+            this.cbConfirmExit.AutoSize = true;
+            this.cbConfirmExit.Location = new System.Drawing.Point(6, 304);
+            this.cbConfirmExit.Name = "cbConfirmExit";
+            this.cbConfirmExit.Size = new System.Drawing.Size(81, 17);
+            this.cbConfirmExit.TabIndex = 18;
+            this.cbConfirmExit.Text = "Confirm Exit";
+            this.cbConfirmExit.UseVisualStyleBackColor = true;
+            this.cbConfirmExit.CheckedChanged += new System.EventHandler(this.cbConfirmExit_CheckedChanged);
             // 
             // frmSettings
             // 
@@ -995,6 +1008,7 @@ namespace Radegast
             this.gbDisplayNames.PerformLayout();
             this.tbpAutoResponse.ResumeLayout(false);
             this.tbpAutoResponse.PerformLayout();
+            this.gnAutoScriptPermission.ResumeLayout(false);
             this.gnAutoInventory.ResumeLayout(false);
             this.gbAutoResponse.ResumeLayout(false);
             this.gbAutoResponse.PerformLayout();
@@ -1006,7 +1020,6 @@ namespace Radegast
             ((System.ComponentModel.ISupportInitialize)(this.pseudoHomeTolerance)).EndInit();
             this.autoSit.ResumeLayout(false);
             this.autoSit.PerformLayout();
-            this.gnAutoScriptPermission.ResumeLayout(false);
             this.ResumeLayout(false);
 
         }
@@ -1085,6 +1098,7 @@ namespace Radegast
         public System.Windows.Forms.CheckBox cbShowScriptErrors;
         public System.Windows.Forms.GroupBox gnAutoScriptPermission;
         public System.Windows.Forms.ComboBox cbAutoScriptPermission;
+        private System.Windows.Forms.CheckBox cbConfirmExit;
 
 
     }
index b92ac2d..0f91012 100644 (file)
@@ -123,6 +123,8 @@ namespace Radegast
 
             if (!s.ContainsKey("disable_look_at")) s["disable_look_at"] = false;
 
+            if (!s.ContainsKey("confirm_exit")) s["confirm_exit"] = false;
+
             if (!s.ContainsKey("highlight_on_chat")) s["highlight_on_chat"] = true;
 
             if (!s.ContainsKey("highlight_on_im")) s["highlight_on_im"] = true;
@@ -264,6 +266,12 @@ namespace Radegast
                 s["disable_look_at"] = cbDisableLookAt.Checked;
             };
 
+            cbConfirmExit.Checked = s["confirm_exit"];
+            cbConfirmExit.CheckedChanged += (sender, e) =>
+            {
+                s["confirm_exit"] = cbConfirmExit.Checked;
+            };
+
             cbTaskBarHighLight.Checked = s["taskbar_highlight"];
             cbTaskBarHighLight.CheckedChanged += (sender, e) =>
             {
@@ -483,6 +491,11 @@ namespace Radegast
             s["log_to_file"] = OSD.FromBoolean(cbRadegastLogToFile.Checked);
         }
 
+        private void cbConfirmExit_CheckedChanged(object sender, EventArgs e)
+        {
+            s["confirm_exit"] = OSD.FromBoolean(cbConfirmExit.Checked);
+        }
+
         #region Auto-Sit
 
         private void autoSitPrefsUpdate()