This commit is contained in:
Vladimir Bratukhin 2023-08-11 13:45:28 +06:00 committed by GitHub
commit 8defa9cca7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -67,6 +67,9 @@ namespace OnTopReplica.StartupOptions {
private static void ParseCommandLine(string[] args, Options options) { private static void ParseCommandLine(string[] args, Options options) {
var cmdOptions = new NDesk.Options.OptionSet() var cmdOptions = new NDesk.Options.OptionSet()
.Add<int>("screen=", "ScreenIndex to display on.", id => {
options.ScreenIndex = id;
})
.Add<long>("windowId=", "Window handle ({HWND}) to be cloned.", id => { .Add<long>("windowId=", "Window handle ({HWND}) to be cloned.", id => {
options.WindowId = new IntPtr(id); options.WindowId = new IntPtr(id);
options.WindowTitle = null; options.WindowTitle = null;

View file

@ -5,7 +5,8 @@ using System.Text;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using OnTopReplica.WindowSeekers; using OnTopReplica.WindowSeekers;
using System.Windows.Forms;
namespace OnTopReplica.StartupOptions { namespace OnTopReplica.StartupOptions {
/// <summary> /// <summary>
@ -19,7 +20,9 @@ namespace OnTopReplica.StartupOptions {
DisableChrome = false; DisableChrome = false;
MustBeVisible = false; MustBeVisible = false;
Fullscreen = false; Fullscreen = false;
} }
public int ScreenIndex = 0;
#region Position and size #region Position and size
@ -97,6 +100,12 @@ namespace OnTopReplica.StartupOptions {
#region Application #region Application
private void setFormLocation(Form form, Screen screen) {
Point start = StartLocation ?? default(Point);
Point loc = new Point(start.X + screen.WorkingArea.Location.X, start.Y + screen.WorkingArea.Location.Y);
form.Location = loc;
}
public void Apply(MainForm form) { public void Apply(MainForm form) {
Log.Write("Applying command line launch parameters"); Log.Write("Applying command line launch parameters");
@ -160,6 +169,9 @@ namespace OnTopReplica.StartupOptions {
form.ClientSize = StartSize.Value; form.ClientSize = StartSize.Value;
} }
if (ScreenIndex != 0) {
setFormLocation(form, Screen.AllScreens[ScreenIndex]);
}
//Other features //Other features
if (EnableClickForwarding) { if (EnableClickForwarding) {
form.ClickForwardingEnabled = true; form.ClickForwardingEnabled = true;