Selaa lähdekoodia

Add SaveSdCard User Control
Use Path.Combine to generate folder/file path

Snoopy 4 vuotta sitten
vanhempi
commit
c49c6a6392

+ 2 - 2
App.xaml.cs

@@ -13,9 +13,9 @@ namespace Phihong_EVSE_UI_Tool
         {
             base.OnStartup(e);
 
-            Directory.CreateDirectory(Environment.CurrentDirectory + @"\Output");
+            Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "Output"));
 
-            DirectoryInfo di = Directory.CreateDirectory(Environment.CurrentDirectory + @"\CustomTemp");
+            DirectoryInfo di = Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "CustomTemp"));
             di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
         }
     }

+ 15 - 15
AuthenticationUC.xaml.cs

@@ -49,21 +49,21 @@ namespace Phihong_EVSE_UI_Tool
             switch (rb.Tag.ToString())
             {
                 case "Verify":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_VERIFY, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_VERIFY), UriKind.Relative);
                     uxVerifyImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFY);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFY));
                     mySettings.IsVerifyDefault = true;
                     break;
                 case "VerifyOk":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_VERIFYOK, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_VERIFYOK), UriKind.Relative);
                     uxVerifyOkImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFYOK);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFYOK));
                     mySettings.IsVerifyOkDefault = true;
                     break;
                 case "VerifyFail":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_VERIFYFAIL, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_VERIFYFAIL), UriKind.Relative);
                     uxVerifyFailImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFYFAIL);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFYFAIL));
                     mySettings.IsVerifyFailDefault = true;
                     break;
                 default:
@@ -87,7 +87,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(verifyCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxVerifyImage, verifyCustomImgPath);
-                        File.Copy(verifyCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFY, true);
+                        File.Copy(verifyCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFY), true);
                         mySettings.IsVerifyDefault = false;
                     }
                     break;
@@ -95,7 +95,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(verifyOkCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxVerifyOkImage, verifyOkCustomImgPath);
-                        File.Copy(verifyOkCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFYOK, true);
+                        File.Copy(verifyOkCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFYOK), true);
                         mySettings.IsVerifyOkDefault = false;
                     }
                     break;
@@ -103,7 +103,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(verifyFailCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxVerifyFailImage, verifyFailCustomImgPath);
-                        File.Copy(verifyFailCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFYFAIL, true);
+                        File.Copy(verifyFailCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFYFAIL), true);
                         mySettings.IsVerifyFailDefault = false;
                     }
                     break;
@@ -142,9 +142,9 @@ namespace Phihong_EVSE_UI_Tool
                 {
                     case "Verify":
                         uxVerifyExploreTextBox.Text = dlg.FileName;
-                        verifyCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_VERIFY;
+                        verifyCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_VERIFY);
                         File.Copy(dlg.FileName, verifyCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFY, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFY), true);
                         Utility.LoadImageFromPath(uxVerifyImage, verifyCustomImgPath);
                         mySettings.IsVerifyDefault = false;
                         mySettings.VerifyCustomImgPath = verifyCustomImgPath;
@@ -152,9 +152,9 @@ namespace Phihong_EVSE_UI_Tool
                         break;
                     case "VerifyOk":
                         uxVerifyOkExploreTextBox.Text = dlg.FileName;
-                        verifyOkCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_VERIFYOK;
+                        verifyOkCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_VERIFYOK);
                         File.Copy(dlg.FileName, verifyOkCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFYOK, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFYOK), true);
                         Utility.LoadImageFromPath(uxVerifyOkImage, verifyOkCustomImgPath);
                         mySettings.IsVerifyOkDefault = false;
                         mySettings.VerifyOkCustomImgPath = verifyOkCustomImgPath;
@@ -162,9 +162,9 @@ namespace Phihong_EVSE_UI_Tool
                         break;
                     case "VerifyFail":
                         uxVerifyFailExploreTextBox.Text = dlg.FileName;
