Screenshots correctly taken from windowed tab

Screenshots can be taken from undock tabs, created helper tab singleton class to make it easy to determine the current tab in the DPS - mremote model
This commit is contained in:
Camilo Alvarez
2019-02-05 20:50:13 -05:00
parent 39b919c38a
commit c836e29d2f
4 changed files with 39 additions and 4 deletions

View File

@@ -23,7 +23,7 @@ namespace mRemoteNG.UI.Tabs
private void ConnectionTab_GotFocus(object sender, EventArgs e)
{
Runtime.MessageCollector.AddMessage(Messages.MessageClass.DebugMsg,"Tab got focused: " + TabText);
TabHelper.Instance.CurrentTab = this;
}
protected override void OnFormClosing(FormClosingEventArgs e)

View File

@@ -0,0 +1,34 @@
using mRemoteNG.App;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mRemoteNG.UI.Tabs
{
class TabHelper
{
private static readonly Lazy<TabHelper> lazyHelper= new Lazy<TabHelper>(() => new TabHelper());
public static TabHelper Instance { get { return lazyHelper.Value; } }
private TabHelper()
{
}
private ConnectionTab currentTab;
public ConnectionTab CurrentTab
{
get
{
return currentTab;
}
set
{
currentTab = value;
Runtime.MessageCollector.AddMessage(Messages.MessageClass.DebugMsg, "Tab got focused: " + currentTab.TabText);
}
}
}
}

View File

@@ -723,9 +723,9 @@ namespace mRemoteNG.UI.Window
{
cmenTab.Close();
Application.DoEvents();
var selectedTab = (ConnectionTab)GetInterfaceControl()?.Parent;
if (selectedTab == null) return;
Windows.ScreenshotForm.AddScreenshot(MiscTools.TakeScreenshot(selectedTab));
//var selectedTab = (ConnectionTab)GetInterfaceControl()?.Parent;
if (TabHelper.Instance.CurrentTab == null) return;
Windows.ScreenshotForm.AddScreenshot(MiscTools.TakeScreenshot(TabHelper.Instance.CurrentTab));
}
#endregion

View File

@@ -701,6 +701,7 @@
<Compile Include="UI\Tabs\MremoteNGAutoHideStrip.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Tabs\TabHelper.cs" />
<Compile Include="UI\TaskDialog\CommandButton.cs">
<SubType>Component</SubType>
</Compile>