Исправил баги с переключением экранна

This commit is contained in:
klavirshik 2024-11-02 18:56:44 +02:00
parent c4793cf63f
commit 3ce6ddffe4
21 changed files with 176 additions and 42 deletions

Binary file not shown.

View File

@ -42,9 +42,9 @@
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 180); this.label1.Location = new System.Drawing.Point(12, 180);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(355, 13); this.label1.Size = new System.Drawing.Size(347, 13);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "SCCMманагер программа для удобной организации работы c CSSM\r\n"; this.label1.Text = "SCCMанагер программа для удобной организации работы c CSSM\r\n";
// //
// label20 // label20
// //

View File

@ -103,15 +103,30 @@ namespace Remontor.Connector
SetParent(Proc.MainWindowHandle, View.Handle); SetParent(Proc.MainWindowHandle, View.Handle);
SetWindowLong(Proc.MainWindowHandle, GWL_STYLE, WS_VISIBLE); SetWindowLong(Proc.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
ModeMonitor.Resize(Proc, View); ModeMonitor.Resize(Proc, View);
ModeMonitor.Resize(Proc, View);
// hwnd = GetWindowHandleByTitle("Устанавливается контакт с агентом удаленного управления на клиенте " + ConnectStr);
Thread.Sleep(50); Thread.Sleep(50);
hwnd = GetWindowHandleByTitle("Contacting Remote Control Agent on client " + ConnectStr);
hwnd = GetWindowHandleByTitle("Устанавливается контакт с агентом удаленного управления на клиенте " + ConnectStr.Split(' ')[0]) ;
// hwnd = GetWindowHandleByTitle("Contacting Remote Control Agent on client " + ConnectStr);
Point CenterView = new Point(View.Bounds.Width/2, View.Bounds.Height/2); Point CenterView = new Point(View.Bounds.Width/2, View.Bounds.Height/2);
Point CenterDraw = View.PointToScreen(CenterView); Point CenterDraw = View.PointToScreen(CenterView);
MoveWindow(hwnd, CenterDraw.X- 325, CenterDraw.Y - 125 ,650,250,true); MoveWindow(hwnd, CenterDraw.X- 325, CenterDraw.Y - 125 ,650,250,true);
Task.Run(new Action(() => {
Thread.Sleep(3000);
System.Console.WriteLine("reenew");
SConnector.FormMain.Invoke(new MethodInvoker(delegate
{
Resize();
}));
}));
}
}
catch (Exception) { catch (Exception) {
MessageBox.Show("Не верно заданно приложение для подключения."); MessageBox.Show("Не верно заданно приложение для подключения.");
ModeMonitor = new OffMon(); ModeMonitor = new OffMon();
@ -169,10 +184,13 @@ namespace Remontor.Connector
{ {
this.Active = act; this.Active = act;
View.Visible = act; View.Visible = act;
if (act) Resize(); // if (act) Resize();
if (act) if (act)
{ {
ShowWindow(hwnd, 5); ShowWindow(hwnd, 5);
ModeMonitor.Set();
ModeMonitor.Resize(Proc, View);
Point CenterView = new Point(View.Bounds.Width / 2, View.Bounds.Height / 2); Point CenterView = new Point(View.Bounds.Width / 2, View.Bounds.Height / 2);
Point CenterDraw = View.PointToScreen(CenterView); Point CenterDraw = View.PointToScreen(CenterView);
MoveWindow(hwnd, CenterDraw.X - 325, CenterDraw.Y - 125, 650, 250, true); MoveWindow(hwnd, CenterDraw.X - 325, CenterDraw.Y - 125, 650, 250, true);
@ -183,7 +201,7 @@ namespace Remontor.Connector
} }
ModeMonitor.Resize(Proc, View);
Update(); Update();
} }
@ -201,6 +219,11 @@ namespace Remontor.Connector
MoveWindow(hwnd, CenterDraw.X - 325, CenterDraw.Y - 125, 650, 250, true); MoveWindow(hwnd, CenterDraw.X - 325, CenterDraw.Y - 125, 650, 250, true);
} }
public void StateChange()
{
ModeMonitor.Set();
}
public IModeMon GetModeMon() public IModeMon GetModeMon()
{ {
return ModeMonitor; return ModeMonitor;
@ -209,6 +232,7 @@ namespace Remontor.Connector
public IModeMon SetModeMon(IModeMon Mode) public IModeMon SetModeMon(IModeMon Mode)
{ {
ModeMonitor = ModeMonitor.Change(Mode); ModeMonitor = ModeMonitor.Change(Mode);
ModeMonitor.Set();
ModeMonitor.Resize(Proc, View); ModeMonitor.Resize(Proc, View);
return ModeMonitor; return ModeMonitor;
} }

View File

@ -23,13 +23,22 @@ namespace Remontor.Connector
private int over = 0; private int over = 0;
public DobleMonFull() public DobleMonFull()
{ {
OldWidth = SConnector.FormMain.Bounds.Width; // OldWidth = SConnector.FormMain.Bounds.Width;
OldHeight = SConnector.FormMain.Height; //OldHeight = SConnector.FormMain.Height;
OldState = SConnector.FormMain.WindowState; //OldState = SConnector.FormMain.WindowState;
OldPoint = SConnector.FormMain.Location; //OldPoint = SConnector.FormMain.Location;
//System.Console.WriteLine(OldWidth.ToString());
//System.Console.WriteLine(OldHeight.ToString());
}
public override void Set()
{
} }
public override void Resize(Process Proc, Control View) public override void Resize(Process Proc, Control View)
{ {
if (Chanded) return;
Chanded = true;
if (over == 0) if (over == 0)
{ {
over = 1; over = 1;
@ -38,32 +47,20 @@ namespace Remontor.Connector
{ {
over = 0; over = 0;
} }
if (Chanded) return;
Chanded = true;
SConnector.FormMain.WindowState = FormWindowState.Normal; SConnector.FormMain.WindowState = FormWindowState.Normal;
Chanded = false;
SConnector.FormMain.Width = SGlobalSetting.settingApp.WidthDoble; SConnector.FormMain.Width = SGlobalSetting.settingApp.WidthDoble;
SConnector.FormMain.Height = SGlobalSetting.settingApp.HeightDoble; SConnector.FormMain.Height = SGlobalSetting.settingApp.HeightDoble;
SConnector.FormMain.Location = new System.Drawing.Point(SGlobalSetting.settingApp.xPosDoble, SGlobalSetting.settingApp.yPosDoble); SConnector.FormMain.Location = new System.Drawing.Point(SGlobalSetting.settingApp.xPosDoble, SGlobalSetting.settingApp.yPosDoble);
Chanded = false;
MoveWindow(Proc.MainWindowHandle, View.Bounds.X, View.Bounds.Y + 9, View.Bounds.Width, View.Bounds.Height - 9 + over, true); MoveWindow(Proc.MainWindowHandle, View.Bounds.X, View.Bounds.Y + 9, View.Bounds.Width, View.Bounds.Height - 9 + over, true);
} }
public override IModeMon Change(IModeMon Mode) public override IModeMon Change(IModeMon Mode)
{ {
if (!(Mode is DobleMonFull)) if (Mode == this) return this;
{
Chanded = true;
SConnector.FormMain.WindowState = OldState;
SConnector.FormMain.Width = OldWidth;
SConnector.FormMain.Height = OldHeight;
SConnector.FormMain.Location = OldPoint;
Chanded = false;
}
else
{
return this;
}
return Mode; return Mode;
} }
} }

View File

@ -15,9 +15,22 @@ namespace Remontor.Connector
[DllImport("user32.dll")] [DllImport("user32.dll")]
static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint); static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint);
private int over = 0; private int over = 0;
public DobleMonOne() { } private bool Chanded = true;
public override void Resize(Process Proc, Control View) public DobleMonOne() {
}
public override void Set()
{ {
Chanded = true;
SConnector.FormMain.WindowState = SConnector.WindowState;
SConnector.FormMain.Location = new System.Drawing.Point(SConnector.x, SConnector.y);
SConnector.FormMain.Width = SConnector.Width;
SConnector.FormMain.Height = SConnector.Height;
Chanded = false;
}
public override void Resize(Process Proc, Control View)
{
if (Chanded) return;
if (over == 0) if (over == 0)
{ {
over = 1; over = 1;
@ -26,6 +39,17 @@ namespace Remontor.Connector
{ {
over = 0; over = 0;
} }
Chanded = true;
if(SConnector.FormMain.WindowState == FormWindowState.Normal)
{
SConnector.Width = SConnector.FormMain.Width;
SConnector.Height = SConnector.FormMain.Height;
SConnector.x = SConnector.FormMain.Location.X;
SConnector.y = SConnector.FormMain.Location.Y;
}
SConnector.WindowState = SConnector.FormMain.WindowState;
Chanded = false;
MoveWindow(Proc.MainWindowHandle, View.Bounds.X, View.Bounds.Y + 9, View.Bounds.Width * 2, View.Bounds.Height - 9 + over, true); MoveWindow(Proc.MainWindowHandle, View.Bounds.X, View.Bounds.Y + 9, View.Bounds.Width * 2, View.Bounds.Height - 9 + over, true);
} }
public override IModeMon Change(IModeMon Mode) public override IModeMon Change(IModeMon Mode)

View File

@ -14,9 +14,22 @@ namespace Remontor.Connector
[DllImport("user32.dll")] [DllImport("user32.dll")]
static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint); static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint);
private int over = 0; private int over = 0;
public DobleMonTwo() { } private bool Chanded = true;
public override void Resize(Process Proc, Control View) public DobleMonTwo() {
}
public override void Set()
{ {
Chanded = true;
SConnector.FormMain.WindowState = SConnector.WindowState;
SConnector.FormMain.Location = new System.Drawing.Point(SConnector.x, SConnector.y);
SConnector.FormMain.Width = SConnector.Width;
SConnector.FormMain.Height = SConnector.Height;
Chanded = false;
}
public override void Resize(Process Proc, Control View)
{
if (Chanded) return;
if (over == 0) if (over == 0)
{ {
over = 1; over = 1;
@ -25,6 +38,17 @@ namespace Remontor.Connector
{ {
over = 0; over = 0;
} }
Chanded = true;
if (SConnector.FormMain.WindowState == FormWindowState.Normal)
{
SConnector.Width = SConnector.FormMain.Width;
SConnector.Height = SConnector.FormMain.Height;
SConnector.x = SConnector.FormMain.Location.X;
SConnector.y = SConnector.FormMain.Location.Y;
}
SConnector.WindowState = SConnector.FormMain.WindowState;
Chanded = false;
MoveWindow(Proc.MainWindowHandle, View.Bounds.X - View.Bounds.Width, View.Bounds.Y + 9, View.Bounds.Width * 2, View.Bounds.Height - 9 + over, true); MoveWindow(Proc.MainWindowHandle, View.Bounds.X - View.Bounds.Width, View.Bounds.Y + 9, View.Bounds.Width * 2, View.Bounds.Height - 9 + over, true);
} }
public override IModeMon Change(IModeMon Mode) public override IModeMon Change(IModeMon Mode)

View File

@ -13,5 +13,6 @@ namespace Remontor.Connector
{ {
public abstract void Resize(Process Proc, Control View); public abstract void Resize(Process Proc, Control View);
public abstract IModeMon Change(IModeMon Mode); public abstract IModeMon Change(IModeMon Mode);
public abstract void Set();
} }
} }

