mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-25 15:20:10 +00:00
Version 1.1
This commit is contained in:
parent
6fa4dfadda
commit
d4c4203931
14 changed files with 1534 additions and 294 deletions
|
@ -15,33 +15,36 @@ namespace MSFSPopoutPanelManager
|
||||||
{
|
{
|
||||||
public class AnalysisEngine
|
public class AnalysisEngine
|
||||||
{
|
{
|
||||||
[DllImport("user32.dll", EntryPoint = "GetWindowText",
|
|
||||||
ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)]
|
|
||||||
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount);
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
private static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr lParam);
|
private static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr lParam);
|
||||||
|
|
||||||
[DllImport("user32.dll", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
|
|
||||||
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||||
public static extern Int32 GetClassName(IntPtr hWnd, StringBuilder StrPtrClassName, Int32 nMaxCount);
|
public static extern Int32 GetClassName(IntPtr hWnd, StringBuilder StrPtrClassName, Int32 nMaxCount);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||||
|
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern bool SetWindowText(System.IntPtr hwnd, System.String lpString);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern int GetWindowRect(IntPtr hwnd, out Rect lpRect);
|
private static extern int GetWindowRect(IntPtr hwnd, out Rect lpRect);
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
|
[DllImport("user32.dll")]
|
||||||
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
|
static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll")]
|
||||||
|
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, uint wFlags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
static extern bool SetForegroundWindow(IntPtr hWnd);
|
static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||||
|
|
||||||
private delegate bool EnumWindowProc(IntPtr hwnd, IntPtr lParam);
|
private delegate bool EnumWindowProc(IntPtr hwnd, IntPtr lParam);
|
||||||
private const short SWP_NOZORDER = 0X4;
|
const int SWP_SHOWWINDOW = 0x0040;
|
||||||
private const int SWP_SHOWWINDOW = 0x0040;
|
|
||||||
|
|
||||||
|
|
||||||
public AnalysisEngine() { }
|
public AnalysisEngine() { }
|
||||||
|
|
||||||
|
@ -91,8 +94,16 @@ namespace MSFSPopoutPanelManager
|
||||||
childWindow.ClassName = className.ToString();
|
childWindow.ClassName = className.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all child windows where class name is not 'AceApp'
|
// Remove all child windows where class name is not 'AceApp' and try to determine popout type
|
||||||
simWindow.ChildWindowsData.RemoveAll(x => x.ClassName != "AceApp" || (x.Title != null && x.Title.Contains("Microsoft Flight Simulator", StringComparison.CurrentCultureIgnoreCase)));
|
simWindow.ChildWindowsData.RemoveAll(x => x.ClassName != "AceApp" || (x.Title != null && x.Title.Contains("Microsoft Flight Simulator", StringComparison.CurrentCultureIgnoreCase)));
|
||||||
|
simWindow.ChildWindowsData = simWindow.ChildWindowsData.GroupBy(x => x.Handle).Select(g => g.First()).ToList();
|
||||||
|
|
||||||
|
simWindow.ChildWindowsData.ForEach(x => {
|
||||||
|
if (String.IsNullOrEmpty(x.Title) || x.Title.Contains("Custom - ") || x.Title.Contains("Failed Analysis"))
|
||||||
|
x.PopoutType = PopoutType.Custom;
|
||||||
|
else
|
||||||
|
x.PopoutType = PopoutType.BuiltIn;
|
||||||
|
});
|
||||||
|
|
||||||
if(simWindow.ChildWindowsData.Count > 0)
|
if(simWindow.ChildWindowsData.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -102,9 +113,9 @@ namespace MSFSPopoutPanelManager
|
||||||
|
|
||||||
foreach (var childWindow in simWindow.ChildWindowsData)
|
foreach (var childWindow in simWindow.ChildWindowsData)
|
||||||
{
|
{
|
||||||
// Figure out what windows is what?
|
if (childWindow.PopoutType == PopoutType.Custom)
|
||||||
if (String.IsNullOrEmpty(childWindow.Title))
|
|
||||||
{
|
{
|
||||||
|
// Figure out what windows is what?
|
||||||
// Theses are the windows with no system menu bar title (ie. PFD, MFD, FMS, etc)
|
// Theses are the windows with no system menu bar title (ie. PFD, MFD, FMS, etc)
|
||||||
// We need to take a screenshot and do OCR to try to figure them out
|
// We need to take a screenshot and do OCR to try to figure them out
|
||||||
Rect rect = new Rect();
|
Rect rect = new Rect();
|
||||||
|
@ -118,23 +129,23 @@ namespace MSFSPopoutPanelManager
|
||||||
var newHeight = Convert.ToInt32(originalHeight * ocrImageScale);
|
var newHeight = Convert.ToInt32(originalHeight * ocrImageScale);
|
||||||
rect.Right = rect.Left + newWidth;
|
rect.Right = rect.Left + newWidth;
|
||||||
rect.Bottom = rect.Top + newHeight;
|
rect.Bottom = rect.Top + newHeight;
|
||||||
SetWindowPos(childWindow.Handle, 0, rect.Left, rect.Top, newWidth, newHeight, SWP_NOZORDER | SWP_SHOWWINDOW);
|
MoveWindow(childWindow.Handle, rect.Left, rect.Top, newWidth, newHeight, true);
|
||||||
SetForegroundWindow(childWindow.Handle);
|
SetForegroundWindow(childWindow.Handle);
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
|
|
||||||
var image = TakeScreenShot(rect);
|
var image = TakeScreenShot(rect);
|
||||||
SetWindowPos(childWindow.Handle, 0, rect.Left, rect.Top, originalWidth, originalHeight, SWP_NOZORDER | SWP_SHOWWINDOW);
|
MoveWindow(childWindow.Handle, rect.Left, rect.Top, originalWidth, originalHeight, true);
|
||||||
|
|
||||||
// OCR the image into text
|
// OCR the image into text
|
||||||
var imageText = OcrImage(image);
|
var imageText = OcrImage(image);
|
||||||
var popoutName = EvaluateImageText(imageText, ocrEvaluationData);
|
var popoutName = EvaluateImageText(imageText, ocrEvaluationData);
|
||||||
childWindow.Title = childWindow.Title ?? popoutName;
|
childWindow.Title = popoutName == null ? $"Failed Analysis - {childWindow.Handle}" : $"Custom - {popoutName}";
|
||||||
childWindow.PopoutType = PopoutType.Custom;
|
childWindow.PopoutType = popoutName == null ? PopoutType.Undetermined : PopoutType.Custom;
|
||||||
|
|
||||||
if(!debugInfo.TryAdd(popoutName ?? $"Failed Analysis - {childWindow.Handle.ToString()}", imageText))
|
SetWindowText(childWindow.Handle, childWindow.Title);
|
||||||
{
|
|
||||||
debugInfo.Add($"{popoutName} - {childWindow.Handle.ToString()}", imageText);
|
if (!debugInfo.TryAdd(childWindow.Title, imageText))
|
||||||
}
|
debugInfo.Add($"{childWindow.Title} - {childWindow.Handle}", imageText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +155,8 @@ namespace MSFSPopoutPanelManager
|
||||||
|
|
||||||
// Remove all windows that cannot be identified
|
// Remove all windows that cannot be identified
|
||||||
simWindow.ChildWindowsData.RemoveAll(x => x.Title == null);
|
simWindow.ChildWindowsData.RemoveAll(x => x.Title == null);
|
||||||
|
|
||||||
|
OnStatusUpdated?.Invoke(this, new EventArgs<string>("Anaylsis completed."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -240,7 +253,6 @@ namespace MSFSPopoutPanelManager
|
||||||
return result.GetText();
|
return result.GetText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private string EvaluateImageText(string imageText, OcrEvalData ocrEvaluationData)
|
private string EvaluateImageText(string imageText, OcrEvalData ocrEvaluationData)
|
||||||
{
|
{
|
||||||
if(ocrEvaluationData != null)
|
if(ocrEvaluationData != null)
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace MSFSPopoutPanelManager
|
||||||
{
|
{
|
||||||
public ChildWindow()
|
public ChildWindow()
|
||||||
{
|
{
|
||||||
PopoutType = PopoutType.BuiltIn;
|
PopoutType = PopoutType.Undetermined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ProcessId { get; set; }
|
public int ProcessId { get; set; }
|
||||||
|
@ -23,6 +23,7 @@ namespace MSFSPopoutPanelManager
|
||||||
public enum PopoutType
|
public enum PopoutType
|
||||||
{
|
{
|
||||||
BuiltIn,
|
BuiltIn,
|
||||||
Custom
|
Custom,
|
||||||
|
Undetermined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
<TargetFramework>net5.0-windows</TargetFramework>
|
<TargetFramework>net5.0-windows</TargetFramework>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<Platforms>x64</Platforms>
|
<Platforms>x64</Platforms>
|
||||||
<Version>1.0</Version>
|
<Version>1.1</Version>
|
||||||
<AssemblyName>MSFSPopoutPanelManager</AssemblyName>
|
<AssemblyName>MSFSPopoutPanelManager</AssemblyName>
|
||||||
<RootNamespace>MSFSPopoutPanelManager</RootNamespace>
|
<RootNamespace>MSFSPopoutPanelManager</RootNamespace>
|
||||||
<ApplicationIcon>WindowManager.ico</ApplicationIcon>
|
<ApplicationIcon>WindowManager.ico</ApplicationIcon>
|
||||||
<Authors>Stanley Kwok</Authors>
|
<Authors>Stanley Kwok</Authors>
|
||||||
<Product>MSFS Popout Window Manager</Product>
|
<Product>MSFS 2020 Popout Window Manager</Product>
|
||||||
|
<PackageId>MSFS 2020 Popout Panel Manager</PackageId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -103,9 +104,16 @@
|
||||||
<None Update="LICENSE">
|
<None Update="LICENSE">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Vesion.md">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="README.md">
|
<None Update="README.md">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<NativeLibs Remove="Vesion.md" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
147
MainForm.Designer.cs
generated
147
MainForm.Designer.cs
generated
|
@ -29,42 +29,48 @@ namespace MSFSPopoutPanelManager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
this.btnAnalyze = new System.Windows.Forms.Button();
|
this.btnAnalyze = new System.Windows.Forms.Button();
|
||||||
this.btnSave = new System.Windows.Forms.Button();
|
this.btnSaveSettings = new System.Windows.Forms.Button();
|
||||||
this.comboBoxProfile = new System.Windows.Forms.ComboBox();
|
this.comboBoxProfile = new System.Windows.Forms.ComboBox();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
|
||||||
this.txtStatus = new System.Windows.Forms.TextBox();
|
this.txtStatus = new System.Windows.Forms.TextBox();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
this.lblMsfsRunning = new System.Windows.Forms.Label();
|
this.lblMsfsRunning = new System.Windows.Forms.Label();
|
||||||
this.label4 = new System.Windows.Forms.Label();
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
this.tabControlOcrDebug = new System.Windows.Forms.TabControl();
|
this.tabControlOcrDebug = new System.Windows.Forms.TabControl();
|
||||||
|
this.chkHidePanelTitleBar = new System.Windows.Forms.CheckBox();
|
||||||
|
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
||||||
|
this.checkBoxMinimizeToTray = new System.Windows.Forms.CheckBox();
|
||||||
|
this.lblVersion = new System.Windows.Forms.Label();
|
||||||
|
this.chkAlwaysOnTop = new System.Windows.Forms.CheckBox();
|
||||||
|
this.btnApplySettings = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// btnAnalyze
|
// btnAnalyze
|
||||||
//
|
//
|
||||||
this.btnAnalyze.Enabled = false;
|
this.btnAnalyze.Enabled = false;
|
||||||
this.btnAnalyze.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.btnAnalyze.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.btnAnalyze.Location = new System.Drawing.Point(332, 18);
|
this.btnAnalyze.Location = new System.Drawing.Point(85, 60);
|
||||||
this.btnAnalyze.Name = "btnAnalyze";
|
this.btnAnalyze.Name = "btnAnalyze";
|
||||||
this.btnAnalyze.Size = new System.Drawing.Size(230, 31);
|
this.btnAnalyze.Size = new System.Drawing.Size(103, 31);
|
||||||
this.btnAnalyze.TabIndex = 2;
|
this.btnAnalyze.TabIndex = 2;
|
||||||
this.btnAnalyze.Text = "Analyze / Load Saved Positions";
|
this.btnAnalyze.Text = "Analyze";
|
||||||
this.btnAnalyze.UseVisualStyleBackColor = true;
|
this.btnAnalyze.UseVisualStyleBackColor = true;
|
||||||
this.btnAnalyze.Click += new System.EventHandler(this.btnAnalyze_Click);
|
this.btnAnalyze.Click += new System.EventHandler(this.btnAnalyze_Click);
|
||||||
//
|
//
|
||||||
// btnSave
|
// btnSaveSettings
|
||||||
//
|
//
|
||||||
this.btnSave.Enabled = false;
|
this.btnSaveSettings.Enabled = false;
|
||||||
this.btnSave.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.btnSaveSettings.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.btnSave.Location = new System.Drawing.Point(587, 18);
|
this.btnSaveSettings.Location = new System.Drawing.Point(364, 60);
|
||||||
this.btnSave.Name = "btnSave";
|
this.btnSaveSettings.Name = "btnSaveSettings";
|
||||||
this.btnSave.Size = new System.Drawing.Size(124, 31);
|
this.btnSaveSettings.Size = new System.Drawing.Size(115, 31);
|
||||||
this.btnSave.TabIndex = 3;
|
this.btnSaveSettings.TabIndex = 3;
|
||||||
this.btnSave.Text = "Save Positions";
|
this.btnSaveSettings.Text = "Save Settings";
|
||||||
this.btnSave.UseVisualStyleBackColor = true;
|
this.btnSaveSettings.UseVisualStyleBackColor = true;
|
||||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
this.btnSaveSettings.Click += new System.EventHandler(this.btnSaveSettings_Click);
|
||||||
//
|
//
|
||||||
// comboBoxProfile
|
// comboBoxProfile
|
||||||
//
|
//
|
||||||
|
@ -73,8 +79,9 @@ namespace MSFSPopoutPanelManager
|
||||||
this.comboBoxProfile.FormattingEnabled = true;
|
this.comboBoxProfile.FormattingEnabled = true;
|
||||||
this.comboBoxProfile.Location = new System.Drawing.Point(85, 21);
|
this.comboBoxProfile.Location = new System.Drawing.Point(85, 21);
|
||||||
this.comboBoxProfile.Name = "comboBoxProfile";
|
this.comboBoxProfile.Name = "comboBoxProfile";
|
||||||
this.comboBoxProfile.Size = new System.Drawing.Size(217, 28);
|
this.comboBoxProfile.Size = new System.Drawing.Size(212, 28);
|
||||||
this.comboBoxProfile.TabIndex = 1;
|
this.comboBoxProfile.TabIndex = 1;
|
||||||
|
this.comboBoxProfile.SelectedIndexChanged += new System.EventHandler(this.comboBoxProfile_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
|
@ -86,30 +93,21 @@ namespace MSFSPopoutPanelManager
|
||||||
this.label1.TabIndex = 4;
|
this.label1.TabIndex = 4;
|
||||||
this.label1.Text = "Profile";
|
this.label1.Text = "Profile";
|
||||||
//
|
//
|
||||||
// label2
|
|
||||||
//
|
|
||||||
this.label2.AutoSize = true;
|
|
||||||
this.label2.Location = new System.Drawing.Point(23, 432);
|
|
||||||
this.label2.Name = "label2";
|
|
||||||
this.label2.Size = new System.Drawing.Size(118, 15);
|
|
||||||
this.label2.TabIndex = 6;
|
|
||||||
this.label2.Text = "© 2021 Stanley Kwok";
|
|
||||||
//
|
|
||||||
// txtStatus
|
// txtStatus
|
||||||
//
|
//
|
||||||
this.txtStatus.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.txtStatus.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.txtStatus.Location = new System.Drawing.Point(85, 69);
|
this.txtStatus.Location = new System.Drawing.Point(85, 108);
|
||||||
this.txtStatus.Multiline = true;
|
this.txtStatus.Multiline = true;
|
||||||
this.txtStatus.Name = "txtStatus";
|
this.txtStatus.Name = "txtStatus";
|
||||||
this.txtStatus.ReadOnly = true;
|
this.txtStatus.ReadOnly = true;
|
||||||
this.txtStatus.Size = new System.Drawing.Size(626, 47);
|
this.txtStatus.Size = new System.Drawing.Size(606, 47);
|
||||||
this.txtStatus.TabIndex = 5;
|
this.txtStatus.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.label3.AutoSize = true;
|
||||||
this.label3.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.label3.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.label3.Location = new System.Drawing.Point(23, 72);
|
this.label3.Location = new System.Drawing.Point(23, 111);
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(49, 20);
|
this.label3.Size = new System.Drawing.Size(49, 20);
|
||||||
this.label3.TabIndex = 8;
|
this.label3.TabIndex = 8;
|
||||||
|
@ -121,7 +119,7 @@ namespace MSFSPopoutPanelManager
|
||||||
this.lblMsfsRunning.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.lblMsfsRunning.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.lblMsfsRunning.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.lblMsfsRunning.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.lblMsfsRunning.ForeColor = System.Drawing.Color.Red;
|
this.lblMsfsRunning.ForeColor = System.Drawing.Color.Red;
|
||||||
this.lblMsfsRunning.Location = new System.Drawing.Point(562, 428);
|
this.lblMsfsRunning.Location = new System.Drawing.Point(546, 429);
|
||||||
this.lblMsfsRunning.Name = "lblMsfsRunning";
|
this.lblMsfsRunning.Name = "lblMsfsRunning";
|
||||||
this.lblMsfsRunning.Size = new System.Drawing.Size(145, 22);
|
this.lblMsfsRunning.Size = new System.Drawing.Size(145, 22);
|
||||||
this.lblMsfsRunning.TabIndex = 9;
|
this.lblMsfsRunning.TabIndex = 9;
|
||||||
|
@ -132,7 +130,7 @@ namespace MSFSPopoutPanelManager
|
||||||
//
|
//
|
||||||
this.label4.AutoSize = true;
|
this.label4.AutoSize = true;
|
||||||
this.label4.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.label4.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.label4.Location = new System.Drawing.Point(23, 131);
|
this.label4.Location = new System.Drawing.Point(23, 174);
|
||||||
this.label4.Name = "label4";
|
this.label4.Name = "label4";
|
||||||
this.label4.Size = new System.Drawing.Size(169, 20);
|
this.label4.Size = new System.Drawing.Size(169, 20);
|
||||||
this.label4.TabIndex = 10;
|
this.label4.TabIndex = 10;
|
||||||
|
@ -140,32 +138,102 @@ namespace MSFSPopoutPanelManager
|
||||||
//
|
//
|
||||||
// tabControlOcrDebug
|
// tabControlOcrDebug
|
||||||
//
|
//
|
||||||
this.tabControlOcrDebug.Location = new System.Drawing.Point(26, 154);
|
this.tabControlOcrDebug.Location = new System.Drawing.Point(26, 197);
|
||||||
this.tabControlOcrDebug.Name = "tabControlOcrDebug";
|
this.tabControlOcrDebug.Name = "tabControlOcrDebug";
|
||||||
this.tabControlOcrDebug.SelectedIndex = 0;
|
this.tabControlOcrDebug.SelectedIndex = 0;
|
||||||
this.tabControlOcrDebug.Size = new System.Drawing.Size(685, 266);
|
this.tabControlOcrDebug.Size = new System.Drawing.Size(665, 220);
|
||||||
this.tabControlOcrDebug.TabIndex = 12;
|
this.tabControlOcrDebug.TabIndex = 12;
|
||||||
//
|
//
|
||||||
|
// chkHidePanelTitleBar
|
||||||
|
//
|
||||||
|
this.chkHidePanelTitleBar.AutoSize = true;
|
||||||
|
this.chkHidePanelTitleBar.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.chkHidePanelTitleBar.Location = new System.Drawing.Point(317, 22);
|
||||||
|
this.chkHidePanelTitleBar.Name = "chkHidePanelTitleBar";
|
||||||
|
this.chkHidePanelTitleBar.Size = new System.Drawing.Size(158, 24);
|
||||||
|
this.chkHidePanelTitleBar.TabIndex = 15;
|
||||||
|
this.chkHidePanelTitleBar.Text = "Hide Panel Title Bar";
|
||||||
|
this.chkHidePanelTitleBar.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// notifyIcon1
|
||||||
|
//
|
||||||
|
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
|
||||||
|
this.notifyIcon1.Text = "MSFS 2020 Pop OUt Panel Manager";
|
||||||
|
this.notifyIcon1.Visible = true;
|
||||||
|
this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
|
||||||
|
//
|
||||||
|
// checkBoxMinimizeToTray
|
||||||
|
//
|
||||||
|
this.checkBoxMinimizeToTray.AutoSize = true;
|
||||||
|
this.checkBoxMinimizeToTray.Checked = true;
|
||||||
|
this.checkBoxMinimizeToTray.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.checkBoxMinimizeToTray.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.checkBoxMinimizeToTray.Location = new System.Drawing.Point(26, 427);
|
||||||
|
this.checkBoxMinimizeToTray.Name = "checkBoxMinimizeToTray";
|
||||||
|
this.checkBoxMinimizeToTray.Size = new System.Drawing.Size(189, 24);
|
||||||
|
this.checkBoxMinimizeToTray.TabIndex = 16;
|
||||||
|
this.checkBoxMinimizeToTray.Text = "Minimize to System Tray";
|
||||||
|
this.checkBoxMinimizeToTray.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// lblVersion
|
||||||
|
//
|
||||||
|
this.lblVersion.AutoSize = true;
|
||||||
|
this.lblVersion.Location = new System.Drawing.Point(305, 448);
|
||||||
|
this.lblVersion.Name = "lblVersion";
|
||||||
|
this.lblVersion.Size = new System.Drawing.Size(51, 15);
|
||||||
|
this.lblVersion.TabIndex = 17;
|
||||||
|
this.lblVersion.Text = "Version: ";
|
||||||
|
//
|
||||||
|
// chkAlwaysOnTop
|
||||||
|
//
|
||||||
|
this.chkAlwaysOnTop.AutoSize = true;
|
||||||
|
this.chkAlwaysOnTop.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.chkAlwaysOnTop.Location = new System.Drawing.Point(495, 22);
|
||||||
|
this.chkAlwaysOnTop.Name = "chkAlwaysOnTop";
|
||||||
|
this.chkAlwaysOnTop.Size = new System.Drawing.Size(124, 24);
|
||||||
|
this.chkAlwaysOnTop.TabIndex = 18;
|
||||||
|
this.chkAlwaysOnTop.Text = "Always on Top";
|
||||||
|
this.chkAlwaysOnTop.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// btnApplySettings
|
||||||
|
//
|
||||||
|
this.btnApplySettings.Enabled = false;
|
||||||
|
this.btnApplySettings.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.btnApplySettings.Location = new System.Drawing.Point(216, 60);
|
||||||
|
this.btnApplySettings.Name = "btnApplySettings";
|
||||||
|
this.btnApplySettings.Size = new System.Drawing.Size(119, 31);
|
||||||
|
this.btnApplySettings.TabIndex = 19;
|
||||||
|
this.btnApplySettings.Text = "Apply Settings";
|
||||||
|
this.btnApplySettings.UseVisualStyleBackColor = true;
|
||||||
|
this.btnApplySettings.Click += new System.EventHandler(this.btnApplySettings_Click);
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(733, 462);
|
this.ClientSize = new System.Drawing.Size(713, 472);
|
||||||
|
this.Controls.Add(this.btnApplySettings);
|
||||||
|
this.Controls.Add(this.chkAlwaysOnTop);
|
||||||
|
this.Controls.Add(this.lblVersion);
|
||||||
|
this.Controls.Add(this.checkBoxMinimizeToTray);
|
||||||
|
this.Controls.Add(this.chkHidePanelTitleBar);
|
||||||
this.Controls.Add(this.tabControlOcrDebug);
|
this.Controls.Add(this.tabControlOcrDebug);
|
||||||
this.Controls.Add(this.label4);
|
this.Controls.Add(this.label4);
|
||||||
this.Controls.Add(this.lblMsfsRunning);
|
this.Controls.Add(this.lblMsfsRunning);
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.txtStatus);
|
this.Controls.Add(this.txtStatus);
|
||||||
this.Controls.Add(this.label2);
|
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Controls.Add(this.comboBoxProfile);
|
this.Controls.Add(this.comboBoxProfile);
|
||||||
this.Controls.Add(this.btnSave);
|
this.Controls.Add(this.btnSaveSettings);
|
||||||
this.Controls.Add(this.btnAnalyze);
|
this.Controls.Add(this.btnAnalyze);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.Text = "MSFS 2020 Pop Out Panel Manager";
|
this.Text = "MSFS 2020 Pop Out Panel Manager";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||||
|
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||||
|
this.Resize += new System.EventHandler(this.MainForm_Resize);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -174,15 +242,20 @@ namespace MSFSPopoutPanelManager
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Button btnAnalyze;
|
private System.Windows.Forms.Button btnAnalyze;
|
||||||
private System.Windows.Forms.Button btnSave;
|
private System.Windows.Forms.Button btnSaveSettings;
|
||||||
private System.Windows.Forms.ComboBox comboBoxProfile;
|
private System.Windows.Forms.ComboBox comboBoxProfile;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
private System.Windows.Forms.Label label2;
|
|
||||||
private System.Windows.Forms.TextBox txtStatus;
|
private System.Windows.Forms.TextBox txtStatus;
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
private System.Windows.Forms.Label lblMsfsRunning;
|
private System.Windows.Forms.Label lblMsfsRunning;
|
||||||
private System.Windows.Forms.Label label4;
|
private System.Windows.Forms.Label label4;
|
||||||
private System.Windows.Forms.TabControl tabControlOcrDebug;
|
private System.Windows.Forms.TabControl tabControlOcrDebug;
|
||||||
|
private System.Windows.Forms.CheckBox chkHidePanelTitleBar;
|
||||||
|
private System.Windows.Forms.NotifyIcon notifyIcon1;
|
||||||
|
private System.Windows.Forms.CheckBox checkBoxMinimizeToTray;
|
||||||
|
private System.Windows.Forms.Label lblVersion;
|
||||||
|
private System.Windows.Forms.CheckBox chkAlwaysOnTop;
|
||||||
|
private System.Windows.Forms.Button btnApplySettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
89
MainForm.cs
89
MainForm.cs
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
@ -13,6 +14,14 @@ namespace MSFSPopoutPanelManager
|
||||||
private SynchronizationContext _syncRoot;
|
private SynchronizationContext _syncRoot;
|
||||||
private WindowManager _popoutWindowsManager;
|
private WindowManager _popoutWindowsManager;
|
||||||
|
|
||||||
|
private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
|
||||||
|
private const UInt32 SWP_NOSIZE = 0x0001;
|
||||||
|
private const UInt32 SWP_NOMOVE = 0x0002;
|
||||||
|
private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
|
||||||
|
|
||||||
|
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
|
||||||
|
public static extern IntPtr SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int Y, int cx, int cy, uint wFlags);
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -26,6 +35,11 @@ namespace MSFSPopoutPanelManager
|
||||||
_popoutWindowsManager.OnSimulatorStarted += HandleOnSimulatorStarted;
|
_popoutWindowsManager.OnSimulatorStarted += HandleOnSimulatorStarted;
|
||||||
_popoutWindowsManager.OnOcrDebugged += HandleOnOcrDebugged;
|
_popoutWindowsManager.OnOcrDebugged += HandleOnOcrDebugged;
|
||||||
_popoutWindowsManager.CheckSimulatorStarted();
|
_popoutWindowsManager.CheckSimulatorStarted();
|
||||||
|
|
||||||
|
SetWindowPos(this.Handle, HWND_TOPMOST, this.Left, this.Top, this.Width, this.Height, TOPMOST_FLAGS);
|
||||||
|
|
||||||
|
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
lblVersion.Text += version.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnAnalyze_Click(object sender, EventArgs e)
|
private void btnAnalyze_Click(object sender, EventArgs e)
|
||||||
|
@ -33,15 +47,26 @@ namespace MSFSPopoutPanelManager
|
||||||
txtStatus.Clear();
|
txtStatus.Clear();
|
||||||
|
|
||||||
var profile = GetProfileDropDown();
|
var profile = GetProfileDropDown();
|
||||||
_popoutWindowsManager.Analyze(profile);
|
var success = _popoutWindowsManager.Analyze(profile);
|
||||||
|
|
||||||
|
btnApplySettings.Enabled = success;
|
||||||
|
btnSaveSettings.Enabled = success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSave_Click(object sender, EventArgs e)
|
private void btnApplySettings_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
txtStatus.Clear();
|
txtStatus.Clear();
|
||||||
|
|
||||||
var profile = GetProfileDropDown();
|
var profile = GetProfileDropDown();
|
||||||
_popoutWindowsManager.SaveProfile(profile);
|
_popoutWindowsManager.ApplySettings(profile, chkHidePanelTitleBar.Checked, chkAlwaysOnTop.Checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSaveSettings_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
txtStatus.Clear();
|
||||||
|
|
||||||
|
var profile = GetProfileDropDown();
|
||||||
|
_popoutWindowsManager.SaveSettings(profile, chkHidePanelTitleBar.Checked, chkAlwaysOnTop.Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetProfileDropDown()
|
private void SetProfileDropDown()
|
||||||
|
@ -81,6 +106,7 @@ namespace MSFSPopoutPanelManager
|
||||||
private void HandleOnSimulatorStarted(object source, EventArgs arg)
|
private void HandleOnSimulatorStarted(object source, EventArgs arg)
|
||||||
{
|
{
|
||||||
_syncRoot.Post(SetMsfsRunningMessage, "MSFS is running");
|
_syncRoot.Post(SetMsfsRunningMessage, "MSFS is running");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetMsfsRunningMessage(object arg)
|
private void SetMsfsRunningMessage(object arg)
|
||||||
|
@ -93,7 +119,6 @@ namespace MSFSPopoutPanelManager
|
||||||
}
|
}
|
||||||
|
|
||||||
btnAnalyze.Enabled = true;
|
btnAnalyze.Enabled = true;
|
||||||
btnSave.Enabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleOnOcrDebugged(object source, EventArgs<Dictionary<string, string>> arg)
|
private void HandleOnOcrDebugged(object source, EventArgs<Dictionary<string, string>> arg)
|
||||||
|
@ -128,5 +153,61 @@ namespace MSFSPopoutPanelManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
notifyIcon1.BalloonTipText = "Application Minimized";
|
||||||
|
notifyIcon1.BalloonTipTitle = "MSFS 2020 Pop Out Panel Manager";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
// Put all panels popout back to original state
|
||||||
|
_popoutWindowsManager.RestorePanelTitleBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MainForm_Resize(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.WindowState == FormWindowState.Minimized)
|
||||||
|
{
|
||||||
|
if (checkBoxMinimizeToTray.Checked)
|
||||||
|
{
|
||||||
|
ShowInTaskbar = false;
|
||||||
|
notifyIcon1.Visible = true;
|
||||||
|
notifyIcon1.ShowBalloonTip(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ShowInTaskbar = true;
|
||||||
|
notifyIcon1.Visible = false;
|
||||||
|
WindowState = FormWindowState.Normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxProfile_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var userData = FileManager.ReadUserData();
|
||||||
|
|
||||||
|
if (userData != null)
|
||||||
|
{
|
||||||
|
var userProfile = userData.Profiles.Find(x => x.Name == Convert.ToString(comboBoxProfile.SelectedValue));
|
||||||
|
if (userProfile != null)
|
||||||
|
{
|
||||||
|
chkAlwaysOnTop.Checked = userProfile.AlwaysOnTop;
|
||||||
|
chkHidePanelTitleBar.Checked = userProfile.HidePanelTitleBar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// default values
|
||||||
|
chkAlwaysOnTop.Checked = false;
|
||||||
|
chkHidePanelTitleBar.Checked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
btnApplySettings.Enabled = false;
|
||||||
|
btnSaveSettings.Enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1135
MainForm.resx
1135
MainForm.resx
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,9 @@ namespace MSFSPopoutPanelManager
|
||||||
|
|
||||||
public bool DefaultProfile { get; set; }
|
public bool DefaultProfile { get; set; }
|
||||||
|
|
||||||
// scale the image so OCR can better recognize the text
|
/// <summary>
|
||||||
|
/// Scale the image so OCR can better recognize text
|
||||||
|
/// </summary>
|
||||||
public double OCRImageScale { get; set; }
|
public double OCRImageScale { get; set; }
|
||||||
|
|
||||||
public List<PopoutEvalData> EvalData { get; set; }
|
public List<PopoutEvalData> EvalData { get; set; }
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace MSFSPopoutPanelManager
|
namespace MSFSPopoutPanelManager
|
||||||
|
|
26
README.md
26
README.md
|
@ -1,4 +1,4 @@
|
||||||
# MSFS Pop Out Panel Manager
|
# MSFS Pop Out Panel Manager
|
||||||
MSFS Pop Out Panel Manager is a utility application for MSFS 2020 which helps save and position pop out panels such as PDF and MFD to be used by applications such as Sim Innovations Air Manager's overlay. This is a **proof of concept** application since I do not use Air Manager so I'm kind of guessing how it works. I kept reading messages on flightsimulator.com that flightsimers would like a utility like this so as a coding exercise I just created it. I welcome any feedback to help improve the accuracy and usefulness of this utility. You are welcome to take a copy of this code to further enhance it and use within anything you created.
|
MSFS Pop Out Panel Manager is a utility application for MSFS 2020 which helps save and position pop out panels such as PDF and MFD to be used by applications such as Sim Innovations Air Manager's overlay. This is a **proof of concept** application since I do not use Air Manager so I'm kind of guessing how it works. I kept reading messages on flightsimulator.com that flightsimers would like a utility like this so as a coding exercise I just created it. I welcome any feedback to help improve the accuracy and usefulness of this utility. You are welcome to take a copy of this code to further enhance it and use within anything you created.
|
||||||
|
|
||||||
## Pop Out Panel Positioning Annoyance
|
## Pop Out Panel Positioning Annoyance
|
||||||
|
@ -12,15 +12,15 @@ The concept to determine the untitled panels to be reposition is pretty straight
|
||||||
- The OCRed text (mostly 'gibberish' by the way) will be compared to a predefined set of keywords that are defined by the user. These comparison text can be customized and additional panel types and profiles can be [added](#profile-and-ocr-data-file-definition) for various plane configurations.
|
- The OCRed text (mostly 'gibberish' by the way) will be compared to a predefined set of keywords that are defined by the user. These comparison text can be customized and additional panel types and profiles can be [added](#profile-and-ocr-data-file-definition) for various plane configurations.
|
||||||
- By being able to identify the untitled panels, this solves the problem of not able to easily reposition these panel in subsequent flight.
|
- By being able to identify the untitled panels, this solves the problem of not able to easily reposition these panel in subsequent flight.
|
||||||
|
|
||||||
## Application Workflow Steps
|
## How to Use?
|
||||||
1. User starts the utility. The application will automatic connect when MSFS starts.
|
1. User starts the application and it will automatic connect when MSFS starts.
|
||||||
2. User pops out the **Individual** untitled panels such as MFD or PFD on G1000 in MSFS. **Please make sure the pop out panels are not inactive/blank.** If so, there will be nothing to analyze.
|
2. User pops out the **Individual** untitled panels such as MFD or PFD on G1000 in MSFS. **Please make sure the pop out panels are not inactive/blank.**
|
||||||
3. **Important!** User choose the desired profile.
|
3. **Important!** User choose the desired profile.
|
||||||
4. User selects **Analyze** for the panels that were popped out.
|
4. User selects **Analyze** for the panels that were popped out.
|
||||||
5. Once analysis is completed, user positions these untitled panels in addition to any predefined toolbar menu panels to the desired location on the screen.
|
5. Once analysis is completed, user can positions these untitled panels in addition to any predefined toolbar menu panels to the desired location on the screen. You will notice now the "untitled" panels will have new captions.
|
||||||
6. User **Saves** the positions of these panels.
|
6. User select **Save Settings** to save the position of these panels. If desire, user can change addition settings of 'Hide Panel Title Bar' and 'Always on Top'. When everything is perfect, user selects **Save Settings** to save all open panels coordinates and settings for this particular profile.
|
||||||
7. In subsequent flight, user pops out the untitled and/or predefined panels again.
|
7. In subsequent flight, user pops out some or all of the untitled and/or predefined panels again.
|
||||||
8. User selects **Analyze**.
|
8. User selects **Analyze** then selects **Apply Settings**.
|
||||||
9. These panels will then automatically reposition themselves to their saved positions.
|
9. These panels will then automatically reposition themselves to their saved positions.
|
||||||
|
|
||||||
## User Interface
|
## User Interface
|
||||||
|
@ -28,15 +28,15 @@ The concept to determine the untitled panels to be reposition is pretty straight
|
||||||
<img src="images/ui-screenshot.png" hspace="10"/>
|
<img src="images/ui-screenshot.png" hspace="10"/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
### OCR Debug Information
|
## OCR Debug Information
|
||||||
All untitled panels OCR extracted text will be represented here by an individual tab. When an untitled panel failed analysis, a tab control marked ***Failed Analysis - xxxx*** will be shown. You can use the extracted text here (if any) as basis to adjust the OCR data definition file.
|
All untitled panels OCR extracted text will be represented here by individual tab. When an untitled panel failed analysis, a tab control marked **Failed Analysis - xxxx **will be shown. You can use these extracted text as basis to adjust the OCR data definition file.
|
||||||
|
|
||||||
## OCR Concept / Further Enhancement
|
## OCR Concept / Further Enhancement
|
||||||
|
|
||||||
- Currently, Tesseract OCR recognition is not very accurate but is good enough!
|
- Currently, Tesseract OCR recognition is not very accurate for this use case but is good enough!
|
||||||
- Screenshot images text recognition can be [customized](#profile-and-ocr-data-file-definition) by configuration file for better accuracy.
|
- Screenshot images text recognition can be [customized](#profile-and-ocr-data-file-definition) by configuration file for better accuracy.
|
||||||
- To enhance the initial accuracy of Tessearat OCR, the screenshot has its color inverted, then sharpened, then grayscale before text recognition occurs.
|
- To enhance the initial accuracy of Tessearat OCR, the screenshot has its color inverted, then sharpened, then grayscale before text recognition occurs.
|
||||||
- I only used the default Tessearact OCR function. There are probably better way to improve the accuracy with OCR advanced features and more image preprocessing.
|
- I only used the default Tessearact OCR function. There are probably better way to improve the accuracy with OCR advanced features and more preprocessing of the images.
|
||||||
- For panels that have no obvious text such as some of the pop out gauges on A320, currently these panels cannot be recognized. Maybe for future enhancement, using color mapping or snippet of screenshot to do the comparison.
|
- For panels that have no obvious text such as some of the pop out gauges on A320, currently these panels cannot be recognized. Maybe for future enhancement, using color mapping or snippet of screenshot to do the comparison.
|
||||||
|
|
||||||
## Profile and OCR Data File Definition
|
## Profile and OCR Data File Definition
|
||||||
|
@ -72,7 +72,7 @@ The file definition [config/ocrdata.json](config/ocrdata.json) is pretty self-ex
|
||||||
|
|
||||||
## Common Problem Resolution
|
## Common Problem Resolution
|
||||||
|
|
||||||
- Failed Analysis - Make sure to select correct/desire profile before clicking Analyze.
|
- Failed Analysis - Make sure to select correct/desire profile before clicking Analyze. You can manually adjust the size of the panel and try to analyze it again.
|
||||||
- Failed Analysis - Experiment with ocrImageScale and keyword list in ocrdata definition file.
|
- Failed Analysis - Experiment with ocrImageScale and keyword list in ocrdata definition file.
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
|
@ -21,6 +21,10 @@ namespace MSFSPopoutPanelManager
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public bool AlwaysOnTop { get; set; }
|
||||||
|
|
||||||
|
public bool HidePanelTitleBar { get; set; }
|
||||||
|
|
||||||
public Dictionary<string, Rect> PopoutNames;
|
public Dictionary<string, Rect> PopoutNames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
VERSION.md
Normal file
13
VERSION.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Version History
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
## Version 1.1
|
||||||
|
* Added caption title for the "untitled" windows. After analysis, if the panel window matches the name in the profile/ocr definition file, it will now display a caption of "Custom - XXXXX" (ie. Custom - PFD). This allows user to use various 3rd party windows layout manager to organize pop out panel windows.
|
||||||
|
* Added hide panel title bar feature.
|
||||||
|
* Added ability to have pop out panels to be always on top.
|
||||||
|
* Added minimize application to tray feature.
|
||||||
|
* Made application flow more intuitive.
|
||||||
|
* Fix various small bugs in the application.
|
||||||
|
|
||||||
|
## Version 1.0
|
||||||
|
* Initial Release
|
174
Welcome file.md
174
Welcome file.md
|
@ -1,174 +0,0 @@
|
||||||
# MSFS Pop Out Panel Manager
|
|
||||||
|
|
||||||
MSFS Pop Out Panel Manager is an utility application for MSFS 2020 which help to save and position pop out panels such as PDF and MFD to be used by applications such as Sim Innovations Air Manager's overlay. This is a proof of concept application since I do not use Air Manager. I kept seeing people want an application like this in flightsimulator.com so I just create it. I welcome feedback and help to improve the accuracy and usefulness of this utility.
|
|
||||||
|
|
||||||
## Pop Out Panel annoyance
|
|
||||||
In MSFS, by holding **Right-Alt** + **Left Clicking** selected instrumentation panels, these panels will pop out as floating windows that can be moved to a different monitor. Predefined toolbar menu windows such as ATC, Checklist, VFR Map, etc can also be popped out. For the MSFS predefined toolbar menu windows, they are easier to save and reposition in the each start of a flight using 3rd party windows position utility because these windows have a **title** for the pop out window. But panels such as PFD and MFD on G1000 or the FMS panel on G3000 do not have windows title. This makes remember there last used position more difficult and very annoying to resize and readjust their positions on every flight to be used by Air Manager.
|
|
||||||
|
|
||||||
## Concept
|
|
||||||
The concept to determine the untitled panels is pretty simple:
|
|
||||||
|
|
||||||
- User will pop out the untitled panel
|
|
||||||
- This utility will take a screenshot of each panel
|
|
||||||
- The screenshot image will be fed into OCR using [Tesseract](https://github.com/charlesw/tesseract/)
|
|
||||||
- The OCR text (mostly 'gibberish') will be compared to a predefined set of keyword text that is defined by the user. These comparison text can be customized and additional panel type and profile can be added by the user for more plane configuration.
|
|
||||||
- By being able to identify the untitled panel, this solves the problem of not able to easily reposition these panel in subsequent flight.
|
|
||||||
|
|
||||||
## Workflow
|
|
||||||
:
|
|
||||||
|
|
||||||
1. User pops out the untitled panels such as MFD or PFD on G1000
|
|
||||||
2. User selects **Analyze** for the types of panel just got popped out
|
|
||||||
3. User positions these panels in addition to any predefined toolbar menu windows to their liking
|
|
||||||
4. User saves the position
|
|
||||||
5. In next flight, user pops out the untitled panels
|
|
||||||
6. User selects Analyze
|
|
||||||
7. The windows will reposition themselves to their saved position.
|
|
||||||
|
|
||||||
In addition,
|
|
||||||
|
|
||||||
- Profiles can be added for each plane configuration
|
|
||||||
- Customizable
|
|
||||||
|
|
||||||
which focuses on touch inputs to make your flying more enjoyable! It is designed for an iPad and Android tablet plus Arduino's input controls in mind to provide a simple DIY cockpit for all the casual sim fans out there. This application can also be used in any modern browser on PC or tablet with all features enabled. The initial release includes features such as:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Files
|
|
||||||
|
|
||||||
StackEdit stores your files in your browser, which means all your files are automatically saved locally and are accessible **offline!**
|
|
||||||
|
|
||||||
## Create files and folders
|
|
||||||
|
|
||||||
The file explorer is accessible using the button in left corner of the navigation bar. You can create a new file by clicking the **New file** button in the file explorer. You can also create folders by clicking the **New folder** button.
|
|
||||||
|
|
||||||
## Switch to another file
|
|
||||||
|
|
||||||
All your files and folders are presented as a tree in the file explorer. You can switch from one to another by clicking a file in the tree.
|
|
||||||
|
|
||||||
## Rename a file
|
|
||||||
|
|
||||||
You can rename the current file by clicking the file name in the navigation bar or by clicking the **Rename** button in the file explorer.
|
|
||||||
|
|
||||||
## Delete a file
|
|
||||||
|
|
||||||
You can delete the current file by clicking the **Remove** button in the file explorer. The file will be moved into the **Trash** folder and automatically deleted after 7 days of inactivity.
|
|
||||||
|
|
||||||
## Export a file
|
|
||||||
|
|
||||||
You can export the current file by clicking **Export to disk** in the menu. You can choose to export the file as plain Markdown, as HTML using a Handlebars template or as a PDF.
|
|
||||||
|
|
||||||
|
|
||||||
# Synchronization
|
|
||||||
|
|
||||||
Synchronization is one of the biggest features of StackEdit. It enables you to synchronize any file in your workspace with other files stored in your **Google Drive**, your **Dropbox** and your **GitHub** accounts. This allows you to keep writing on other devices, collaborate with people you share the file with, integrate easily into your workflow... The synchronization mechanism takes place every minute in the background, downloading, merging, and uploading file modifications.
|
|
||||||
|
|
||||||
There are two types of synchronization and they can complement each other:
|
|
||||||
|
|
||||||
- The workspace synchronization will sync all your files, folders and settings automatically. This will allow you to fetch your workspace on any other device.
|
|
||||||
> To start syncing your workspace, just sign in with Google in the menu.
|
|
||||||
|
|
||||||
- The file synchronization will keep one file of the workspace synced with one or multiple files in **Google Drive**, **Dropbox** or **GitHub**.
|
|
||||||
> Before starting to sync files, you must link an account in the **Synchronize** sub-menu.
|
|
||||||
|
|
||||||
## Open a file
|
|
||||||
|
|
||||||
You can open a file from **Google Drive**, **Dropbox** or **GitHub** by opening the **Synchronize** sub-menu and clicking **Open from**. Once opened in the workspace, any modification in the file will be automatically synced.
|
|
||||||
|
|
||||||
## Save a file
|
|
||||||
|
|
||||||
You can save any file of the workspace to **Google Drive**, **Dropbox** or **GitHub** by opening the **Synchronize** sub-menu and clicking **Save on**. Even if a file in the workspace is already synced, you can save it to another location. StackEdit can sync one file with multiple locations and accounts.
|
|
||||||
|
|
||||||
## Synchronize a file
|
|
||||||
|
|
||||||
Once your file is linked to a synchronized location, StackEdit will periodically synchronize it by downloading/uploading any modification. A merge will be performed if necessary and conflicts will be resolved.
|
|
||||||
|
|
||||||
If you just have modified your file and you want to force syncing, click the **Synchronize now** button in the navigation bar.
|
|
||||||
|
|
||||||
> **Note:** The **Synchronize now** button is disabled if you have no file to synchronize.
|
|
||||||
|
|
||||||
## Manage file synchronization
|
|
||||||
|
|
||||||
Since one file can be synced with multiple locations, you can list and manage synchronized locations by clicking **File synchronization** in the **Synchronize** sub-menu. This allows you to list and remove synchronized locations that are linked to your file.
|
|
||||||
|
|
||||||
|
|
||||||
# Publication
|
|
||||||
|
|
||||||
Publishing in StackEdit makes it simple for you to publish online your files. Once you're happy with a file, you can publish it to different hosting platforms like **Blogger**, **Dropbox**, **Gist**, **GitHub**, **Google Drive**, **WordPress** and **Zendesk**. With [Handlebars templates](http://handlebarsjs.com/), you have full control over what you export.
|
|
||||||
|
|
||||||
> Before starting to publish, you must link an account in the **Publish** sub-menu.
|
|
||||||
|
|
||||||
## Publish a File
|
|
||||||
|
|
||||||
You can publish your file by opening the **Publish** sub-menu and by clicking **Publish to**. For some locations, you can choose between the following formats:
|
|
||||||
|
|
||||||
- Markdown: publish the Markdown text on a website that can interpret it (**GitHub** for instance),
|
|
||||||
- HTML: publish the file converted to HTML via a Handlebars template (on a blog for example).
|
|
||||||
|
|
||||||
## Update a publication
|
|
||||||
|
|
||||||
After publishing, StackEdit keeps your file linked to that publication which makes it easy for you to re-publish it. Once you have modified your file and you want to update your publication, click on the **Publish now** button in the navigation bar.
|
|
||||||
|
|
||||||
> **Note:** The **Publish now** button is disabled if your file has not been published yet.
|
|
||||||
|
|
||||||
## Manage file publication
|
|
||||||
|
|
||||||
Since one file can be published to multiple locations, you can list and manage publish locations by clicking **File publication** in the **Publish** sub-menu. This allows you to list and remove publication locations that are linked to your file.
|
|
||||||
|
|
||||||
|
|
||||||
# Markdown extensions
|
|
||||||
|
|
||||||
StackEdit extends the standard Markdown syntax by adding extra **Markdown extensions**, providing you with some nice features.
|
|
||||||
|
|
||||||
> **ProTip:** You can disable any **Markdown extension** in the **File properties** dialog.
|
|
||||||
|
|
||||||
|
|
||||||
## SmartyPants
|
|
||||||
|
|
||||||
SmartyPants converts ASCII punctuation characters into "smart" typographic punctuation HTML entities. For example:
|
|
||||||
|
|
||||||
| |ASCII |HTML |
|
|
||||||
|----------------|-------------------------------|-----------------------------|
|
|
||||||
|Single backticks|`'Isn't this fun?'` |'Isn't this fun?' |
|
|
||||||
|Quotes |`"Isn't this fun?"` |"Isn't this fun?" |
|
|
||||||
|Dashes |`-- is en-dash, --- is em-dash`|-- is en-dash, --- is em-dash|
|
|
||||||
|
|
||||||
|
|
||||||
## KaTeX
|
|
||||||
|
|
||||||
You can render LaTeX mathematical expressions using [KaTeX](https://khan.github.io/KaTeX/):
|
|
||||||
|
|
||||||
The *Gamma function* satisfying $\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$ is via the Euler integral
|
|
||||||
|
|
||||||
$$
|
|
||||||
\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,.
|
|
||||||
$$
|
|
||||||
|
|
||||||
> You can find more information about **LaTeX** mathematical expressions [here](http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference).
|
|
||||||
|
|
||||||
|
|
||||||
## UML diagrams
|
|
||||||
|
|
||||||
You can render UML diagrams using [Mermaid](https://mermaidjs.github.io/). For example, this will produce a sequence diagram:
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
sequenceDiagram
|
|
||||||
Alice ->> Bob: Hello Bob, how are you?
|
|
||||||
Bob-->>John: How about you John?
|
|
||||||
Bob--x Alice: I am good thanks!
|
|
||||||
Bob-x John: I am good thanks!
|
|
||||||
Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.
|
|
||||||
|
|
||||||
Bob-->Alice: Checking with John...
|
|
||||||
Alice->John: Yes... John, how are you?
|
|
||||||
```
|
|
||||||
|
|
||||||
And this will produce a flow chart:
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
graph LR
|
|
||||||
A[Square Rect] -- Link text --> B((Circle))
|
|
||||||
A --> C(Round Rect)
|
|
||||||
B --> D{Rhombus}
|
|
||||||
C --> D
|
|
||||||
```
|
|
150
WindowManager.cs
150
WindowManager.cs
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
|
||||||
|
@ -12,17 +11,35 @@ namespace MSFSPopoutPanelManager
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
|
public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
|
[DllImport("user32.dll")]
|
||||||
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
|
public static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
const short SWP_NOZORDER = 0X4;
|
[DllImport("USER32.dll")]
|
||||||
const int SWP_SHOWWINDOW = 0x0040;
|
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern IntPtr SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
|
||||||
|
|
||||||
|
const int SWP_NOMOVE = 0x0002;
|
||||||
|
const int SWP_NOSIZE = 0x0001;
|
||||||
|
const int SWP_ALWAYS_ON_TOP = SWP_NOMOVE | SWP_NOSIZE;
|
||||||
|
|
||||||
|
const int GWL_STYLE = -16;
|
||||||
|
|
||||||
|
const int WS_SIZEBOX = 0x00040000;
|
||||||
|
const int WS_BORDER = 0x00800000;
|
||||||
|
const int WS_DLGFRAME = 0x00400000;
|
||||||
|
const int WS_CAPTION = WS_BORDER | WS_DLGFRAME;
|
||||||
|
|
||||||
private const int MSFS_CONNECTION_RETRY_TIMEOUT = 2000;
|
private const int MSFS_CONNECTION_RETRY_TIMEOUT = 2000;
|
||||||
private Timer _timer;
|
private Timer _timer;
|
||||||
private UserData _userData;
|
private UserData _userData;
|
||||||
private MainWindow _simWindow;
|
private MainWindow _simWindow;
|
||||||
private AnalysisEngine _analysisEngine;
|
private AnalysisEngine _analysisEngine;
|
||||||
|
private Dictionary<IntPtr, Int64> _originalChildWindowStyles;
|
||||||
|
|
||||||
public WindowManager()
|
public WindowManager()
|
||||||
{
|
{
|
||||||
|
@ -53,16 +70,40 @@ namespace MSFSPopoutPanelManager
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Analyze(string profileName)
|
public bool Analyze(string profileName)
|
||||||
{
|
{
|
||||||
|
_originalChildWindowStyles = null;
|
||||||
|
_simWindow.ChildWindowsData = new List<ChildWindow>();
|
||||||
|
|
||||||
_analysisEngine.Analyze(ref _simWindow, profileName);
|
_analysisEngine.Analyze(ref _simWindow, profileName);
|
||||||
|
|
||||||
// Load previously saved position if available
|
return _simWindow.ChildWindowsData.FindAll(x => x.PopoutType == PopoutType.Custom || x.PopoutType == PopoutType.BuiltIn).Count > 0;
|
||||||
if(_simWindow.ChildWindowsData.Count > 0)
|
|
||||||
LoadProfile(profileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveProfile(string profileName)
|
public void ApplySettings(string profileName, bool showPanelTitleBar, bool alwaysOnTop)
|
||||||
|
{
|
||||||
|
// Try to load previous profiles
|
||||||
|
_userData = FileManager.ReadUserData();
|
||||||
|
var profileSettings = _userData != null ? _userData.Profiles.Find(x => x.Name == profileName) : null;
|
||||||
|
|
||||||
|
if (profileSettings == null)
|
||||||
|
{
|
||||||
|
OnStatusUpdated?.Invoke(this, new EventArgs<string>("Profile settings does not exist. Please move pop out panels to desire location and click Save Settings."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// select all valid windows
|
||||||
|
var childWindows = _simWindow.ChildWindowsData.FindAll(x => x.PopoutType == PopoutType.Custom || x.PopoutType == PopoutType.BuiltIn);
|
||||||
|
|
||||||
|
if (childWindows.Count > 0)
|
||||||
|
{
|
||||||
|
ApplyPositions(profileSettings, childWindows);
|
||||||
|
ApplyAlwaysOnTop(alwaysOnTop, childWindows);
|
||||||
|
ApplyHidePanelTitleBar(showPanelTitleBar, childWindows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveSettings(string profileName, bool hidePanelTitleBar, bool alwaysOnTop)
|
||||||
{
|
{
|
||||||
if (_userData == null)
|
if (_userData == null)
|
||||||
_userData = new UserData();
|
_userData = new UserData();
|
||||||
|
@ -70,19 +111,27 @@ namespace MSFSPopoutPanelManager
|
||||||
var profile = _userData.Profiles.Find(x => x.Name == profileName);
|
var profile = _userData.Profiles.Find(x => x.Name == profileName);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
profile = new Profile() { Name = profileName };
|
profile = new Profile() { Name = profileName, AlwaysOnTop = alwaysOnTop, HidePanelTitleBar = hidePanelTitleBar };
|
||||||
_userData.Profiles.Add(profile);
|
_userData.Profiles.Add(profile);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
profile.HidePanelTitleBar = hidePanelTitleBar;
|
||||||
|
profile.AlwaysOnTop = alwaysOnTop;
|
||||||
|
}
|
||||||
|
|
||||||
if (_simWindow.ChildWindowsData.Count > 0)
|
if (_simWindow.ChildWindowsData.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var window in _simWindow.ChildWindowsData)
|
foreach (var window in _simWindow.ChildWindowsData)
|
||||||
{
|
{
|
||||||
var rect = new Rect();
|
if (!window.Title.Contains("Failed Analysis"))
|
||||||
GetWindowRect(window.Handle, ref rect);
|
{
|
||||||
|
var rect = new Rect();
|
||||||
|
GetWindowRect(window.Handle, ref rect);
|
||||||
|
|
||||||
if (!profile.PopoutNames.TryAdd(window.Title, rect))
|
if (!profile.PopoutNames.TryAdd(window.Title, rect))
|
||||||
profile.PopoutNames[window.Title] = rect;
|
profile.PopoutNames[window.Title] = rect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileManager.WriteUserData(_userData);
|
FileManager.WriteUserData(_userData);
|
||||||
|
@ -90,31 +139,70 @@ namespace MSFSPopoutPanelManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadProfile(string profileName)
|
public void RestorePanelTitleBar()
|
||||||
{
|
{
|
||||||
_userData = FileManager.ReadUserData();
|
if (_simWindow != null)
|
||||||
var profile = _userData != null ? _userData.Profiles.Find(x => x.Name == profileName) : null;
|
|
||||||
|
|
||||||
if(profile == null)
|
|
||||||
{
|
{
|
||||||
OnStatusUpdated?.Invoke(this, new EventArgs<string>("Position settings for this profile does not exist. Please move pop out panels to desire location and click Save Positions."));
|
var childWindows = _simWindow.ChildWindowsData.FindAll(x => x.PopoutType == PopoutType.Custom || x.PopoutType == PopoutType.BuiltIn);
|
||||||
return;
|
ApplyHidePanelTitleBar(false, childWindows);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_simWindow.ChildWindowsData.Count > 0)
|
private void ApplyPositions(Profile userProfile, List<ChildWindow> childWindows)
|
||||||
|
{
|
||||||
|
foreach (var childWindow in childWindows)
|
||||||
{
|
{
|
||||||
foreach (var window in _simWindow.ChildWindowsData)
|
var hasCoordinates = userProfile.PopoutNames.ContainsKey(childWindow.Title);
|
||||||
{
|
|
||||||
var coor = profile.PopoutNames.FirstOrDefault(w => w.Key == window.Title);
|
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(coor.Key))
|
if (hasCoordinates)
|
||||||
|
{
|
||||||
|
var rect = userProfile.PopoutNames[childWindow.Title];
|
||||||
|
MoveWindow(childWindow.Handle, rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyAlwaysOnTop(bool alwaysOnTop, List<ChildWindow> childWindows)
|
||||||
|
{
|
||||||
|
if (alwaysOnTop)
|
||||||
|
{
|
||||||
|
foreach (var childWindow in childWindows)
|
||||||
|
{
|
||||||
|
Rect rect = new Rect();
|
||||||
|
GetWindowRect(childWindow.Handle, ref rect);
|
||||||
|
SetWindowPos(childWindow.Handle, new IntPtr(-1), rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top, SWP_ALWAYS_ON_TOP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyHidePanelTitleBar(bool hidePanelTitleBar, List<ChildWindow> childWindows)
|
||||||
|
{
|
||||||
|
if (hidePanelTitleBar)
|
||||||
|
{
|
||||||
|
_originalChildWindowStyles = new Dictionary<IntPtr, Int64>();
|
||||||
|
|
||||||
|
foreach (var childWindow in childWindows)
|
||||||
|
{
|
||||||
|
// Save the current panel title bar styles so we can restore it later
|
||||||
|
if (!_originalChildWindowStyles.ContainsKey(childWindow.Handle))
|
||||||
|
_originalChildWindowStyles[childWindow.Handle] = GetWindowLong(childWindow.Handle, GWL_STYLE).ToInt64();
|
||||||
|
|
||||||
|
SetWindowLong(childWindow.Handle, GWL_STYLE, (uint)(_originalChildWindowStyles[childWindow.Handle] & ~(WS_CAPTION | WS_SIZEBOX)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_originalChildWindowStyles != null)
|
||||||
|
{
|
||||||
|
foreach (var childWindow in childWindows)
|
||||||
{
|
{
|
||||||
var rect = coor.Value;
|
if (_originalChildWindowStyles.ContainsKey(childWindow.Handle))
|
||||||
SetWindowPos(window.Handle, 0, rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top, SWP_NOZORDER | SWP_SHOWWINDOW);
|
{
|
||||||
|
SetWindowLong(childWindow.Handle, GWL_STYLE, (uint)_originalChildWindowStyles[childWindow.Handle]);
|
||||||
|
_originalChildWindowStyles.Remove(childWindow.Handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OnStatusUpdated?.Invoke(this, new EventArgs<string>("Previously saved panel positions have been set."));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 29 KiB |
Loading…
Reference in a new issue