Browse Source

option window avancée

olinox14 10 năm trước cách đây
mục cha
commit
9603f2604b
31 tập tin đã thay đổi với 183 bổ sung và 14 xóa
  1. BIN
      .vs/barry/v14/.suo
  2. 5 3
      barry/OptionsWindow.xaml
  3. 79 6
      barry/OptionsWindow.xaml.cs
  4. 20 0
      barry/barry.csproj
  5. BIN
      barry/bin/Debug/Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll
  6. BIN
      barry/bin/Debug/Microsoft.WindowsAPICodePack.Sensors.dll
  7. BIN
      barry/bin/Debug/Microsoft.WindowsAPICodePack.Shell.dll
  8. BIN
      barry/bin/Debug/Microsoft.WindowsAPICodePack.ShellExtensions.dll
  9. BIN
      barry/bin/Debug/Microsoft.WindowsAPICodePack.dll
  10. BIN
      barry/bin/Debug/barry.exe
  11. BIN
      barry/bin/Debug/barry.pdb
  12. 1 1
      barry/core/BackupConfig.cs
  13. BIN
      barry/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
  14. BIN
      barry/obj/Debug/MainWindow.baml
  15. BIN
      barry/obj/Debug/OptionsWindow.baml
  16. 35 1
      barry/obj/Debug/OptionsWindow.g.cs
  17. 35 1
      barry/obj/Debug/OptionsWindow.g.i.cs
  18. 5 0
      barry/obj/Debug/barry.csproj.FileListAbsolute.txt
  19. BIN
      barry/obj/Debug/barry.csprojResolveAssemblyReference.cache
  20. BIN
      barry/obj/Debug/barry.exe
  21. BIN
      barry/obj/Debug/barry.g.resources
  22. BIN
      barry/obj/Debug/barry.pdb
  23. 1 1
      barry/obj/Debug/barry_MarkupCompile.cache
  24. 1 1
      barry/obj/Debug/barry_MarkupCompile.i.cache
  25. 1 0
      barry/packages.config
  26. BIN
      packages/WindowsAPICodePack.1.1.0/WindowsAPICodePack.1.1.0.nupkg
  27. BIN
      packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll
  28. BIN
      packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.Sensors.dll
  29. BIN
      packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.Shell.dll
  30. BIN
      packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.ShellExtensions.dll
  31. BIN
      packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.dll

BIN
.vs/barry/v14/.suo


+ 5 - 3
barry/OptionsWindow.xaml

@@ -9,14 +9,14 @@
         </Grid.RowDefinitions>
 
         <Label Content="Directory on the PC" HorizontalAlignment="Left" Margin="10,2,0,0" VerticalAlignment="Top"/>
-        <TextBox Name="txt_path" HorizontalAlignment="Left" Height="23" Margin="10,28,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="361" TextChanged="txt_path_TextChanged"/>
+        <TextBox Name="txt_path" HorizontalAlignment="Left" Height="23" Margin="10,28,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="323" TextChanged="txt_path_TextChanged"/>
 
         <Label Content="Sub-directory of the USB Device" HorizontalAlignment="Left" Margin="10,56,0,0" VerticalAlignment="Top" Grid.RowSpan="2"/>
-        <TextBox Name="txt_subdir" HorizontalAlignment="Left" Height="23" Margin="10,19,0,0" Grid.Row="1" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="361" TextChanged="txt_subdir_TextChanged"/>
+        <TextBox Name="txt_subdir" HorizontalAlignment="Left" Height="23" Margin="10,11,0,0" Grid.Row="1" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="323" TextChanged="txt_subdir_TextChanged"/>
 
         <Label Content="What should barry do:" HorizontalAlignment="Left" Margin="10,52,0,0" Grid.Row="1" VerticalAlignment="Top"/>
 
-        <ComboBox Name="cb_bkptype" HorizontalAlignment="Left" Margin="143,54,0,0" VerticalAlignment="Top" Width="228" SelectionChanged="cb_bkptype_SelectionChanged" Grid.Row="1">
+        <ComboBox Name="cb_bkptype"  HorizontalAlignment="Left" Margin="143,54,0,0" VerticalAlignment="Top" Width="228" SelectionChanged="cb_bkptype_SelectionChanged" Grid.Row="1">
             <ComboBoxItem Tag="0" Content="Nothing"/>
             <ComboBoxItem Tag="1" Content="Backup : USB Device >> Computer" IsSelected="True"/>
             <ComboBoxItem Tag="-1" Content="Backup : Computer >> USB Device"/>