-                        verifyFailCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_VERIFYFAIL;
+                        verifyFailCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_VERIFYFAIL);
                         File.Copy(dlg.FileName, verifyFailCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_VERIFYFAIL, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_VERIFYFAIL), true);
                         Utility.LoadImageFromPath(uxVerifyFailImage, verifyFailCustomImgPath);
                         mySettings.IsVerifyFailDefault = false;
                         mySettings.VerifyFailCustomImgPath = verifyFailCustomImgPath;

+ 1 - 1
BuildIco.xaml

@@ -38,7 +38,7 @@
                     </DataGrid>
                     <Button x:Name="uxBuildButton" Tag="Build" Content="Build" HorizontalAlignment="Left" Width="90" Height="35" Margin="0,18,0,12"  
                             Style="{StaticResource ButtonRevealStyle}" Click="uxBuildButton_Click" Visibility="Collapsed" Foreground="Black"/>
-                    <Viewbox x:Name="viewbox" Stretch="Uniform">
+                    <Viewbox x:Name="viewbox" Stretch="Uniform" RenderOptions.BitmapScalingMode="HighQuality">
                         <UniformGrid x:Name="uxIcoUniformGrid" Background="AliceBlue"/>
                     </Viewbox>
                 </StackPanel>

+ 1 - 1
BuildIco.xaml.cs

@@ -75,7 +75,7 @@ namespace Phihong_EVSE_UI_Tool
 
         private void BuildIcoFile()
         {
-            icoFileName = Utility.OUTPUT_DIRECTORY + Utility.ICO_NAME;
+            icoFileName = Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.ICO_NAME);
             FileStream icoFile = new FileStream(icoFileName, FileMode.Create, FileAccess.ReadWrite);
             byte[] array = new byte[4 * bytesPerPixel];
             long contentOffset = 131072 * bytesPerPixel;

+ 10 - 10
InitialIdleUC.xaml.cs

@@ -43,15 +43,15 @@ namespace Phihong_EVSE_UI_Tool
             switch (rb.Tag.ToString())
             {
                 case "Initial":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_INITIAL, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_INITIAL), UriKind.Relative);
                     uxInitImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_INITIAL);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_INITIAL));
                     mySettings.IsInitialDefault = true;
                     break;
                 case "Idle":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_IDLE, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_IDLE), UriKind.Relative);
                     uxIdleImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_IDLE);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_IDLE));
                     mySettings.IsIdleDefault = true;
                     break;
                 default:
@@ -75,7 +75,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(initCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxInitImage, initCustomImgPath);
-                        File.Copy(initCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_INITIAL, true);
+                        File.Copy(initCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_INITIAL), true);
                         mySettings.IsInitialDefault = false;
                     }
                     break;
@@ -83,7 +83,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(idleCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxIdleImage, idleCustomImgPath);
-                        File.Copy(initCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_IDLE, true);
+                        File.Copy(initCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_IDLE), true);
                         mySettings.IsIdleDefault = false;
                     }
                     break;
@@ -122,9 +122,9 @@ namespace Phihong_EVSE_UI_Tool
                 {
                     case "Initial":
                         uxInitExploreTextBox.Text = dlg.FileName;
-                        initCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_INITIAL;
+                        initCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_INITIAL);
                         File.Copy(dlg.FileName, initCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_INITIAL, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_INITIAL), true);
                         Utility.LoadImageFromPath(uxInitImage, initCustomImgPath);
                         mySettings.IsInitialDefault = false;
                         mySettings.InitialCustomImgPath = initCustomImgPath;
@@ -132,9 +132,9 @@ namespace Phihong_EVSE_UI_Tool
                         break;
                     case "Idle":
                         uxIdleExploreTextBox.Text = dlg.FileName;
-                        idleCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_IDLE;
+                        idleCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_IDLE);
                         File.Copy(dlg.FileName, idleCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_IDLE, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_IDLE), true);
                         Utility.LoadImageFromPath(uxIdleImage, idleCustomImgPath);
                         mySettings.IsIdleDefault = false;
                         mySettings.IdleCustomImgPath = idleCustomImgPath;

