Добавили создание сессий

This commit is contained in:
klavirshik 2024-10-14 19:08:50 +02:00
parent 146918dfd8
commit 48e501b1dc
20 changed files with 231 additions and 123 deletions

Binary file not shown.

View File

@ -28,42 +28,49 @@
/// </summary>
private void InitializeComponent()
{
this.button6 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.NameBtn = new System.Windows.Forms.Label();
this.CloseBtn = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button6
// NameBtn
//
this.button6.BackColor = System.Drawing.SystemColors.Control;
this.button6.BackgroundImage = global::Remontor.Properties.Resources.close_min;
this.button6.FlatAppearance.BorderSize = 0;
this.button6.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.button6.Location = new System.Drawing.Point(131, 1);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(20, 20);
this.button6.TabIndex = 7;
this.button6.UseVisualStyleBackColor = false;
this.NameBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.NameBtn.AutoSize = true;
this.NameBtn.Location = new System.Drawing.Point(7, 4);
this.NameBtn.Name = "NameBtn";
this.NameBtn.Size = new System.Drawing.Size(13, 13);
this.NameBtn.TabIndex = 8;
this.NameBtn.Text = "_";
this.NameBtn.Click += new System.EventHandler(this.NameBtn_Click);
//
// label1
// CloseBtn
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(7, 4);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(118, 13);
this.label1.TabIndex = 8;
this.label1.Text = "v.volkova(1MA001234)";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.CloseBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.CloseBtn.BackColor = System.Drawing.Color.Transparent;
this.CloseBtn.BackgroundImage = global::Remontor.Properties.Resources.close_min;
this.CloseBtn.FlatAppearance.BorderSize = 0;
this.CloseBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.CloseBtn.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.CloseBtn.Location = new System.Drawing.Point(20, 1);
this.CloseBtn.Name = "CloseBtn";
this.CloseBtn.Size = new System.Drawing.Size(20, 20);
this.CloseBtn.TabIndex = 7;
this.CloseBtn.UseVisualStyleBackColor = false;
this.CloseBtn.Click += new System.EventHandler(this.CloseBtn_Click);
//
// BarButtonControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.Controls.Add(this.label1);
this.Controls.Add(this.button6);
this.Controls.Add(this.NameBtn);
this.Controls.Add(this.CloseBtn);
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "BarButtonControl";
this.Size = new System.Drawing.Size(150, 21);
this.Size = new System.Drawing.Size(42, 21);
this.ResumeLayout(false);
this.PerformLayout();
@ -71,7 +78,7 @@
#endregion
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button CloseBtn;
private System.Windows.Forms.Label NameBtn;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Remontor.Connector;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -10,16 +11,46 @@ using System.Windows.Forms;
namespace Remontor
{
public partial class BarButtonControl : UserControl
internal partial class BarButtonControl : UserControl
{
Connect connect = null;
Color Background;
public BarButtonControl()
{
InitializeComponent();
}
private void BarButtonControl_Load(object sender, EventArgs e)
public BarButtonControl(Connect connect, bool backColor)
{
InitializeComponent();
if(backColor) this.BackColor = Color.Gainsboro;
this.connect = connect;
NameBtn.Text = connect.toString();
this.Width = NameBtn.Width + 32;
Background = this.BackColor;
connect.Update += UpdateAct;
}
private void UpdateAct()
{
if (connect.ActiveOn)
{
this.BackColor = SystemColors.ActiveCaption;
}
else
{
this.BackColor = Background;
}
}
private void NameBtn_Click(object sender, EventArgs e)
{
SConnector.Activ(connect);
}
private void CloseBtn_Click(object sender, EventArgs e)
{
SConnector.DeleteConnect(connect);
}
}
}

View File

@ -28,59 +28,41 @@
/// </summary>
private void InitializeComponent()
{
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.barButtonControl3 = new Remontor.BarButtonControl();
this.barButtonControl2 = new Remontor.BarButtonControl();
this.barButtonControl1 = new Remontor.BarButtonControl();
this.FlowButton = new System.Windows.Forms.FlowLayoutPanel();
this.NewBtn = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.NewBtn = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.ShowBar = new System.Windows.Forms.Button();
this.flowLayoutPanel1.SuspendLayout();
this.FlowButton.SuspendLayout();
this.SuspendLayout();
//
// flowLayoutPanel1
// FlowButton
//
this.flowLayoutPanel1.Controls.Add(this.barButtonControl3);
this.flowLayoutPanel1.Controls.Add(this.barButtonControl2);
this.flowLayoutPanel1.Controls.Add(this.barButtonControl1);
this.flowLayoutPanel1.Controls.Add(this.NewBtn);
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(589, 21);
this.flowLayoutPanel1.TabIndex = 8;
this.FlowButton.Controls.Add(this.NewBtn);
this.FlowButton.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.FlowButton.Location = new System.Drawing.Point(0, 0);
this.FlowButton.Margin = new System.Windows.Forms.Padding(0);
this.FlowButton.Name = "FlowButton";
this.FlowButton.Size = new System.Drawing.Size(589, 21);
this.FlowButton.TabIndex = 8;
this.FlowButton.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.FlowButton_ControlRemoved);
//
// barButtonControl3
// NewBtn
//
this.barButtonControl3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.barButtonControl3.Location = new System.Drawing.Point(439, 0);
this.barButtonControl3.Margin = new System.Windows.Forms.Padding(0);
this.barButtonControl3.Name = "barButtonControl3";
this.barButtonControl3.Size = new System.Drawing.Size(150, 21);
this.barButtonControl3.TabIndex = 3;
//
// barButtonControl2
//
this.barButtonControl2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.barButtonControl2.Location = new System.Drawing.Point(289, 0);
this.barButtonControl2.Margin = new System.Windows.Forms.Padding(0);
this.barButtonControl2.Name = "barButtonControl2";
this.barButtonControl2.Size = new System.Drawing.Size(150, 21);
this.barButtonControl2.TabIndex = 2;
//
// barButtonControl1
//
this.barButtonControl1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.barButtonControl1.Location = new System.Drawing.Point(139, 0);
this.barButtonControl1.Margin = new System.Windows.Forms.Padding(0);
this.barButtonControl1.Name = "barButtonControl1";
this.barButtonControl1.Size = new System.Drawing.Size(150, 21);
this.barButtonControl1.TabIndex = 1;
this.NewBtn.BackColor = System.Drawing.Color.Transparent;
this.NewBtn.BackgroundImage = global::Remontor.Properties.Resources.connect_min;
this.NewBtn.FlatAppearance.BorderSize = 0;
this.NewBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.NewBtn.Location = new System.Drawing.Point(559, 0);
this.NewBtn.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
this.NewBtn.Name = "NewBtn";
this.NewBtn.Size = new System.Drawing.Size(20, 20);
this.NewBtn.TabIndex = 0;
this.NewBtn.UseVisualStyleBackColor = false;
this.NewBtn.Click += new System.EventHandler(this.NewBtn_Click);
//
// button4
//
@ -134,20 +116,6 @@
this.button1.TabIndex = 9;
this.button1.UseVisualStyleBackColor = false;
//
// NewBtn
//
this.NewBtn.BackColor = System.Drawing.Color.Transparent;
this.NewBtn.BackgroundImage = global::Remontor.Properties.Resources.connect_min;
this.NewBtn.FlatAppearance.BorderSize = 0;
this.NewBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.NewBtn.Location = new System.Drawing.Point(108, 0);
this.NewBtn.Margin = new System.Windows.Forms.Padding(10, 0, 10, 0);
this.NewBtn.Name = "NewBtn";
this.NewBtn.Size = new System.Drawing.Size(21, 21);
this.NewBtn.TabIndex = 0;
this.NewBtn.UseVisualStyleBackColor = false;
this.NewBtn.Click += new System.EventHandler(this.NewBtn_Click);
//
// button5
//
this.button5.BackColor = System.Drawing.SystemColors.Control;
@ -181,12 +149,12 @@
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.flowLayoutPanel1);
this.Controls.Add(this.FlowButton);
this.Controls.Add(this.button5);
this.Controls.Add(this.ShowBar);
this.Name = "BarSessionControl";
this.Size = new System.Drawing.Size(768, 21);
this.flowLayoutPanel1.ResumeLayout(false);
this.FlowButton.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -196,11 +164,8 @@
private System.Windows.Forms.Button NewBtn;
private System.Windows.Forms.Button ShowBar;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.FlowLayoutPanel FlowButton;
private System.Windows.Forms.Button button1;
private BarButtonControl barButtonControl1;
private BarButtonControl barButtonControl3;
private BarButtonControl barButtonControl2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;