@@ -26,6 +26,8 @@
 
         <Button Name="btn_save" Content="Save" HorizontalAlignment="Left" Margin="277,201,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Click="btn_save_Click" RenderTransformOrigin="0.507,2.182"/>
         <Button Name="btn_cancel" Content="Cancel" HorizontalAlignment="Left" Margin="49,201,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.413,2.136" Click="btn_cancel_Click"/>
+        <Button x:Name="btn_explorecpu" Content="..." HorizontalAlignment="Left" Margin="338,28,0,0" VerticalAlignment="Top" Width="33" Height="23" Click="btn_explorecpu_Click"/>
+        <Button x:Name="btn_exploredevice" Content="..." HorizontalAlignment="Left" Margin="338,11,0,0" VerticalAlignment="Top" Width="33" Height="23" Grid.Row="1" RenderTransformOrigin="0.303,0.435" Click="btn_exploredevice_Click"/>
 
     </Grid>
 </Window>

+ 79 - 6
barry/OptionsWindow.xaml.cs

@@ -1,5 +1,7 @@
-using System;
+using Microsoft.Win32;
+using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -11,6 +13,8 @@ using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Shapes;
+using Microsoft.WindowsAPICodePack.Dialogs;
+using System.IO;
 
 namespace barry
 {
@@ -32,14 +36,14 @@ namespace barry
 
             txt_path.Text = bkp.dir_path;
             txt_subdir.Text = bkp.local_subdir;
-            foreach (ComboBoxItem item in cb_bkptype.Items)
+            for (int i = 0; i < cb_bkptype.Items.Count; i++)
             {
-                if(item.Tag.Equals(bkp.bkp_type))
+                if (int.Parse(((ComboBoxItem)cb_bkptype.Items[i]).Tag.ToString()) == bkp.bkp_type)
                 {
-                    cb_bkptype.SelectedItem = item;
+                    cb_bkptype.SelectedIndex = i;
+                    break;
                 }
             }
-
         }
 
         private void btn_save_Click(object sender, RoutedEventArgs e)
@@ -56,7 +60,7 @@ namespace barry
         private void cb_bkptype_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             if (!_loaded) { return; }
-            bkp.bkp_type = int.Parse(cb_bkptype.Tag.ToString());
+            bkp.bkp_type = int.Parse(((ComboBoxItem)cb_bkptype.SelectedItem).Tag.ToString());
             update_window();
         }
 
@@ -86,5 +90,74 @@ namespace barry
             update_window();
         }
 
+        private void btn_explorecpu_Click(object sender, RoutedEventArgs e)
+        {
+            var dlg = new CommonOpenFileDialog();
+            dlg.Title = "Select a directory on your computer";
+            dlg.IsFolderPicker = true;
+            dlg.InitialDirectory = "";
+            dlg.EnsurePathExists = true;
+            dlg.ShowPlacesList = true;
+
+            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
+            {
+                var folder = dlg.FileName;
+                Console.WriteLine(folder + " - " + methods.current_drive_letter() + " - " + is_subdir(folder, methods.current_drive_letter()));
+                if (is_subdir(folder, methods.current_drive_letter()))
+                {
+                    MessageBox.Show("This directory should NOT be on your usb device", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+                }
+                else
+                {
+                    txt_path.Text = folder;
+                }
+            }
+        }
+
+        private void btn_exploredevice_Click(object sender, RoutedEventArgs e)
+        {
+            var dlg = new CommonOpenFileDialog();
+            dlg.Title = "Select a directory on your device";
+            dlg.IsFolderPicker = true;
+            dlg.InitialDirectory = "";
+            dlg.EnsurePathExists = true;
+            dlg.ShowPlacesList = true;
+
+            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
+            {
+                var folder = dlg.FileName;
+                if (!is_subdir(folder, methods.current_drive_letter()))
+                {
+                    MessageBox.Show("This directory should be on your usb device", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+                }
+                else
+                {
+                    txt_subdir.Text = folder;
+                }
+            }
+
+
+        }
+
+        /// <summary>
+        /// is dir1 a subdir of dir2
+        /// </summary>
+        /// <param name="dir1"></param>
+        /// <param name="dir2"></param>
+        private bool is_subdir(string dir1, string dir2)
+        {
+            DirectoryInfo di1 = new DirectoryInfo(dir1);
+            DirectoryInfo di2 = new DirectoryInfo(dir2);
+            while (di1.Parent != null)
+            {
+                if (di1.Parent.FullName == di2.FullName)
+                {
+                    return true;
+                }
+                else di1 = di1.Parent;
+            }
+            return false;
+        }
+
     }
 }

