1. Patrick Schaller
  2. KeePassTrueCryptMount

Commits

Patrick Schaller  committed ad7f7e5

TrueCryptMountForm: Changed the BackgroundCheck action, AskPassword checkbox will be disabled by uncheck Background.

  • Participants
  • Parent commits c4f3939
  • Branches master

Comments (0)

Files changed (4)

File src/KeepassTrueCryptMount/EntryStrings.cs

View file
  • Ignore whitespace
 
         public const string Silent = "truecrypt.option.silent";
 
-        public const string Quit = "truecrypt.option.quit";
+        public const string Background = "truecrypt.option.quit";
 
         public const string Beep = "truecrypt.option.beep";
 

File src/KeepassTrueCryptMount/PwEntryExtension.cs

View file
  • Ignore whitespace
 
             // quit
             {
-                var quitString = entry.Strings.GetSafe(EntryStrings.Quit).ReadString();
+                var quitString = entry.Strings.GetSafe(EntryStrings.Background).ReadString();
                 bool quit;
                 bool.TryParse(quitString, out quit);
                 if (quit)
                 bool askForPassword;
                 bool.TryParse(askForPasswordString, out askForPassword);
 
-                arguments.Append(" /p ");
-
                 if (!askForPassword)
                 {
+                    arguments.Append(" /p ");
                     arguments.Append(entry.Strings.GetSafe("Password").ReadString());                    
                 }
             }

File src/KeepassTrueCryptMount/TrueCryptMountForm.Designer.cs

View file
  • Ignore whitespace
             this.mountOptionsLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
             this.readonlyCheckBox = new System.Windows.Forms.CheckBox();
             this.removableCheckBox = new System.Windows.Forms.CheckBox();
-            this.quitCheckBox = new System.Windows.Forms.CheckBox();
+            this.backgroundCheckBox = new System.Windows.Forms.CheckBox();
             this.silentCheckBox = new System.Windows.Forms.CheckBox();
             this.beepCheckBox = new System.Windows.Forms.CheckBox();
             this.explorerCheckBox = new System.Windows.Forms.CheckBox();
             // 
             this.mountOptionsLayoutPanel.Controls.Add(this.readonlyCheckBox);
             this.mountOptionsLayoutPanel.Controls.Add(this.removableCheckBox);
-            this.mountOptionsLayoutPanel.Controls.Add(this.quitCheckBox);
+            this.mountOptionsLayoutPanel.Controls.Add(this.backgroundCheckBox);
             this.mountOptionsLayoutPanel.Controls.Add(this.silentCheckBox);
             this.mountOptionsLayoutPanel.Controls.Add(this.beepCheckBox);
             this.mountOptionsLayoutPanel.Controls.Add(this.explorerCheckBox);
             // 
             // quitCheckBox
             // 
-            this.quitCheckBox.Location = new System.Drawing.Point(215, 3);
-            this.quitCheckBox.Name = "quitCheckBox";
-            this.quitCheckBox.Size = new System.Drawing.Size(100, 24);
-            this.quitCheckBox.TabIndex = 4;
-            this.quitCheckBox.Text = "Background";
-            this.tipInfo.SetToolTip(this.quitCheckBox, "Automatically perform requested actions and exit (main TrueCrypt window will not " +
+            this.backgroundCheckBox.Location = new System.Drawing.Point(215, 3);
+            this.backgroundCheckBox.Name = "quitCheckBox";
+            this.backgroundCheckBox.Size = new System.Drawing.Size(100, 24);
+            this.backgroundCheckBox.TabIndex = 4;
+            this.backgroundCheckBox.Text = "Background";
+            this.tipInfo.SetToolTip(this.backgroundCheckBox, "Automatically perform requested actions and exit (main TrueCrypt window will not " +
         "be displayed).");
-            this.quitCheckBox.UseVisualStyleBackColor = true;
-            this.quitCheckBox.CheckedChanged += new System.EventHandler(this.OnAnyOptionChanged);
+            this.backgroundCheckBox.UseVisualStyleBackColor = true;
+            this.backgroundCheckBox.CheckedChanged += new System.EventHandler(this.OnAnyOptionChanged);
             // 
             // silentCheckBox
             // 
         private System.Windows.Forms.Button btnApply;
         private System.Windows.Forms.CheckBox hideDialogCheckBox;
         private System.Windows.Forms.CheckBox beepCheckBox;
-        private System.Windows.Forms.CheckBox quitCheckBox;
+        private System.Windows.Forms.CheckBox backgroundCheckBox;
         private System.Windows.Forms.CheckBox explorerCheckBox;
         private System.Windows.Forms.CheckBox askPasswordCheckBox;
         private System.Windows.Forms.Button btnReloadDrives;

File src/KeepassTrueCryptMount/TrueCryptMountForm.cs

View file
  • Ignore whitespace
             this.driveComboBox.Items.Add(new AutoDriveLetterComboBoxItem());
             this.driveComboBox.Items.AddRange(LogicalDriveLetters.FreeDriveLetters.ToArray());
 
-            this.quitCheckBox.CheckedChanged += this.OnQuitCheckBoxChanged;
+            this.backgroundCheckBox.CheckedChanged += this.OnBackgroundCheckBoxChanged;
         }
 
         public string ContainerVolume
                 bool.TryParse(explorerString.ReadString(), out explorer);
                 this.explorerCheckBox.Checked = explorer;
             }