View File

@ -1,4 +1,5 @@
using System;
using Remontor.Connector;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -11,21 +12,43 @@ using System.Windows.Forms;
namespace Remontor
{
public partial class BarSessionControl : UserControl
internal partial class BarSessionControl : UserControl
{
public delegate bool HideWors();
public HideWors hideWors;
public List<BarButtonControl> buttons;
public BarSessionControl()
{
InitializeComponent();
SConnector.Update += UpdateBar;
buttons = new List<BarButtonControl>();
}
public void UpdateBar(List<Connect> connects)
{
bool GreyBackground = false;
buttons.Clear();
FlowButton.Controls.Clear();
foreach (var item in connects)
{
BarButtonControl button = new BarButtonControl(item, GreyBackground);
buttons.Add(button);
GreyBackground = !GreyBackground;
FlowButton.Controls.Add(button);
}
FlowButton.Controls.Add(NewBtn);
}
private void ShowBar_Click(object sender, EventArgs e)
{
if (!hideWors())
{
ShowBar.BackgroundImage = global::Remontor.Properties.Resources.down_min11;
ShowBar.BackgroundImage = global::Remontor.Properties.Resources.
down_min11;
}
else
{
@ -38,5 +61,10 @@ namespace Remontor
Finder.Finder finder = new Finder.Finder();
finder.ShowDialog();
}
private void FlowButton_ControlRemoved(object sender, ControlEventArgs e)
{
if(e.Control is BarButtonControl) e.Control.Dispose();
}
}
}

View File

@ -1,20 +1,52 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Remontor.Connector
{
internal class Connect
{
{
private const int SWP_NOOWNERZORDER = 0x200;
private const int SWP_NOREDRAW = 0x8;
private const int SWP_NOZORDER = 0x4;
private const int SWP_SHOWWINDOW = 0x0040;
private const int WS_EX_MDICHILD = 0x40;
private const int SWP_FRAMECHANGED = 0x20;
private const int SWP_NOACTIVATE = 0x10;
private const int SWP_ASYNCWINDOWPOS = 0x4000;
private const int SWP_NOMOVE = 0x2;
private const int SWP_NOSIZE = 0x1;
private const int GWL_STYLE = (-16);
private const int WS_VISIBLE = 0x10000000;
private const int WM_CLOSE = 0x10;
private const int WS_CHILD = 0x40000000;
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll")]
static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint);
private Process Proc;
private bool Active = false;
private IComp Comp;
private string Login = "";
public delegate void UpdateConnect();
public event UpdateConnect Update;
public Connect(IComp comp)
{
Comp = comp;
}
public Connect(IComp comp, string login)
@ -23,20 +55,38 @@ namespace Remontor.Connector
this.Login = login;
}
public void ConnectSCCM(Control panel)
{
Proc = Process.Start("notepad");
//Thread.Sleep(500); // Allow the process to open it's window
Proc.WaitForInputIdle();
SetParent(Proc.MainWindowHandle, panel.Handle);
SetWindowLong(Proc.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
MoveWindow(Proc.MainWindowHandle, panel.Bounds.X, panel.Bounds.Y, panel.Bounds.Width, panel.Bounds.Height, true);
}
public void Activ(bool act)
{
this.Active = act;
Update();
}
public bool ActiveOn
{
get { return this.Active; }
}
public IComp GetComp
{
get { return Comp; }
}
public string toString()
{
string result;
if (Login == "")
{
return Comp.GetNetNameStr();
}
return Login + "(" + Comp.GetNetNameStr() + ")";
}
}
}

View File

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Remontor.Connector
{
@ -11,9 +13,29 @@ namespace Remontor.Connector
public delegate void UpdateConnect(List<Connect> connects);
public static event UpdateConnect Update;
private static List<Connect> Connects = new List<Connect>();
public static Control Panel;
public static void NewConnect(IComp comp)
{
Connects.Add(new Connect(comp));
Connect con = new Connect(comp);
Connects.Add(con);
Update(Connects);
Activ(con);
con.ConnectSCCM(Panel);
}
public static void Activ(Connect actConnect)
{
actConnect.Activ(true);
foreach (var connect in Connects)
{
if (connect != actConnect) connect.Activ(false);
}
}
public static void DeleteConnect(Connect Connect)
{
Connects.Remove(Connect);
Update(Connects);
}
}

View File

@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.CompNameLB = new System.Windows.Forms.TextBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.label1 = new System.Windows.Forms.Label();
this.ConnectBtn = new System.Windows.Forms.Button();
@ -44,15 +44,14 @@
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// textBox1
// CompNameLB
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.CompNameLB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(125, 12);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(328, 20);
this.textBox1.TabIndex = 0;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
this.CompNameLB.Location = new System.Drawing.Point(125, 12);
this.CompNameLB.Name = "CompNameLB";
this.CompNameLB.Size = new System.Drawing.Size(328, 20);
this.CompNameLB.TabIndex = 0;
//
// flowLayoutPanel1
//
@ -91,6 +90,7 @@
this.ConnectBtn.TabIndex = 3;
this.ConnectBtn.Text = "Подключиться";
this.ConnectBtn.UseVisualStyleBackColor = true;
this.ConnectBtn.Click += new System.EventHandler(this.ConnectBtn_Click);
//
// sessionItemControl1
//
@ -163,7 +163,7 @@
this.Controls.Add(this.ConnectBtn);
this.Controls.Add(this.label1);
this.Controls.Add(this.flowLayoutPanel1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.CompNameLB);
this.Name = "Finder";
this.Text = "Новое подключение";
this.flowLayoutPanel1.ResumeLayout(false);
@ -174,7 +174,7 @@
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox CompNameLB;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private SessionItemControl sessionItemControl1;
private SessionItemControl sessionItemControl2;

View File

@ -1,4 +1,5 @@
using System;
using Remontor.Connector;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -17,9 +18,10 @@ namespace Remontor.Finder
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
private void ConnectBtn_Click(object sender, EventArgs e)
{
SConnector.NewConnect(new CompId(CompNameLB.Text));
this.Close();
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using Remontor.Connector;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -38,7 +39,7 @@ namespace Remontor
{
InitializeComponent();
barSessionControl1.hideWors = flowContainer1.HideBar;
SConnector.Panel = this.panel3;
//p1 = Process.Start("notepad");
@ -47,12 +48,14 @@ namespace Remontor
//SetParent(p1.MainWindowHandle, panel1.Handle);
//SetWindowLong(p1.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
//MoveWindow(p1.MainWindowHandle, panel1.Bounds.X, panel1.Bounds.Y - 24, panel1.Bounds.Width, panel1.Bounds.Height, true);
p = Process.Start("notepad");
//p = Process.Start("notepad");
//Thread.Sleep(500); // Allow the process to open it's window
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, panel3.Handle);
SetWindowLong(p.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
MoveWindow(p.MainWindowHandle, panel3.Bounds.X, panel3.Bounds.Y, panel3.Bounds.Width, panel3.Bounds.Height, true);
//p.WaitForInputIdle();
//SetParent(p.MainWindowHandle, panel3.Handle);
//SetWindowLong(p.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
//MoveWindow(p.MainWindowHandle, panel3.Bounds.X, panel3.Bounds.Y, panel3.Bounds.Width, panel3.Bounds.Height, true);
}
private void button1_Click(object sender, EventArgs e)
@ -75,7 +78,7 @@ namespace Remontor
private void tabControl1_SizeChanged(object sender, EventArgs e)
{
//MoveWindow(p1.MainWindowHandle, panel1.Bounds.X, panel1.Bounds.Y - 24, panel1.Bounds.Width, panel1.Bounds.Height, true);
MoveWindow(p.MainWindowHandle, panel3.Bounds.X, panel3.Bounds.Y, panel3.Bounds.Width, panel3.Bounds.Height, true);
//MoveWindow(p.MainWindowHandle, panel3.Bounds.X, panel3.Bounds.Y, panel3.Bounds.Width, panel3.Bounds.Height, true);
}
private void splitContainer2_Panel2_Paint(object sender, PaintEventArgs e)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.