+ 12 - 1
MainWindow.xaml

@@ -68,9 +68,20 @@
                             <TextBlock Text="Modify ICO" FontSize="15" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="12"/>
                         </StackPanel>
                     </ListViewItem>
+                    <!-- Save -->
+                    <ListViewItem Padding="1" IsEnabled="False">
+                        <TextBlock Text="Save" FontWeight="SemiBold" FontSize="15" Foreground="Transparent" HorizontalAlignment="Left" Margin="16,30,0,18"/>
+                    </ListViewItem>
+                    <ListViewItem x:Name="uxSaveListViewItem" Padding="1">
+                        <StackPanel Orientation="Horizontal">
+                            <md:PackIcon Kind="SdCard" Margin="16,12,6,12" VerticalAlignment="Center"/>
+                            <TextBlock Text="Save to SD Card" FontSize="15" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="12"/>
+                        </StackPanel>
+                    </ListViewItem>
                 </ListView>
             </StackPanel>
-            <TextBlock Text="Icon" FontWeight="SemiBold" FontSize="15" HorizontalAlignment="Left" Margin="17,318,0,362"/>
+            <TextBlock Text="Icon" FontWeight="SemiBold" FontSize="15" HorizontalAlignment="Left" Margin="17,318,0,460"/>
+            <TextBlock Text="Save" FontWeight="SemiBold" FontSize="15" HorizontalAlignment="Left" Margin="17,479,0,280"/>
         </Grid>
 
         <Grid x:Name="uxTitleGrid" Grid.Column="1" Grid.Row="0" Background="White" fd:PointerTracker.Enabled="True">

+ 5 - 0
MainWindow.xaml.cs

@@ -19,6 +19,7 @@ namespace Phihong_EVSE_UI_Tool
         private MaintenanceUC ucMaintenance = new MaintenanceUC();
         private BuildIco ucBuildIco = new BuildIco();
         private ModifyIco ucModifyIco = new ModifyIco();
+        private SaveSdCard ucSaveSdCard = new SaveSdCard();
 
         public MainWindow()
         {
@@ -77,6 +78,10 @@ namespace Phihong_EVSE_UI_Tool
                         uxContentGrid.Children.Add(ucModifyIco);
                         uxContentGrid.Children.OfType<ModifyIco>().First().uxContentScrollViewer.ScrollToTop();
                         break;
+                    case "uxSaveListViewItem":
+                        uxContentGrid.Children.Add(ucSaveSdCard);
+                        uxContentGrid.Children.OfType<SaveSdCard>().First().uxContentScrollViewer.ScrollToTop();
+                        break;
                     default:
                         break;
                 }

+ 5 - 5
MaintenanceUC.xaml.cs

@@ -37,9 +37,9 @@ namespace Phihong_EVSE_UI_Tool
             switch (rb.Tag.ToString())
             {
                 case "Maintain":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_MAINTAIN, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_MAINTAIN), UriKind.Relative);
                     uxMaintainImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_MAINTAIN);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_MAINTAIN));
                     mySettings.IsMaintainDefault = true;
                     break;
                 default:
@@ -63,7 +63,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(maintainCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxMaintainImage, maintainCustomImgPath);
-                        File.Copy(maintainCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_MAINTAIN, true);
+                        File.Copy(maintainCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_MAINTAIN), true);
                         mySettings.IsMaintainDefault = false;
                     }
                     break;
@@ -102,9 +102,9 @@ namespace Phihong_EVSE_UI_Tool
                 {
                     case "Maintain":
                         uxMaintainExploreTextBox.Text = dlg.FileName;
-                        maintainCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_MAINTAIN;
+                        maintainCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_MAINTAIN);
                         File.Copy(dlg.FileName, maintainCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_MAINTAIN, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_MAINTAIN), true);
                         Utility.LoadImageFromPath(uxMaintainImage, maintainCustomImgPath);
                         mySettings.IsMaintainDefault = false;
                         mySettings.MaintainCustomImgPath = maintainCustomImgPath;

+ 2 - 1
ModifyIco.xaml