View File

@ -13,9 +13,20 @@ namespace Remontor.Connector
{ {
[DllImport("user32.dll")] [DllImport("user32.dll")]
static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint); static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint);
public OffMon() { } private bool Chanded = true;
public OffMon() {
// SConnector.FormMain.Bounds = SConnector.MainBounds;
Chanded = false;
}
public override void Set()
{
}
public override void Resize(Process Proc, Control View) public override void Resize(Process Proc, Control View)
{ {
if (Chanded) return;
// SConnector.MainBounds = SConnector.FormMain.Bounds;
} }
public override IModeMon Change(IModeMon Mode) public override IModeMon Change(IModeMon Mode)
{ {

View File

@ -1,4 +1,5 @@
using System; using Remontor.Setting;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -13,12 +14,27 @@ namespace Remontor.Connector
{ {
[DllImport("user32.dll")] [DllImport("user32.dll")]
static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint); static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint);
private int over = 0; private int over = 0;
private bool Chanded = true;
public OneMon() { } public OneMon() {
}
public override void Set()
{
Chanded = true;
SConnector.FormMain.WindowState = SConnector.WindowState;
SConnector.FormMain.Location = new System.Drawing.Point(SConnector.x, SConnector.y);
SConnector.FormMain.Width = SConnector.Width;
SConnector.FormMain.Height = SConnector.Height;
Chanded = false;
}
public override void Resize(Process Proc, Control View) public override void Resize(Process Proc, Control View)
{ {
if(over == 0) if (Chanded) return;
;
if (over == 0)
{ {
over = 1; over = 1;
} }
@ -26,6 +42,17 @@ namespace Remontor.Connector
{ {
over = 0; over = 0;
} }
Chanded = true;
if (SConnector.FormMain.WindowState == FormWindowState.Normal)
{
SConnector.Width = SConnector.FormMain.Width;
SConnector.Height = SConnector.FormMain.Height;
SConnector.x = SConnector.FormMain.Location.X;
SConnector.y = SConnector.FormMain.Location.Y;
}
SConnector.WindowState = SConnector.FormMain.WindowState;
Chanded = false;
MoveWindow(Proc.MainWindowHandle, View.Bounds.X, View.Bounds.Y + 9, View.Bounds.Width, View.Bounds.Height - 9 + over, true); MoveWindow(Proc.MainWindowHandle, View.Bounds.X, View.Bounds.Y + 9, View.Bounds.Width, View.Bounds.Height - 9 + over, true);
} }
public override IModeMon Change(IModeMon Mode) public override IModeMon Change(IModeMon Mode)

View File

@ -21,6 +21,8 @@ namespace Remontor.Connector
public static Control Panel; public static Control Panel;
public static Form1 FormMain; public static Form1 FormMain;
public static Connect ActionConnect = null; public static Connect ActionConnect = null;
public static int x,y, Width, Height;
public static FormWindowState WindowState = FormWindowState.Normal;
public static void NewConnect(IComp comp) public static void NewConnect(IComp comp)
{ {
Connect con = new Connect(comp); Connect con = new Connect(comp);
@ -92,6 +94,14 @@ namespace Remontor.Connector
} }
} }
public static void StateChangeActiv()
{
if (ActionConnect != null)
{
ActionConnect.StateChange();
}
}
public static int ActivConnect() public static int ActivConnect()
{ {
return Connects.Count(); return Connects.Count();

View File

@ -121,7 +121,7 @@
this.DoubleBuffered = true; this.DoubleBuffered = true;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1"; this.Name = "Form1";
this.Text = "SCCMманагер"; this.Text = "SCCMанагер";
this.Deactivate += new System.EventHandler(this.Form1_Deactivate); this.Deactivate += new System.EventHandler(this.Form1_Deactivate);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);

View File

@ -24,6 +24,7 @@ namespace Remontor
public bool CloseOn = false; public bool CloseOn = false;
public bool ShowOn = false; public bool ShowOn = false;
private FormWindowState lastWindowsState = FormWindowState.Minimized;
public MenuStripCommand MenuStripCommand; public MenuStripCommand MenuStripCommand;
public Form1() public Form1()
{ {
@ -35,6 +36,7 @@ namespace Remontor
barSessionControl1.hideTabSetting += flowConteinerSetting1.HideBar; barSessionControl1.hideTabSetting += flowConteinerSetting1.HideBar;
SConnector.Panel = this.panel3; SConnector.Panel = this.panel3;
SConnector.FormMain = this; SConnector.FormMain = this;
MenuStripCommand = new MenuStripCommand(); MenuStripCommand = new MenuStripCommand();
MenuStripCommand.UpdateTree += flowContainerWords1.UpdateTree; MenuStripCommand.UpdateTree += flowContainerWords1.UpdateTree;
@ -53,6 +55,18 @@ namespace Remontor
private void tabControl1_SizeChanged(object sender, EventArgs e) private void tabControl1_SizeChanged(object sender, EventArgs e)
{ {
SConnector.ResizeActiv(); SConnector.ResizeActiv();
if (this.WindowState != lastWindowsState)
{
lastWindowsState = this.WindowState;
// if(this.WindowState == FormWindowState.Maximized) SConnector.WindowState = FormWindowState.Maximized;
//if (this.WindowState == FormWindowState.Normal)
//{
// SConnector.WindowState = FormWindowState.Normal;
SConnector.StateChangeActiv();
//}
}
} }
@ -73,7 +87,10 @@ namespace Remontor
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {
SConnector.x = this.Bounds.X;
SConnector.y = this.Bounds.Y;
SConnector.Width = this.Bounds.Width;
SConnector.Height = this.Bounds.Height;
} }
private void barSessionControl1_Load(object sender, EventArgs e) private void barSessionControl1_Load(object sender, EventArgs e)

View File

@ -25,8 +25,7 @@ namespace Remontor.Picter
} }
} }
else
{
if (comp.GetName() != null) if (comp.GetName() != null)
{ {
@ -41,7 +40,7 @@ namespace Remontor.Picter
new PicLoaderTask(comp.GetName(), image); new PicLoaderTask(comp.GetName(), image);
} }
} }
}
} }
static public void WriteResult(PicBase picBase) static public void WriteResult(PicBase picBase)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.