|
@@ -15,6 +15,7 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
{
|
|
|
private Properties.Settings mySettings = Properties.Settings.Default;
|
|
|
private string logoCustomImgPath;
|
|
|
+ private string compLogoCustomImgPath;
|
|
|
private int bytesPerPixel = 2;
|
|
|
|
|
|
public ModifyIco()
|
|
@@ -25,21 +26,35 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
uxLogoDefaultRadioButton.IsChecked = mySettings.IsLogoDefault;
|
|
|
uxLogoCustomRadioButton.IsChecked = !mySettings.IsLogoDefault;
|
|
|
uxLogoBrowseTextBox.Text = mySettings.LogoCustomImgPath_org;
|
|
|
+
|
|
|
+ compLogoCustomImgPath = mySettings.CompLogoCustomImgPath;
|
|
|
+ uxCompLogoDefaultRadioButton.IsChecked = mySettings.IsCompLogoDefault;
|
|
|
+ uxCompLogoCustomRadioButton.IsChecked = !mySettings.IsCompLogoDefault;
|
|
|
+ uxCompLogoBrowseTextBox.Text = mySettings.CompLogoCustomImgPath_org;
|
|
|
}
|
|
|
|
|
|
- private void ModifyIcoContent(int index)
|
|
|
+ private void ModifyIcoContent(int index, string path)
|
|
|
{
|
|
|
- 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)
|
|
|
+ string icoPath = Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.ICO_NAME);
|
|
|
+ if (!File.Exists(icoPath))
|
|
|
{
|
|
|
- return;
|
|
|
+ Uri srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_NAME), UriKind.Relative);
|
|
|
+ Utility.CopyFileFromResource(srcPath, icoPath);
|
|
|
}
|
|
|
|
|
|
int width = 0, height = 0;
|
|
|
byte[] pixels = null;
|
|
|
- Utility.ConvertToBitmap565Array(logoCustomImgPath, out width, out height, out pixels);
|
|
|
+
|
|
|
+ if (String.IsNullOrEmpty(path))
|
|
|
+ {
|
|
|
+ //Default
|
|
|
+ Uri resourcePath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, index.ToString() + ".bmp"), UriKind.Relative);
|
|
|
+ Utility.ConvertResourceToBitmap565Array(resourcePath, out width, out height, out pixels);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Utility.ConvertFileToBitmap565Array(path, out width, out height, out pixels);
|
|
|
+ }
|
|
|
|
|
|
FileStream icoFile = new FileStream(Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.ICO_NAME),
|
|
|
FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
|
@@ -130,8 +145,8 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
|
|
|
Image image = new Image()
|
|
|
{
|
|
|
- Width = 200,
|
|
|
- Height = 200,
|
|
|
+ Width = 270,
|
|
|
+ Height = 270,
|
|
|
Stretch = Stretch.None,
|
|
|
Margin = new Thickness(0),
|
|
|
Source = wbitmap
|
|
@@ -153,17 +168,23 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
switch (rb.Tag.ToString())
|
|
|
{
|
|
|
case "Logo":
|
|
|
- srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_LOGO), UriKind.Relative);
|
|
|
+ srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_MAINLOGO), UriKind.Relative);
|
|
|
uxLogoImage.Source = new BitmapImage(srcPath);
|
|
|
mySettings.IsLogoDefault = true;
|
|
|
+ ModifyIcoContent((int)IcoElement.Logo, String.Empty);
|
|
|
+ break;
|
|
|
+ case "CompLogo":
|
|
|
+ srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_COMPLETELOGO), UriKind.Relative);
|
|
|
+ uxCompLogoImage.Source = new BitmapImage(srcPath);
|
|
|
+ mySettings.IsCompLogoDefault = true;
|
|
|
+ ModifyIcoContent((int)IcoElement.LogoComplete, String.Empty);
|
|
|
break;
|
|
|
default:
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ Utility.ChangedFiles[Utility.ICO_NAME] = true;
|
|
|
mySettings.Save();
|
|
|
|
|
|
- ModifyIcoContent((int)IcoElement.Logo);
|
|
|
//Display Ico
|
|
|
uxIcoUniformGrid.Children.Clear();
|
|
|
DisplayDWIcoContent();
|
|
@@ -184,18 +205,26 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
{
|
|
|
Utility.LoadImageFromPath(uxLogoImage, logoCustomImgPath);
|
|
|
mySettings.IsLogoDefault = false;
|
|
|
-
|
|
|
- ModifyIcoContent((int)IcoElement.Logo);
|
|
|
- //Display Ico
|
|
|
- uxIcoUniformGrid.Children.Clear();
|
|
|
- DisplayDWIcoContent();
|
|
|
+ ModifyIcoContent((int)IcoElement.Logo, logoCustomImgPath);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "CompLogo":
|
|
|
+ if (File.Exists(compLogoCustomImgPath))
|
|
|
+ {
|
|
|
+ Utility.LoadImageFromPath(uxCompLogoImage, compLogoCustomImgPath);
|
|
|
+ mySettings.IsCompLogoDefault = false;
|
|
|
+ ModifyIcoContent((int)IcoElement.LogoComplete, compLogoCustomImgPath);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ Utility.ChangedFiles[Utility.ICO_NAME] = true;
|
|
|
mySettings.Save();
|
|
|
+
|
|
|
+ //Display Ico
|
|
|
+ uxIcoUniformGrid.Children.Clear();
|
|
|
+ DisplayDWIcoContent();
|
|
|
}
|
|
|
|
|
|
private void uxBrowseButton_Click(object sender, RoutedEventArgs e)
|
|
@@ -217,7 +246,7 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
{
|
|
|
if (!Utility.IsIcoLogoSizeQualified(dlg.FileName))
|
|
|
{
|
|
|
- MessageBox.Show(dlg.FileName + "\r\n" + "The resolution of the image must be 186x34",
|
|
|
+ MessageBox.Show(dlg.FileName + "\r\n" + "The resolution of the image must be 255x34",
|
|
|
"Incorrect Resolution", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
return;
|
|
|
}
|
|
@@ -226,24 +255,37 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
{
|
|
|
case "Logo":
|
|
|
uxLogoBrowseTextBox.Text = dlg.FileName;
|
|
|
- logoCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.ICO_LOGO);
|
|
|
+ logoCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.ICO_MAINLOGO);
|
|
|
File.Copy(dlg.FileName, logoCustomImgPath, true);
|
|
|
Utility.LoadImageFromPath(uxLogoImage, logoCustomImgPath);
|
|
|
mySettings.IsLogoDefault = false;
|
|
|
mySettings.LogoCustomImgPath = logoCustomImgPath;
|
|
|
mySettings.LogoCustomImgPath_org = uxLogoBrowseTextBox.Text;
|
|
|
|
|
|
- ModifyIcoContent((int)IcoElement.Logo);
|
|
|
- //Display Ico
|
|
|
- uxIcoUniformGrid.Children.Clear();
|
|
|
- DisplayDWIcoContent();
|
|
|
+ ModifyIcoContent((int)IcoElement.Logo, logoCustomImgPath);
|
|
|
+ break;
|
|
|
+ case "CompLogo":
|
|
|
+ uxCompLogoBrowseTextBox.Text = dlg.FileName;
|
|
|
+ compLogoCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.ICO_COMPLETELOGO);
|
|
|
+ File.Copy(dlg.FileName, compLogoCustomImgPath, true);
|
|
|
+ Utility.LoadImageFromPath(uxCompLogoImage, compLogoCustomImgPath);
|
|
|
+ mySettings.IsCompLogoDefault = false;
|
|
|
+ mySettings.CompLogoCustomImgPath = compLogoCustomImgPath;
|
|
|
+ mySettings.CompLogoCustomImgPath_org = uxCompLogoBrowseTextBox.Text;
|
|
|
+
|
|
|
+ ModifyIcoContent((int)IcoElement.LogoComplete, compLogoCustomImgPath);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- mySettings.Save();
|
|
|
+ Utility.ChangedFiles[Utility.ICO_NAME] = true;
|
|
|
+ mySettings.Save();
|
|
|
+
|
|
|
+ //Display Ico
|
|
|
+ uxIcoUniformGrid.Children.Clear();
|
|
|
+ DisplayDWIcoContent();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|