@@ -33,8 +33,9 @@
                     <TextBox x:Name="uxLogoBrowseTextBox" VerticalContentAlignment="Center" Margin="1,0,0,0" Width="270" Height="35" 
                              Style="{StaticResource TextBoxRevealStyle}" Text="Please select logo image" IsReadOnly="True"/>
                 </StackPanel>
+                <!-- Ico Preview -->
                 <TextBlock Text="ICO Preview" FontSize="24" HorizontalAlignment="Left" Margin="22,18,0,0"/>
-                <Viewbox x:Name="viewbox" Stretch="Uniform" Margin="22,12,180,12">
+                <Viewbox x:Name="viewbox" Stretch="Uniform" Margin="22,12,180,12" RenderOptions.BitmapScalingMode="HighQuality">
                     <UniformGrid x:Name="uxIcoUniformGrid" Background="AliceBlue"/>
                 </Viewbox>
                 <StackPanel Margin="22,0,450,10" Height="15"/>

+ 8 - 6
ModifyIco.xaml.cs

@@ -29,8 +29,8 @@ namespace Phihong_EVSE_UI_Tool
 
         private void ModifyIcoContent(int index)
         {
-            Uri srcPath = new Uri(Utility.ICO_PARENTFOLDER + Utility.ICO_NAME, UriKind.Relative);
-            Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.ICO_NAME);
+            Uri srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_NAME), UriKind.Relative);
+            Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.ICO_NAME));
 
             if (mySettings.IsLogoDefault)
             {
@@ -41,7 +41,8 @@ namespace Phihong_EVSE_UI_Tool
             byte[] pixels = null;
             Utility.ConvertToBitmap565Array(logoCustomImgPath, out width, out height, out pixels);
 
-            FileStream icoFile = new FileStream(Utility.OUTPUT_DIRECTORY + Utility.ICO_NAME, FileMode.OpenOrCreate, FileAccess.ReadWrite);
+            FileStream icoFile = new FileStream(Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.ICO_NAME), 
+                                                FileMode.OpenOrCreate, FileAccess.ReadWrite);
 
             byte[] array = new byte[4 * bytesPerPixel];
             icoFile.Position = index * 4 * bytesPerPixel;
@@ -64,7 +65,8 @@ namespace Phihong_EVSE_UI_Tool
 
         private void DisplayDWIcoContent()
         {
-            FileStream fs = new FileStream(Utility.OUTPUT_DIRECTORY + Utility.ICO_NAME, FileMode.OpenOrCreate, FileAccess.ReadWrite);
+            FileStream fs = new FileStream(Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.ICO_NAME), 
+                                           FileMode.OpenOrCreate, FileAccess.ReadWrite);
 
             if (fs.Length > 131072 * bytesPerPixel)
             {
@@ -151,7 +153,7 @@ namespace Phihong_EVSE_UI_Tool
             switch (rb.Tag.ToString())
             {
                 case "Logo":
-                    srcPath = new Uri(Utility.ICO_PARENTFOLDER + Utility.ICO_LOGO, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_LOGO), UriKind.Relative);
                     uxLogoImage.Source = new BitmapImage(srcPath);
                     mySettings.IsLogoDefault = true;
                     break;
@@ -224,7 +226,7 @@ namespace Phihong_EVSE_UI_Tool
                 {
                     case "Logo":
                         uxLogoBrowseTextBox.Text = dlg.FileName;
-                        logoCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.ICO_LOGO;
+                        logoCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.ICO_LOGO);
                         File.Copy(dlg.FileName, logoCustomImgPath, true);
                         Utility.LoadImageFromPath(uxLogoImage, logoCustomImgPath);
                         mySettings.IsLogoDefault = false;

+ 34 - 0
Phihong EVSE UI Tool.csproj

@@ -16,6 +16,21 @@
     <Deterministic>true</Deterministic>
     <NuGetPackageImportStamp>
     </NuGetPackageImportStamp>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -110,6 +125,9 @@
     <Compile Include="ModifyIco.xaml.cs">
       <DependentUpon>ModifyIco.xaml</DependentUpon>
     </Compile>
+    <Compile Include="SaveSdCard.xaml.cs">
+      <DependentUpon>SaveSdCard.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Utility.cs" />
     <Compile Include="InitialIdleUC.xaml.cs">
       <DependentUpon>InitialIdleUC.xaml</DependentUpon>
@@ -129,6 +147,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="SaveSdCard.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="PlugChargingUC.xaml.cs">
@@ -181,6 +203,18 @@
   <ItemGroup>
     <Resource Include="ICO\60.ICO" />
   </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4.7.2 %28x86 和 x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="packages\MaterialDesignThemes.3.2.0\build\MaterialDesignThemes.targets" Condition="Exists('packages\MaterialDesignThemes.3.2.0\build\MaterialDesignThemes.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

+ 20 - 20
PlugChargingUC.xaml.cs

@@ -55,27 +55,27 @@ namespace Phihong_EVSE_UI_Tool
             switch (rb.Tag.ToString())
             {
                 case "Plug":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_PLUG, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_PLUG), UriKind.Relative);
                     uxPlugImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_PLUG);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_PLUG));
                     mySettings.IsPlugDefault = true;
                     break;
                 case "Precharge":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_PRECHARGE, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_PRECHARGE), UriKind.Relative);
                     uxPrechargeImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_PRECHARGE);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_PRECHARGE));
                     mySettings.IsPreChargeDefault = true;
                     break;
                 case "Charging":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_CHARGING, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_CHARGING), UriKind.Relative);
                     uxChargingImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_CHARGING);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_CHARGING));
                     mySettings.IsChargingDefault = true;
                     break;
                 case "Complete":
