From c1c3c9519dc10019c4098d813fcbfca1725f7e1d Mon Sep 17 00:00:00 2001 From: rainerosion Date: Thu, 12 Jan 2023 02:46:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AA=97=E5=8F=A3=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E5=8C=96=E3=80=81=E6=9C=80=E5=B0=8F=E5=8C=96=E3=80=81=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=E4=BB=A5=E5=8F=8A=E7=AA=97=E5=8F=A3=E6=8B=96=E5=8A=A8?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tech.sln.DotSettings.user | 2 + Tech/ArpUtil.cs | 129 ++++++++++++++++++++++ Tech/Form1.Designer.cs | 178 ++++++++++++++++++++++++------- Tech/Form1.cs | 54 ++++++++++ Tech/Form1.resx | 162 ++++++++++++++++++++++------ Tech/GetIPNetTable.cs | 149 ++++++++++++++++++++++++++ Tech/MultiPlayerView.Designer.cs | 46 ++++++++ Tech/MultiPlayerView.cs | 12 +++ Tech/PlayerView.Designer.cs | 60 ++++++----- Tech/PlayerView.cs | 9 +- Tech/Program.cs | 6 ++ Tech/Tech.csproj | 11 ++ Tech/Tech.csproj.DotSettings | 2 +- Tech/UCOverview.Designer.cs | 2 + Tech/UCOverview.cs | 15 +++ 15 files changed, 734 insertions(+), 103 deletions(-) create mode 100644 Tech/ArpUtil.cs create mode 100644 Tech/GetIPNetTable.cs create mode 100644 Tech/MultiPlayerView.Designer.cs create mode 100644 Tech/MultiPlayerView.cs diff --git a/Tech.sln.DotSettings.user b/Tech.sln.DotSettings.user index 56a0f3e..48e2470 100644 --- a/Tech.sln.DotSettings.user +++ b/Tech.sln.DotSettings.user @@ -1,4 +1,6 @@  True True + True + True True \ No newline at end of file diff --git a/Tech/ArpUtil.cs b/Tech/ArpUtil.cs new file mode 100644 index 0000000..ce44949 --- /dev/null +++ b/Tech/ArpUtil.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace PlumByteUI_Learn +{ + public class ArpUtil + { + /// + /// 引入windowsAPI + /// + + //用于转换ip地址 + [DllImport("ws2_32.dll")] + public static extern int inet_addr(string cp); + + //用于发送APR包(根据APR协议!) + [DllImport("IPHLPAPI.dll")] + public static extern int SendARP(int DestIP, int ScrIP, ref long pMacAddr, ref int PhyAddrLen); + + /// + /// 根据ARP映射获取指定IP的MAC地址 + /// + /// + /// + public string GetMACAddressByIP(string ip) + { + StringBuilder macRouteBuilder = new StringBuilder(); + string macRoute; + try + { + int ldest = inet_addr(ip); //将IP地址从 点数格式转换成无符号长整型 + long macinfo = new long(); + int len = 6; + //SendARP函数发送一个地址解析协议(ARP)请求获得指定的目的地IPv4地址相对应的物理地址 + SendARP(ldest, 0, ref macinfo, ref len); + string TmpMac = Convert.ToString(macinfo, 16).PadLeft(12, '0'); //转换成16进制 + // + for (int i = 10; i >= 0; i = i - 2) //反过来读取,原因可以查看接口函数sendApr! + { + macRouteBuilder.Append(TmpMac.Substring(i, 2).ToUpper()); + if (i >= 2) + { + macRouteBuilder.Append("-"); + } + } + } + catch (Exception Mye) + { + macRouteBuilder.Append("获取远程主机的MAC错误:"); + macRouteBuilder.Append(Mye.ToString()); + } + + macRoute = macRouteBuilder.ToString(); + return macRoute; + } + + /// + /// 获取ARP查询字符串 + /// + /// + private static string GetArpResult() + { + Process p = null; + string output = string.Empty; + try + { + p = Process.Start(new ProcessStartInfo("arp", "-a -n 192.168.0.105") + { + CreateNoWindow = true, + UseShellExecute = false, + RedirectStandardOutput = true + }); + output = p.StandardOutput.ReadToEnd(); + } + catch (Exception ex) + { + throw new Exception("IPInfo: Error Retrieving 'arp -a' Results", ex); + } + finally + { + if (p != null) + { + p.Close(); + } + } + + return output; + } + + /// + /// 获取IP地址与Mac地址对应数据表 + /// + /// Mac-IP + public static List GetIpInfo() + { + try + { + var list = new List(); + var arpResult = GetArpResult(); + foreach (var arp in arpResult.Split(new char[] { '\n', '\r' })) + { + if (!string.IsNullOrEmpty(arp)) + { + var oArp = arp.Split(new char[] { ' ', '\t' }); + var pieces = (from piece in oArp + where !string.IsNullOrEmpty(piece) + select piece).ToArray(); + if (pieces.Length == 3) + { + //pieces[1]Mac + //pieces[0]IP + list.Add(new string[2] { pieces[1], pieces[0] }); + } + } + } + + return list; + } + catch (Exception ex) + { + throw new Exception("IPInfo: Error Parsing 'arp -a' results", ex); + } + } + } +} \ No newline at end of file diff --git a/Tech/Form1.Designer.cs b/Tech/Form1.Designer.cs index 685af98..49eb755 100644 --- a/Tech/Form1.Designer.cs +++ b/Tech/Form1.Designer.cs @@ -34,40 +34,48 @@ this.button3 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.panelContainer = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.pictureBox4 = new System.Windows.Forms.PictureBox(); + this.pictureBox3 = new System.Windows.Forms.PictureBox(); + this.closeBtn = new System.Windows.Forms.PictureBox(); + this.label1 = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.closeBtn)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // panel1 // - this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(22)))), ((int)(((byte)(101)))), ((int)(((byte)(193))))); + this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(118)))), ((int)(((byte)(211))))); this.panel1.Controls.Add(this.button4); this.panel1.Controls.Add(this.button3); this.panel1.Controls.Add(this.button2); this.panel1.Controls.Add(this.button1); - this.panel1.Controls.Add(this.pictureBox1); this.panel1.Dock = System.Windows.Forms.DockStyle.Left; - this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Location = new System.Drawing.Point(0, 30); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(237, 550); + this.panel1.Size = new System.Drawing.Size(60, 520); this.panel1.TabIndex = 0; // // button4 // + this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.button4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(118)))), ((int)(((byte)(211))))); this.button4.FlatAppearance.BorderSize = 0; this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button4.ForeColor = System.Drawing.Color.White; this.button4.Image = ((System.Drawing.Image)(resources.GetObject("button4.Image"))); - this.button4.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.button4.Location = new System.Drawing.Point(0, 274); + this.button4.Location = new System.Drawing.Point(0, 462); this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(237, 54); + this.button4.Size = new System.Drawing.Size(60, 58); this.button4.TabIndex = 4; - this.button4.Text = " Settings"; - this.button4.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button4.Text = " 设置"; + this.button4.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.button4.UseVisualStyleBackColor = false; this.button4.Click += new System.EventHandler(this.button4_Click); // @@ -78,13 +86,12 @@ this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button3.ForeColor = System.Drawing.Color.White; this.button3.Image = ((System.Drawing.Image)(resources.GetObject("button3.Image"))); - this.button3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.button3.Location = new System.Drawing.Point(0, 173); + this.button3.Location = new System.Drawing.Point(0, 116); this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(237, 54); + this.button3.Size = new System.Drawing.Size(60, 58); this.button3.TabIndex = 3; - this.button3.Text = " Scan"; - this.button3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button3.Text = " 相册"; + this.button3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.button3.UseVisualStyleBackColor = false; this.button3.Click += new System.EventHandler(this.button3_Click); // @@ -95,13 +102,12 @@ this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button2.ForeColor = System.Drawing.Color.White; this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image"))); - this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.button2.Location = new System.Drawing.Point(0, 223); + this.button2.Location = new System.Drawing.Point(0, 58); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(237, 54); + this.button2.Size = new System.Drawing.Size(60, 58); this.button2.TabIndex = 2; - this.button2.Text = " Recovery"; - this.button2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button2.Text = "回放"; + this.button2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.button2.UseVisualStyleBackColor = false; // // button1 @@ -111,34 +117,112 @@ this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button1.ForeColor = System.Drawing.Color.White; this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image"))); - this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.button1.Location = new System.Drawing.Point(0, 123); + this.button1.Location = new System.Drawing.Point(0, 0); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(237, 54); + this.button1.Size = new System.Drawing.Size(60, 58); this.button1.TabIndex = 1; - this.button1.Text = " 直播"; - this.button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.button1.Text = " 直播"; + this.button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.button1.UseVisualStyleBackColor = false; this.button1.Click += new System.EventHandler(this.button1_Click); // - // pictureBox1 - // - this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); - this.pictureBox1.Location = new System.Drawing.Point(35, 22); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(161, 49); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pictureBox1.TabIndex = 0; - this.pictureBox1.TabStop = false; - // // panelContainer // - this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; - this.panelContainer.Location = new System.Drawing.Point(237, 0); + this.panelContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.panelContainer.Location = new System.Drawing.Point(60, 30); this.panelContainer.Name = "panelContainer"; - this.panelContainer.Size = new System.Drawing.Size(921, 550); + this.panelContainer.Size = new System.Drawing.Size(1098, 520); this.panelContainer.TabIndex = 1; // + // panel2 + // + this.panel2.AccessibleRole = System.Windows.Forms.AccessibleRole.TitleBar; + this.panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(110)))), ((int)(((byte)(255))))); + this.panel2.Controls.Add(this.pictureBox4); + this.panel2.Controls.Add(this.pictureBox3); + this.panel2.Controls.Add(this.closeBtn); + this.panel2.Controls.Add(this.label1); + this.panel2.Controls.Add(this.pictureBox1); + this.panel2.Dock = System.Windows.Forms.DockStyle.Top; + this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(1158, 30); + this.panel2.TabIndex = 5; + this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint); + this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TopPanel_MouseDown); + // + // pictureBox4 + // + this.pictureBox4.Dock = System.Windows.Forms.DockStyle.Right; + this.pictureBox4.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox4.ErrorImage"))); + this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image"))); + this.pictureBox4.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox4.InitialImage"))); + this.pictureBox4.Location = new System.Drawing.Point(1068, 0); + this.pictureBox4.Name = "pictureBox4"; + this.pictureBox4.Padding = new System.Windows.Forms.Padding(8); + this.pictureBox4.Size = new System.Drawing.Size(30, 30); + this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox4.TabIndex = 4; + this.pictureBox4.TabStop = false; + this.pictureBox4.Click += new System.EventHandler(this.pictureBox4_Click); + // + // pictureBox3 + // + this.pictureBox3.Dock = System.Windows.Forms.DockStyle.Right; + this.pictureBox3.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox3.ErrorImage"))); + this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image"))); + this.pictureBox3.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox3.InitialImage"))); + this.pictureBox3.Location = new System.Drawing.Point(1098, 0); + this.pictureBox3.Name = "pictureBox3"; + this.pictureBox3.Padding = new System.Windows.Forms.Padding(8); + this.pictureBox3.Size = new System.Drawing.Size(30, 30); + this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox3.TabIndex = 3; + this.pictureBox3.TabStop = false; + this.pictureBox3.Click += new System.EventHandler(this.pictureBox3_Click); + // + // closeBtn + // + this.closeBtn.Dock = System.Windows.Forms.DockStyle.Right; + this.closeBtn.ErrorImage = ((System.Drawing.Image)(resources.GetObject("closeBtn.ErrorImage"))); + this.closeBtn.Image = ((System.Drawing.Image)(resources.GetObject("closeBtn.Image"))); + this.closeBtn.InitialImage = ((System.Drawing.Image)(resources.GetObject("closeBtn.InitialImage"))); + this.closeBtn.Location = new System.Drawing.Point(1128, 0); + this.closeBtn.Name = "closeBtn"; + this.closeBtn.Padding = new System.Windows.Forms.Padding(8); + this.closeBtn.Size = new System.Drawing.Size(30, 30); + this.closeBtn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.closeBtn.TabIndex = 2; + this.closeBtn.TabStop = false; + this.closeBtn.Click += new System.EventHandler(this.pictureBox2_Click); + this.closeBtn.MouseLeave += new System.EventHandler(this.closeBtn_MouseLeave); + this.closeBtn.MouseHover += new System.EventHandler(this.closeBtn_MouseHover); + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Left; + this.label1.Font = new System.Drawing.Font("Century Gothic", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(60, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(0, 3, 0, 0); + this.label1.Size = new System.Drawing.Size(154, 30); + this.label1.TabIndex = 1; + this.label1.Text = "实训示教"; + // + // pictureBox1 + // + this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Left; + this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); + this.pictureBox1.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.InitialImage"))); + this.pictureBox1.Location = new System.Drawing.Point(0, 0); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Padding = new System.Windows.Forms.Padding(2); + this.pictureBox1.Size = new System.Drawing.Size(60, 30); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // // Form1 // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -146,6 +230,7 @@ this.ClientSize = new System.Drawing.Size(1158, 550); this.Controls.Add(this.panelContainer); this.Controls.Add(this.panel1); + this.Controls.Add(this.panel2); this.Font = new System.Drawing.Font("Century Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "Form1"; @@ -153,10 +238,26 @@ this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.closeBtn)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); } + private System.Windows.Forms.PictureBox pictureBox4; + + private System.Windows.Forms.PictureBox pictureBox3; + + private System.Windows.Forms.PictureBox closeBtn; + + private System.Windows.Forms.Label label1; + + private System.Windows.Forms.PictureBox pictureBox1; + + private System.Windows.Forms.Panel panel2; + #endregion private System.Windows.Forms.Panel panel1; @@ -164,7 +265,6 @@ private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button1; - private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Panel panelContainer; } } diff --git a/Tech/Form1.cs b/Tech/Form1.cs index 8d380bf..dbd46f9 100644 --- a/Tech/Form1.cs +++ b/Tech/Form1.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -45,5 +46,58 @@ namespace PlumByteUI_Learn this.panelContainer.Controls.Clear(); this.panelContainer.Controls.Add(playerView); } + + private void panel2_Paint(object sender, PaintEventArgs e) + { + // throw new System.NotImplementedException(); + } + + private void pictureBox2_Click(object sender, EventArgs e) + { + DialogResult dialogResult = MessageBox.Show(@"确定要退出吗?", @"确定退出?", MessageBoxButtons.OKCancel,MessageBoxIcon.Question); + if (dialogResult.Equals(DialogResult.OK)) + { + System.Environment.Exit(0); + // Application.Exit(); + } + } + + private void pictureBox2_MouseHover(object sender, EventArgs e) + { + + } + + private void closeBtn_MouseHover(object sender, EventArgs e) + { + closeBtn.BackColor = Color.Crimson; + } + + private void closeBtn_MouseLeave(object sender, EventArgs e) + { + closeBtn.BackColor = Color.FromArgb(0, 110, 255); + } + + [DllImport("user32.dll")] + public static extern bool ReleaseCapture(); + [DllImport("user32.dll")] + private static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); + private const int WM_SYSCOMMAND = 0x0112; + private const int SC_MOVE = 0xF010; + private const int HTCAPTION = 0x0002; + private void TopPanel_MouseDown(object sender, MouseEventArgs e) + { + ReleaseCapture(); + SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); + } + + private void pictureBox3_Click(object sender, EventArgs e) + { + this.WindowState = this.WindowState == FormWindowState.Maximized ? FormWindowState.Normal : FormWindowState.Maximized; + } + + private void pictureBox4_Click(object sender, EventArgs e) + { + this.WindowState = System.Windows.Forms.FormWindowState.Minimized; + } } } diff --git a/Tech/Form1.resx b/Tech/Form1.resx index 89edf2e..73ad3be 100644 --- a/Tech/Form1.resx +++ b/Tech/Form1.resx @@ -159,45 +159,137 @@ - iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAABGdBTUEAALGPC/xhBQAAARVJREFUSEvt - lD1qAlEUhYfY+rcErQXrkFSCe7AJaSxDljBiEdxDCleRRnABoguxtkoRAi/f9Z1hiMyfb6aw8IPD4577 - 7j2DD4zuBOGca6EF2qBtDdl8jFpanYL5iprkRatTMJe+50aygrB5v8YtZaWY6XvXhXB/gtoqmw/h7sqP - uHdZzYZwLwk4oJ7ssBDqOfpCXVmXAX3ZZ6iDQt687Xaoh3IDDLywnwsv6R11ZgYY+OFvgv/h2/kBBr16 - D0/vGXVUZmLztgTCQqpg835NcUgZJ51lZIbYn1oZe/SA7F3KiLU6BfMJ/Zzb+Xyjtc4ibM+jVv+HxhBN - G9BAK28EvmiGflER1p9p5HoYHqPPChpr5E5dougP9qR2rggdy1IAAAAASUVORK5CYII= + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAURJREFUWEft + lj1OAzEQhbdFnCBUFFQpaBB9LkKDOEgkCg4Qpaajo0lBm0twBZqIOzjfG4+z3hCF9fKzSPiTnhI/z8zO + 2pt4m0qlsk8IYYYWaD1AT2jupcoheYq+g/ImSDpBr5YewiPSSpTqAWklRFkTJFzGvLBxaxDk38Uy4dkt + eRN0g27RhdtdmNAdiLVbBmMlT3z4KcR26vA5R2/mRF4scB8mPjTA92W0jKXbRyFuVwflF9a2pu258vAW + zEMNbKJl9Noa4lKdhC587nOpgZkF58iMc50GVtEyVm4fhbh8BezCCfdEvwYEY+1h7yea2IN1hLw4VdBA + KeTXBv5OA+jrD2Ep5Kc6ieE/wyGQn69ATv5HdO3hLZg/0cAZukfvMhwdeKce3oL5W4fR1O0uTIx7HAuS + xnshSZCsOxnnlaxS+Yc0zRbFM/3HCeup+QAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAADFJREFUWEft + zaENAEEMwLDuv/Q/CTqpsMzGkTIAwOs71mZXd6bNru5Mm13dmTYAQGZ+rNR+kCjI6MYAAAAASUVORK5C + YII= + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAADFJREFUWEft + zaENAEEMwLDuv/Q/CTqpsMzGkTIAwOs71mZXd6bNru5Mm13dmTYAQGZ+rNR+kCjI6MYAAAAASUVORK5C + YII= + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAADFJREFUWEft + zaENAEEMwLDuv/Q/CTqpsMzGkTIAwOs71mZXd6bNru5Mm13dmTYAQGZ+rNR+kCjI6MYAAAAASUVORK5C + YII= + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAJlJREFUWEft + l8ENwCAIRR3NARyqm7mE+1jAb9NU0pPoQV7CQTD4TDho+KPWmigyhQXc98JROrxBttpRcJQObei3j0hN + A30rljpUdwF7AQoetCIrG9Rpb6Um0G9pyTDtyIuAgPx00H7oj7QLuIALuIALuMBBAkT8hLBSQCOvFOCH + zzv4JZaWCWA5groLnC2w5Vn+QMUtH5NGCDcjuMvveyxH/gAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAJlJREFUWEft + l8ENwCAIRR3NARyqm7mE+1jAb9NU0pPoQV7CQTD4TDho+KPWmigyhQXc98JROrxBttpRcJQObei3j0hN + A30rljpUdwF7AQoetCIrG9Rpb6Um0G9pyTDtyIuAgPx00H7oj7QLuIALuIALuMBBAkT8hLBSQCOvFOCH + zzv4JZaWCWA5groLnC2w5Vn+QMUtH5NGCDcjuMvveyxH/gAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAJlJREFUWEft + l8ENwCAIRR3NARyqm7mE+1jAb9NU0pPoQV7CQTD4TDho+KPWmigyhQXc98JROrxBttpRcJQObei3j0hN + A30rljpUdwF7AQoetCIrG9Rpb6Um0G9pyTDtyIuAgPx00H7oj7QLuIALuIALuMBBAkT8hLBSQCOvFOCH + zzv4JZaWCWA5groLnC2w5Vn+QMUtH5NGCDcjuMvveyxH/gAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAVdJREFUWEfF + 10tywjAQRVHWk/3PmWXEMPtxdJLXRYj5WLZsbpXAtLrva4oRp2mazu18tvNxOghZ7Vx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/3L4XxvXIJOBaI6y3GvM+jvLWonYtmjW0G8plk8Qk8rRm3laZtL6t + heYSKQ1gMD1y62fnaolmDcxIn3HZKDHJIqpJQa1rr5IvdE1EJ4sqCxU5mO9zSnrasqQt0azBHC5dAwZl + hu3Rt6fNXjBJW7S3yk5jD5fPEZN4BNfM2yKz5mC22XnfbI4YtdfsD5FJ+oARN2mtIuWYLURDjNpjtqnR + QI7UjBgpjiUnygUxrKe/fhOZB4JnZA9NGdcQ07gq1QzVxMaYFEMNj5yNyZygoSmjhhi4ZjgXU/zO0Dlq + DwOWIi9bdRm7ECN5ZH8ScbVK781XDO7p6bvRTNqrw5h8NNZu/LYoTF6BoqUZ16qUk8PkRnruMGjh3LuL + /wGqMOZppubid2iNIooNoDKTEnJhrttDSBAEQRAEQRAEQRD8ZE6n33Fuhf9TKD6wAAAAAElFTkSuQmCC \ No newline at end of file diff --git a/Tech/GetIPNetTable.cs b/Tech/GetIPNetTable.cs new file mode 100644 index 0000000..fb26166 --- /dev/null +++ b/Tech/GetIPNetTable.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using System.ComponentModel; +using System.Net; + +namespace PlumByteUI_Learn +{ + public class GetIPNetTable + { + // The max number of physical addresses. + const int MAXLEN_PHYSADDR = 8; + + // Define the MIB_IPNETROW structure. + [StructLayout(LayoutKind.Sequential)] + struct MIB_IPNETROW + { + [MarshalAs(UnmanagedType.U4)] public int dwIndex; + [MarshalAs(UnmanagedType.U4)] public int dwPhysAddrLen; + [MarshalAs(UnmanagedType.U1)] public byte mac0; + [MarshalAs(UnmanagedType.U1)] public byte mac1; + [MarshalAs(UnmanagedType.U1)] public byte mac2; + [MarshalAs(UnmanagedType.U1)] public byte mac3; + [MarshalAs(UnmanagedType.U1)] public byte mac4; + [MarshalAs(UnmanagedType.U1)] public byte mac5; + [MarshalAs(UnmanagedType.U1)] public byte mac6; + [MarshalAs(UnmanagedType.U1)] public byte mac7; + [MarshalAs(UnmanagedType.U4)] public int dwAddr; + [MarshalAs(UnmanagedType.U4)] public int dwType; + } + + // Declare the GetIpNetTable function. + [DllImport("IpHlpApi.dll")] + [return: MarshalAs(UnmanagedType.U4)] + static extern int GetIpNetTable( + IntPtr pIpNetTable, + [MarshalAs(UnmanagedType.U4)] ref int pdwSize, + bool bOrder); + + [DllImport("IpHlpApi.dll", SetLastError = true, CharSet = CharSet.Auto)] + internal static extern int FreeMibTable(IntPtr plpNetTable); + + // The insufficient buffer error. + const int ERROR_INSUFFICIENT_BUFFER = 122; + + /// + /// 获取 + /// + public static List Get_IPNetTable() + { + List ArrArpIP = new List(); + // The number of bytes needed. + int bytesNeeded = 0; + + // The result from the API call. + int result = GetIpNetTable(IntPtr.Zero, ref bytesNeeded, false); + + // Call the function, expecting an insufficient buffer. + if (result != ERROR_INSUFFICIENT_BUFFER) + { + // Throw an exception. + throw new Win32Exception(result); + } + + // Allocate the memory, do it in a try/finally block, to ensure + // that it is released. + IntPtr buffer = IntPtr.Zero; + + // Try/finally. + try + { + // Allocate the memory. + buffer = Marshal.AllocCoTaskMem(bytesNeeded); + + // Make the call again. If it did not succeed, then + // raise an error. + result = GetIpNetTable(buffer, ref bytesNeeded, false); + + // If the result is not 0 (no error), then throw an exception. + if (result != 0) + { + // Throw an exception. + throw new Win32Exception(result); + } + + // Now we have the buffer, we have to marshal it. We can read + // the first 4 bytes to get the length of the buffer. + int entries = Marshal.ReadInt32(buffer); + + // Increment the memory pointer by the size of the int. + IntPtr currentBuffer = new IntPtr(buffer.ToInt64() + + Marshal.SizeOf(typeof(int))); + + // Allocate an array of entries. + MIB_IPNETROW[] table = new MIB_IPNETROW[entries]; + + // Cycle through the entries. + for (int index = 0; index < entries; index++) + { + // Call PtrToStructure, getting the structure information. + table[index] = (MIB_IPNETROW)Marshal.PtrToStructure(new + IntPtr(currentBuffer.ToInt64() + (index * + Marshal.SizeOf(typeof(MIB_IPNETROW)))), typeof(MIB_IPNETROW)); + } + + for (int index = 0; index < entries; index++) + { + MIB_IPNETROW row = table[index]; + IPAddress ip = new IPAddress(BitConverter.GetBytes(row.dwAddr)); + Console.Write("IP:" + ip.ToString() + "\t\tMAC:"); + Console.Write(row.mac0.ToString("X2") + '-'); + Console.Write(row.mac1.ToString("X2") + '-'); + Console.Write(row.mac2.ToString("X2") + '-'); + Console.Write(row.mac3.ToString("X2") + '-'); + Console.Write(row.mac4.ToString("X2") + '-'); + Console.WriteLine(row.mac5.ToString("X2")); + ArrArpIP.Add(new ArpIP(ip.ToString(), row.mac0.ToString("X2"))); + ArrArpIP.Add(new ArpIP(ip.ToString(), row.mac1.ToString("X2"))); + ArrArpIP.Add(new ArpIP(ip.ToString(), row.mac2.ToString("X2"))); + ArrArpIP.Add(new ArpIP(ip.ToString(), row.mac3.ToString("X2"))); + ArrArpIP.Add(new ArpIP(ip.ToString(), row.mac4.ToString("X2"))); + ArrArpIP.Add(new ArpIP(ip.ToString(), row.mac5.ToString("X2"))); + ArrArpIP.Add(new ArpIP(ip.ToString(), row.mac6.ToString("X2"))); + ArrArpIP.Add(new ArpIP(ip.ToString(), row.mac7.ToString("X2"))); + } + } + finally + { + // Release the memory. + FreeMibTable(buffer); + } + + return ArrArpIP; + } + + public class ArpIP + { + public ArpIP(string _IPAddress, string _MacAddress) + { + IPAddress = _IPAddress; + MacAddress = _MacAddress; + } + + public string IPAddress { get; set; } + public string MacAddress { get; set; } + } + } +} \ No newline at end of file diff --git a/Tech/MultiPlayerView.Designer.cs b/Tech/MultiPlayerView.Designer.cs new file mode 100644 index 0000000..7bf4bc1 --- /dev/null +++ b/Tech/MultiPlayerView.Designer.cs @@ -0,0 +1,46 @@ +using System.ComponentModel; + +namespace PlumByteUI_Learn +{ + partial class MultiPlayerView + { + /// + /// Required designer variable. + /// + private IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // MultiPlayerView + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.Name = "MultiPlayerView"; + this.Size = new System.Drawing.Size(921, 550); + this.ResumeLayout(false); + } + + #endregion + } +} \ No newline at end of file diff --git a/Tech/MultiPlayerView.cs b/Tech/MultiPlayerView.cs new file mode 100644 index 0000000..b3c84a3 --- /dev/null +++ b/Tech/MultiPlayerView.cs @@ -0,0 +1,12 @@ +using System.Windows.Forms; + +namespace PlumByteUI_Learn +{ + public partial class MultiPlayerView : UserControl + { + public MultiPlayerView() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Tech/PlayerView.Designer.cs b/Tech/PlayerView.Designer.cs index 79108b9..2d2e097 100644 --- a/Tech/PlayerView.Designer.cs +++ b/Tech/PlayerView.Designer.cs @@ -31,28 +31,15 @@ namespace PlumByteUI_Learn /// private void InitializeComponent() { - this.vlcControl = new Vlc.DotNet.Forms.VlcControl(); this.panel1 = new System.Windows.Forms.Panel(); this.playBtn = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.vlcControl)).BeginInit(); + this.panel2 = new System.Windows.Forms.Panel(); + this.vlcControl = new Vlc.DotNet.Forms.VlcControl(); this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.vlcControl)).BeginInit(); this.SuspendLayout(); // - // vlcControl - // - this.vlcControl.BackColor = System.Drawing.Color.Black; - this.vlcControl.Dock = System.Windows.Forms.DockStyle.Top; - this.vlcControl.Location = new System.Drawing.Point(0, 0); - this.vlcControl.Name = "vlcControl"; - this.vlcControl.Size = new System.Drawing.Size(921, 460); - this.vlcControl.Spu = -1; - this.vlcControl.TabIndex = 0; - this.vlcControl.Text = "vlcControl1"; - this.vlcControl.VlcLibDirectory = null; - this.vlcControl.VlcMediaplayerOptions = null; - this.vlcControl.VlcLibDirectoryNeeded += new System.EventHandler(this.vlcControl_VlcLibDirectoryNeeded); - this.vlcControl.Click += new System.EventHandler(this.vlcControl_Click); - // // panel1 // this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(46)))), ((int)(((byte)(57)))), ((int)(((byte)(75))))); @@ -65,7 +52,7 @@ namespace PlumByteUI_Learn // // playBtn // - this.playBtn.Location = new System.Drawing.Point(439, 39); + this.playBtn.Location = new System.Drawing.Point(301, 39); this.playBtn.Name = "playBtn"; this.playBtn.Size = new System.Drawing.Size(75, 23); this.playBtn.TabIndex = 0; @@ -73,26 +60,51 @@ namespace PlumByteUI_Learn this.playBtn.UseVisualStyleBackColor = true; this.playBtn.Click += new System.EventHandler(this.playBtn_Click); // + // panel2 + // + this.panel2.Controls.Add(this.vlcControl); + this.panel2.Dock = System.Windows.Forms.DockStyle.Top; + this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(921, 460); + this.panel2.TabIndex = 2; + // + // vlcControl + // + this.vlcControl.Anchor = System.Windows.Forms.AnchorStyles.None; + this.vlcControl.BackColor = System.Drawing.Color.WhiteSmoke; + this.vlcControl.Location = new System.Drawing.Point(0, 0); + this.vlcControl.Name = "vlcControl"; + this.vlcControl.Size = new System.Drawing.Size(921, 460); + this.vlcControl.Spu = -1; + this.vlcControl.TabIndex = 0; + this.vlcControl.Text = "vlcControl1"; + this.vlcControl.VlcLibDirectory = null; + this.vlcControl.VlcMediaplayerOptions = null; + this.vlcControl.VlcLibDirectoryNeeded += new System.EventHandler(this.vlcControl_VlcLibDirectoryNeeded); + // // PlayerView // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.Controls.Add(this.panel2); this.Controls.Add(this.panel1); - this.Controls.Add(this.vlcControl); this.Name = "PlayerView"; this.Size = new System.Drawing.Size(921, 550); this.Load += new System.EventHandler(this.PlayerView_Load); - ((System.ComponentModel.ISupportInitialize)(this.vlcControl)).EndInit(); this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.vlcControl)).EndInit(); this.ResumeLayout(false); } + private Vlc.DotNet.Forms.VlcControl vlcControl; + + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Button playBtn; private System.Windows.Forms.Panel panel1; #endregion - - private Vlc.DotNet.Forms.VlcControl vlcControl; } } \ No newline at end of file diff --git a/Tech/PlayerView.cs b/Tech/PlayerView.cs index 7f66520..e44aae3 100644 --- a/Tech/PlayerView.cs +++ b/Tech/PlayerView.cs @@ -15,9 +15,9 @@ namespace PlumByteUI_Learn private void PlayerView_Load(object sender, EventArgs e) { - string[] options = { ":network-caching=100", ":rtsp-tcp"};// { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; // --avcodec-hw={any,d3d11va,dxva2,none} - var videoUri = new Uri(@"rtsp://127.0.0.1:8554/rains"); - vlcControl.Play(videoUri, options); + // string[] options = { ":network-caching=100", ":rtsp-tcp"};// { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; // --avcodec-hw={any,d3d11va,dxva2,none} + // var videoUri = new Uri(@"rtsp://127.0.0.1:8554/rains"); + // vlcControl.Play(videoUri, options); // vlcControl.Controls // using(SaveFileDialog sfd = new SaveFileDialog()) @@ -65,9 +65,10 @@ namespace PlumByteUI_Learn */ private void playBtn_Click(object sender, EventArgs e) { - string[] options = { ":network-caching=100", ":rtsp-tcp", ":no-audio" };// { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; // --avcodec-hw={any,d3d11va,dxva2,none} + string[] options = { ":network-caching=10", ":rtsp-tcp"};// { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; // --avcodec-hw={any,d3d11va,dxva2,none} var videoUri = new Uri(@"rtsp://127.0.0.1:8554/rains"); vlcControl.Play(videoUri, options); + Console.WriteLine("播放rtsp视频"); } } } \ No newline at end of file diff --git a/Tech/Program.cs b/Tech/Program.cs index 9bbfe97..1479817 100644 --- a/Tech/Program.cs +++ b/Tech/Program.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows.Forms; @@ -12,8 +13,13 @@ namespace PlumByteUI_Learn /// The main entry point for the application. /// [STAThread] + [DllImport("kernel32.dll")] + static extern bool AttachConsole(int dwProcessId); + private const int ATTACH_PARENT_PROCESS = -1; + static void Main() { + AttachConsole(ATTACH_PARENT_PROCESS); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); diff --git a/Tech/Tech.csproj b/Tech/Tech.csproj index 0ab72fc..3c3abe1 100644 --- a/Tech/Tech.csproj +++ b/Tech/Tech.csproj @@ -55,12 +55,20 @@ + Form Form1.cs + + + UserControl + + + MultiPlayerView.cs + UserControl @@ -78,6 +86,9 @@ Form1.cs + + MultiPlayerView.cs + PlayerView.cs diff --git a/Tech/Tech.csproj.DotSettings b/Tech/Tech.csproj.DotSettings index acc7abf..a6b0ef8 100644 --- a/Tech/Tech.csproj.DotSettings +++ b/Tech/Tech.csproj.DotSettings @@ -1,2 +1,2 @@  - D:\develop\RiderProjects\UI-Design-in-C\PlumByteUI-Learn\packages\Vlc.DotNet.Forms.3.1.0\lib\net45\Vlc.DotNet.Forms.dll|Vlc.DotNet.Forms.VlcControl \ No newline at end of file + D:\develop\RiderProjects\UI-Design-in-C\PlumByteUI-Learn\packages\Vlc.DotNet.Forms.3.1.0\lib\net45\Vlc.DotNet.Forms.dll| \ No newline at end of file diff --git a/Tech/UCOverview.Designer.cs b/Tech/UCOverview.Designer.cs index 6c1aad1..4c15e91 100644 --- a/Tech/UCOverview.Designer.cs +++ b/Tech/UCOverview.Designer.cs @@ -65,6 +65,7 @@ this.button1.TabIndex = 3; this.button1.Text = "Quick Scan"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // label2 // @@ -114,6 +115,7 @@ this.button3.Text = "\r\nQuick Scan"; this.button3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.button3.UseVisualStyleBackColor = false; + this.button3.Click += new System.EventHandler(this.button3_Click); // // button2 // diff --git a/Tech/UCOverview.cs b/Tech/UCOverview.cs index 1662c9b..73e9650 100644 --- a/Tech/UCOverview.cs +++ b/Tech/UCOverview.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -21,5 +22,19 @@ namespace PlumByteUI_Learn { } + + private void button3_Click(object sender, EventArgs e) + { + var ipNetTable = GetIPNetTable.Get_IPNetTable(); + } + + private void button1_Click(object sender, EventArgs e) + { + var ipInfo = ArpUtil.GetIpInfo(); + foreach (var ip in ipInfo) + { + Console.WriteLine("{0} => {1}", ip[0], ip[1]); + } + } } }