+ 20 - 0
barry/barry.csproj

@@ -56,6 +56,26 @@
     <NoWin32Manifest>true</NoWin32Manifest>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\WindowsAPICodePack.1.1.0\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="Microsoft.WindowsAPICodePack.ExtendedLinguisticServices, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\WindowsAPICodePack.1.1.0\lib\Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="Microsoft.WindowsAPICodePack.Sensors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\WindowsAPICodePack.1.1.0\lib\Microsoft.WindowsAPICodePack.Sensors.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\WindowsAPICodePack.1.1.0\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="Microsoft.WindowsAPICodePack.ShellExtensions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\WindowsAPICodePack.1.1.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
     <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
       <Private>True</Private>

BIN
barry/bin/Debug/Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll


BIN
barry/bin/Debug/Microsoft.WindowsAPICodePack.Sensors.dll


BIN
barry/bin/Debug/Microsoft.WindowsAPICodePack.Shell.dll


BIN
barry/bin/Debug/Microsoft.WindowsAPICodePack.ShellExtensions.dll


BIN
barry/bin/Debug/Microsoft.WindowsAPICodePack.dll


BIN
barry/bin/Debug/barry.exe


BIN
barry/bin/Debug/barry.pdb


+ 1 - 1
barry/core/BackupConfig.cs

@@ -58,6 +58,6 @@ namespace barry
             return msg;
         }
 
-
     }
+
 }

BIN
barry/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache


BIN
barry/obj/Debug/MainWindow.baml


BIN
barry/obj/Debug/OptionsWindow.baml


+ 35 - 1
barry/obj/Debug/OptionsWindow.g.cs