-                    srcPath = new Uri(Utility.BG_PARENTFOLDER + Utility.BG_COMPLETE, UriKind.Relative);
+                    srcPath = new Uri(Path.Combine(Utility.BG_PARENTFOLDER, Utility.BG_COMPLETE), UriKind.Relative);
                     uxCompleteImage.Source = new BitmapImage(srcPath);
-                    Utility.CopyFileFromResource(srcPath, Utility.OUTPUT_DIRECTORY + Utility.BG_COMPLETE);
+                    Utility.CopyFileFromResource(srcPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_COMPLETE));
                     mySettings.IsCompleteDefault = true;
                     break;
                 default:
@@ -99,7 +99,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(plugCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxPlugImage, plugCustomImgPath);
-                        File.Copy(plugCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_PLUG, true);
+                        File.Copy(plugCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_PLUG), true);
                         mySettings.IsPlugDefault = false;
                     }
                     break;
@@ -107,7 +107,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(prechargeCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxPrechargeImage, prechargeCustomImgPath);
-                        File.Copy(prechargeCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_PRECHARGE, true);
+                        File.Copy(prechargeCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_PRECHARGE), true);
                         mySettings.IsPreChargeDefault = false;
                     }
                     break;
@@ -115,7 +115,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(chargingCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxChargingImage, chargingCustomImgPath);
-                        File.Copy(chargingCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_CHARGING, true);
+                        File.Copy(chargingCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_CHARGING), true);
                         mySettings.IsChargingDefault = false;
                     }
                     break;
@@ -123,7 +123,7 @@ namespace Phihong_EVSE_UI_Tool
                     if (File.Exists(completeCustomImgPath))
                     {
                         Utility.LoadImageFromPath(uxCompleteImage, completeCustomImgPath);
-                        File.Copy(completeCustomImgPath, Utility.OUTPUT_DIRECTORY + Utility.BG_COMPLETE, true);
+                        File.Copy(completeCustomImgPath, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_COMPLETE), true);
                         mySettings.IsCompleteDefault = false;
                     }
                     break;
