diff --git a/ColorControl/ColorControl.csproj b/ColorControl/ColorControl.csproj
index 0c6b14d..cbe23ba 100644
--- a/ColorControl/ColorControl.csproj
+++ b/ColorControl/ColorControl.csproj
@@ -18,8 +18,8 @@
Maassoft
Maassoft
0
- 9.5.0.0
- 9.5.0.0
+ 9.6.0.0
+ 9.6.0.0
false
true
false
@@ -48,14 +48,10 @@
MinimumRecommendedRules.ruleset
-
+
+
-
- True
- True
- Settings.settings
-
Form
@@ -74,6 +70,9 @@
PreserveNewest
+
+ Never
+
@@ -105,9 +104,9 @@
-
- MSBuild:Compile
-
+
+ MSBuild:Compile
+
@@ -116,14 +115,8 @@
-
- Designer
-
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
+
+ Designer
+
\ No newline at end of file
diff --git a/ColorControl/Common/ProcessExtensions.cs b/ColorControl/Common/ProcessExtensions.cs
index 0cccd8a..e3e552c 100644
--- a/ColorControl/Common/ProcessExtensions.cs
+++ b/ColorControl/Common/ProcessExtensions.cs
@@ -1,7 +1,11 @@
-using System;
+using ColorControl.Native;
+using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
+using System.Runtime.InteropServices;
+using static ColorControl.Native.WinApi;
namespace ColorControl.Common
{
@@ -46,6 +50,18 @@ namespace ColorControl.Common
public static Process Parent(this Process process, IEnumerable processes = null)
{
+ if (Utils.IsAdministrator())
+ {
+ try
+ {
+ return GetParentProcess(process.Handle);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
var indexedProcessName = FindIndexedProcessName(process.Id, process.ProcessName, processes);
if (indexedProcessName == null)
{
@@ -54,5 +70,25 @@ namespace ColorControl.Common
return FindPidFromIndexedProcessName(indexedProcessName, processes);
}
+
+ public static Process GetParentProcess(IntPtr handle)
+ {
+ var pbi = new ParentProcessUtilities();
+ int returnLength;
+ int status = WinApi.NtQueryInformationProcess(handle, 0, ref pbi, Marshal.SizeOf(pbi), out returnLength);
+ if (status != 0)
+ throw new Win32Exception(status);
+
+ try
+ {
+ return Process.GetProcessById(pbi.InheritedFromUniqueProcessId.ToInt32());
+ }
+ catch (ArgumentException)
+ {
+ // not found
+ return null;
+ }
+ }
+
}
}
diff --git a/ColorControl/Forms/DarkModeUtils.cs b/ColorControl/Forms/DarkModeUtils.cs
index f99318c..0965ea3 100644
--- a/ColorControl/Forms/DarkModeUtils.cs
+++ b/ColorControl/Forms/DarkModeUtils.cs
@@ -16,7 +16,7 @@ namespace ColorControl.Forms
private static Dictionary> _defaultColors = new Dictionary>();
private static ToolStripRenderer _defaultRenderer;
private static Type[] _windowColorTypes = new[] { typeof(GroupBox), typeof(TabPage), typeof(UserControl) };
- private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
+ public const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
public class DarkModeToolStripRenderer : ToolStripProfessionalRenderer
{
diff --git a/ColorControl/MainForm.Designer.cs b/ColorControl/MainForm.Designer.cs
index ca56c3b..2c66fba 100644
--- a/ColorControl/MainForm.Designer.cs
+++ b/ColorControl/MainForm.Designer.cs
@@ -41,6 +41,7 @@
lblFixChromeFontsDescription = new System.Windows.Forms.Label();
chkFixChromeFonts = new System.Windows.Forms.CheckBox();
grpGeneralOptions = new System.Windows.Forms.GroupBox();
+ btnOptionsLog = new System.Windows.Forms.Button();
btnOptionsAdvanced = new System.Windows.Forms.Button();
chkOptionsUseDarkMode = new System.Windows.Forms.CheckBox();
chkAutoInstallUpdates = new System.Windows.Forms.CheckBox();
@@ -57,11 +58,6 @@
chkMinimizeOnClose = new System.Windows.Forms.CheckBox();
chkStartMinimized = new System.Windows.Forms.CheckBox();
chkStartAfterLogin = new System.Windows.Forms.CheckBox();
- tabLog = new System.Windows.Forms.TabPage();
- lblShowLog = new System.Windows.Forms.Label();
- cbxLogType = new System.Windows.Forms.ComboBox();
- btnClearLog = new System.Windows.Forms.Button();
- edtLog = new System.Windows.Forms.TextBox();
tabInfo = new System.Windows.Forms.TabPage();
grpNVIDIAInfo = new System.Windows.Forms.GroupBox();
btnRefreshNVIDIAInfo = new System.Windows.Forms.Button();
@@ -71,13 +67,11 @@
label7 = new System.Windows.Forms.Label();
lblInfo = new System.Windows.Forms.Label();
btnUpdate = new System.Windows.Forms.Button();
- btnOptionsLog = new System.Windows.Forms.Button();
tcMain.SuspendLayout();
tabOptions.SuspendLayout();
grpOptionsModules.SuspendLayout();
grpMiscellaneousOptions.SuspendLayout();
grpGeneralOptions.SuspendLayout();
- tabLog.SuspendLayout();
tabInfo.SuspendLayout();
grpNVIDIAInfo.SuspendLayout();
groupBox3.SuspendLayout();
@@ -87,7 +81,6 @@
//
tcMain.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
tcMain.Controls.Add(tabOptions);
- tcMain.Controls.Add(tabLog);
tcMain.Controls.Add(tabInfo);
tcMain.Location = new System.Drawing.Point(14, 14);
tcMain.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
@@ -243,6 +236,17 @@
grpGeneralOptions.TabStop = false;
grpGeneralOptions.Text = "General";
//
+ // btnOptionsLog
+ //
+ btnOptionsLog.Location = new System.Drawing.Point(103, 172);
+ btnOptionsLog.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ btnOptionsLog.Name = "btnOptionsLog";
+ btnOptionsLog.Size = new System.Drawing.Size(88, 27);
+ btnOptionsLog.TabIndex = 68;
+ btnOptionsLog.Text = "Logging...";
+ btnOptionsLog.UseVisualStyleBackColor = true;
+ btnOptionsLog.Click += btnOptionsLog_Click;
+ //
// btnOptionsAdvanced
//
btnOptionsAdvanced.Location = new System.Drawing.Point(7, 172);
@@ -435,67 +439,6 @@
chkStartAfterLogin.UseVisualStyleBackColor = true;
chkStartAfterLogin.CheckedChanged += chkStartAfterLogin_CheckedChanged;
//
- // tabLog
- //
- tabLog.Controls.Add(lblShowLog);
- tabLog.Controls.Add(cbxLogType);
- tabLog.Controls.Add(btnClearLog);
- tabLog.Controls.Add(edtLog);
- tabLog.Location = new System.Drawing.Point(4, 24);
- tabLog.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
- tabLog.Name = "tabLog";
- tabLog.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
- tabLog.Size = new System.Drawing.Size(1114, 539);
- tabLog.TabIndex = 3;
- tabLog.Text = "Log";
- tabLog.UseVisualStyleBackColor = true;
- //
- // lblShowLog
- //
- lblShowLog.AutoSize = true;
- lblShowLog.Location = new System.Drawing.Point(8, 14);
- lblShowLog.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- lblShowLog.Name = "lblShowLog";
- lblShowLog.Size = new System.Drawing.Size(88, 15);
- lblShowLog.TabIndex = 33;
- lblShowLog.Text = "Show log from:";
- //
- // cbxLogType
- //
- cbxLogType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- cbxLogType.FormattingEnabled = true;
- cbxLogType.Items.AddRange(new object[] { "Main application", "Service" });
- cbxLogType.Location = new System.Drawing.Point(102, 9);
- cbxLogType.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
- cbxLogType.Name = "cbxLogType";
- cbxLogType.Size = new System.Drawing.Size(189, 23);
- cbxLogType.TabIndex = 32;
- cbxLogType.SelectedIndexChanged += cbxLogType_SelectedIndexChanged;
- //
- // btnClearLog
- //
- btnClearLog.Location = new System.Drawing.Point(299, 6);
- btnClearLog.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
- btnClearLog.Name = "btnClearLog";
- btnClearLog.Size = new System.Drawing.Size(88, 27);
- btnClearLog.TabIndex = 2;
- btnClearLog.Text = "Clear log";
- btnClearLog.UseVisualStyleBackColor = true;
- btnClearLog.Click += btnClearLog_Click;
- //
- // edtLog
- //
- edtLog.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
- edtLog.Location = new System.Drawing.Point(7, 40);
- edtLog.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
- edtLog.MaxLength = 327670;
- edtLog.Multiline = true;
- edtLog.Name = "edtLog";
- edtLog.ReadOnly = true;
- edtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- edtLog.Size = new System.Drawing.Size(1098, 478);
- edtLog.TabIndex = 0;
- //
// tabInfo
//
tabInfo.Controls.Add(grpNVIDIAInfo);
@@ -604,17 +547,6 @@
btnUpdate.Visible = false;
btnUpdate.Click += btnUpdate_Click;
//
- // btnOptionsLog
- //
- btnOptionsLog.Location = new System.Drawing.Point(103, 172);
- btnOptionsLog.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
- btnOptionsLog.Name = "btnOptionsLog";
- btnOptionsLog.Size = new System.Drawing.Size(88, 27);
- btnOptionsLog.TabIndex = 68;
- btnOptionsLog.Text = "Logging...";
- btnOptionsLog.UseVisualStyleBackColor = true;
- btnOptionsLog.Click += btnOptionsLog_Click;
- //
// MainForm
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@@ -646,8 +578,6 @@
grpMiscellaneousOptions.PerformLayout();
grpGeneralOptions.ResumeLayout(false);
grpGeneralOptions.PerformLayout();
- tabLog.ResumeLayout(false);
- tabLog.PerformLayout();
tabInfo.ResumeLayout(false);
grpNVIDIAInfo.ResumeLayout(false);
groupBox3.ResumeLayout(false);
@@ -662,8 +592,6 @@
private System.Windows.Forms.GroupBox grpGeneralOptions;
private System.Windows.Forms.CheckBox chkStartMinimized;
private System.Windows.Forms.CheckBox chkStartAfterLogin;
- private System.Windows.Forms.TabPage tabLog;
- private System.Windows.Forms.TextBox edtLog;
private System.Windows.Forms.TabPage tabInfo;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.ListBox lbPlugins;
@@ -679,7 +607,6 @@
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox edtBlankScreenSaverShortcut;
private System.Windows.Forms.CheckBox chkMinimizeOnClose;
- private System.Windows.Forms.Button btnClearLog;
private System.Windows.Forms.CheckBox chkMinimizeToSystemTray;
private System.Windows.Forms.CheckBox chkCheckForUpdates;
private System.Windows.Forms.CheckBox chkGdiScaling;
@@ -690,8 +617,6 @@
private System.Windows.Forms.RadioButton rbElevationNone;
private System.Windows.Forms.Button btnElevationInfo;
private System.Windows.Forms.Button btnStartStopService;
- private System.Windows.Forms.Label lblShowLog;
- private System.Windows.Forms.ComboBox cbxLogType;
private System.Windows.Forms.CheckBox chkAutoInstallUpdates;
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.GroupBox grpOptionsModules;
diff --git a/ColorControl/MainForm.cs b/ColorControl/MainForm.cs
index 1de9884..3e1e997 100644
--- a/ColorControl/MainForm.cs
+++ b/ColorControl/MainForm.cs
@@ -762,11 +762,7 @@ NOTE: installing the service may cause a User Account Control popup.");
private void InitSelectedTab()
{
- if (tcMain.SelectedTab == tabLog)
- {
- LoadLog();
- }
- else if (tcMain.SelectedTab == tabInfo)
+ if (tcMain.SelectedTab == tabInfo)
{
LoadInfo();
}
@@ -948,48 +944,6 @@ NOTE: installing the service may cause a User Account Control popup.");
await _samsungPanel?.ApplyPreset(preset);
}
- private void LoadLog()
- {
- var logType = cbxLogType.SelectedIndex;
-
- if (logType == -1)
- {
- cbxLogType.SelectedIndex = 0;
- return;
- }
-
- string text;
-
- if (logType == 0)
- {
- var filename = Path.Combine(_dataDir, "LogFile.txt");
-
- text = Utils.ReadText(filename);
-
- text ??= "No log file found";
- }
- else
- {
- if (Utils.IsServiceRunning())
- {
- var message = new SvcMessage { MessageType = SvcMessageType.GetLog };
-
- var result = PipeUtils.SendMessage(message);
-
- text = result?.Data ?? "Cannot get log from service";
- }
- else
- {
- text = "The service is not installed or not running";
- }
- }
-
- edtLog.Text = text;
-
- edtLog.SelectionStart = text.Length;
- edtLog.ScrollToCaret();
- }
-
private void LoadInfo()
{
grpNVIDIAInfo.Visible = _serviceManager.NvService != null;
@@ -1035,40 +989,12 @@ NOTE: installing the service may cause a User Account Control popup.");
private void MainForm_Activated(object sender, EventArgs e)
{
- if (tcMain.SelectedTab == tabLog)
- {
- LoadLog();
- }
- else if (tcMain.SelectedTab?.Controls.Count > 0 && tcMain.SelectedTab.Controls[0] is IModulePanel panel)
+ if (tcMain.SelectedTab?.Controls.Count > 0 && tcMain.SelectedTab.Controls[0] is IModulePanel panel)
{
panel.UpdateInfo();
}
}
- private void btnClearLog_Click(object sender, EventArgs e)
- {
- var logType = cbxLogType.SelectedIndex;
-
- if (logType == -1)
- {
- return;
- }
-
- if (logType == 0)
- {
- var filename = Program.LogFilename;
- if (File.Exists(filename))
- {
- File.Delete(filename);
- }
- }
- else
- {
- PipeUtils.SendMessage(SvcMessageType.ClearLog);
- }
- edtLog.Clear();
- }
-
private void AfterInitialized()
{
_nvPanel?.AfterInitialized();
@@ -1096,7 +1022,7 @@ NOTE: installing the service may cause a User Account Control popup.");
BeginInvoke(() => HandleCheckForUpdates(latest));
}
- private void HandleCheckForUpdates(dynamic latest)
+ private void HandleCheckForUpdates(dynamit)
{
if (latest?.tag_name == null)
{
@@ -1104,9 +1030,33 @@ NOTE: installing the service may cause a User Account Control popup.");
}
var currentVersion = Application.ProductVersion;
+ var cvParts = currentVersion.Split(".");
- var newVersion = latest.tag_name.Value.Substring(1);
- if (newVersion.CompareTo(currentVersion) > 0)
+ var newVersion = (string)latest.tag_name.Value.Substring(1);
+ var nvParts = newVersion.Split(".");
+
+ bool CompareVersions()
+ {
+ var result = true;
+
+ for (var i = 0; i < nvParts.Length; i++)
+ {
+ var part = nvParts[i];
+ var cvPart = cvParts[i];
+
+ if (Utils.ParseInt(part) >= Utils.ParseInt(cvPart))
+ {
+ continue;
+ }
+
+ result = false;
+ break;
+ }
+
+ return result;
+ }
+
+ if (nvParts.Length != cvParts.Length || CompareVersions())
{
_updateHtmlUrl = latest.html_url.Value;
@@ -1362,11 +1312,6 @@ Currently ColorControl is {(Utils.IsAdministrator() ? "" : "not ")}running as ad
UpdateServiceInfo();
}
- private void cbxLogType_SelectedIndexChanged(object sender, EventArgs e)
- {
- LoadLog();
- }
-
private async void MainForm_Click(object sender, EventArgs e)
{
//_powerEventDispatcher.SendEvent(PowerEventDispatcher.Event_Shutdown);
diff --git a/ColorControl/Native/WinApi.cs b/ColorControl/Native/WinApi.cs
index 2733a90..aadf42a 100644
--- a/ColorControl/Native/WinApi.cs
+++ b/ColorControl/Native/WinApi.cs
@@ -96,6 +96,18 @@ namespace ColorControl.Native
public MessageFilterInfo info;
}
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ParentProcessUtilities
+ {
+ // These members must match PROCESS_BASIC_INFORMATION
+ internal IntPtr Reserved1;
+ internal IntPtr PebBaseAddress;
+ internal IntPtr Reserved2_0;
+ internal IntPtr Reserved2_1;
+ internal IntPtr UniqueProcessId;
+ internal IntPtr InheritedFromUniqueProcessId;
+ }
+
public const int ENUM_CURRENT_SETTINGS = -1;
public const int ENUM_REGISTRY_SETTINGS = -2;
@@ -149,5 +161,8 @@ namespace ColorControl.Native
[DllImport("dwmapi.dll", PreserveSig = true)]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
+
+ [DllImport("ntdll.dll")]
+ public static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessUtilities processInformation, int processInformationLength, out int returnLength);
}
}
diff --git a/ColorControl/Properties/Settings.Designer.cs b/ColorControl/Properties/Settings.Designer.cs
deleted file mode 100644
index 3532d1d..0000000
--- a/ColorControl/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 ColorControl.Properties {
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.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/ColorControl/Properties/Settings.settings b/ColorControl/Properties/Settings.settings
deleted file mode 100644
index 3964565..0000000
--- a/ColorControl/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/ColorControl/Services/Samsung/SamsungPanel.Designer.cs b/ColorControl/Services/Samsung/SamsungPanel.Designer.cs
index 7779aba..6921d6d 100644
--- a/ColorControl/Services/Samsung/SamsungPanel.Designer.cs
+++ b/ColorControl/Services/Samsung/SamsungPanel.Designer.cs
@@ -360,6 +360,7 @@
chkSamsungRemoteControlShow.TabIndex = 43;
chkSamsungRemoteControlShow.Text = "Remote Control";
chkSamsungRemoteControlShow.UseVisualStyleBackColor = true;
+ chkSamsungRemoteControlShow.Visible = false;
chkSamsungRemoteControlShow.CheckedChanged += chkSamsungRemoteControlShow_CheckedChanged;
//
// label3
diff --git a/ColorControl/Services/Samsung/SamsungPanel.cs b/ColorControl/Services/Samsung/SamsungPanel.cs
index 2fec244..c3587e7 100644
--- a/ColorControl/Services/Samsung/SamsungPanel.cs
+++ b/ColorControl/Services/Samsung/SamsungPanel.cs
@@ -41,6 +41,8 @@ namespace ColorControl.Services.Samsung
InitializeComponent();
+ scSamsungController.Panel2Collapsed = true;
+
FillLgPresets();
FormUtils.InitSortState(lvSamsungPresets, _config.LgPresetsSortState);
@@ -816,7 +818,7 @@ Do you want to continue?"
private void chkSamsungRemoteControlShow_CheckedChanged(object sender, EventArgs e)
{
- scSamsungController.Panel2Collapsed = !chkSamsungRemoteControlShow.Checked;
+ //scSamsungController.Panel2Collapsed = !chkSamsungRemoteControlShow.Checked;
//_samsungService.Config.ShowRemoteControl = chkSamsungRemoteControlShow.Checked;
}
diff --git a/ColorControl/Services/Samsung/SamsungPanel.resx b/ColorControl/Services/Samsung/SamsungPanel.resx
index 877bf37..ab6c3a4 100644
--- a/ColorControl/Services/Samsung/SamsungPanel.resx
+++ b/ColorControl/Services/Samsung/SamsungPanel.resx
@@ -120,9 +120,6 @@
288, 16
-
- 17, 17
-
147, 17
diff --git a/ColorControl/Themes/DarkTheme.xaml b/ColorControl/Themes/DarkTheme.xaml
new file mode 100644
index 0000000..c552809
--- /dev/null
+++ b/ColorControl/Themes/DarkTheme.xaml
@@ -0,0 +1,4569 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ColorControl/XForms/LogWindow.xaml b/ColorControl/XForms/LogWindow.xaml
index ea2fe17..e2fa2b6 100644
--- a/ColorControl/XForms/LogWindow.xaml
+++ b/ColorControl/XForms/LogWindow.xaml
@@ -11,11 +11,12 @@
Height="600"
WindowStartupLocation="CenterOwner"
SnapsToDevicePixels="True"
+ Style="{DynamicResource CustomWindowStyle}"
d:DesignHeight="450" d:DesignWidth="800" Loaded="Window_Loaded">
- Log level:
+ Log level:
Trace
Debug
@@ -30,11 +31,19 @@
+
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ColorControl/XForms/LogWindow.xaml.cs b/ColorControl/XForms/LogWindow.xaml.cs
index a6c3b14..765e3b6 100644
--- a/ColorControl/XForms/LogWindow.xaml.cs
+++ b/ColorControl/XForms/LogWindow.xaml.cs
@@ -1,9 +1,16 @@
using ColorControl.Common;
+using ColorControl.Forms;
+using ColorControl.Native;
+using ColorControl.Svc;
+using DJ;
using NLog;
using System;
+using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
+using System.Linq;
using System.Windows;
+using System.Windows.Interop;
using System.Windows.Navigation;
namespace ColorControl.XForms
@@ -36,9 +43,9 @@ namespace ColorControl.XForms
public static void CreateAndShow(bool show = true)
{
- if (Application.Current == null)
+ if (System.Windows.Application.Current == null)
{
- new Application();
+ new System.Windows.Application();
}
_window ??= new LogWindow();
@@ -46,12 +53,47 @@ namespace ColorControl.XForms
if (show)
{
_window.WindowState = WindowState.Normal;
+ _window.InitTheme();
_window.Show();
+ _window.InitThemeAfterShow();
_window.Topmost = true;
_window.Topmost = false;
}
}
+ protected void InitThemeAfterShow()
+ {
+ var useDarkTheme = DarkModeUtils.UseDarkMode;
+
+ var handle = new WindowInteropHelper(_window).Handle;
+
+ var value = useDarkTheme ? 1 : 0;
+
+ // Takes care of title bar
+ WinApi.DwmSetWindowAttribute(handle, DarkModeUtils.DWMWA_USE_IMMERSIVE_DARK_MODE, ref value, 4);
+ }
+
+ protected void InitTheme()
+ {
+ if (DarkModeUtils.UseDarkMode)
+ {
+ var dict = new ResourceDictionary { Source = new Uri($"Themes/DarkTheme.xaml", UriKind.Relative) };
+
+ if (Application.Current.Resources.MergedDictionaries.Any())
+ {
+ Application.Current.Resources.MergedDictionaries[0] = dict;
+ }
+ else
+ {
+ Application.Current.Resources.MergedDictionaries.Add(dict);
+ }
+ }
+ else
+ {
+ Application.Current.Resources.MergedDictionaries.Clear();
+ }
+ }
+
protected override void OnClosing(CancelEventArgs e)
{
e.Cancel = true;
@@ -72,19 +114,47 @@ namespace ColorControl.XForms
private void RawLog_Click(object sender, RoutedEventArgs e)
{
var context = AppContext.CurrentContext;
- var logFile = Path.Combine(context.DataPath, "LogFile.txt");
+
+ string logFile;
+ if (tabControl.SelectedIndex == 0)
+ {
+ logFile = Program.LogFilename;
+ }
+ else
+ {
+ if (!Utils.IsServiceRunning())
+ {
+ MessageForms.WarningOk("Service is not running");
+ return;
+ }
+
+ var message = new SvcMessage { MessageType = SvcMessageType.GetLog };
+
+ var result = PipeUtils.SendMessage(message);
+
+ var logData = result?.Data ?? "Cannot get log from service";
+
+ logFile = Path.Combine(Path.GetTempPath(), "CCServiceLogFile.txt");
+
+ Utils.WriteText(logFile, logData);
+ }
+
+ if (!File.Exists(logFile))
+ {
+ MessageForms.WarningOk("Log file not found.");
+ return;
+ }
Utils.StartProcess(logFile);
}
private void LoadOlder_Click(object sender, RoutedEventArgs e)
{
- var context = AppContext.CurrentContext;
- var logFile = Path.Combine(context.DataPath, "LogFile.txt");
+ var viewer = GetCurrentViewer();
- var lines = Utils.ReadLines(logFile);
+ var lines = LoadLog();
- logViewer.LoadLines(lines);
+ viewer.LoadLines(lines);
}
private void Close_Click(object sender, RoutedEventArgs e)
@@ -103,17 +173,72 @@ namespace ColorControl.XForms
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- if (logViewer.HasEvents())
+ var viewer = GetCurrentViewer();
+
+ if (viewer.HasEvents())
{
return;
}
var context = AppContext.CurrentContext;
- var logFile = Path.Combine(context.DataPath, "LogFile.txt");
- var lines = Utils.ReadLines(logFile);
+ var lines = LoadLog();
- logViewer.LoadLines(lines, context.StartTime);
+ viewer.LoadLines(lines, context.StartTime);
+ }
+
+ private List LoadLog()
+ {
+ string logFile;
+
+ if (tabControl.SelectedIndex == 0)
+ {
+ return Utils.ReadLines(Program.LogFilename);
+ }
+
+ if (Utils.IsServiceRunning())
+ {
+ var message = new SvcMessage { MessageType = SvcMessageType.GetLog };
+
+ var result = PipeUtils.SendMessage(message);
+
+ logFile = result?.Data ?? "Cannot get log from service";
+ }
+ else
+ {
+ logFile = "The service is not installed or not running";
+ }
+
+ return logFile.Split("\r\n").ToList();
+ }
+
+ private NLogViewer GetCurrentViewer()
+ {
+ return tabControl.SelectedIndex == 0 ? logViewerApplication : logViewerService;
+ }
+
+ private void DeleteLog_Click(object sender, RoutedEventArgs e)
+ {
+ if (MessageForms.QuestionYesNo("Are you sure you want to delete the log? This will clear all logging.") != System.Windows.Forms.DialogResult.Yes)
+ {
+ return;
+ }
+
+ if (tabControl.SelectedIndex == 0)
+ {
+ var filename = Program.LogFilename;
+ if (File.Exists(filename))
+ {
+ File.Delete(filename);
+ }
+
+ logViewerApplication.ClearCommand.Execute(null);
+ }
+ else
+ {
+ PipeUtils.SendMessage(SvcMessageType.ClearLog);
+ logViewerService.ClearCommand.Execute(null);
+ }
}
}
}
\ No newline at end of file
diff --git a/NLogViewer/NLogViewer.xaml b/NLogViewer/NLogViewer.xaml
index 664f7fc..aa8b62c 100644
--- a/NLogViewer/NLogViewer.xaml
+++ b/NLogViewer/NLogViewer.xaml
@@ -123,14 +123,6 @@
-
-
-
-
-
-
-
-
@@ -172,20 +164,40 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/NLogViewer/NLogViewer.xaml.cs b/NLogViewer/NLogViewer.xaml.cs
index 9c556ce..d63c52b 100644
--- a/NLogViewer/NLogViewer.xaml.cs
+++ b/NLogViewer/NLogViewer.xaml.cs
@@ -562,9 +562,16 @@ namespace DJ
if (lastEventInfo != null && !string.IsNullOrWhiteSpace(line))
{
lastEventInfo.Message += "\r\n" + line;
+
+ continue;
}
- continue;
+ if (lines.Count > 1)
+ {
+ continue;
+ }
+
+ parts = new string[] { DateTime.Now.ToString(), "info", "", line };
}
var timeStamp = DateTime.Parse(parts[0]);
diff --git a/NLogViewer/global.json b/NLogViewer/global.json
deleted file mode 100644
index f45c840..0000000
--- a/NLogViewer/global.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "sdk": {
- "version": "6.0.101",
- "rollForward": "disable"
- }
-}
\ No newline at end of file