Skip to content

Commit

Permalink
глобальное обновление
Browse files Browse the repository at this point in the history
  • Loading branch information
Stive99 committed Jun 1, 2022
1 parent 1c33e9b commit a169be0
Show file tree
Hide file tree
Showing 14 changed files with 779 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ ipch/
*.psess
*.vsp
*.vspx
.vs

# Guidance Automation Toolkit
*.gpState
Expand Down
51 changes: 16 additions & 35 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 89 additions & 35 deletions Form1.cs
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();
}
}
}
18 changes: 13 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;

namespace TimeWidget
Expand All @@ -18,13 +16,18 @@ static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += new ThreadExceptionEventHandler(Exception);

Process pr = RI();
/*Process pr = RI();
if (pr != null)
{
MessageBox.Show("Приложение уже запущено!", "Приложение запущено!");
return;
}
else

{*/
Application.Run(new Form1());
//}
}
private static Process RI()
{
Expand All @@ -42,5 +45,10 @@ private static Process RI()
}
return null;
}

static void Exception(object sender, ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.ToString());
}
}
}
8 changes: 4 additions & 4 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("TimeWidget")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Виджет времени")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TimeWidget")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © BZH Studio")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
Loading

0 comments on commit a169be0

Please sign in to comment.