diff --git a/Momo.sln b/Momo.sln new file mode 100644 index 0000000..77efdb7 --- /dev/null +++ b/Momo.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2046 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Momo", "Momo\Momo.csproj", "{D6AA87B7-9503-4CBC-B4EB-2B34BE0EE96E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D6AA87B7-9503-4CBC-B4EB-2B34BE0EE96E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6AA87B7-9503-4CBC-B4EB-2B34BE0EE96E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6AA87B7-9503-4CBC-B4EB-2B34BE0EE96E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6AA87B7-9503-4CBC-B4EB-2B34BE0EE96E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6D77ECBE-EEDC-44AD-94DB-3350A3C22266} + EndGlobalSection +EndGlobal diff --git a/Momo/App.config b/Momo/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/Momo/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Momo/Momo.Designer.cs b/Momo/Momo.Designer.cs new file mode 100644 index 0000000..a5f3c64 --- /dev/null +++ b/Momo/Momo.Designer.cs @@ -0,0 +1,111 @@ +namespace Momo +{ + partial class Momo + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lblClock = new System.Windows.Forms.Label(); + this.lblDate = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // lblClock + // + this.lblClock.AutoSize = true; + this.lblClock.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblClock.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblClock.Location = new System.Drawing.Point(0, 20); + this.lblClock.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0); + this.lblClock.Name = "lblClock"; + this.lblClock.Size = new System.Drawing.Size(51, 18); + this.lblClock.TabIndex = 0; + this.lblClock.Text = "label1"; + this.lblClock.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lblDate + // + this.lblDate.AutoSize = true; + this.lblDate.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblDate.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblDate.Location = new System.Drawing.Point(0, 0); + this.lblDate.Margin = new System.Windows.Forms.Padding(0); + this.lblDate.Name = "lblDate"; + this.lblDate.Size = new System.Drawing.Size(51, 19); + this.lblDate.TabIndex = 2; + this.lblDate.Text = "label1"; + this.lblDate.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.AutoSize = true; + this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.lblDate, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.lblClock, 0, 1); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(51, 38); + this.tableLayoutPanel1.TabIndex = 3; + // + // Momo + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.BackColor = System.Drawing.SystemColors.Desktop; + this.ClientSize = new System.Drawing.Size(708, 487); + this.Controls.Add(this.tableLayoutPanel1); + this.Font = new System.Drawing.Font("Consolas", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.ForeColor = System.Drawing.Color.White; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "Momo"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "Form1"; + this.TopMost = true; + this.Load += new System.EventHandler(this.Momo_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblClock; + private System.Windows.Forms.Label lblDate; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + } +} + diff --git a/Momo/Momo.cs b/Momo/Momo.cs new file mode 100644 index 0000000..8611f40 --- /dev/null +++ b/Momo/Momo.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.IO; + +namespace Momo +{ + public partial class Momo : Form + { + private static readonly TimeSpan TIME_TOTAL = TimeSpan.FromHours(7.7 + 0.5); + private static readonly String DUMP_FILE = @"kassio"; + + private DateTime startTime; + private Boolean isMouseDown; + private Point lastMouseDownPosition; + + public Momo() + { + this.startTime = DateTime.Now; + + InitializeComponent(); + AddEvents(this); + + UpdateMomo(); + UpdatePosition(); + } + + private void Momo_Load(object sender, EventArgs e) + { + if (File.Exists(DUMP_FILE)) + { + String ticks = File.ReadAllText(DUMP_FILE); + DateTime dumpTime = new DateTime(long.Parse(ticks), DateTimeKind.Utc).ToLocalTime(); + if(dumpTime.Date.CompareTo(startTime.Date) == 0) + { + string text = "A current dump date was found.\n\n" + + "Dump Date:\t"+dumpTime+"\n" + + "Start Date:\t"+startTime+"\n\n" + + "Do you want to use the dump date?"; + string caption = "Dump Date Found"; + DialogResult result = MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + Console.WriteLine("Old start time " + startTime); + this.startTime = dumpTime; + Console.WriteLine("Using dump time as new start time " + startTime); + } + else + { + WriteDumpTime(); + } + } + } + else + { + WriteDumpTime(); + } + + Timer clockTimer = new Timer { Interval = 200 }; + clockTimer.Tick += ClockTimer_Tick; + clockTimer.Start(); + } + + private void WriteDumpTime() + { + Console.WriteLine("Writing new dump time " + startTime); + if (File.Exists(DUMP_FILE)) + { + if (File.Exists(DUMP_FILE + ".bak")) File.Delete(DUMP_FILE + ".bak"); + File.Move(DUMP_FILE, DUMP_FILE + ".bak"); + } + File.WriteAllText(@"kassio", startTime.ToUniversalTime().Ticks.ToString()); + } + + private void AddEvents(Control control) + { + control.MouseDown += Momo_MouseDown_Drag; + control.MouseUp += Momo_MouseUp_Drag; + control.MouseMove += Momo_MouseMove_Drag; + control.MouseClick += Momo_MouseClick_Drag; + control.MouseDoubleClick += Momo_DoubleClick_Close; + + if (control.Controls.Count == 0) return; + + foreach (Control childControl in control.Controls) + { + AddEvents(childControl); + } + } + + private void ClockTimer_Tick(object sender, EventArgs e) + { + UpdateMomo(); + } + + private void UpdateMomo() + { + UpdateDate(); + UpdateClock(); + } + + private void UpdateDate() + { + this.lblDate.Text = DateTime.Now.ToString("dd.MM.yyyy"); + } + + private void UpdateClock() + { + TimeSpan timeSpent = DateTime.Now.Subtract(startTime); + TimeSpan timeLeft = TIME_TOTAL.Subtract(timeSpent); + + DateTime endTime = startTime.Add(TIME_TOTAL); + + this.lblClock.Text = DateTime.Now.ToString("HH:mm") + " " + + (timeLeft.CompareTo(TimeSpan.Zero) < 0 ? "-" : "") + + timeLeft.ToString("hh\\:mm") + " " + + endTime.ToString("HH:mm"); + } + + private void UpdatePosition() + { + this.Location = new Point(Screen.PrimaryScreen.Bounds.Right - this.Width, + Screen.PrimaryScreen.WorkingArea.Bottom - this.Height); + } + + private void Momo_MouseDown_Drag(object sender, MouseEventArgs e) + { + this.isMouseDown = true; + this.lastMouseDownPosition = e.Location; + } + + private void Momo_MouseMove_Drag(object sender, MouseEventArgs e) + { + if (isMouseDown) + { + this.Location = new Point( + (this.Location.X - lastMouseDownPosition.X) + e.X, (this.Location.Y - lastMouseDownPosition.Y) + e.Y); + + this.Update(); + } + } + + private void Momo_MouseUp_Drag(object sender, MouseEventArgs e) + { + this.isMouseDown = false; + } + + private void Momo_MouseClick_Drag(object sender, MouseEventArgs e) + { + if(e.Button == MouseButtons.Right) + { + this.UpdatePosition(); + } + } + + private void Momo_DoubleClick_Close(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/Momo/Momo.csproj b/Momo/Momo.csproj new file mode 100644 index 0000000..dcd67b5 --- /dev/null +++ b/Momo/Momo.csproj @@ -0,0 +1,87 @@ + + + + + Debug + AnyCPU + {D6AA87B7-9503-4CBC-B4EB-2B34BE0EE96E} + WinExe + Momo + Momo + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Momo.cs + + + + + Momo.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + \ No newline at end of file diff --git a/Momo/Momo.resx b/Momo/Momo.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Momo/Momo.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Momo/Program.cs b/Momo/Program.cs new file mode 100644 index 0000000..78a6310 --- /dev/null +++ b/Momo/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Momo +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Momo()); + } + } +} diff --git a/Momo/Properties/AssemblyInfo.cs b/Momo/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3c9d370 --- /dev/null +++ b/Momo/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Momo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Momo")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d6aa87b7-9503-4cbc-b4eb-2b34be0ee96e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Momo/Properties/Resources.Designer.cs b/Momo/Properties/Resources.Designer.cs new file mode 100644 index 0000000..06be1cf --- /dev/null +++ b/Momo/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Momo.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Momo.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Momo/Properties/Resources.resx b/Momo/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Momo/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Momo/Properties/Settings.Designer.cs b/Momo/Properties/Settings.Designer.cs new file mode 100644 index 0000000..bd5057d --- /dev/null +++ b/Momo/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Momo.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Momo/Properties/Settings.settings b/Momo/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Momo/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Momo/res/kassiopeia.ico b/Momo/res/kassiopeia.ico new file mode 100644 index 0000000..d830897 Binary files /dev/null and b/Momo/res/kassiopeia.ico differ