Skip to content

Commit

Permalink
animated buttons and small update
Browse files Browse the repository at this point in the history
  • Loading branch information
hexadecimal233 committed Feb 8, 2021
1 parent cfc86be commit 6306ada
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
60 changes: 49 additions & 11 deletions code/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management;

using WinUtils;

namespace Windows_Store_Downloader
{
Expand Down Expand Up @@ -81,14 +81,14 @@ private string SetAttributeText() {
private void DownloadButton_Click(object sender, EventArgs e)
{
progressBar1.Value = 0;
downloadButton.Enabled = false;//禁止重复点击
this.Enabled = false;//禁止重复点击
Form2.complete = false;
HasText();
if (typeBox.SelectedIndex == -1 || routeBox.SelectedIndex == -1 || textBoxHasText == false)
{

MessageBox.Show(Language.lang_baddown,Language.lang_baddowninfo,MessageBoxButtons.OK,MessageBoxIcon.Error);
downloadButton.Enabled = true;
this.Enabled = true;
return;
}//参数完整
if (langText.Text == "")
Expand Down Expand Up @@ -117,7 +117,7 @@ private void DownloadButton_Click(object sender, EventArgs e)

}//伪装进度条
progressBar1.Value = 100;
downloadButton.Enabled = true;
this.Enabled = true;



Expand Down Expand Up @@ -330,8 +330,10 @@ private bool IsWinLess10()
}

}

Thread thread1;
Thread thread2;
Thread thread3;
Thread thread4;
private void CloseButton_MouseLeave(object sender, EventArgs e)
{
thread2 = new Thread(GoIntoB);
Expand All @@ -343,12 +345,13 @@ private void CloseButton_Click(object sender, EventArgs e)
{
this.Close();
}
Thread thread1;

private void CloseButton_MouseHover(object sender, EventArgs e)
{
thread1 = new Thread(GoIntoA);
thread1.IsBackground = true;
thread1.Start();
try { thread1.Start(); } catch { }


}
private void GoIntoA()
Expand All @@ -370,6 +373,25 @@ private void GoIntoB()
}
this.CloseButton.BackColor = Color.FromArgb(0, 0, 0, 0);
}
private void GoIntoC()
{
for (int i = 0; i < 231; i += 3)
{
Thread.Sleep(1);
this.MinimizeButton.BackColor = Color.FromArgb(i, i+3, i+2, i);
}

}
private void GoIntoD()
{
thread3.Abort();
for (int i = this.MinimizeButton.BackColor.B; i > 0; i -= 3)
{
Thread.Sleep(1);
this.MinimizeButton.BackColor = Color.FromArgb(i, i + 3, i + 2, i);
}
this.MinimizeButton.BackColor = Color.FromArgb(0, 0, 0, 0);
}

public void SetWindowRegion()
{
Expand Down Expand Up @@ -412,9 +434,18 @@ private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
return path;
}



private void label2_MouseDown(object sender, MouseEventArgs e)
{
WinUtils.FormUtils.DragWindow(this.Handle);
if (e.Button == MouseButtons.Right)
{

} else
{
FormUtils.DragWindow(this.Handle);
}

}//拖拽窗口

private void downloadButton_MouseEnter(object sender, EventArgs e)
Expand All @@ -429,18 +460,25 @@ private void downloadButton_MouseLeave(object sender, EventArgs e)

private void label3_MouseEnter(object sender, EventArgs e)
{
MinimizeButton.BackColor = Color.FromArgb(50, 233, 232, 231);
thread3 = new Thread(GoIntoC);
thread3.IsBackground = true;
try { thread3.Start(); } catch { }

}

private void label3_MouseLeave(object sender, EventArgs e) {
MinimizeButton.BackColor = Color.FromArgb(0, 0, 0, 0);
private void label3_MouseLeave(object sender, EventArgs e) {
thread4 = new Thread(GoIntoD);
thread4.IsBackground = true;
thread4.Start();

}

private void MinimizeButton_Click(object sender, EventArgs e)
{

this.WindowState = FormWindowState.Minimized;
}

}
class User32
{
Expand Down
3 changes: 2 additions & 1 deletion code/WinUtils/FormUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Drawing;

namespace WinUtils
Expand All @@ -22,8 +23,8 @@ public static void ShowSystemMenu(IntPtr hwnd)
IntPtr hmenu = WinAPI.GetSystemMenu(hwnd, false);
IntPtr cmd = WinAPI.TrackPopupMenuEx(hmenu, Constants.TPM_LEFTBUTTON | Constants.TPM_RETURNCMD, (uint)defPnt.X, (uint)defPnt.Y, hwnd, IntPtr.Zero);


if (cmd != IntPtr.Zero)

WinAPI.PostMessage(hwnd, Constants.WM_SYSCOMMAND, cmd, IntPtr.Zero);

}
Expand Down

0 comments on commit 6306ada

Please sign in to comment.