-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
779 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ ipch/ | |
*.psess | ||
*.vsp | ||
*.vspx | ||
.vs | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,128 @@ | ||
using System; | ||
using Microsoft.Win32; | ||
using System; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Windows.Forms; | ||
using TimeWidget.Utils; | ||
|
||
namespace TimeWidget | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
|
||
private Int32 tmpX; | ||
private Int32 tmpY; | ||
private bool flMove = false; | ||
public string hms = "HH:mm:ss"; | ||
|
||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
|
||
labelTime.Text = DateTime.Now.ToString("HH:mm:ss"); | ||
|
||
labelTime.Text = DateTime.Now.ToString(hms); | ||
timerTime.Enabled = true; | ||
} | ||
|
||
private void Form1_MouseDown(object sender, MouseEventArgs e) | ||
private void Form1_Load(object sender, EventArgs e) | ||
{ | ||
base.Capture = false; | ||
Message m = Message.Create(base.Handle, 0xa1, new IntPtr(2), IntPtr.Zero); | ||
this.WndProc(ref m); | ||
} | ||
if (File.Exists("TimeWidgetOldVersion.exe")) | ||
{ | ||
File.Delete("TimeWidgetOldVersion.exe"); | ||
} | ||
|
||
private void выходToolStripMenuItem_Click(object sender, EventArgs e) | ||
{ | ||
Application.Exit(); | ||
Util.CheckUpdate(); | ||
|
||
using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\TimeWidget", true)) | ||
{ | ||
if (key.GetValue("TopMost") != null) | ||
{ | ||
bool topMost = key?.GetValue("TopMost")?.ToString() == "True"; | ||
_ = topMost == true ? TopMost = true : TopMost = false; | ||
} | ||
else | ||
{ | ||
key.SetValue("TopMost", false); | ||
} | ||
|
||
if (key.GetValue("TextColor") != null) | ||
{ | ||
object textColor = key?.GetValue("TextColor"); | ||
labelTime.ForeColor = ColorTranslator.FromWin32((int)textColor); | ||
} | ||
else | ||
{ | ||
key.SetValue("TextColor", ColorTranslator.ToWin32(Color.FromArgb(0, 255, 255, 255))); | ||
} | ||
|
||
if (key.GetValue("BackgroundColor") != null) | ||
{ | ||
object bgColor = key?.GetValue("BackgroundColor"); | ||
BackColor = ColorTranslator.FromWin32((int)bgColor); | ||
} | ||
else | ||
{ | ||
key.SetValue("BackgroundColor", ColorTranslator.ToWin32(Color.FromArgb(0, 29, 29, 29))); | ||
} | ||
|
||
if (key.GetValue("RunWithWindows") != null) | ||
{ | ||
|
||
} | ||
else | ||
{ | ||
key.SetValue("RunWithWindows", false); | ||
} | ||
|
||
if (key.GetValue("Font") != null) | ||
{ | ||
object font = key?.GetValue("Font"); | ||
labelTime.Font = new Font(font.ToString(), labelTime.Font.Size); | ||
} | ||
else | ||
{ | ||
key.SetValue("Font", labelTime.Font.Name); | ||
} | ||
} | ||
} | ||
|
||
private void вклToolStripMenuItem_Click(object sender, EventArgs e) | ||
private void Form1_MouseDown(object sender, MouseEventArgs e) | ||
{ | ||
TopMost = true; | ||
Capture = false; | ||
Message m = Message.Create(base.Handle, 0xa1, new IntPtr(2), IntPtr.Zero); | ||
WndProc(ref m); | ||
} | ||
|
||
private void выклToolStripMenuItem_Click(object sender, EventArgs e) | ||
private void выходToolStripMenuItem_Click(object sender, EventArgs e) | ||
{ | ||
TopMost = false; | ||
Application.Exit(); | ||
} | ||
|
||
private void timerTime_Tick(object sender, EventArgs e) | ||
{ | ||
DateTime now = DateTime.Now; | ||
labelTime.Text = now.ToString("HH:mm:ss"); | ||
labelTime.Text = now.ToString(hms); | ||
} | ||
|
||
private void labelTime_MouseMove(object sender, MouseEventArgs e) | ||
private void labelTime_MouseDown(object sender, MouseEventArgs e) | ||
{ | ||
if (flMove) | ||
{ | ||
this.Left = this.Left + (Cursor.Position.X - tmpX); | ||
this.Top = this.Top + (Cursor.Position.Y - tmpY); | ||
|
||
tmpX = Cursor.Position.X; | ||
tmpY = Cursor.Position.Y; | ||
} | ||
labelTime.Capture = false; | ||
Message m = Message.Create(base.Handle, 0xa1, new IntPtr(2), IntPtr.Zero); | ||
WndProc(ref m); | ||
} | ||
|
||
private void labelTime_MouseUp(object sender, MouseEventArgs e) | ||
private void настройкиToolStripMenuItem_Click(object sender, EventArgs e) | ||
{ | ||
flMove = false; | ||
if (Application.OpenForms["Settings"] == null) | ||
{ | ||
new Settings(this).Show(); | ||
} | ||
else | ||
{ | ||
Application.OpenForms["Settings"].Focus(); | ||
} | ||
} | ||
|
||
private void labelTime_MouseDown(object sender, MouseEventArgs e) | ||
private void Form1_FormClosed(object sender, FormClosedEventArgs e) | ||
{ | ||
tmpX = Cursor.Position.X; | ||
tmpY = Cursor.Position.Y; | ||
flMove = true; | ||
Application.Exit(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.