@@ -162,9 +162,9 @@ namespace Phihong_EVSE_UI_Tool
                 {
                     case "Plug":
                         uxPlugExploreTextBox.Text = dlg.FileName;
-                        plugCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_PLUG;
+                        plugCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_PLUG);
                         File.Copy(dlg.FileName, plugCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_PLUG, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_PLUG), true);
                         Utility.LoadImageFromPath(uxPlugImage, plugCustomImgPath);
                         mySettings.IsPlugDefault = false;
                         mySettings.PlugCustomImgPath = plugCustomImgPath;
@@ -172,9 +172,9 @@ namespace Phihong_EVSE_UI_Tool
                         break;
                     case "Precharge":
                         uxPrechargeExploreTextBox.Text = dlg.FileName;
-                        prechargeCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_PRECHARGE;
+                        prechargeCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_PRECHARGE);
                         File.Copy(dlg.FileName, prechargeCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_PRECHARGE, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_PRECHARGE), true);
                         Utility.LoadImageFromPath(uxPrechargeImage, prechargeCustomImgPath);
                         mySettings.IsPreChargeDefault = false;
                         mySettings.PreChargeCustomImgPath = prechargeCustomImgPath;
@@ -182,9 +182,9 @@ namespace Phihong_EVSE_UI_Tool
                         break;
                     case "Charging":
                         uxChargingExploreTextBox.Text = dlg.FileName;
-                        chargingCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_CHARGING;
+                        chargingCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_CHARGING);
                         File.Copy(dlg.FileName, chargingCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_CHARGING, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_CHARGING), true);
                         Utility.LoadImageFromPath(uxChargingImage, chargingCustomImgPath);
                         mySettings.IsChargingDefault = false;
                         mySettings.ChargingCustomImgPath = chargingCustomImgPath;
@@ -192,9 +192,9 @@ namespace Phihong_EVSE_UI_Tool
                         break;
                     case "Complete":
                         uxCompleteExploreTextBox.Text = dlg.FileName;
-                        completeCustomImgPath = Utility.CUSTOM_DIRECTORY + Utility.BG_COMPLETE;
+                        completeCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.BG_COMPLETE);
                         File.Copy(dlg.FileName, completeCustomImgPath, true);
-                        File.Copy(dlg.FileName, Utility.OUTPUT_DIRECTORY + Utility.BG_COMPLETE, true);
+                        File.Copy(dlg.FileName, Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.BG_COMPLETE), true);
                         Utility.LoadImageFromPath(uxCompleteImage, completeCustomImgPath);
                         mySettings.IsCompleteDefault = false;
                         mySettings.CompleteCustomImgPath = completeCustomImgPath;

+ 29 - 0
SaveSdCard.xaml

@@ -0,0 +1,29 @@
+<UserControl x:Class="Phihong_EVSE_UI_Tool.SaveSdCard"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:Phihong_EVSE_UI_Tool"
+             xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
+             xmlns:fd="clr-namespace:SourceChord.FluentWPF;assembly=FluentWPF"
+             mc:Ignorable="d" 
+             d:DesignHeight="500" d:DesignWidth="880" FontSize="15" FontFamily="Segoe UI">
+    <UserControl.Resources>
+        <BooleanToVisibilityConverter x:Key="b2v"/>
+    </UserControl.Resources>
+    <Grid fd:PointerTracker.Enabled="True">
+        <ScrollViewer x:Name="uxContentScrollViewer" HorizontalContentAlignment="Center" PanningMode="VerticalOnly" IsDeferredScrollingEnabled="False" DataContext="{Binding}">
+            <StackPanel>
+                <TextBlock Text="Temporary output folder (DO NOT delete)" HorizontalAlignment="Left" Margin="22,6,0,12"/>
+                <TextBlock Text="{x:Static local:Utility.OUTPUT_DIRECTORY}" HorizontalAlignment="Left" Margin="22,0,0,12" Foreground="{Binding Path=(fd:AccentColors.ImmersiveSystemAccentBrush)}"/>
+                <TextBlock Text="Save to SD card" HorizontalAlignment="Left" Margin="22,12,0,12"/>
+                <StackPanel x:Name="uxLogoCustomStackPanel" Orientation="Horizontal" Margin="22,0,450,12">
+                    <Button Tag="Save" Content="Save" HorizontalAlignment="Left" Width="90" Height="35"
+                            Style="{StaticResource ButtonRevealStyle}" Click="uxBrowseButton_Click" Foreground="Black"/>
+                    <TextBox x:Name="uxSdBrowseTextBox" VerticalContentAlignment="Center" Margin="1,0,0,0" Width="270" Height="35" 
+                             Style="{StaticResource TextBoxRevealStyle}" Text="Please locate the SD card" IsReadOnly="True"/>
+                </StackPanel>
+            </StackPanel>
+        </ScrollViewer>
+    </Grid>
+</UserControl>

