Сделал задержку закрытия ремоутера

This commit is contained in:
klavirshik 2024-10-28 19:01:44 +02:00
parent fcbc5c5b7d
commit 3ae22202b9
18 changed files with 117 additions and 29 deletions

Binary file not shown.

View File

@ -54,7 +54,7 @@ namespace Remontor
private void CloseBtn_Click(object sender, EventArgs e)
{
SConnector.DeleteConnect(connect);
connect.Delete();
}
}

View File

@ -161,9 +161,9 @@ namespace Remontor
if (SConnector.ActionConnect != null)
{
SConnector.DeleteConnect(SConnector.ActionConnect);
SConnector.ActionConnect.Delete();
SConnector.NewConnect(SConnector.ActionConnect.GetComp);
// SConnector.DeleteConnect(SConnector.ActionConnect);
SConnector.ActionConnect.Reconnect();
// SConnector.NewConnect(SConnector.ActionConnect.GetComp);
}
}else if (e.Button == MouseButtons.Right)
{

View File

@ -6,10 +6,12 @@ using System.Drawing;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Remontor.Connector
{
@ -69,6 +71,9 @@ namespace Remontor.Connector
public event UpdateConnect Update;
public Control View;
public IntPtr hwnd;
private bool RecconectFlag, RecconectFlagIp;
public Connect(IComp comp)
{
Comp = comp;
@ -92,11 +97,14 @@ namespace Remontor.Connector
Proc = Process.Start(SGlobalSetting.settingApp.pathApp, ConnectStr);
//Proc = Process.Start(SGlobalSetting.settingApp.pathApp);
Proc.WaitForInputIdle();
Proc.EnableRaisingEvents = true;
Proc.Exited += Proc_Exited;
SetParent(Proc.MainWindowHandle, View.Handle);
SetWindowLong(Proc.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
ModeMonitor.Resize(Proc, View);
//Thread.Sleep(500);
hwnd = GetWindowHandleByTitle("Contacting Remote Control Agent on client " + ConnectStr);
hwnd = GetWindowHandleByTitle("Устанавливается контакт с агентом удаленного управления на клиенте " + ConnectStr);
// hwnd = GetWindowHandleByTitle("Contacting Remote Control Agent on client " + ConnectStr);
Point CenterView = new Point(View.Bounds.Width/2, View.Bounds.Height/2);
Point CenterDraw = View.PointToScreen(CenterView);
MoveWindow(hwnd, CenterDraw.X- 325, CenterDraw.Y - 125 ,650,250,true);
@ -112,6 +120,39 @@ namespace Remontor.Connector
}
private void Proc_Exited(object sender, EventArgs e)
{
SConnector.FormMain.Invoke(new MethodInvoker(delegate
{
DelBar();
}));
if (RecconectFlag)
{
if (RecconectFlagIp)
{
SConnector.FormMain.Invoke(new MethodInvoker(delegate
{
ReconnectBarIp();
}));
}
else
{
SConnector.FormMain.Invoke(new MethodInvoker(delegate
{
ReconnectBar();
}));
}
}
RecconectFlag = false;
RecconectFlagIp = false;
Proc.Dispose();
Proc = null;
}
public void Activ(bool act)
{
this.Active = act;
@ -154,9 +195,7 @@ namespace Remontor.Connector
}
public IModeMon SetModeMon(IModeMon Mode)
{
ModeMonitor = ModeMonitor.Change(Mode);
ModeMonitor.Resize(Proc, View);
return ModeMonitor;
@ -175,14 +214,53 @@ namespace Remontor.Connector
return Comp.GetName() + "(" + Comp.GetNetNameStr() + ")";
}
public void Delete()
public async void DelBar()
{
if (Proc != null) Proc.CloseMainWindow();
SConnector.DeleteConnect(this);
ModeMonitor = new OffMon();
SConnector.Panel.Controls.Remove(View);
if (Proc != null) Proc.Close();
if (Proc != null) Proc.Dispose();
Proc = null;
}
public async void ReconnectBar()
{
SConnector.NewConnect(Comp);
}
public async void ReconnectBarIp()
{
SConnector.NewConnectIP(Comp);
}
public void Delete()
{
if (Proc != null)
{
Proc.CloseMainWindow();
}
}
public void Reconnect()
{
RecconectFlag = true;
RecconectFlagIp = false;
if (Proc != null)
{
Proc.CloseMainWindow();
}
}
public void ReconnectIP()
{
RecconectFlag = true;
RecconectFlagIp = true;
if (Proc != null)
{
Proc.CloseMainWindow();
}
}
}
}

View File

@ -25,11 +25,11 @@ namespace Remontor
{
InitializeComponent();
NormalSize = this.Size;
this.Visible = true;
//WordsList.MainCategory = SGlobalSetting.LoadWords();
WordsTree.Nodes.AddRange(WordsList.ListNodes());
SGlobalSetting.settingExpand.ExpendAll(WordsTree.Nodes);
@ -52,14 +52,16 @@ namespace Remontor
{
if(barShow == BarShow.ShowWords)
{
this.Visible = true;
this.Height = NormalSize.Height;
}
else
{
this.Visible = false;
this.Height = 0;
//this.Visible = false;
}
return this.Visible;
return (this.Height != 0);
}

View File

@ -93,7 +93,6 @@
this.flowContainerWords1.Name = "flowContainerWords1";
this.flowContainerWords1.Size = new System.Drawing.Size(330, 678);
this.flowContainerWords1.TabIndex = 1;
this.flowContainerWords1.Visible = false;
//
// flowConteinerSetting1
//

View File

@ -70,22 +70,28 @@ namespace Remontor
{
if (NowConnect != null)
{
SConnector.DeleteConnect(NowConnect);
NowConnect.Delete();
SConnector.ActionConnect.Reconnect();
}
if (actForm != null) actForm.Close();
SConnector.NewConnect(Comp);
else
{
if (actForm != null) actForm.Close();
SConnector.NewConnect(Comp);
}
}
private void CommandConnecIP_Click(object sender, EventArgs e)
{
if (NowConnect != null)
{
SConnector.DeleteConnect(NowConnect);
NowConnect.Delete();
SConnector.ActionConnect.ReconnectIP();
}
if (actForm != null) actForm.Close();
if (Comp.GetIP() != null)SConnector.NewConnectIP(Comp);
else
{
if (actForm != null) actForm.Close();
if (Comp.GetIP() != null) SConnector.NewConnectIP(Comp);
}
}
private void CommandConnectRDP_Click(object sender, EventArgs e)
@ -97,7 +103,7 @@ namespace Remontor
private void CommandOpenFS_Click(object sender, EventArgs e)
{
if (actForm != null) actForm.Close();
Process.Start("explorer", @"\\" + Comp.GetNetNameStr());
Process.Start("explorer", @"\\" + Comp.GetNetNameStr() + @"\c$");
}
private void CommandOpenRegEdit_Click(object sender, EventArgs e)

View File

@ -21,6 +21,7 @@ namespace Remontor.Picter
};
public static Image GetImageMax(int index)
{
return CollectImgMax[index];
}
}

View File

@ -18,7 +18,7 @@ namespace Remontor.Picter
IComp Comp = WordsList.FindCompName(comp.GetNetName());
if(Comp != null)
{
image.Image = PicBaseWords.GetImageMax(comp.GetImage());
image.Image = PicBaseWords.GetImageMax(Comp.GetImage());
return;
}
else

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -54,3 +54,5 @@ C:\Users\klavi\source\repos\Remontor\Remontor\obj\Debug\Remontor.FlowConteinerSe
C:\Users\klavi\source\repos\Remontor\Remontor\obj\Debug\Remontor.Setting.settingAppControl.resources
C:\Users\klavi\source\repos\Remontor\Remontor\obj\Debug\Remontor.MenuStripCommand.resources
C:\Users\klavi\source\repos\Remontor\Remontor\obj\Debug\Remontor.Words.AboutForm.resources
C:\Users\Владимир\source\repos\Remontor\Remontor\obj\Debug\Remontor.MenuStripCommand.resources
C:\Users\Владимир\source\repos\Remontor\Remontor\obj\Debug\Remontor.Words.AboutForm.resources

Binary file not shown.

Binary file not shown.