aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYour Name <you@example.com>2019-01-16 02:48:17 +0900
committerYour Name <you@example.com>2019-01-16 02:48:17 +0900
commit96dfb5c08ffc78c7eafd833d2a4d5107d5c06d5b (patch)
tree0e3ff86fb69a3138f367cd1bf6d4bad433c2c37b
downloadwf-clock-96dfb5c08ffc78c7eafd833d2a4d5107d5c06d5b.tar.gz
initial commit
-rw-r--r--.gitattributes63
-rw-r--r--.gitignore261
-rw-r--r--README.txt9
-rw-r--r--WarframeClock.sln25
-rw-r--r--WarframeClock/App.config6
-rw-r--r--WarframeClock/ClockOverlay.cs196
-rw-r--r--WarframeClock/Native.cs69
-rw-r--r--WarframeClock/Program.cs136
-rw-r--r--WarframeClock/Properties/AssemblyInfo.cs36
-rw-r--r--WarframeClock/Properties/Resources.resx124
-rw-r--r--WarframeClock/Properties/Resources1.Designer.cs73
-rw-r--r--WarframeClock/Resources/TrayIcon.icobin0 -> 45451 bytes
-rw-r--r--WarframeClock/WarframeClock.csproj123
-rw-r--r--WarframeClock/packages.config8
14 files changed, 1129 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..1ff0c42
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln merge=binary
+#*.csproj merge=binary
+#*.vbproj merge=binary
+#*.vcxproj merge=binary
+#*.vcproj merge=binary
+#*.dbproj merge=binary
+#*.fsproj merge=binary
+#*.lsproj merge=binary
+#*.wixproj merge=binary
+#*.modelproj merge=binary
+#*.sqlproj merge=binary
+#*.wwaproj merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg binary
+#*.png binary
+#*.gif binary
+
+###############################################################################
+# diff behavior for common document formats
+#
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the
+# entries below.
+###############################################################################
+#*.doc diff=astextplain
+#*.DOC diff=astextplain
+#*.docx diff=astextplain
+#*.DOCX diff=astextplain
+#*.dot diff=astextplain
+#*.DOT diff=astextplain
+#*.pdf diff=astextplain
+#*.PDF diff=astextplain
+#*.rtf diff=astextplain
+#*.RTF diff=astextplain
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c4efe2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,261 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc \ No newline at end of file
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..c274a7f
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,9 @@
+Warframe Clock
+==============
+
+WORK IN PROGRESS
+
+License
+-------
+
+MIT \ No newline at end of file
diff --git a/WarframeClock.sln b/WarframeClock.sln
new file mode 100644
index 0000000..b5cb3dd
--- /dev/null
+++ b/WarframeClock.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.271
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarframeClock", "WarframeClock\WarframeClock.csproj", "{B6F30BD0-5917-4C89-8C8D-DEF0029E08A3}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B6F30BD0-5917-4C89-8C8D-DEF0029E08A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B6F30BD0-5917-4C89-8C8D-DEF0029E08A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B6F30BD0-5917-4C89-8C8D-DEF0029E08A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B6F30BD0-5917-4C89-8C8D-DEF0029E08A3}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {E2FD2F13-EFB9-4FB8-9382-108F4409943E}
+ EndGlobalSection
+EndGlobal
diff --git a/WarframeClock/App.config b/WarframeClock/App.config
new file mode 100644
index 0000000..ff3c507
--- /dev/null
+++ b/WarframeClock/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
+ </startup>
+</configuration>
diff --git a/WarframeClock/ClockOverlay.cs b/WarframeClock/ClockOverlay.cs
new file mode 100644
index 0000000..0e39049
--- /dev/null
+++ b/WarframeClock/ClockOverlay.cs
@@ -0,0 +1,196 @@
+using System;
+using System.Linq;
+using Process.NET;
+using Process.NET.Memory;
+using SharpDX;
+using SharpDX.Direct2D1;
+using SharpDX.DirectWrite;
+using SharpDX.DXGI;
+using SharpDX.Mathematics.Interop;
+using AlphaMode = SharpDX.Direct2D1.AlphaMode;
+using Color = System.Drawing.Color;
+
+namespace WarframeClock
+{
+ class ClockOverlay : IDisposable
+ {
+ private readonly string targetProcessName;
+ private Program.WorldStateDataStruct worldStateData;
+ private IntPtr targetWindowHandle;
+ private IntPtr handle;
+ private bool isVisible;
+ private bool isTopMost;
+ private IntPtr previousActiveWindow = IntPtr.Zero;
+ private Native.Rect parentBounds;
+
+ private WindowRenderTarget device;
+ private SharpDX.Direct2D1.Factory _factory;
+ private SharpDX.DirectWrite.Factory _fontFactory;
+ private static readonly Color gdiTransparent = Color.Transparent;
+ private readonly RawColor4 transparent = new RawColor4(gdiTransparent.R, gdiTransparent.G, gdiTransparent.B,
+ gdiTransparent.A);
+ private TextFormat textFont;
+ private SolidColorBrush textBrush;
+
+ public ClockOverlay(Program.WorldStateDataStruct worldStateData, string targetProcessName)
+ {
+ this.worldStateData = worldStateData;
+ this.targetProcessName = targetProcessName;
+
+ SetupOverlayWindow();
+ }
+
+ ~ClockOverlay()
+ {
+ Dispose();
+ }
+
+ private void SetupOverlayWindow()
+ {
+ isVisible = false;
+
+ parentBounds = new Native.Rect()
+ {
+ Top = 0,
+ Left = 0,
+ Right = Native.GetSystemMetrics(0),
+ Bottom = Native.GetSystemMetrics(1),
+ };
+
+ handle = Native.CreateWindowEx(
+ 0x8000000 /* WS_EX_NOACTIVATE */
+ | 0x80000 /* WS_EX_LAYERED */
+ | 0x80 /* WS_EX_TOOLWINDOW */
+ | 0x20 /* WS_EX_TRANSPARENT */,
+ "Static",
+ "",
+ 0x8000000 /* WS_DISABLED */
+ | 0x80000000 /* WS_POPUP */,
+ parentBounds.Left,
+ parentBounds.Top,
+ parentBounds.Right - parentBounds.Left,
+ parentBounds.Bottom - parentBounds.Top,
+ IntPtr.Zero,
+ IntPtr.Zero,
+ IntPtr.Zero,
+ IntPtr.Zero);
+ if (handle == IntPtr.Zero)
+ {
+ throw new Exception("Could not create OverlayWindow");
+ }
+ Native.SetLayeredWindowAttributes(handle, 0, 255, 0x00000002 /* LWA_ALPHA */);
+
+ // Setup Direct*
+ _factory = new SharpDX.Direct2D1.Factory();
+ _fontFactory = new SharpDX.DirectWrite.Factory();
+
+ var targetProperties = new HwndRenderTargetProperties
+ {
+ Hwnd = handle,
+ PixelSize = new Size2(
+ parentBounds.Right - parentBounds.Left,
+ parentBounds.Bottom - parentBounds.Top),
+ PresentOptions = PresentOptions.None
+ };
+
+ var prop = new RenderTargetProperties(RenderTargetType.Hardware,
+ new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None,
+ FeatureLevel.Level_DEFAULT);
+ device = new WindowRenderTarget(_factory, prop, targetProperties);
+
+ textBrush = new SolidColorBrush(device, new RawColor4(0xff, 0xff, 0xff, 0x7f));
+ textFont = new TextFormat(_fontFactory, "Segoe UI", FontWeight.Normal, FontStyle.Normal, 12);
+ }
+
+ public void Dispose()
+ {
+ textBrush.Dispose();
+ textFont.Dispose();
+ _fontFactory.Dispose();
+ _factory.Dispose();
+ device.Dispose();
+
+ Native.DestroyWindow(handle);
+ }
+
+ public void Update()
+ {
+ GetTargetWindow();
+ if (targetWindowHandle != IntPtr.Zero != isVisible)
+ {
+ isVisible = !isVisible;
+ Native.ShowWindow(handle, isVisible ? (uint)5 : 0);
+ }
+ if (!isVisible)
+ return;
+
+ var currentActiveWindow = Native.GetForegroundWindow();
+ if (currentActiveWindow == targetWindowHandle != isTopMost)
+ {
+ isTopMost = !isTopMost;
+ Native.SetWindowPos(handle, isTopMost ? -1 : -2, 0, 0, 0, 0,
+ 0x0001 /* SWP_NOSIZE */ | 0x0002 /* SWP_NOMOVE */);
+ }
+
+ Native.Rect newBounds;
+ Native.GetWindowRect(targetWindowHandle, out newBounds);
+ if (parentBounds.Left != newBounds.Left || parentBounds.Right != newBounds.Right ||
+ parentBounds.Top != newBounds.Top || parentBounds.Bottom != newBounds.Bottom)
+ {
+ parentBounds = newBounds;
+
+ var width = parentBounds.Right - parentBounds.Left;
+ var height = parentBounds.Bottom - parentBounds.Top;
+
+ Native.SetWindowPos(handle, 0, parentBounds.Left, parentBounds.Top, width, height,
+ 0x0004 /* SWP_NOZORDER */);
+
+ device.Resize(new Size2(width, height));
+
+ Native.RawMargin _margin;
+ _margin.cxLeftWidth = parentBounds.Left;
+ _margin.cxRightWidth = width;
+ _margin.cyBottomHeight = height;
+ _margin.cyTopHeight = parentBounds.Top;
+ Native.DwmExtendFrameIntoClientArea(handle, ref _margin);
+ }
+
+ // Render text
+ device.BeginDraw();
+ device.Clear(transparent);
+
+ var infoText = $"{worldStateData.CetusExpiryString()} {worldStateData.VallisExpiryString()}";
+ device.DrawText(infoText, textFont,
+ new RawRectangleF(30, parentBounds.Bottom - parentBounds.Top - 50, float.MaxValue, float.MaxValue),
+ textBrush);
+
+ device.EndDraw();
+ }
+
+ private void GetTargetWindow()
+ {
+ if (targetWindowHandle == IntPtr.Zero || Native.IsWindow(targetWindowHandle) == 0)
+ {
+ targetWindowHandle = IntPtr.Zero;
+
+ var process = System.Diagnostics.Process.GetProcessesByName(targetProcessName).FirstOrDefault();
+ if (process == null)
+ {
+ Console.WriteLine($"ClockOverlay: Process with name={targetProcessName} not found; skipping");
+ return;
+ }
+ try
+ {
+ using (var processSharp = new ProcessSharp(process, MemoryType.Remote))
+ {
+ targetWindowHandle = processSharp.WindowFactory.MainWindow.Handle;
+ }
+ }
+ catch (InvalidOperationException)
+ {
+ // e.g. process is exiting
+ }
+ }
+ }
+ }
+}
diff --git a/WarframeClock/Native.cs b/WarframeClock/Native.cs
new file mode 100644
index 0000000..e1203a8
--- /dev/null
+++ b/WarframeClock/Native.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace WarframeClock
+{
+ class Native
+ {
+ [DllImport("user32.dll")]
+ public static extern IntPtr CreateWindowEx(
+ uint dwExStyle,
+ string lpClassName,
+ string lpWindowName,
+ uint dwStyle,
+ int x,
+ int y,
+ int nWidth,
+ int nHeight,
+ IntPtr hWndParent,
+ IntPtr hMenu,
+ IntPtr hInstance,
+ IntPtr lpParam);
+
+ [DllImport("user32.dll")]
+ public static extern int DestroyWindow(IntPtr hwnd);
+
+ [DllImport("user32.dll")]
+ public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy,
+ uint uFlags);
+
+ [DllImport("user32.dll")]
+ public static extern int GetSystemMetrics(int index);
+
+ [DllImport("user32.dll")]
+ public static extern int IsWindow(IntPtr hWnd);
+
+ [DllImport("user32.dll")]
+ public static extern IntPtr GetForegroundWindow();
+
+ [DllImport("user32.dll")]
+ public static extern int ShowWindow(IntPtr hWnd, uint nCmdShow);
+
+ [DllImport("user32.dll")]
+ public static extern int GetWindowRect(IntPtr hwnd, out Rect lpRect);
+
+ [DllImport("user32.dll")]
+ public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Rect
+ {
+ public int Left;
+ public int Top;
+ public int Right;
+ public int Bottom;
+ }
+
+ [DllImport("dwmapi.dll")]
+ public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref RawMargin pMargins);
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct RawMargin
+ {
+ public int cxLeftWidth;
+ public int cxRightWidth;
+ public int cyTopHeight;
+ public int cyBottomHeight;
+ }
+ }
+} \ No newline at end of file
diff --git a/WarframeClock/Program.cs b/WarframeClock/Program.cs
new file mode 100644
index 0000000..9d287f0
--- /dev/null
+++ b/WarframeClock/Program.cs
@@ -0,0 +1,136 @@
+using System;
+using System.Net.Http;
+using System.Threading;
+using System.Windows.Forms;
+using Newtonsoft.Json;
+
+namespace WarframeClock
+{
+ class Program
+ {
+ public class WorldStateDataStruct
+ {
+ public long CetusExpiry { get; set; } = -1;
+
+ public string CetusExpiryString()
+ {
+ if (CetusExpiry < 0)
+ return "Plains: <NOT READY>";
+
+ long cetusLen = 150 * 60, cetusDayLen = 100 * 60;
+
+ var currentTime = GetCurrentTime();
+ var cetusBegin = CetusExpiry / 1000 - cetusLen;
+ cetusBegin += (currentTime - cetusBegin) / cetusLen * cetusLen;
+
+ if (currentTime < cetusBegin + cetusDayLen)
+ return $"Plains: ☀ {GetReadableTimeSpan(cetusBegin + cetusDayLen - currentTime)}";
+ else
+ return $"Plains: 🌙 {GetReadableTimeSpan(cetusBegin + cetusLen - currentTime)}";
+ }
+
+ public string VallisExpiryString()
+ {
+ long currentTime = GetCurrentTime();
+ long dayStart = 1542131224;
+ dayStart += (currentTime - dayStart) / 1600 * 1600;
+
+ if (currentTime - dayStart < 400)
+ return $"Vallis: ❄️[→☁] {GetReadableTimeSpan(dayStart + 400 - currentTime)}";
+ else if (currentTime - dayStart < 800)
+ return $"Vallis: ☁[→🌣] {GetReadableTimeSpan(dayStart + 800 - currentTime)}";
+ else if (currentTime - dayStart < 1200)
+ return $"Vallis: 🌣[→☁] {GetReadableTimeSpan(dayStart + 1200 - currentTime)}";
+ else
+ return $"Vallis: ☁[→❄️] {GetReadableTimeSpan(dayStart + 1600 - currentTime)}";
+ }
+
+ private long GetCurrentTime() => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
+
+ private string GetReadableTimeSpan(long span) => $"{span / 60}m{span % 60}s";
+ }
+
+ public static WorldStateDataStruct WorldStateData = new WorldStateDataStruct();
+
+ [STAThread]
+ static void Main(string[] args)
+ {
+ StartNotifyIcon();
+ StartWorldStateFetch();
+ StartOverlay();
+ }
+
+ private static void StartNotifyIcon()
+ {
+ var thread = new Thread(delegate ()
+ {
+ var iconMenu = new ContextMenu();
+ var icon = new NotifyIcon()
+ {
+ Text = "Warframe Clock",
+ ContextMenu = iconMenu,
+ Icon = Properties.Resources.TrayIcon
+ };
+
+ iconMenu.MenuItems.Add("Quit", (_, __) =>
+ {
+ icon.Dispose();
+ Environment.Exit(0);
+ });
+ icon.Visible = true;
+
+ Application.Run();
+ });
+ thread.Start();
+ }
+
+ private static void StartWorldStateFetch()
+ {
+ var httpClient = new HttpClient();
+
+ var period = 10 * 60 * 1000; // 10 Minutes
+ var timer = new System.Threading.Timer(state =>
+ {
+ lock (state)
+ {
+ var res = httpClient.GetAsync("http://content.warframe.com/dynamic/worldState.php").Result;
+ if (!res.IsSuccessStatusCode)
+ {
+ Console.WriteLine("WorldState: Could not fetch worldState.php");
+ return;
+ }
+
+ var json = res.Content.ReadAsStringAsync().Result;
+ dynamic obj = JsonConvert.DeserializeObject(json);
+
+ dynamic cetusSyndicate = null;
+ foreach (var syndicateMission in obj.SyndicateMissions)
+ {
+ if (syndicateMission.Tag == "CetusSyndicate")
+ cetusSyndicate = syndicateMission;
+ }
+ if (cetusSyndicate == null)
+ {
+ Console.WriteLine("WorldState: CetusSyndicate missions not found");
+ return;
+ }
+
+ dynamic cetusExpiry = cetusSyndicate.Expiry["$date"]["$numberLong"];
+ Console.WriteLine($"WorldState: CetusSyndicate missions expire at {cetusExpiry}");
+
+ WorldStateData.CetusExpiry = cetusExpiry;
+ }
+ }, new object(), 0, period);
+ }
+
+ private static void StartOverlay()
+ {
+ var plugin = new ClockOverlay(WorldStateData, "Warframe.x64");
+ while (true)
+ {
+ plugin.Update();
+ Thread.Sleep(16);
+ }
+ }
+ }
+}
diff --git a/WarframeClock/Properties/AssemblyInfo.cs b/WarframeClock/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b24e4b0
--- /dev/null
+++ b/WarframeClock/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("WarframeClock")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WarframeClock")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[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("b6f30bd0-5917-4c89-8c8d-def0029e08a3")]
+
+// 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/WarframeClock/Properties/Resources.resx b/WarframeClock/Properties/Resources.resx
new file mode 100644
index 0000000..a03fc62
--- /dev/null
+++ b/WarframeClock/Properties/Resources.resx
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="TrayIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\TrayIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+</root> \ No newline at end of file
diff --git a/WarframeClock/Properties/Resources1.Designer.cs b/WarframeClock/Properties/Resources1.Designer.cs
new file mode 100644
index 0000000..4c6da81
--- /dev/null
+++ b/WarframeClock/Properties/Resources1.Designer.cs
@@ -0,0 +1,73 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// 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.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace WarframeClock.Properties {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // 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", "15.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() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WarframeClock.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ /// </summary>
+ internal static System.Drawing.Icon TrayIcon {
+ get {
+ object obj = ResourceManager.GetObject("TrayIcon", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
+ }
+}
diff --git a/WarframeClock/Resources/TrayIcon.ico b/WarframeClock/Resources/TrayIcon.ico
new file mode 100644
index 0000000..5d06b9f
--- /dev/null
+++ b/WarframeClock/Resources/TrayIcon.ico
Binary files differ
diff --git a/WarframeClock/WarframeClock.csproj b/WarframeClock/WarframeClock.csproj
new file mode 100644
index 0000000..1ec7fd2
--- /dev/null
+++ b/WarframeClock/WarframeClock.csproj
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{B6F30BD0-5917-4C89-8C8D-DEF0029E08A3}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <RootNamespace>WarframeClock</RootNamespace>
+ <AssemblyName>WarframeClock</AssemblyName>
+ <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Deterministic>true</Deterministic>
+ <TargetFrameworkProfile />
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <PropertyGroup />
+ <PropertyGroup>
+ <SignAssembly>false</SignAssembly>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="Process.NET, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\Process.NET.1.0.8\lib\Process.NET.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
+ <HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpDX.Direct2D1, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
+ <HintPath>..\packages\SharpDX.Direct2D1.4.2.0\lib\net45\SharpDX.Direct2D1.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpDX.DXGI, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
+ <HintPath>..\packages\SharpDX.DXGI.4.2.0\lib\net45\SharpDX.DXGI.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ClockOverlay.cs" />
+ <Compile Include="Native.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Properties\Resources1.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\TrayIcon.ico" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources1.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include=".NETFramework,Version=v4.6.2">
+ <Visible>False</Visible>
+ <ProductName>Microsoft .NET Framework 4.6.2 %28x86 and x64%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/WarframeClock/packages.config b/WarframeClock/packages.config
new file mode 100644
index 0000000..07efd4d
--- /dev/null
+++ b/WarframeClock/packages.config
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
+ <package id="Process.NET" version="1.0.8" targetFramework="net462" />
+ <package id="SharpDX" version="4.2.0" targetFramework="net462" />
+ <package id="SharpDX.Direct2D1" version="4.2.0" targetFramework="net462" />
+ <package id="SharpDX.DXGI" version="4.2.0" targetFramework="net462" />
+</packages> \ No newline at end of file