Changeset 2077


Ignore:
Timestamp:
5/8/2010 6:00:27 AM (4 years ago)
Author:
lowjoel
Message:

Don't use the split button to pick the file or folder to move to; ask the user what he wants moved, then present the appropriate dialogs. Addresses #60: Eraser Secure Cut.

Location:
trunk/eraser/Eraser.DefaultPlugins/ErasureTargets
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.DefaultPlugins/ErasureTargets/SecureMoveErasureTargetConfigurer.Designer.cs

    r2068 r2077  
    5050        private void InitializeComponent() 
    5151        { 
    52             this.components = new System.ComponentModel.Container(); 
    53             this.fileDialog = new System.Windows.Forms.OpenFileDialog(); 
     52            this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 
    5453            this.folderDialog = new System.Windows.Forms.FolderBrowserDialog(); 
    5554            this.fromLbl = new System.Windows.Forms.Label(); 
     
    5756            this.toLbl = new System.Windows.Forms.Label(); 
    5857            this.toTxt = new System.Windows.Forms.TextBox(); 
    59             this.fromBrowseMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 
    60             this.fromSelectFile = new System.Windows.Forms.ToolStripMenuItem(); 
    61             this.fromSelectFolder = new System.Windows.Forms.ToolStripMenuItem(); 
    6258            this.toSelectButton = new System.Windows.Forms.Button(); 
    63             this.fromSelectButton = new System.Windows.Forms.SplitButton(); 
    64             this.fromBrowseMenu.SuspendLayout(); 
     59            this.moveFileRadio = new System.Windows.Forms.RadioButton(); 
     60            this.moveFolderRadio = new System.Windows.Forms.RadioButton(); 
     61            this.fromSelectBtn = new System.Windows.Forms.Button(); 
     62            this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 
    6563            this.SuspendLayout(); 
    6664            //  
     
    6866            //  
    6967            this.fromLbl.AutoSize = true; 
    70             this.fromLbl.Location = new System.Drawing.Point(-3, 3); 
     68            this.fromLbl.Location = new System.Drawing.Point(-3, 28); 
    7169            this.fromLbl.Name = "fromLbl"; 
    7270            this.fromLbl.Size = new System.Drawing.Size(38, 15); 
     
    7876            this.fromTxt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    7977                        | System.Windows.Forms.AnchorStyles.Right))); 
    80             this.fromTxt.Location = new System.Drawing.Point(41, 0); 
     78            this.fromTxt.Location = new System.Drawing.Point(41, 25); 
    8179            this.fromTxt.Name = "fromTxt"; 
    8280            this.fromTxt.Size = new System.Drawing.Size(397, 23); 
    83             this.fromTxt.TabIndex = 1; 
     81            this.fromTxt.TabIndex = 3; 
    8482            //  
    8583            // toLbl 
    8684            //  
    8785            this.toLbl.AutoSize = true; 
    88             this.toLbl.Location = new System.Drawing.Point(-3, 33); 
     86            this.toLbl.Location = new System.Drawing.Point(-3, 57); 
    8987            this.toLbl.Name = "toLbl"; 
    9088            this.toLbl.Size = new System.Drawing.Size(24, 15); 
     
    9694            this.toTxt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    9795                        | System.Windows.Forms.AnchorStyles.Right))); 
    98             this.toTxt.Location = new System.Drawing.Point(41, 30); 
     96            this.toTxt.Location = new System.Drawing.Point(41, 54); 
    9997            this.toTxt.Name = "toTxt"; 
    10098            this.toTxt.Size = new System.Drawing.Size(397, 23); 
    10199            this.toTxt.TabIndex = 5; 
    102100            //  
    103             // fromBrowseMenu 
    104             //  
    105             this.fromBrowseMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 
    106             this.fromSelectFile, 
    107             this.fromSelectFolder}); 
    108             this.fromBrowseMenu.Name = "contextMenuStrip1"; 
    109             this.fromBrowseMenu.Size = new System.Drawing.Size(176, 48); 
    110             //  
    111             // fromSelectFile 
    112             //  
    113             this.fromSelectFile.Name = "fromSelectFile"; 
    114             this.fromSelectFile.Size = new System.Drawing.Size(175, 22); 
    115             this.fromSelectFile.Text = "Browse for File..."; 
    116             this.fromSelectFile.Click += new System.EventHandler(this.fromSelectButton_Click); 
    117             //  
    118             // fromSelectFolder 
    119             //  
    120             this.fromSelectFolder.Name = "fromSelectFolder"; 
    121             this.fromSelectFolder.Size = new System.Drawing.Size(175, 22); 
    122             this.fromSelectFolder.Text = "Browse for Folder..."; 
    123             this.fromSelectFolder.Click += new System.EventHandler(this.fromSelectFolder_Click); 
    124             //  
    125101            // toSelectButton 
    126102            //  
    127103            this.toSelectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 
    128             this.toSelectButton.Location = new System.Drawing.Point(444, 29); 
     104            this.toSelectButton.Location = new System.Drawing.Point(444, 53); 
    129105            this.toSelectButton.Name = "toSelectButton"; 
    130106            this.toSelectButton.Size = new System.Drawing.Size(75, 23); 
    131             this.toSelectButton.TabIndex = 10; 
     107            this.toSelectButton.TabIndex = 6; 
    132108            this.toSelectButton.Text = "Browse"; 
    133109            this.toSelectButton.UseVisualStyleBackColor = true; 
    134110            this.toSelectButton.Click += new System.EventHandler(this.toSelectButton_Click); 
    135111            //  
    136             // fromSelectButton 
     112            // moveFileRadio 
    137113            //  
    138             this.fromSelectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 
    139             this.fromSelectButton.ContextMenuStrip = this.fromBrowseMenu; 
    140             this.fromSelectButton.FlatStyle = System.Windows.Forms.FlatStyle.System; 
    141             this.fromSelectButton.Location = new System.Drawing.Point(444, -1); 
    142             this.fromSelectButton.Name = "fromSelectButton"; 
    143             this.fromSelectButton.Size = new System.Drawing.Size(75, 23); 
    144             this.fromSelectButton.TabIndex = 7; 
    145             this.fromSelectButton.Text = "Browse"; 
    146             this.fromSelectButton.UseVisualStyleBackColor = true; 
    147             this.fromSelectButton.Click += new System.EventHandler(this.fromSelectButton_Click); 
     114            this.moveFileRadio.AutoSize = true; 
     115            this.moveFileRadio.Checked = true; 
     116            this.moveFileRadio.Location = new System.Drawing.Point(0, 0); 
     117            this.moveFileRadio.Name = "moveFileRadio"; 
     118            this.moveFileRadio.Size = new System.Drawing.Size(85, 19); 
     119            this.moveFileRadio.TabIndex = 1; 
     120            this.moveFileRadio.TabStop = true; 
     121            this.moveFileRadio.Text = "Move a File"; 
     122            this.moveFileRadio.UseVisualStyleBackColor = true; 
     123            //  
     124            // moveFolderRadio 
     125            //  
     126            this.moveFolderRadio.AutoSize = true; 
     127            this.moveFolderRadio.Location = new System.Drawing.Point(91, 0); 
     128            this.moveFolderRadio.Name = "moveFolderRadio"; 
     129            this.moveFolderRadio.Size = new System.Drawing.Size(100, 19); 
     130            this.moveFolderRadio.TabIndex = 2; 
     131            this.moveFolderRadio.TabStop = true; 
     132            this.moveFolderRadio.Text = "Move a Folder"; 
     133            this.moveFolderRadio.UseVisualStyleBackColor = true; 
     134            //  
     135            // fromSelectBtn 
     136            //  
     137            this.fromSelectBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 
     138            this.fromSelectBtn.Location = new System.Drawing.Point(444, 24); 
     139            this.fromSelectBtn.Name = "fromSelectBtn"; 
     140            this.fromSelectBtn.Size = new System.Drawing.Size(75, 23); 
     141            this.fromSelectBtn.TabIndex = 4; 
     142            this.fromSelectBtn.Text = "Browse"; 
     143            this.fromSelectBtn.UseVisualStyleBackColor = true; 
     144            this.fromSelectBtn.Click += new System.EventHandler(this.fromSelectButton_Click); 
    148145            //  
    149146            // SecureMoveErasureTargetConfigurer 
     
    151148            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 
    152149            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 
     150            this.Controls.Add(this.fromSelectBtn); 
     151            this.Controls.Add(this.moveFolderRadio); 
     152            this.Controls.Add(this.moveFileRadio); 
    153153            this.Controls.Add(this.fromTxt); 
    154154            this.Controls.Add(this.fromLbl); 
    155155            this.Controls.Add(this.toTxt); 
    156             this.Controls.Add(this.fromSelectButton); 
    157156            this.Controls.Add(this.toLbl); 
    158157            this.Controls.Add(this.toSelectButton); 
    159158            this.Font = new System.Drawing.Font("Segoe UI", 9F); 
    160159            this.Name = "SecureMoveErasureTargetConfigurer"; 
    161             this.Size = new System.Drawing.Size(519, 55); 
    162             this.fromBrowseMenu.ResumeLayout(false); 
     160            this.Size = new System.Drawing.Size(519, 82); 
    163161            this.ResumeLayout(false); 
    164162            this.PerformLayout(); 
     
    168166        #endregion 
    169167 
    170         private System.Windows.Forms.OpenFileDialog fileDialog; 
     168        private System.Windows.Forms.OpenFileDialog openFileDialog; 
    171169        private System.Windows.Forms.FolderBrowserDialog folderDialog; 
    172170        private System.Windows.Forms.Label fromLbl; 
     
    174172        private System.Windows.Forms.Label toLbl; 
    175173        private System.Windows.Forms.TextBox toTxt; 
    176         private System.Windows.Forms.SplitButton fromSelectButton; 
    177         private System.Windows.Forms.ContextMenuStrip fromBrowseMenu; 
    178         private System.Windows.Forms.ToolStripMenuItem fromSelectFile; 
    179         private System.Windows.Forms.ToolStripMenuItem fromSelectFolder; 
    180174        private System.Windows.Forms.Button toSelectButton; 
     175        private System.Windows.Forms.RadioButton moveFileRadio; 
     176        private System.Windows.Forms.RadioButton moveFolderRadio; 
     177        private System.Windows.Forms.Button fromSelectBtn; 
     178        private System.Windows.Forms.SaveFileDialog saveFileDialog; 
    181179    } 
    182180} 
  • trunk/eraser/Eraser.DefaultPlugins/ErasureTargets/SecureMoveErasureTargetConfigurer.cs

    r2071 r2077  
    2828using System.Text; 
    2929using System.Windows.Forms; 
     30using System.IO; 
    3031 
    3132using Eraser.Manager; 
     
    5354            fromTxt.Text = secureMove.Path; 
    5455            toTxt.Text = secureMove.Destination; 
     56 
     57            moveFolderRadio.Checked = File.Exists(secureMove.Path) && 
     58                (File.GetAttributes(secureMove.Path) & FileAttributes.Directory) != 0; 
    5559        } 
    5660 
     
    8589        private void fromSelectButton_Click(object sender, EventArgs e) 
    8690        { 
    87             fromTxt.Text = SelectFile(fromTxt.Text, S._("Select the Source file")); 
    88         } 
    89  
    90         private void fromSelectFolder_Click(object sender, EventArgs e) 
    91         { 
    92             fromTxt.Text = SelectFolder(fromTxt.Text, S._("Select the Source folder")); 
     91            if (moveFolderRadio.Checked) 
     92                fromTxt.Text = SelectFolder(fromTxt.Text, S._("Select the Source folder")); 
     93            else 
     94                fromTxt.Text = SelectFile(fromTxt.Text, S._("Select the Source file")); 
    9395        } 
    9496 
    9597        private void toSelectButton_Click(object sender, EventArgs e) 
    9698        { 
    97             toTxt.Text = SelectFolder(toTxt.Text, S._("Select the Destination folder")); 
     99            if (moveFolderRadio.Checked) 
     100                toTxt.Text = SelectFolder(toTxt.Text, S._("Save moved file as")); 
     101            else 
     102                toTxt.Text = SaveFile(toTxt.Text, S._("Move Source folder to:")); 
    98103        } 
    99104 
    100105        private string SelectFile(string currentPath, string description) 
    101106        { 
    102             fileDialog.FileName = currentPath; 
    103             fileDialog.Title = description; 
    104             if (fileDialog.ShowDialog(this) == DialogResult.OK) 
     107            openFileDialog.FileName = currentPath; 
     108            openFileDialog.Title = description; 
     109            if (openFileDialog.ShowDialog(this) == DialogResult.OK) 
    105110            { 
    106                 return fileDialog.FileName; 
     111                return openFileDialog.FileName; 
     112            } 
     113 
     114            return string.Empty; 
     115        } 
     116 
     117        private string SaveFile(string currentPath, string description) 
     118        { 
     119            saveFileDialog.FileName = currentPath; 
     120            saveFileDialog.Title = description; 
     121            if (saveFileDialog.ShowDialog(this) == DialogResult.OK) 
     122            { 
     123                return saveFileDialog.FileName; 
    107124            } 
    108125 
  • trunk/eraser/Eraser.DefaultPlugins/ErasureTargets/SecureMoveErasureTargetConfigurer.resx

    r2068 r2077  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    119119  </resheader> 
    120   <metadata name="fileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
     120  <metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    121121    <value>17, 20</value> 
    122122  </metadata> 
    123123  <metadata name="folderDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    124     <value>120, 20</value> 
     124    <value>279, 20</value> 
    125125  </metadata> 
    126   <metadata name="fromBrowseMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    127     <value>239, 20</value> 
     126  <metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
     127    <value>150, 20</value> 
    128128  </metadata> 
    129129</root> 
Note: See TracChangeset for help on using the changeset viewer.