/trunk/Winify/Form1.cs |
@@ -47,7 +47,6 @@ |
|
// Upgrade settings if required. |
if (!ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).HasFile) |
{ |
if (Properties.Settings.Default.UpdateRequired) |
{ |
Properties.Settings.Default.Upgrade(); |
@@ -60,7 +59,6 @@ |
Process.Start(Application.ExecutablePath); |
Environment.Exit(0); |
} |
} |
|
// Bind to settings changed event. |
Properties.Settings.Default.SettingsLoaded += Default_SettingsLoaded; |
@@ -126,10 +124,7 @@ |
|
private async void SettingsToolStripMenuItem_Click(object sender, EventArgs e) |
{ |
if (_settingsForm != null) |
{ |
return; |
} |
if (_settingsForm != null) return; |
|
var servers = await LoadServers(); |
var announcements = await LoadAnnouncements(); |
@@ -170,7 +165,6 @@ |
var announcements = await LoadAnnouncements(); |
|
foreach (var announcement in announcements.Announcement) |
{ |
if (announcement.AppId == e.Notification.AppId) |
{ |
var configuredNotification = new Notification( |
@@ -183,7 +177,6 @@ |
|
return; |
} |
} |
|
var notification = new Notification( |
$"{e.Notification.Title} ({e.Notification.Server.Name}/{e.Notification.AppId})", |
@@ -196,10 +189,7 @@ |
|
private void SettingsForm_Closing(object sender, CancelEventArgs e) |
{ |
if (_settingsForm == null) |
{ |
return; |
} |
if (_settingsForm == null) return; |
|
_settingsForm.Save -= SettingsForm_Save; |
_settingsForm.Closing -= SettingsForm_Closing; |
@@ -209,10 +199,7 @@ |
|
private void AboutToolStripMenuItem_Click(object sender, EventArgs e) |
{ |
if (_aboutForm != null) |
{ |
return; |
} |
if (_aboutForm != null) return; |
|
_aboutForm = new AboutForm(); |
_aboutForm.Closing += AboutForm_Closing; |
@@ -221,10 +208,7 @@ |
|
private void AboutForm_Closing(object sender, CancelEventArgs e) |
{ |
if (_aboutForm == null) |
{ |
return; |
} |
if (_aboutForm == null) return; |
|
_aboutForm.Closing -= AboutForm_Closing; |
_aboutForm.Dispose(); |
@@ -250,7 +234,7 @@ |
private static async Task SaveAnnouncements(Announcements.Announcements announcements) |
{ |
switch (await ServersSerialization.Serialize(announcements, Constants.AnnouncementsFile, "Announcements", |
"<!ATTLIST Announcements xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>")) |
"<!ATTLIST Announcements xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>")) |
{ |
case SerializationFailure serializationFailure: |
Log.Warning(serializationFailure.Exception, "Unable to serialize announcements."); |
@@ -275,7 +259,7 @@ |
} |
|
switch (await ServersSerialization.Serialize(@protected, Constants.ServersFile, "Servers", |
"<!ATTLIST Servers xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>")) |
"<!ATTLIST Servers xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>")) |
{ |
case SerializationFailure serializationFailure: |
Log.Warning(serializationFailure.Exception, "Unable to serialize servers."); |
@@ -286,9 +270,7 @@ |
private static async Task<Announcements.Announcements> LoadAnnouncements() |
{ |
if (!Directory.Exists(Constants.UserApplicationDirectory)) |
{ |
Directory.CreateDirectory(Constants.UserApplicationDirectory); |
} |
|
var deserializationResult = |
await ServersSerialization.Deserialize<Announcements.Announcements>(Constants.AnnouncementsFile, |
@@ -309,9 +291,7 @@ |
private static async Task<global::Servers.Servers> LoadServers() |
{ |
if (!Directory.Exists(Constants.UserApplicationDirectory)) |
{ |
Directory.CreateDirectory(Constants.UserApplicationDirectory); |
} |
|
var deserializationResult = |
await ServersSerialization.Deserialize<global::Servers.Servers>(Constants.ServersFile, |
/trunk/Winify/Gotify/GotifyConnection.cs |
@@ -56,15 +56,12 @@ |
|
public void Start() |
{ |
if (!Uri.TryCreate(_server.Url, UriKind.Absolute, out var httpUri)) |
{ |
return; |
} |
if (!Uri.TryCreate(_server.Url, UriKind.Absolute, out var httpUri)) return; |
|
// Build the web sockets URI. |
var webSocketsUriBuilder = new UriBuilder(httpUri); |
webSocketsUriBuilder.Scheme = "ws"; |
webSocketsUriBuilder.Path = $"{webSocketsUriBuilder.Path}/stream"; |
webSocketsUriBuilder.Path = Path.Combine($"{webSocketsUriBuilder.Path}", "stream"); |
var webSocketsUri = webSocketsUriBuilder.Uri; |
|
_cancellationTokenSource = new CancellationTokenSource(); |
@@ -75,10 +72,7 @@ |
|
public void Stop() |
{ |
if (_cancellationTokenSource != null) |
{ |
_cancellationTokenSource.Cancel(); |
} |
if (_cancellationTokenSource != null) _cancellationTokenSource.Cancel(); |
} |
|
#endregion |
@@ -86,7 +80,7 @@ |
#region Private Methods |
|
private async Task Run(Uri webSocketsUri, Uri httpUri, string username, string password, |
CancellationToken cancellationToken) |
CancellationToken cancellationToken) |
{ |
try |
{ |
@@ -108,20 +102,15 @@ |
|
var result = await webSocketClient.ReceiveAsync(payload, cancellationToken); |
|
if (result.Count == 0) |
{ |
continue; |
} |
if (result.Count == 0) continue; |
|
if (payload.Array == null || payload.Count == 0) |
{ |
continue; |
} |
if (payload.Array == null || payload.Count == 0) continue; |
|
var message = Encoding.UTF8.GetString(payload.Array, 0, payload.Count); |
|
if (!(JsonConvert.DeserializeObject<GotifyNotification>(message) is GotifyNotification |
gotifyNotification)) |
var gotifyNotification = JsonConvert.DeserializeObject<GotifyNotification>(message); |
|
if (gotifyNotification == null) |
{ |
Log.Warning($"Could not deserialize gotify notification: {message}"); |
|
@@ -130,11 +119,9 @@ |
|
gotifyNotification.Server = _server; |
|
if (!Uri.TryCreate($"{httpUri}/application", UriKind.Absolute, |
out var applicationUri)) |
{ |
if (!Uri.TryCreate(Path.Combine($"{httpUri}", "application"), UriKind.Absolute, |
out var applicationUri)) |
continue; |
} |
|
var image = await RetrieveGotifyApplicationImage(gotifyNotification.AppId, httpUri, |
applicationUri, auth, cancellationToken); |
@@ -165,8 +152,8 @@ |
} |
|
private static async Task<Image> RetrieveGotifyApplicationImage(int appId, Uri httpUri, Uri applicationUri, |
string auth, |
CancellationToken cancellationToken) |
string auth, |
CancellationToken cancellationToken) |
{ |
using (var httpClient = new HttpClient()) |
{ |
@@ -180,23 +167,15 @@ |
var gotifyApplications = |
JsonConvert.DeserializeObject<GotifyApplication[]>(applications); |
|
if (gotifyApplications == null) |
{ |
return null; |
} |
if (gotifyApplications == null) return null; |
|
foreach (var application in gotifyApplications) |
{ |
if (application.Id != appId) |
{ |
continue; |
} |
if (application.Id != appId) continue; |
|
if (!Uri.TryCreate($"{httpUri}/{application.Image}", UriKind.Absolute, |
out var applicationImageUri)) |
{ |
if (!Uri.TryCreate(Path.Combine($"{httpUri}", $"{application.Image}"), UriKind.Absolute, |
out var applicationImageUri)) |
continue; |
} |
|
var imageResponse = await httpClient.GetAsync(applicationImageUri, cancellationToken); |
|
/trunk/Winify/Properties/Annotations.cs |
@@ -141,13 +141,6 @@ |
AttributeTargets.Property | AttributeTargets.Delegate)] |
public sealed class StringFormatMethodAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string FormatParameterName { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
/// <param name="formatParameterName"> |
@@ -159,6 +152,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string FormatParameterName { get; } |
|
#endregion |
} |
|
/// <summary> |
@@ -195,13 +194,6 @@ |
AllowMultiple = true)] |
public sealed class ValueProviderAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Name { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public ValueProviderAttribute([NotNull] string name) |
@@ -210,6 +202,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Name { get; } |
|
#endregion |
} |
|
/// <summary> |
@@ -366,8 +364,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[CanBeNull] |
public string ParameterName { get; } |
[CanBeNull] public string ParameterName { get; } |
|
#endregion |
|
@@ -446,8 +443,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Contract { get; } |
[NotNull] public string Contract { get; } |
|
public bool ForceFullStates { get; } |
|
@@ -547,13 +543,6 @@ |
[BaseTypeRequired(typeof(Attribute))] |
public sealed class BaseTypeRequiredAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public Type BaseType { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public BaseTypeRequiredAttribute([NotNull] Type baseType) |
@@ -562,6 +551,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public Type BaseType { get; } |
|
#endregion |
} |
|
/// <summary> |
@@ -618,11 +613,9 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[UsedImplicitly] |
public ImplicitUseKindFlags UseKindFlags { get; } |
[UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; } |
|
[UsedImplicitly] |
public ImplicitUseTargetFlags TargetFlags { get; } |
[UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; } |
|
#endregion |
|
@@ -708,8 +701,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[CanBeNull] |
public string Comment { get; } |
[CanBeNull] public string Comment { get; } |
|
#endregion |
|
@@ -771,8 +763,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[CanBeNull] |
public string Justification { get; } |
[CanBeNull] public string Justification { get; } |
|
#endregion |
|
@@ -824,8 +815,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[CanBeNull] |
public string BasePath { get; } |
[CanBeNull] public string BasePath { get; } |
|
#endregion |
|
@@ -935,13 +925,6 @@ |
AllowMultiple = true)] |
public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Format { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) |
@@ -950,6 +933,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Format { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, |
@@ -956,13 +945,6 @@ |
AllowMultiple = true)] |
public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Format { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) |
@@ -971,6 +953,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Format { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, |
@@ -977,13 +965,6 @@ |
AllowMultiple = true)] |
public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Format { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) |
@@ -992,6 +973,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Format { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, |
@@ -998,13 +985,6 @@ |
AllowMultiple = true)] |
public sealed class AspMvcMasterLocationFormatAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Format { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AspMvcMasterLocationFormatAttribute([NotNull] string format) |
@@ -1013,6 +993,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Format { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, |
@@ -1019,13 +1005,6 @@ |
AllowMultiple = true)] |
public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Format { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) |
@@ -1034,6 +1013,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Format { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, |
@@ -1040,13 +1025,6 @@ |
AllowMultiple = true)] |
public sealed class AspMvcViewLocationFormatAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Format { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AspMvcViewLocationFormatAttribute([NotNull] string format) |
@@ -1055,6 +1033,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Format { get; } |
|
#endregion |
} |
|
/// <summary> |
@@ -1069,8 +1053,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[CanBeNull] |
public string AnonymousProperty { get; } |
[CanBeNull] public string AnonymousProperty { get; } |
|
#endregion |
|
@@ -1098,8 +1081,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[CanBeNull] |
public string AnonymousProperty { get; } |
[CanBeNull] public string AnonymousProperty { get; } |
|
#endregion |
|
@@ -1129,8 +1111,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[CanBeNull] |
public string AnonymousProperty { get; } |
[CanBeNull] public string AnonymousProperty { get; } |
|
#endregion |
|
@@ -1270,8 +1251,7 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[CanBeNull] |
public string Name { get; } |
[CanBeNull] public string Name { get; } |
|
#endregion |
|
@@ -1292,13 +1272,6 @@ |
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] |
public sealed class HtmlAttributeValueAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Name { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public HtmlAttributeValueAttribute([NotNull] string name) |
@@ -1307,6 +1280,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Name { get; } |
|
#endregion |
} |
|
/// <summary> |
@@ -1351,12 +1330,6 @@ |
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] |
public sealed class CollectionAccessAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
public CollectionAccessType CollectionAccessType { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public CollectionAccessAttribute(CollectionAccessType collectionAccessType) |
@@ -1365,6 +1338,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
public CollectionAccessType CollectionAccessType { get; } |
|
#endregion |
} |
|
/// <summary> |
@@ -1405,12 +1384,6 @@ |
[AttributeUsage(AttributeTargets.Parameter)] |
public sealed class AssertionConditionAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
public AssertionConditionType ConditionType { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AssertionConditionAttribute(AssertionConditionType conditionType) |
@@ -1419,6 +1392,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
public AssertionConditionType ConditionType { get; } |
|
#endregion |
} |
|
/// <summary> |
@@ -1543,16 +1522,6 @@ |
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] |
public sealed class AspChildControlTypeAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string TagName { get; } |
|
[NotNull] |
public Type ControlType { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType) |
@@ -1562,6 +1531,14 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string TagName { get; } |
|
[NotNull] public Type ControlType { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] |
@@ -1582,13 +1559,6 @@ |
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] |
public sealed class AspRequiredAttributeAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Attribute { get; } |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
|
public AspRequiredAttributeAttribute([NotNull] string attribute) |
@@ -1597,17 +1567,17 @@ |
} |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Property)] |
public sealed class AspTypePropertyAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
public bool CreateConstructorReferences { get; } |
[NotNull] public string Attribute { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Property)] |
public sealed class AspTypePropertyAttribute : Attribute |
{ |
#region Constructors, Destructors and Finalizers |
|
public AspTypePropertyAttribute(bool createConstructorReferences) |
@@ -1616,18 +1586,17 @@ |
} |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
public sealed class RazorImportNamespaceAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Name { get; } |
public bool CreateConstructorReferences { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
public sealed class RazorImportNamespaceAttribute : Attribute |
{ |
#region Constructors, Destructors and Finalizers |
|
public RazorImportNamespaceAttribute([NotNull] string name) |
@@ -1636,21 +1605,17 @@ |
} |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
public sealed class RazorInjectionAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Type { get; } |
[NotNull] public string Name { get; } |
|
[NotNull] |
public string FieldName { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
public sealed class RazorInjectionAttribute : Attribute |
{ |
#region Constructors, Destructors and Finalizers |
|
public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName) |
@@ -1660,18 +1625,19 @@ |
} |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
public sealed class RazorDirectiveAttribute : Attribute |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string Directive { get; } |
[NotNull] public string Type { get; } |
|
[NotNull] public string FieldName { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
public sealed class RazorDirectiveAttribute : Attribute |
{ |
#region Constructors, Destructors and Finalizers |
|
public RazorDirectiveAttribute([NotNull] string directive) |
@@ -1680,6 +1646,12 @@ |
} |
|
#endregion |
|
#region Public Enums, Properties and Fields |
|
[NotNull] public string Directive { get; } |
|
#endregion |
} |
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
@@ -1687,11 +1659,9 @@ |
{ |
#region Public Enums, Properties and Fields |
|
[NotNull] |
public string BaseType { get; } |
[NotNull] public string BaseType { get; } |
|
[CanBeNull] |
public string PageName { get; } |
[CanBeNull] public string PageName { get; } |
|
#endregion |
|
/trunk/Winify/Utilities/Miscellaneous.cs |
@@ -17,21 +17,18 @@ |
public static TimeSpan GetIdleTime() |
{ |
var lastInPut = new Natives.LASTINPUTINFO(); |
lastInPut.cbSize = (uint) Marshal.SizeOf(lastInPut); |
lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut); |
Natives.GetLastInputInfo(ref lastInPut); |
|
return TimeSpan.FromMilliseconds((uint) Environment.TickCount - lastInPut.dwTime); |
return TimeSpan.FromMilliseconds((uint)Environment.TickCount - lastInPut.dwTime); |
} |
|
public static bool LaunchOnBootSet(bool enable) |
{ |
using (var key = Registry.CurrentUser.OpenSubKey |
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) |
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) |
{ |
if (key == null) |
{ |
return false; |
} |
if (key == null) return false; |
|
switch (enable) |
{ |
@@ -50,7 +47,7 @@ |
public static bool LaunchOnBootGet() |
{ |
using (var key = Registry.CurrentUser.OpenSubKey |
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) |
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) |
{ |
return key?.GetValue(Constants.AssemblyName) != null; |
} |
@@ -64,18 +61,12 @@ |
/// <remarks>Do not enable double buffering on RDP: https://devblogs.microsoft.com/oldnewthing/20060103-12/?p=32793</remarks> |
public static bool SetDoubleBuffered(this Control control) |
{ |
if (SystemInformation.TerminalServerSession) |
{ |
return false; |
} |
if (SystemInformation.TerminalServerSession) return false; |
|
var dgvType = control.GetType(); |
var pi = dgvType.GetProperty("DoubleBuffered", |
BindingFlags.Instance | BindingFlags.NonPublic); |
if (pi == null) |
{ |
return false; |
} |
if (pi == null) return false; |
|
pi.SetValue(control, true, null); |
|
@@ -87,7 +78,7 @@ |
var iconBytes = await LoadResource(resource); |
using (var iconMemoryStream = new MemoryStream(iconBytes)) |
{ |
var bitmap = (Bitmap) Image.FromStream(iconMemoryStream); |
var bitmap = (Bitmap)Image.FromStream(iconMemoryStream); |
var bitmapIntPtr = bitmap.GetHicon(); |
var icon = Icon.FromHandle(bitmapIntPtr); |
return icon; |
@@ -100,10 +91,7 @@ |
|
using (var manifestResourceStream = assembly.GetManifestResourceStream(resource)) |
{ |
if (manifestResourceStream == null) |
{ |
return null; |
} |
if (manifestResourceStream == null) return null; |
|
var memoryStream = new MemoryStream(); |
|
@@ -119,7 +107,7 @@ |
{ |
if (control.InvokeRequired) |
{ |
control.BeginInvoke((MethodInvoker) delegate { action(control); }); |
control.BeginInvoke((MethodInvoker)delegate { action(control); }); |
return; |
} |
|
@@ -129,14 +117,14 @@ |
public static T MapValueToRange<T>(this T value, T xMin, T xMax, T yMin, T yMax) |
where T : struct, IComparable<T>, IConvertible |
{ |
return (dynamic) yMin + |
((dynamic) yMax - (dynamic) yMin) * ((dynamic) value - (dynamic) xMin) / |
((dynamic) xMax - (dynamic) xMin); |
return (dynamic)yMin + |
((dynamic)yMax - (dynamic)yMin) * ((dynamic)value - (dynamic)xMin) / |
((dynamic)xMax - (dynamic)xMin); |
} |
|
public static IEnumerable<TU> SequenceSubtract<TU, TV>(this IEnumerable<TU> a, |
IEnumerable<TV> b, |
Func<TU, TV, bool> cmp) |
IEnumerable<TV> b, |
Func<TU, TV, bool> cmp) |
{ |
var eb = new List<TV>(b); |
|
@@ -144,17 +132,11 @@ |
{ |
while (ea.MoveNext()) |
{ |
if (ea.Current == null) |
{ |
continue; |
} |
if (ea.Current == null) continue; |
|
foreach (var ib in eb) |
{ |
if (cmp.Invoke(ea.Current, ib)) |
{ |
continue; |
} |
if (cmp.Invoke(ea.Current, ib)) continue; |
|
yield return ea.Current; |
|
@@ -175,22 +157,18 @@ |
var name = "MachineGuid"; |
|
using (var localMachineX64View = |
RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) |
RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) |
{ |
using (var rk = localMachineX64View.OpenSubKey(location)) |
{ |
if (rk == null) |
{ |
throw new KeyNotFoundException( |
string.Format("Key Not Found: {0}", location)); |
} |
|
var machineGuid = rk.GetValue(name); |
if (machineGuid == null) |
{ |
throw new IndexOutOfRangeException( |
string.Format("Index Not Found: {0}", name)); |
} |
|
return machineGuid.ToString(); |
} |
/trunk/Winify/Winify.csproj |
@@ -12,6 +12,8 @@ |
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
<Deterministic>true</Deterministic> |
<TargetFrameworkProfile /> |
<NuGetPackageImportStamp> |
</NuGetPackageImportStamp> |
</PropertyGroup> |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
<PlatformTarget>AnyCPU</PlatformTarget> |
@@ -39,14 +41,24 @@ |
<StartupObject /> |
</PropertyGroup> |
<ItemGroup> |
<Reference Include="AutoUpdater.NET, Version=1.7.0.0, Culture=neutral, PublicKeyToken=501435c91b35f4bc, processorArchitecture=MSIL"> |
<HintPath>..\packages\Autoupdater.NET.Official.1.7.0\lib\net45\AutoUpdater.NET.dll</HintPath> |
<Reference Include="AutoUpdater.NET, Version=1.7.5.0, Culture=neutral, PublicKeyToken=501435c91b35f4bc, processorArchitecture=MSIL"> |
<HintPath>..\packages\Autoupdater.NET.Official.1.7.5\lib\net45\AutoUpdater.NET.dll</HintPath> |
</Reference> |
<Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.1293.44, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL"> |
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.1293.44\lib\net45\Microsoft.Web.WebView2.Core.dll</HintPath> |
</Reference> |
<Reference Include="Microsoft.Web.WebView2.WinForms, Version=1.0.1293.44, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL"> |
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.1293.44\lib\net45\Microsoft.Web.WebView2.WinForms.dll</HintPath> |
</Reference> |
<Reference Include="Microsoft.Web.WebView2.Wpf, Version=1.0.1293.44, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL"> |
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.1293.44\lib\net45\Microsoft.Web.WebView2.Wpf.dll</HintPath> |
</Reference> |
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> |
</Reference> |
<Reference Include="PresentationFramework" /> |
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> |
<HintPath>..\packages\Serilog.2.11.0\lib\net45\Serilog.dll</HintPath> |
<HintPath>..\packages\Serilog.2.12.0\lib\net45\Serilog.dll</HintPath> |
</Reference> |
<Reference Include="Serilog.Sinks.File, Version=5.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL"> |
<HintPath>..\packages\Serilog.Sinks.File.5.0.0\lib\net45\Serilog.Sinks.File.dll</HintPath> |
@@ -57,6 +69,7 @@ |
</Reference> |
<Reference Include="System.Configuration" /> |
<Reference Include="System.Core" /> |
<Reference Include="System.Data" /> |
<Reference Include="System.Net.WebSockets.Client.Managed, Version=1.0.22.0, Culture=neutral, processorArchitecture=MSIL"> |
<HintPath>..\packages\System.Net.WebSockets.Client.Managed.1.0.22\lib\net45\System.Net.WebSockets.Client.Managed.dll</HintPath> |
</Reference> |
@@ -63,6 +76,7 @@ |
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\portable-net45+win8+wp8+wpa81\System.Numerics.Vectors.dll</HintPath> |
</Reference> |
<Reference Include="System.Runtime.Serialization" /> |
<Reference Include="System.Speech" /> |
<Reference Include="System.Windows" /> |
<Reference Include="System.Xaml" /> |
@@ -175,4 +189,11 @@ |
</ItemGroup> |
<ItemGroup /> |
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1293.44\build\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1293.44\build\Microsoft.Web.WebView2.targets')" /> |
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
<PropertyGroup> |
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
</PropertyGroup> |
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1293.44\build\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1293.44\build\Microsoft.Web.WebView2.targets'))" /> |
</Target> |
</Project> |