@@ -1,4 +1,4 @@
-#pragma checksum "..\..\OptionsWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "FBB84F9DDF6F2AF19D5888246AC437FB"
+#pragma checksum "..\..\OptionsWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "5708FA111ED630C1E493A69993002E22"
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     Ce code a été généré par un outil.
@@ -87,6 +87,22 @@ namespace barry {
         #line default
         #line hidden
         
+        
+        #line 29 "..\..\OptionsWindow.xaml"
+        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+        internal System.Windows.Controls.Button btn_explorecpu;
+        
+        #line default
+        #line hidden
+        
+        
+        #line 30 "..\..\OptionsWindow.xaml"
+        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+        internal System.Windows.Controls.Button btn_exploredevice;
+        
+        #line default
+        #line hidden
+        
         private bool _contentLoaded;
         
         /// <summary>
@@ -162,6 +178,24 @@ namespace barry {
             #line 28 "..\..\OptionsWindow.xaml"
             this.btn_cancel.Click += new System.Windows.RoutedEventHandler(this.btn_cancel_Click);
             
+            #line default
+            #line hidden
+            return;
+            case 7:
+            this.btn_explorecpu = ((System.Windows.Controls.Button)(target));
+            
+            #line 29 "..\..\OptionsWindow.xaml"
+            this.btn_explorecpu.Click += new System.Windows.RoutedEventHandler(this.btn_explorecpu_Click);
+            
+            #line default
+            #line hidden
+            return;
+            case 8:
+            this.btn_exploredevice = ((System.Windows.Controls.Button)(target));
+            
+            #line 30 "..\..\OptionsWindow.xaml"
+            this.btn_exploredevice.Click += new System.Windows.RoutedEventHandler(this.btn_exploredevice_Click);
+            
             #line default
             #line hidden
             return;

+ 35 - 1
barry/obj/Debug/OptionsWindow.g.i.cs

@@ -1,4 +1,4 @@
-#pragma checksum "..\..\OptionsWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "FBB84F9DDF6F2AF19D5888246AC437FB"
+#pragma checksum "..\..\OptionsWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "5708FA111ED630C1E493A69993002E22"
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     Ce code a été généré par un outil.
@@ -87,6 +87,22 @@ namespace barry {
         #line default
         #line hidden
         
+        
+        #line 29 "..\..\OptionsWindow.xaml"
+        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+        internal System.Windows.Controls.Button btn_explorecpu;
+        
+        #line default
+        #line hidden
+        
+        
+        #line 30 "..\..\OptionsWindow.xaml"
+        [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+        internal System.Windows.Controls.Button btn_exploredevice;
+        
+        #line default
+        #line hidden
+        
         private bool _contentLoaded;
         
         /// <summary>
@@ -162,6 +178,24 @@ namespace barry {
             #line 28 "..\..\OptionsWindow.xaml"
             this.btn_cancel.Click += new System.Windows.RoutedEventHandler(this.btn_cancel_Click);
             
+            #line default
+            #line hidden
+            return;
+            case 7:
+            this.btn_explorecpu = ((System.Windows.Controls.Button)(target));
+            
+            #line 29 "..\..\OptionsWindow.xaml"
+            this.btn_explorecpu.Click += new System.Windows.RoutedEventHandler(this.btn_explorecpu_Click);
+            
+            #line default
+            #line hidden
+            return;
+            case 8:
+            this.btn_exploredevice = ((System.Windows.Controls.Button)(target));
+            
+            #line 30 "..\..\OptionsWindow.xaml"
+            this.btn_exploredevice.Click += new System.Windows.RoutedEventHandler(this.btn_exploredevice_Click);
+            
             #line default
             #line hidden
             return;

+ 5 - 0
barry/obj/Debug/barry.csproj.FileListAbsolute.txt

@@ -16,3 +16,8 @@ O:\dev\barry\barry\obj\Debug\barry.pdb
 O:\dev\barry\barry\obj\Debug\barry.csprojResolveAssemblyReference.cache
 O:\dev\barry\barry\obj\Debug\OptionsWindow.baml
 O:\dev\barry\barry\obj\Debug\OptionsWindow.g.cs
+O:\dev\barry\barry\bin\Debug\Microsoft.WindowsAPICodePack.dll
+O:\dev\barry\barry\bin\Debug\Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll
+O:\dev\barry\barry\bin\Debug\Microsoft.WindowsAPICodePack.Sensors.dll
+O:\dev\barry\barry\bin\Debug\Microsoft.WindowsAPICodePack.Shell.dll
+O:\dev\barry\barry\bin\Debug\Microsoft.WindowsAPICodePack.ShellExtensions.dll

BIN
barry/obj/Debug/barry.csprojResolveAssemblyReference.cache


BIN
barry/obj/Debug/barry.exe


BIN
barry/obj/Debug/barry.g.resources


BIN
barry/obj/Debug/barry.pdb


+ 1 - 1
barry/obj/Debug/barry_MarkupCompile.cache

@@ -13,7 +13,7 @@ O:\dev\barry\barry\App.xaml
 21361147038
 
 10-1034403408
-15-1603151776
+20-56864797
 MainWindow.xaml;OptionsWindow.xaml;
 
 False

+ 1 - 1
barry/obj/Debug/barry_MarkupCompile.i.cache

@@ -13,7 +13,7 @@ O:\dev\barry\barry\App.xaml
 21361147038
 
 14-264920352
-15-1603151776
+20-56864797
 MainWindow.xaml;OptionsWindow.xaml;
 
 False

+ 1 - 0
barry/packages.config

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
   <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
+  <package id="WindowsAPICodePack" version="1.1.0" targetFramework="net46" />
 </packages>

BIN
packages/WindowsAPICodePack.1.1.0/WindowsAPICodePack.1.1.0.nupkg


BIN
packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll


BIN
packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.Sensors.dll


BIN
packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.Shell.dll


BIN
packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.ShellExtensions.dll


BIN
packages/WindowsAPICodePack.1.1.0/lib/Microsoft.WindowsAPICodePack.dll