Skip to content

Commit

Permalink
11/9/2018
Browse files Browse the repository at this point in the history
11/9/2018 Update:
    1. Fixed: Exit logic
    2. Added: Taskbar size change event listener
    3. Added: "Not supported" message when taskbar is vertical
    4. Changed: Several keyboard shorcuts
    5. Changed: More complete How To instructions

11/9/2018 更新:
    1. 修复:程序退出逻辑
    2. 新增:任务栏大小改变时的程序逻辑
    3. 新增:“不支持竖任务栏”的提示消息
    4. 改变:一些热键设置
    4. 改变:更完整的使用说明
  • Loading branch information
henryxrl committed Nov 9, 2018
1 parent 1ba1a84 commit f9c90a3
Show file tree
Hide file tree
Showing 72 changed files with 1,109 additions and 753 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[Dd]ebug/
# [Rr]elease/
x64/
build/
# build/
# [Bb]in/
[Oo]bj/

Expand Down
Binary file removed GenereateUpdateXML.exe.lnk
Binary file not shown.
Binary file added GenereateUpdateXML.lnk
Binary file not shown.
7 changes: 5 additions & 2 deletions GenereateUpdateXML/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Costura/>

<Costura>
<IncludeAssemblies>
DevComponents.DotNetBar2
</IncludeAssemblies>
</Costura>
</Weavers>
36 changes: 18 additions & 18 deletions GenereateUpdateXML/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ namespace GenereateUpdateXML
{
public partial class Form1 : DevComponents.DotNetBar.Metro.MetroForm
{
private static String project = Directory.GetParent(Path.Combine(Directory.GetCurrentDirectory(), @"..\..")).Name;
private static String xml_dir = Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..");
private static String xml_path = Path.Combine(xml_dir, project + @"_Update.xml");
private static String exe_path = Path.Combine(xml_dir, project + @"\bin\Release\" + project + ".exe");
private static String exe_name = Path.GetFileName(exe_path);
private static String exe_name_no_ext = Path.GetFileNameWithoutExtension(exe_path);
private static String exe_URL = "https://raw.githubusercontent.com/henryxrl/" + project + "/master/" + project + "/bin/Release/" + project + ".exe";
private static String exe_MD5 = GetMd5(exe_path);
private static String exe_ver = FileVersionInfo.GetVersionInfo(exe_path).ProductVersion;
private static string project = Directory.GetParent(Path.Combine(Directory.GetCurrentDirectory(), @"..\..")).Name;
private static string xml_dir = Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..");
private static string xml_path = Path.Combine(xml_dir, project + @"_Update.xml");
private static string exe_path = Path.Combine(xml_dir, project + @"\bin\Release\" + project + ".exe");
private static string exe_name = Path.GetFileName(exe_path);
private static string exe_name_no_ext = Path.GetFileNameWithoutExtension(exe_path);
private static string exe_URL = "https://raw.githubusercontent.com/henryxrl/" + project + "/master/" + project + "/bin/Release/" + project + ".exe";
private static string exe_MD5 = GetMd5(exe_path);
private static string exe_ver = FileVersionInfo.GetVersionInfo(exe_path).ProductVersion;

private XmlDocument doc = new XmlDocument();
private XmlNode root;
Expand Down Expand Up @@ -55,33 +55,33 @@ private void Form1_Load(object sender, EventArgs e)

private void button1_Click(object sender, EventArgs e)
{
String log = "";
String log_en = "";
String log_cn = "";
string log = "";
string log_en = "";
string log_cn = "";

var log_en_array = textBox1.Lines;
if (log_en_array.Length == 0)
log_en = "";
else
log_en = String.Join("\n ", log_en_array);
log_en = string.Join("\n ", log_en_array);

var log_cn_array = textBox2.Lines;
if (log_cn_array.Length == 0)
log_cn = "";
else
log_cn = String.Join("\n ", log_cn_array);
log_cn = string.Join("\n ", log_cn_array);

String date = DateTime.Today.ToString("d");
string date = DateTime.Today.ToString("d");

log = String.Concat(date, " Update:\n ", log_en, "\n\n", date, " 更新:\n ", log_cn);
log = string.Concat(date, " Update:\n ", log_en, "\n\n", date, " 更新:\n ", log_cn);

appendNode("description", log);
doc.Save(xml_path);

Environment.Exit(1);
}

static private String GetMd5(String path)
static private string GetMd5(string path)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
FileStream stream = File.Open(path, FileMode.Open);
Expand All @@ -97,7 +97,7 @@ static private String GetMd5(String path)
return sb.ToString().ToUpper();
}

private void appendNode(String nodeName, String value)
private void appendNode(string nodeName, string value)
{
XmlNode version = doc.CreateElement(nodeName);
version.InnerText = value;
Expand Down
7 changes: 5 additions & 2 deletions GenereateUpdateXML/GenereateUpdateXML.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.3.1.6\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.1.6\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -88,13 +89,15 @@
<Content Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('..\packages\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets')" />
<Import Project="..\packages\Fody.3.2.16\build\Fody.targets" Condition="Exists('..\packages\Fody.3.2.16\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.3\build\portable-net+sl+win+wpa+wp\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.3.1.6\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.1.6\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Fody.3.2.16\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.2.16\build\Fody.targets'))" />
</Target>
<Import Project="..\packages\Fody.3.2.16\build\Fody.targets" Condition="Exists('..\packages\Fody.3.2.16\build\Fody.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Binary file modified GenereateUpdateXML/bin/Release/GenereateUpdateXML.exe
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
4 changes: 2 additions & 2 deletions GenereateUpdateXML/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="1.3.5.0" targetFramework="net452" developmentDependency="true" />
<package id="Fody" version="1.29.3" targetFramework="net452" developmentDependency="true" />
<package id="Costura.Fody" version="3.1.6" targetFramework="net45" developmentDependency="true" />
<package id="Fody" version="3.2.16" targetFramework="net45" developmentDependency="true" />
</packages>
6 changes: 4 additions & 2 deletions TaskbarHook/Taskbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ private Taskbar() { }

internal static void CreateAndInitialize(IntPtr taskbarHandle)
{
Instance = new Taskbar();
Instance.Handle = taskbarHandle;
Instance = new Taskbar
{
Handle = taskbarHandle
};
Instance.Rectangle = User32.GetWindowRectangle(Instance.Handle);
Instance.TaskbarResizeHandle = User32.RegisterWindowSizeChangeEvent(Instance.Handle, taskbarResizeDelegate);
}
Expand Down
Binary file modified TaskbarHook/bin/Release/TaskbarHook.dll
Binary file not shown.
8 changes: 4 additions & 4 deletions TaskbarReader/APTDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace TaskbarReader
{
public partial class APTDialog : Form
{
public Int32 apt_time = 0;
public int apt_time = 0;

public APTDialog(Tools tools)
{
Expand All @@ -21,10 +21,10 @@ public APTDialog(Tools tools)
this.ForeColor = tools.ForeColor;
this.BackColor = tools.BackColor;

label1.Text = tools.getString("apt_label2");
label2.Text = tools.getString("apt_label_sec");
label1.Text = tools.GetString("apt_label2");
label2.Text = tools.GetString("apt_label_sec");

button1.Text = tools.getString("button_ok");
button1.Text = tools.GetString("button_ok");
}

private void button1_Click(object sender, EventArgs e)
Expand Down
14 changes: 7 additions & 7 deletions TaskbarReader/About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public About(Tools tools)
this.ForeColor = tools.ForeColor;
this.BackColor = tools.BackColor;

about_version_label.Text = tools.getString("about_version_label");
about_author_label.Text = tools.getString("about_author_label");
about_email_label.Text = tools.getString("about_email_label");
about_intro_label.Text = tools.getString("about_intro_label");
about_version_label.Text = tools.GetString("about_version_label");
about_author_label.Text = tools.GetString("about_author_label");
about_email_label.Text = tools.GetString("about_email_label");
about_intro_label.Text = tools.GetString("about_intro_label");

about_name.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
about_version.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
about_author.Text = "Henry Xu";
about_email.Text = "[email protected]";
about_intro.Text = string.Join(Environment.NewLine, tools.getString("about_intro").Split(new string[] { "<br/>" }, StringSplitOptions.None));
about_intro.Text = string.Join(Environment.NewLine, tools.GetString("about_intro").Split(new string[] { "<br/>" }, StringSplitOptions.None));

about_ok_button.Text = tools.getString("button_ok");
about_ok_button.Text = tools.GetString("button_ok");

about_pictureBox.Image = tools.img;
about_pictureBox.Image = tools.Img;
about_pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
}

Expand Down
4 changes: 2 additions & 2 deletions TaskbarReader/AutoUpdate/AutoUpdatable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public interface AutoUpdatable
/// <summary>
/// The name of your application as you want it displayed on the update form
/// </summary>
String ApplicationName { get; }
string ApplicationName { get; }
/// <summary>
/// An identifier string to use to identify your application in the update.xml
/// Should be the same as your appId in the update.xml
/// </summary>
String ApplicationID { get; }
string ApplicationID { get; }
/// <summary>
/// The current language code
/// </summary>
Expand Down
16 changes: 8 additions & 8 deletions TaskbarReader/AutoUpdate/AutoUpdateAcceptForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ internal AutoUpdateAcceptForm(AutoUpdatable applicationInfo, AutoUpdateXml updat
this.updateInfo = updateInfo;
this.tools = applicationInfo.Tools;

pictureBox.Image = tools.img;
pictureBox.Image = tools.Img;

this.Text = tools.getString("update_found_title");
this.Text = tools.GetString("update_found_title");

this.lblAppName.Text = this.applicationInfo.ApplicationName;
this.lblUpdateAvail.Text = tools.getString("update_found");
this.lblNewVersion_label.Text = tools.getString("update_new");
this.lblCurVersion_label.Text = tools.getString("update_cur");
this.lblDescription.Text = tools.getString("update_description");
this.lblUpdateAvail.Text = tools.GetString("update_found");
this.lblNewVersion_label.Text = tools.GetString("update_new");
this.lblCurVersion_label.Text = tools.GetString("update_cur");
this.lblDescription.Text = tools.GetString("update_description");

this.btnYes.Text = tools.getString("button_ok");
this.btnNo.Text = tools.getString("button_cancel");
this.btnYes.Text = tools.GetString("button_ok");
this.btnNo.Text = tools.GetString("button_cancel");

// Assigns the icon if it isn't null
if (this.applicationInfo.ApplicationIcon != null)
Expand Down
30 changes: 15 additions & 15 deletions TaskbarReader/AutoUpdate/AutoUpdateDownloadForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal string TempFilePath
/// <summary>
/// Creates a new AutoUpdateDownloadForm
/// </summary>
internal AutoUpdateDownloadForm(AutoUpdatable applicationInfo, Uri location, String md5, Icon programIcon)
internal AutoUpdateDownloadForm(AutoUpdatable applicationInfo, Uri location, string md5, Icon programIcon)
{
InitializeComponent();

Expand All @@ -64,9 +64,9 @@ internal AutoUpdateDownloadForm(AutoUpdatable applicationInfo, Uri location, Str
if (programIcon != null)
this.Icon = programIcon;

this.Text = applicationInfo.ApplicationName + " - " + tools.getString("update_download");
this.Text = applicationInfo.ApplicationName + " - " + tools.GetString("update_download");

this.lblDownloading.Text = tools.getString("update_downloading");
this.lblDownloading.Text = tools.GetString("update_downloading");

// Set the temp file name and create new 0-byte file
tempFile = Path.GetTempFileName();
Expand Down Expand Up @@ -99,8 +99,8 @@ private void AutoUpdateDownloadForm_Load(object sender, EventArgs e)
private void webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
// Update progressbar on download
this.lblPercentage.Text = String.Format(tools.getString("update_completed") + " {0}", FormatPercentage(e.BytesReceived, e.TotalBytesToReceive, 0));
this.lblProgress.Text = String.Format(tools.getString("update_downloaded") + " {0} / {1}", FormatBytes(e.BytesReceived, 1, true), FormatBytes(e.TotalBytesToReceive, 1, true));
this.lblPercentage.Text = string.Format(tools.GetString("update_completed") + " {0}", FormatPercentage(e.BytesReceived, e.TotalBytesToReceive, 0));
this.lblProgress.Text = string.Format(tools.GetString("update_downloaded") + " {0} / {1}", FormatBytes(e.BytesReceived, 1, true), FormatBytes(e.TotalBytesToReceive, 1, true));
this.progressBar.Value = e.ProgressPercentage;
}

Expand All @@ -119,15 +119,15 @@ private void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventA
else
{
// Show the "Hashing" label and set the progressbar to marquee
this.lblProgress.Text = tools.getString("update_verifying");
this.lblProgress.Text = tools.GetString("update_verifying");
this.progressBar.Style = ProgressBarStyle.Marquee;

// Start the hashing
bgWorker.RunWorkerAsync(new String[] { this.tempFile, this.md5 });
bgWorker.RunWorkerAsync(new string[] { this.tempFile, this.md5 });
}
}

private String FormatPercentage(Int64 bytes1, Int64 bytes2, Int32 decimalPlaces)
private string FormatPercentage(long bytes1, long bytes2, int decimalPlaces)
{
Double newBytes1 = bytes1;
Double newBytes2 = bytes2;
Expand All @@ -142,11 +142,11 @@ private String FormatPercentage(Int64 bytes1, Int64 bytes2, Int32 decimalPlaces)
/// <param name="decimalPlaces">How many decimal places to show</param>
/// <param name="showByteType">Add the byte type on the end of the string</param>
/// <returns>The bytes formatted as specified</returns>
private String FormatBytes(Int64 bytes, Int32 decimalPlaces, Boolean showByteType)
private string FormatBytes(long bytes, int decimalPlaces, bool showByteType)
{
Double newBytes = bytes;
String formatString = "{0";
String byteType = "B";
string formatString = "{0";
string byteType = "B";

// Check if best size in KB
if (newBytes > 1024 && newBytes < 1048576)
Expand All @@ -172,7 +172,7 @@ private String FormatBytes(Int64 bytes, Int32 decimalPlaces, Boolean showByteTyp
formatString += ":0.";

// Add decimals
for (Int32 i = 0; i < decimalPlaces; i++)
for (int i = 0; i < decimalPlaces; i++)
formatString += "0";

// Close placeholder
Expand All @@ -182,13 +182,13 @@ private String FormatBytes(Int64 bytes, Int32 decimalPlaces, Boolean showByteTyp
if (showByteType)
formatString += byteType;

return String.Format(formatString, newBytes);
return string.Format(formatString, newBytes);
}

private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
String file = ((String[])e.Argument)[0];
String updateMD5 = ((String[])e.Argument)[1];
string file = ((string[])e.Argument)[0];
string updateMD5 = ((string[])e.Argument)[1];

// Hash the file and compare to the hash in the update xml
if (Hash.HashFile(file, HashType.MD5).ToUpper() != updateMD5.ToUpper())
Expand Down
Loading

0 comments on commit f9c90a3

Please sign in to comment.