-
-            // quit
-            this.quitCheckBox.Checked = false;
-            var quitString = entry.Strings.GetSafe(EntryStrings.Quit);
-            if (!quitString.IsEmpty)
-            {
-                bool quit;
-                bool.TryParse(quitString.ReadString(), out quit);
-                this.quitCheckBox.Checked = quit;
-            }
-            else
-            {
-                this.quitCheckBox.Checked = true;
-            }
-
+            
             // silent
             this.OptionSilent = false;
             var silentString = entry.Strings.GetSafe(EntryStrings.Silent);
                 this.askPasswordCheckBox.Checked = askPassword;
             }
 
+            // background
+            this.backgroundCheckBox.Checked = false;
+            var backgroundString = entry.Strings.GetSafe(EntryStrings.Background);
+            if (!backgroundString.IsEmpty)
+            {
+                bool background;
+                bool.TryParse(backgroundString.ReadString(), out background);
+                this.backgroundCheckBox.Checked = background;
+            }
+            else
+            {
+                this.backgroundCheckBox.Checked = true;
+            }
+
+            this.OnBackgroundCheckBoxChanged(this, EventArgs.Empty);
+
             this.btnApply.Enabled = false;
 
             return this;
             entry.Strings.Set(EntryStrings.DriveLetter, new ProtectedString(false, this.DriveLetter));
             entry.Strings.Set(EntryStrings.Enabled, new ProtectedString(false, true.ToString()));
             entry.Strings.Set(EntryStrings.MountWithoutDialog, new ProtectedString(false, this.HideForEntry.ToString()));
-            entry.Strings.Set(EntryStrings.Quit, new ProtectedString(false, this.quitCheckBox.Checked.ToString()));
+            entry.Strings.Set(EntryStrings.Background, new ProtectedString(false, this.backgroundCheckBox.Checked.ToString()));
             entry.Strings.Set(EntryStrings.Silent, new ProtectedString(false, this.silentCheckBox.Checked.ToString()));
             entry.Strings.Set(EntryStrings.Removable, new ProtectedString(false, this.removableCheckBox.Checked.ToString()));
             entry.Strings.Set(EntryStrings.Readonly, new ProtectedString(false, this.readonlyCheckBox.Checked.ToString()));
             this.btnApply.Enabled = true;
         }
 
-        private void OnQuitCheckBoxChanged(object sender, EventArgs e)
+        private void OnBackgroundCheckBoxChanged(object sender, EventArgs e)
         {
-            if (this.quitCheckBox.Checked == true)
-            {
-                this.silentCheckBox.Enabled = true;
-            }
-            else
-            {
-                this.silentCheckBox.Enabled = false;
-                this.silentCheckBox.Checked = false;
-            }
+            var backgroundChecked = this.backgroundCheckBox.Checked;
+
+            this.silentCheckBox.Enabled = backgroundChecked;
+            this.silentCheckBox.Checked = !backgroundChecked ? false : this.silentCheckBox.Checked;
+
+            this.askPasswordCheckBox.Enabled = backgroundChecked;
+            this.askPasswordCheckBox.Checked = !backgroundChecked ? true : this.askPasswordCheckBox.Checked;
         }
 
         private void OnApplyButtonClicked(object sender, EventArgs e)