+ 58 - 0
SaveSdCard.xaml.cs

@@ -0,0 +1,58 @@
+using Microsoft.WindowsAPICodePack.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+
+namespace Phihong_EVSE_UI_Tool
+{
+    /// <summary>
+    /// SaveSdCard.xaml 的互動邏輯
+    /// </summary>
+    public partial class SaveSdCard : UserControl
+    {
+        private string sdFolderPath;
+
+        public SaveSdCard()
+        {
+            InitializeComponent();
+        }
+
+        private void uxBrowseButton_Click(object sender, RoutedEventArgs e)
+        {
+            var dlg = new CommonOpenFileDialog()
+            {
+                IsFolderPicker = true,
+                Title = "Locate the SD card",
+            };
+
+            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
+            {
+                sdFolderPath = dlg.FileName;
+                uxSdBrowseTextBox.Text = sdFolderPath;
+                SaveToSdCard();
+            }
+        }
+
+        private void SaveToSdCard()
+        {
+            Directory.CreateDirectory(Path.Combine(sdFolderPath, Utility.SDCARD_SUBDIR));
+
+            foreach (string fileName in Utility.FILES_LIST)
+            {
+                File.Copy(Path.Combine(Utility.OUTPUT_DIRECTORY, fileName),
+                          Path.Combine(sdFolderPath, Utility.SDCARD_SUBDIR, fileName), true);
+            }
+        }
+    }
+}

+ 15 - 5
Utility.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 using System.IO;
 using System.Windows;
 using System.Windows.Controls;
@@ -9,7 +10,7 @@ namespace Phihong_EVSE_UI_Tool
 {
     public static class Utility
     {
-        public const string BG_PARENTFOLDER = @"Background\";
+        public const string BG_PARENTFOLDER = @"Background";
 
         public const string BG_INITIAL = "0_init.bmp";
         public const string BG_IDLE = "1_idle.bmp";
@@ -22,13 +23,22 @@ namespace Phihong_EVSE_UI_Tool
         public const string BG_COMPLETE = "8_complete.bmp";
         public const string BG_MAINTAIN = "9_fix.bmp";
 
-        public const string ICO_PARENTFOLDER = @"ICO\";
+        public const string ICO_PARENTFOLDER = @"ICO";
 
-        public const string ICO_LOGO = "10_logo.bmp";
         public const string ICO_NAME = "60.ICO";
+        public const string ICO_LOGO = "10_logo.bmp";
+
+        public const string SDCARD_SUBDIR = "DWIN_SET";
 
-        public static readonly string OUTPUT_DIRECTORY = Environment.CurrentDirectory + @"\Output\";
-        public static readonly string CUSTOM_DIRECTORY = Environment.CurrentDirectory + @"\CustomTemp\";
+        public static readonly string OUTPUT_DIRECTORY = Environment.CurrentDirectory + @"\Output";
+        public static readonly string CUSTOM_DIRECTORY = Environment.CurrentDirectory + @"\CustomTemp";
+
+        public static readonly List<string> FILES_LIST = new List<string>()
+        {
+            BG_INITIAL, BG_IDLE, BG_VERIFY, BG_VERIFYOK, BG_VERIFYFAIL,
+            BG_PLUG, BG_PRECHARGE, BG_CHARGING, BG_COMPLETE, BG_MAINTAIN,
+            ICO_NAME
+        };
 
         public static void CopyFileFromResource(Uri uriString, string destPath)
         {