|
@@ -16,6 +16,7 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
private Properties.Settings mySettings = Properties.Settings.Default;
|
|
|
private string logoCustomImgPath;
|
|
|
private string compLogoCustomImgPath;
|
|
|
+ private string urlCustomImgPath;
|
|
|
private int bytesPerPixel = 2;
|
|
|
|
|
|
public ModifyIco()
|
|
@@ -23,17 +24,25 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
InitializeComponent();
|
|
|
|
|
|
logoCustomImgPath = mySettings.LogoCustomImgPath;
|
|
|
- uxLogoDefaultRadioButton.IsChecked = mySettings.IsLogoDefault;
|
|
|
- uxLogoCustomRadioButton.IsChecked = !mySettings.IsLogoDefault;
|
|
|
+ uxLogoDefaultRadioButton.IsChecked = mySettings.IsLogoDefault && !mySettings.IsLogoHide;
|
|
|
+ uxLogoCustomRadioButton.IsChecked = !mySettings.IsLogoDefault && !mySettings.IsLogoHide;
|
|
|
+ uxLogoHideRadioButton.IsChecked = mySettings.IsLogoHide;
|
|
|
uxLogoBrowseTextBox.Text = mySettings.LogoCustomImgPath_org;
|
|
|
|
|
|
compLogoCustomImgPath = mySettings.CompLogoCustomImgPath;
|
|
|
- uxCompLogoDefaultRadioButton.IsChecked = mySettings.IsCompLogoDefault;
|
|
|
- uxCompLogoCustomRadioButton.IsChecked = !mySettings.IsCompLogoDefault;
|
|
|
+ uxCompLogoDefaultRadioButton.IsChecked = mySettings.IsCompLogoDefault && !mySettings.IsCompLogoHide;
|
|
|
+ uxCompLogoCustomRadioButton.IsChecked = !mySettings.IsCompLogoDefault && !mySettings.IsCompLogoHide;
|
|
|
+ uxCompLogoHideRadioButton.IsChecked = mySettings.IsCompLogoHide;
|
|
|
uxCompLogoBrowseTextBox.Text = mySettings.CompLogoCustomImgPath_org;
|
|
|
+
|
|
|
+ urlCustomImgPath = mySettings.UrlCustomImgPath;
|
|
|
+ uxUrlDefaultRadioButton.IsChecked = mySettings.IsUrlDefault && !mySettings.IsUrlHide;
|
|
|
+ uxUrlCustomRadioButton.IsChecked = !mySettings.IsUrlDefault && !mySettings.IsUrlHide;
|
|
|
+ uxUrlHideRadioButton.IsChecked = mySettings.IsUrlHide;
|
|
|
+ uxUrlBrowseTextBox.Text = mySettings.UrlCustomImgPath_org;
|
|
|
}
|
|
|
|
|
|
- private void ModifyIcoContent(int index, string path)
|
|
|
+ private void ModifyIcoContent(int index, string path, bool isHide = false)
|
|
|
{
|
|
|
string icoPath = Path.Combine(Utility.OUTPUT_DIRECTORY, Utility.ICO_NAME);
|
|
|
if (!File.Exists(icoPath))
|
|
@@ -45,12 +54,18 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
int width = 0, height = 0;
|
|
|
byte[] pixels = null;
|
|
|
|
|
|
- if (String.IsNullOrEmpty(path))
|
|
|
+ if (String.IsNullOrEmpty(path) && !isHide)
|
|
|
{
|
|
|
//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 if (String.IsNullOrEmpty(path) && isHide)
|
|
|
+ {
|
|
|
+ //Hide
|
|
|
+ Uri resourcePath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, index.ToString() + "_hide.bmp"), UriKind.Relative);
|
|
|
+ Utility.ConvertResourceToBitmap565Array(resourcePath, out width, out height, out pixels);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
Utility.ConvertFileToBitmap565Array(path, out width, out height, out pixels);
|
|
@@ -171,14 +186,23 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_MAINLOGO), UriKind.Relative);
|
|
|
uxLogoImage.Source = new BitmapImage(srcPath);
|
|
|
mySettings.IsLogoDefault = true;
|
|
|
+ mySettings.IsLogoHide = false;
|
|
|
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;
|
|
|
+ mySettings.IsCompLogoHide = false;
|
|
|
ModifyIcoContent((int)IcoElement.LogoComplete, String.Empty);
|
|
|
break;
|
|
|
+ case "Url":
|
|
|
+ srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_URL), UriKind.Relative);
|
|
|
+ uxUrlImage.Source = new BitmapImage(srcPath);
|
|
|
+ mySettings.IsUrlDefault = true;
|
|
|
+ mySettings.IsUrlHide = false;
|
|
|
+ ModifyIcoContent((int)IcoElement.URL, String.Empty);
|
|
|
+ break;
|
|
|
default:
|
|
|
return;
|
|
|
}
|
|
@@ -205,6 +229,7 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
{
|
|
|
Utility.LoadImageFromPath(uxLogoImage, logoCustomImgPath);
|
|
|
mySettings.IsLogoDefault = false;
|
|
|
+ mySettings.IsLogoHide = false;
|
|
|
ModifyIcoContent((int)IcoElement.Logo, logoCustomImgPath);
|
|
|
}
|
|
|
break;
|
|
@@ -213,9 +238,62 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
{
|
|
|
Utility.LoadImageFromPath(uxCompLogoImage, compLogoCustomImgPath);
|
|
|
mySettings.IsCompLogoDefault = false;
|
|
|
+ mySettings.IsCompLogoHide = false;
|
|
|
ModifyIcoContent((int)IcoElement.LogoComplete, compLogoCustomImgPath);
|
|
|
}
|
|
|
break;
|
|
|
+ case "Url":
|
|
|
+ if (File.Exists(urlCustomImgPath))
|
|
|
+ {
|
|
|
+ Utility.LoadImageFromPath(uxUrlImage, urlCustomImgPath);
|
|
|
+ mySettings.IsUrlDefault = false;
|
|
|
+ mySettings.IsUrlHide = false;
|
|
|
+ ModifyIcoContent((int)IcoElement.URL, urlCustomImgPath);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Utility.ChangedFiles[Utility.ICO_NAME] = true;
|
|
|
+ mySettings.Save();
|
|
|
+
|
|
|
+ //Display Ico
|
|
|
+ uxIcoUniformGrid.Children.Clear();
|
|
|
+ DisplayDWIcoContent();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void uxHideRadioButton_Checked(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ Uri srcPath;
|
|
|
+ RadioButton rb = e.Source as RadioButton;
|
|
|
+ if (rb is null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (rb.Tag.ToString())
|
|
|
+ {
|
|
|
+ case "Logo":
|
|
|
+ srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_MAINLOGO_HIDE), UriKind.Relative);
|
|
|
+ uxLogoImage.Source = new BitmapImage(srcPath);
|
|
|
+ mySettings.IsLogoDefault = false;
|
|
|
+ mySettings.IsLogoHide = true;
|
|
|
+ ModifyIcoContent((int)IcoElement.Logo, String.Empty, true);
|
|
|
+ break;
|
|
|
+ case "CompLogo":
|
|
|
+ srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_COMPLETELOGO_HIDE), UriKind.Relative);
|
|
|
+ uxCompLogoImage.Source = new BitmapImage(srcPath);
|
|
|
+ mySettings.IsCompLogoDefault = false;
|
|
|
+ mySettings.IsCompLogoHide = true;
|
|
|
+ ModifyIcoContent((int)IcoElement.LogoComplete, String.Empty, true);
|
|
|
+ break;
|
|
|
+ case "Url":
|
|
|
+ srcPath = new Uri(Path.Combine(Utility.ICO_PARENTFOLDER, Utility.ICO_URL_HIDE), UriKind.Relative);
|
|
|
+ uxUrlImage.Source = new BitmapImage(srcPath);
|
|
|
+ mySettings.IsUrlDefault = false;
|
|
|
+ mySettings.IsUrlHide = true;
|
|
|
+ ModifyIcoContent((int)IcoElement.URL, String.Empty, true);
|
|
|
+ break;
|
|
|
default:
|
|
|
return;
|
|
|
}
|
|
@@ -244,16 +322,15 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
|
|
|
if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
|
|
|
{
|
|
|
- if (!Utility.IsIcoLogoSizeQualified(dlg.FileName))
|
|
|
- {
|
|
|
- MessageBox.Show(dlg.FileName + "\r\n" + "The resolution of the image must be 255x34",
|
|
|
- "Incorrect Resolution", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
switch (btn.Tag.ToString())
|
|
|
{
|
|
|
case "Logo":
|
|
|
+ if (!Utility.IsIcoLogoSizeQualified(dlg.FileName))
|
|
|
+ {
|
|
|
+ MessageBox.Show(dlg.FileName + "\r\n" + "The resolution of the image must be 255x34",
|
|
|
+ "Incorrect Resolution", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
uxLogoBrowseTextBox.Text = dlg.FileName;
|
|
|
logoCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.ICO_MAINLOGO);
|
|
|
File.Copy(dlg.FileName, logoCustomImgPath, true);
|
|
@@ -265,6 +342,12 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
ModifyIcoContent((int)IcoElement.Logo, logoCustomImgPath);
|
|
|
break;
|
|
|
case "CompLogo":
|
|
|
+ if (!Utility.IsIcoLogoSizeQualified(dlg.FileName))
|
|
|
+ {
|
|
|
+ MessageBox.Show(dlg.FileName + "\r\n" + "The resolution of the image must be 255x34",
|
|
|
+ "Incorrect Resolution", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
uxCompLogoBrowseTextBox.Text = dlg.FileName;
|
|
|
compLogoCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.ICO_COMPLETELOGO);
|
|
|
File.Copy(dlg.FileName, compLogoCustomImgPath, true);
|
|
@@ -275,6 +358,23 @@ namespace Phihong_EVSE_UI_Tool
|
|
|
|
|
|
ModifyIcoContent((int)IcoElement.LogoComplete, compLogoCustomImgPath);
|
|
|
break;
|
|
|
+ case "Url":
|
|
|
+ if (!Utility.IsIcoUrlSizeQualified(dlg.FileName))
|
|
|
+ {
|
|
|
+ MessageBox.Show(dlg.FileName + "\r\n" + "The resolution of the image must be 233x28",
|
|
|
+ "Incorrect Resolution", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ uxUrlBrowseTextBox.Text = dlg.FileName;
|
|
|
+ urlCustomImgPath = Path.Combine(Utility.CUSTOM_DIRECTORY, Utility.ICO_URL);
|
|
|
+ File.Copy(dlg.FileName, urlCustomImgPath, true);
|
|
|
+ Utility.LoadImageFromPath(uxUrlImage, urlCustomImgPath);
|
|
|
+ mySettings.IsUrlDefault = false;
|
|
|
+ mySettings.UrlCustomImgPath = urlCustomImgPath;
|
|
|
+ mySettings.UrlCustomImgPath_org = uxUrlBrowseTextBox.Text;
|
|
|
+
|
|
|
+ ModifyIcoContent((int)IcoElement.URL, urlCustomImgPath);
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|