Changeset 1996 for trunk/eraser


Ignore:
Timestamp:
5/1/2010 9:12:41 AM (4 years ago)
Author:
lowjoel
Message:

When dragging and dropping files into Eraser, use a Task Dialog to ask whether the user wants to erase the file now, create a new task, or do nothing. XP computers will display a simple message box.

Location:
trunk/eraser
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser/Eraser.csproj

    r1973 r1996  
    7979    <Reference Include="System.Windows.Forms" /> 
    8080    <Reference Include="System.Xml" /> 
     81    <Reference Include="TaskDialog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3ac89a0351e689b6, processorArchitecture=MSIL"> 
     82      <SpecificVersion>False</SpecificVersion> 
     83      <HintPath>..\Dependencies\TaskDialog.dll</HintPath> 
     84    </Reference> 
    8185  </ItemGroup> 
    8286  <ItemGroup> 
  • trunk/eraser/Eraser/SchedulerPanel.cs

    r1952 r1996  
    2727using System.Windows.Forms; 
    2828 
    29 using Eraser.Manager; 
    30 using Eraser.Util; 
    3129using System.Globalization; 
    3230using System.Runtime.InteropServices; 
     
    3533using System.Runtime.Serialization; 
    3634using System.ComponentModel; 
     35 
     36using Eraser.Manager; 
     37using Eraser.Util; 
     38using Microsoft.Samples; 
    3739using ProgressChangedEventArgs = Eraser.Util.ProgressChangedEventArgs; 
    3840 
     
    421423            if (!e.Data.GetDataPresent(DataFormats.FileDrop)) 
    422424                e.Effect = DragDropEffects.None; 
    423             else 
    424             { 
    425                 string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false); 
    426  
    427                 //Determine whether we are importing a task list or dragging files for 
    428                 //erasure. 
    429                 if (e.Effect == DragDropEffects.Copy) 
    430                 { 
    431                     foreach (string file in files) 
    432                         using (FileStream stream = new FileStream(file, FileMode.Open, 
    433                             FileAccess.Read, FileShare.Read)) 
     425            DropTargetHelper.Drop(e.Data, new Point(e.X, e.Y), e.Effect); 
     426 
     427            //Schedule the task dialog to be shown (to get to the event loop so that 
     428            //ComCtl32.dll v6 is used.) 
     429            BeginInvoke((Action<DragDropEffects, string[]>)scheduler_DragDropConfirm, 
     430                e.Effect, e.Data.GetData(DataFormats.FileDrop, false)); 
     431        } 
     432 
     433        /// <summary> 
     434        /// Called after the files have been dropped into Eraser. 
     435        /// </summary> 
     436        /// <param name="effect">The Drag/drop effect of the operation.</param> 
     437        /// <param name="files">The files which were dropped into the program.</param> 
     438        private void scheduler_DragDropConfirm(DragDropEffects effect, string[] files) 
     439        { 
     440            //Determine whether we are importing a task list or dragging files for 
     441            //erasure. 
     442            if (effect == DragDropEffects.Copy) 
     443            { 
     444                foreach (string file in files) 
     445                    using (FileStream stream = new FileStream(file, FileMode.Open, 
     446                        FileAccess.Read, FileShare.Read)) 
     447                    { 
     448                        try 
    434449                        { 
    435                             try 
    436                             { 
    437                                 Program.eraserClient.Tasks.LoadFromStream(stream); 
    438                             } 
    439                             catch (InvalidDataException ex) 
    440                             { 
    441                                 MessageBox.Show(S._("Could not import task list from {0}. The " + 
    442                                     "error returned was: {1}", file, ex.Message), S._("Eraser"), 
    443                                     MessageBoxButtons.OK, MessageBoxIcon.Error, 
    444                                     MessageBoxDefaultButton.Button1, 
    445                                     Localisation.IsRightToLeft(this) ? 
    446                                         MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign : 0); 
    447                             } 
     450                            Program.eraserClient.Tasks.LoadFromStream(stream); 
    448451                        } 
    449                 } 
    450                 else if (e.Effect == DragDropEffects.Move) 
    451                 { 
    452                     //Create a task with the default settings 
    453                     Task task = new Task(); 
    454                     foreach (string file in files) 
    455                     { 
    456                         FileSystemObjectTarget target; 
    457                         if (Directory.Exists(file)) 
    458                             target = new FolderTarget(); 
    459                         else 
    460                             target = new FileTarget(); 
    461                         target.Path = file; 
    462  
    463                         task.Targets.Add(target); 
     452                        catch (InvalidDataException ex) 
     453                        { 
     454                            MessageBox.Show(S._("Could not import task list from {0}. The " + 
     455                                "error returned was: {1}", file, ex.Message), S._("Eraser"), 
     456                                MessageBoxButtons.OK, MessageBoxIcon.Error, 
     457                                MessageBoxDefaultButton.Button1, 
     458                                Localisation.IsRightToLeft(this) ? 
     459                                    MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign : 0); 
     460                        } 
    464461                    } 
    465  
    466                     //Add the task. 
    467                     Program.eraserClient.Tasks.Add(task); 
    468                 } 
    469             } 
    470  
    471             DropTargetHelper.Drop(e.Data, new Point(e.X, e.Y), e.Effect); 
     462            } 
     463            else if (effect == DragDropEffects.Move) 
     464            { 
     465                //Create a task with the default settings 
     466                Task task = new Task(); 
     467                foreach (string file in files) 
     468                { 
     469                    FileSystemObjectTarget target; 
     470                    if (Directory.Exists(file)) 
     471                        target = new FolderTarget(); 
     472                    else 
     473                        target = new FileTarget(); 
     474                    target.Path = file; 
     475 
     476                    task.Targets.Add(target); 
     477                } 
     478 
     479                //Add the task, asking the user for his intent. 
     480                DialogResult action = DialogResult.No; 
     481                if (TaskDialog.IsAvailableOnThisOS) 
     482                { 
     483                    TaskDialog dialog = new TaskDialog(); 
     484                    dialog.WindowTitle = S._("Eraser"); 
     485                    dialog.MainIcon = TaskDialogIcon.Information; 
     486                    dialog.MainInstruction = S._("You have dropped a set of files and folders into Eraser. What do you want to do with them?"); 
     487                    dialog.AllowDialogCancellation = true; 
     488                    dialog.Buttons = new TaskDialogButton[] { 
     489                        new TaskDialogButton((int)DialogResult.Yes, S._("Erase the selected items\nSchedules the selected items for immediate erasure.")), 
     490                        new TaskDialogButton((int)DialogResult.OK, S._("Create a new Task\nA task will be created containing the selected items.")), 
     491                        new TaskDialogButton((int)DialogResult.No, S._("Cancel the drag-and-drop operation")) 
     492                    }; 
     493                    dialog.RightToLeftLayout = Localisation.IsRightToLeft(this); 
     494                    dialog.UseCommandLinks = true; 
     495                    action = (DialogResult)dialog.Show(this); 
     496                } 
     497                else 
     498                { 
     499                    action = MessageBox.Show(S._("Are you sure you wish to erase the selected " 
     500                        + "items?"), S._("Eraser"), MessageBoxButtons.YesNo, 
     501                        MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 
     502                        Localisation.IsRightToLeft(this) ? 
     503                            MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign : 0); 
     504                } 
     505 
     506                switch (action) 
     507                { 
     508                    case DialogResult.OK: 
     509                        task.Schedule = Schedule.RunManually; 
     510                        goto case DialogResult.Yes; 
     511 
     512                    case DialogResult.Yes: 
     513                        Program.eraserClient.Tasks.Add(task); 
     514                        break; 
     515                } 
     516            } 
    472517        } 
    473518 
  • trunk/eraser/Eraser/Strings.en.resx

    r1973 r1996  
    232232    <value>Could not import task list from {0}. The error returned was: {1}</value> 
    233233  </data> 
     234  <data name="You have dropped a set of files and folders into Eraser. What do you want to do with them?" xml:space="preserve"> 
     235    <value>You have dropped a set of files and folders into Eraser. What do you want to do with them?</value> 
     236  </data> 
     237  <data name="Erase the selected items\nSchedules the selected items for immediate erasure." xml:space="preserve"> 
     238    <value>Erase the selected items\nSchedules the selected items for immediate erasure.</value> 
     239  </data> 
     240  <data name="Create a new Task\nA task will be created containing the selected items." xml:space="preserve"> 
     241    <value>Create a new Task\nA task will be created containing the selected items.</value> 
     242  </data> 
     243  <data name="Cancel the drag-and-drop operation" xml:space="preserve"> 
     244    <value>Cancel the drag-and-drop operation</value> 
     245  </data> 
     246  <data name="Are you sure you wish to erase the selected items?" xml:space="preserve"> 
     247    <value>Are you sure you wish to erase the selected items?</value> 
     248  </data> 
    234249  <data name="Could not load the setting {0}\\{1} for plugin {2}. The setting has been lost." xml:space="preserve"> 
    235250    <value>Could not load the setting {0}\\{1} for plugin {2}. The setting has been lost.</value> 
  • trunk/eraser/Eraser/Strings.it.resx

    r1973 r1996  
    232232    <value>Importazione della lista di operazioni da {0} non riuscita. L'errore è stato: {1}</value> 
    233233  </data> 
     234  <data name="You have dropped a set of files and folders into Eraser. What do you want to do with them?" xml:space="preserve"> 
     235    <value>(Untranslated)</value> 
     236  </data> 
     237  <data name="Erase the selected items\nSchedules the selected items for immediate erasure." xml:space="preserve"> 
     238    <value>(Untranslated)</value> 
     239  </data> 
     240  <data name="Create a new Task\nA task will be created containing the selected items." xml:space="preserve"> 
     241    <value>(Untranslated)</value> 
     242  </data> 
     243  <data name="Cancel the drag-and-drop operation" xml:space="preserve"> 
     244    <value>(Untranslated)</value> 
     245  </data> 
     246  <data name="Are you sure you wish to erase the selected items?" xml:space="preserve"> 
     247    <value>(Untranslated)</value> 
     248  </data> 
    234249  <data name="Could not load the setting {0}\\{1} for plugin {2}. The setting has been lost." xml:space="preserve"> 
    235250    <value>Impossibile caricare l'impostazione {0}\\{1} per il plugin {2}. L'impostazione è stata persa.</value> 
  • trunk/eraser/Eraser/Strings.nl.resx

    r1973 r1996  
    232232    <value>(Untranslated)</value> 
    233233  </data> 
     234  <data name="You have dropped a set of files and folders into Eraser. What do you want to do with them?" xml:space="preserve"> 
     235    <value>(Untranslated)</value> 
     236  </data> 
     237  <data name="Erase the selected items\nSchedules the selected items for immediate erasure." xml:space="preserve"> 
     238    <value>(Untranslated)</value> 
     239  </data> 
     240  <data name="Create a new Task\nA task will be created containing the selected items." xml:space="preserve"> 
     241    <value>(Untranslated)</value> 
     242  </data> 
     243  <data name="Cancel the drag-and-drop operation" xml:space="preserve"> 
     244    <value>(Untranslated)</value> 
     245  </data> 
     246  <data name="Are you sure you wish to erase the selected items?" xml:space="preserve"> 
     247    <value>(Untranslated)</value> 
     248  </data> 
    234249  <data name="Could not load the setting {0}\\{1} for plugin {2}. The setting has been lost." xml:space="preserve"> 
    235250    <value>(Untranslated)</value> 
  • trunk/eraser/Eraser/Strings.pl.resx

    r1973 r1996  
    228228  <data name="Erase {0}" xml:space="preserve"> 
    229229    <value>Wymazywanie {0}</value> 
    230     <comment>Maybe "Wymaż" is more appropriate, it depends on its context</comment> 
    231230  </data> 
    232231  <data name="Could not import task list from {0}. The error returned was: {1}" xml:space="preserve"> 
    233232    <value>Nie można było zaimportować listy zadań z {0}. Wystąpił błąd: {1}</value> 
    234233  </data> 
     234  <data name="You have dropped a set of files and folders into Eraser. What do you want to do with them?" xml:space="preserve"> 
     235    <value>(Untranslated)</value> 
     236  </data> 
     237  <data name="Erase the selected items\nSchedules the selected items for immediate erasure." xml:space="preserve"> 
     238    <value>(Untranslated)</value> 
     239  </data> 
     240  <data name="Create a new Task\nA task will be created containing the selected items." xml:space="preserve"> 
     241    <value>(Untranslated)</value> 
     242  </data> 
     243  <data name="Cancel the drag-and-drop operation" xml:space="preserve"> 
     244    <value>(Untranslated)</value> 
     245  </data> 
     246  <data name="Are you sure you wish to erase the selected items?" xml:space="preserve"> 
     247    <value>(Untranslated)</value> 
     248  </data> 
    235249  <data name="Could not load the setting {0}\\{1} for plugin {2}. The setting has been lost." xml:space="preserve"> 
    236250    <value>Nie można było załadować ustawień {0}\\{1} dla wtyczki {2}. Ustawienia wtyczki zostały utracone.</value> 
  • trunk/eraser/Eraser/Strings.resx

    r1973 r1996  
    232232    <value>Could not import task list from {0}. The error returned was: {1}</value> 
    233233  </data> 
     234  <data name="You have dropped a set of files and folders into Eraser. What do you want to do with them?" xml:space="preserve"> 
     235    <value>You have dropped a set of files and folders into Eraser. What do you want to do with them?</value> 
     236  </data> 
     237  <data name="Erase the selected items\nSchedules the selected items for immediate erasure." xml:space="preserve"> 
     238    <value>Erase the selected items\nSchedules the selected items for immediate erasure.</value> 
     239  </data> 
     240  <data name="Create a new Task\nA task will be created containing the selected items." xml:space="preserve"> 
     241    <value>Create a new Task\nA task will be created containing the selected items.</value> 
     242  </data> 
     243  <data name="Cancel the drag-and-drop operation" xml:space="preserve"> 
     244    <value>Cancel the drag-and-drop operation</value> 
     245  </data> 
     246  <data name="Are you sure you wish to erase the selected items?" xml:space="preserve"> 
     247    <value>Are you sure you wish to erase the selected items?</value> 
     248  </data> 
    234249  <data name="Could not load the setting {0}\\{1} for plugin {2}. The setting has been lost." xml:space="preserve"> 
    235250    <value>Could not load the setting {0}\\{1} for plugin {2}. The setting has been lost.</value> 
  • trunk/eraser/Installer/DirectoryStructure.wxs

    r1994 r1996  
    6565                    <File Id="SharpZipLib" Name="ICSharpCode.SharpZipLib.dll" 
    6666                        Source="..\bin\Release\Plugins\ICSharpCode.SharpZipLib.dll" ProcessorArchitecture="msil" /> 
    67                      
     67                    <File Id="TaskDialog" Name="TaskDialog.dll" 
     68                        Source="..\bin\Release\TaskDialog.dll" ProcessorArchitecture="msil" /> 
     69 
    6870                    <File Id="EraserManager" Name="Eraser.Manager.dll" 
    6971                        Source="..\bin\Release\Eraser.Manager.dll" ProcessorArchitecture="msil" /> 
Note: See TracChangeset for help on using the changeset viewer.