Browse Source

完成网络调试

pull/2/head
笑笑 6 years ago
parent
commit
cb5e18d094
  1. 32
      XCoderLinux/SharpApp.cs
  2. 14
      XCoderLinux/Util/ControlHelper.cs
  3. 5
      XCoderLinux/XApi/FrmMain.cs
  4. 8
      XCoderLinux/XCoderLinux.csproj
  5. 587
      XCoderLinux/XNet/FrmMain.cs
  6. 493
      XCoderLinux/XNet/FrmMain.designer.cs

32
XCoderLinux/SharpApp.cs

@ -1,12 +1,15 @@
using Gtk;
using XApi;
//using XApi;
using XNet;
namespace XCoder
{
class SharpApp : Window
{
#region 窗口初始化
#endregion
VBox vbox = new VBox(false, 2);
private Box xapi;
public SharpApp() : base("新生命码神工具")
{
@ -20,7 +23,7 @@ namespace XCoder
//AddButton();
xapi = new FrmMain(Orientation.Horizontal);
var xapi = new FrmMain();
vbox.PackStart(xapi, false, false, 0);
@ -29,28 +32,7 @@ namespace XCoder
//Show();
ShowAll();
}
void AddButton()
{
var fix = new Fixed();
var btn1 = new Button("Button")
{
Sensitive = false
};
var btn2 = new Button("Button");
var btn3 = new Button(Stock.Close);
var btn4 = new Button("Button");
btn4.SetSizeRequest(80, 40);
fix.Put(btn1, 2 * 20, 2 * 30);
fix.Put(btn2, 2 * 100, 2 * 30);
fix.Put(btn3, 2 * 20, 2 * 80);
fix.Put(btn4, 2 * 100, 2 * 80);
vbox.PackStart(fix, false, false, 0);
//Add(fix);
}
void AddMenu()
{
var mb = new MenuBar();

14
XCoderLinux/Util/ControlHelper.cs

@ -23,12 +23,18 @@ namespace XCoder.Util
return null;
}
public static void AppendValues(this ComboBox comboBox, params Object[] values)
public static void AppendValues(this ComboBox comboBox, List<String> values)
{
//if (!(comboBox.Model is ListStore listStore)) comboBox.Model = listStore = new ListStore(values);
//listStore.AppendValues(values);
if (!(comboBox.Model is ListStore listStore))
{
return;
}
foreach (var value in values)
{
listStore.AppendValues(value);
}
}
}
}

5
XCoderLinux/XApi/FrmMain.cs

@ -14,6 +14,7 @@ using NewLife.Reflection;
using NewLife.Remoting;
using NewLife.Serialization;
using NewLife.Threading;
using XCoder;
using XCoder.Util;
using Object = System.Object;
#if !NET4
@ -23,7 +24,7 @@ using TaskEx = System.Threading.Tasks.Task;
namespace XApi
{
[DisplayName("Api调试")]
public partial class FrmMain : Box
public partial class FrmMain : Box, IXForm
{
ApiServer _Server;
ApiClient _Client;
@ -32,7 +33,7 @@ namespace XApi
ILog BizLog;
#region 窗体
public FrmMain(Orientation orientation, int spacing = 2) : base(orientation, spacing)
public FrmMain(Orientation orientation = Orientation.Horizontal, Int32 spacing = 2) : base(orientation, spacing)
{
InitializeComponent();
}

8
XCoderLinux/XCoderLinux.csproj

@ -8,8 +8,16 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="..\XCoder\IXForm.cs" Link="IXForm.cs" />
<Compile Include="..\XCoder\XApi\ApiConfig.cs" Link="XApi\ApiConfig.cs" />
<Compile Include="..\XCoder\XApi\MyApiController.cs" Link="XApi\MyApiController.cs" />
<Compile Include="..\XCoder\XNet\BenchHelper.cs" Link="XNet\BenchHelper.cs" />
<Compile Include="..\XCoder\XNet\IPPacket.cs" Link="XNet\IPPacket.cs" />
<Compile Include="..\XCoder\XNet\MySqlParser.cs" Link="XNet\MySqlParser.cs" />
<Compile Include="..\XCoder\XNet\NetConfig.cs" Link="XNet\NetConfig.cs" />
<Compile Include="..\XCoder\XNet\RawSocket.cs" Link="XNet\RawSocket.cs" />
<Compile Include="..\XCoder\XNet\TcpPacket.cs" Link="XNet\TcpPacket.cs" />
<Compile Include="..\XCoder\XNet\WorkModes.cs" Link="XNet\WorkModes.cs" />
</ItemGroup>
<ItemGroup>

587
XCoderLinux/XNet/FrmMain.cs

@ -0,0 +1,587 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Mime;
using System.Threading.Tasks;
using Gtk;
using NewLife;
using NewLife.Data;
using NewLife.Log;
using NewLife.Net;
using NewLife.Reflection;
using NewLife.Threading;
using XCoder;
using XCoder.Util;
using XCoder.XNet;
#if !NET4
using TaskEx = System.Threading.Tasks.Task;
#endif
namespace XNet
{
[DisplayName("网络调试工具")]
public partial class FrmMain : Box, IXForm
{
NetServer _Server;
ISocketClient _Client;
static Task<Dictionary<String, Type>> _task;
/// <summary>业务日志输出</summary>
ILog BizLog;
#region 窗体
static FrmMain()
{
_task = Task.Factory.StartNew(() => GetNetServers());
}
public FrmMain(Orientation orientation = Orientation.Horizontal, Int32 spacing = 2) : base(orientation, spacing)
{
InitializeComponent();
//// 动态调节宽度高度,兼容高DPI
//this.FixDpi();
//Icon = IcoHelper.GetIcon("网络");
}
private void FrmMain_Load(Object sender, EventArgs e)
{
var log = TextFileLog.Create(null, "Net_{0:yyyy_MM_dd}.log");
BizLog = txtReceive.Combine(log);
txtReceive.UseWinFormControl();
//txtReceive.SetDefaultStyle(12);
//txtSend.SetDefaultStyle(12);
//numMutilSend.SetDefaultStyle(12);
//gbReceive.Tag = gbReceive.Text;
//gbSend.Tag = gbSend.Text;
_task.ContinueWith(t =>
{
var dic = EnumHelper.GetDescriptions<WorkModes>();
var list = dic.Select(kv => kv.Value).ToList();
//var ds = dic.ToDictionary(s => s.Value, s => s.Value);
foreach (var item in t.Result)
{
list.Add(item.Key);
}
//this.Invoke(() =>
//{
cbMode.AppendValues(list);
var cfg = NetConfig.Current;
if (cfg.Mode > 0 && dic.ContainsKey((WorkModes)cfg.Mode))
cbMode.Active = list.FindIndex(f => f == dic[(WorkModes)cfg.Mode]);
else
cbMode.Active = 0;
//});
});
//// 加载保存的颜色
//UIConfig.Apply(txtReceive);
LoadConfig();
//// 语音识别
//ThreadPoolX.QueueUserWorkItem(() =>
//{
// var sp = SpeechRecognition.Current;
// if (!sp.Enable) return;
// sp.Register("打开", () => this.Invoke(Connect))
// .Register("关闭", () => this.Invoke(Disconnect))
// .Register("退出", () => Application.Exit())
// .Register("发送", () => this.Invoke(() => btnSend_Click(null, null)));
// BizLog.Info("语音识别前缀:{0} 可用命令:{1}", sp.Name, sp.GetAllKeys().Join());
//});
}
#endregion
#region 加载/保存 配置
void LoadConfig()
{
var cfg = NetConfig.Current;
//mi显示应用日志.Checked = cfg.ShowLog;
//mi显示网络日志.Checked = cfg.ShowSocketLog;
//mi显示接收字符串.Checked = cfg.ShowReceiveString;
//mi显示发送数据.Checked = cfg.ShowSend;
//mi显示接收数据.Checked = cfg.ShowReceive;
//mi显示统计信息.Checked = cfg.ShowStat;
//miHexSend.Checked = cfg.HexSend;
txtSend.Buffer.Text = cfg.SendContent;
numMutilSend.Value = cfg.SendTimes;
numSleep.Value = cfg.SendSleep;
numThreads.Value = cfg.SendUsers;
//mi日志着色.Checked = cfg.ColorLog;
var ips = GetIPs().ToList();
cbLocal.AppendValues(ips);
if (!cfg.Local.IsNullOrEmpty())
cbLocal.Active = ips.FindIndex(f => f == cfg.Local);
else
cbLocal.Active = 0;
// 历史地址列表
if (!cfg.Address.IsNullOrEmpty()) cbRemote.AppendValues(cfg.Address.Split(";").ToList());
if (cfg.Port > 0) numPort.Value = cfg.Port;
}
void SaveConfig()
{
var cfg = NetConfig.Current;
//cfg.ShowLog = mi显示应用日志.Checked;
//cfg.ShowSocketLog = mi显示网络日志.Checked;
//cfg.ShowReceiveString = mi显示接收字符串.Checked;
//cfg.ShowSend = mi显示发送数据.Checked;
//cfg.ShowReceive = mi显示接收数据.Checked;
//cfg.ShowStat = mi显示统计信息.Checked;
//cfg.HexSend = miHexSend.Checked;
cfg.SendContent = txtSend.Buffer.Text;
cfg.SendTimes = (Int32)numMutilSend.Value;
cfg.SendSleep = (Int32)numSleep.Value;
cfg.SendUsers = (Int32)numThreads.Value;
//cfg.ColorLog = mi日志着色.Checked;
cfg.Local = cbLocal.GetActiveObject().ToString();
cfg.AddAddress(cbRemote.Entry.Text);
cfg.Port = (Int32)numPort.Value;
cfg.Save();
}
#endregion
#region 收发数据
void Connect()
{
_Server = null;
_Client = null;
var mode = GetMode();
var local = cbLocal.GetActiveObject().ToString();
var remote = cbRemote.Entry.Text;
var port = (Int32)numPort.Value;
var cfg = NetConfig.Current;
cfg.Mode = (Byte)mode;
switch (mode)
{
case WorkModes.UDP_TCP:
_Server = new NetServer();
break;
case WorkModes.UDP_Server:
_Server = new NetServer
{
ProtocolType = NetType.Udp
};
break;
case WorkModes.TCP_Server:
_Server = new NetServer
{
ProtocolType = NetType.Tcp
};
break;
case WorkModes.TCP_Client:
_Client = new TcpSession();
break;
case WorkModes.UDP_Client:
_Client = new UdpServer();
break;
default:
if (mode > 0)
{
var ns = GetServer(cbMode.GetActiveObject() + "");
if (ns == null) throw new XException("未识别服务[{0}]", mode);
_Server = ns.GetType().CreateInstance() as NetServer;
}
break;
}
if (_Client != null)
{
_Client.Log = cfg.ShowLog ? BizLog : Logger.Null;
if (!local.Contains("所有本地")) _Client.Local.Host = local;
_Client.Received += OnReceived;
_Client.Remote.Port = port;
_Client.Remote.Host = remote;
_Client.LogSend = cfg.ShowSend;
_Client.LogReceive = cfg.ShowReceive;
if (!_Client.Open()) return;
//"已连接服务器".SpeechTip();
}
else if (_Server != null)
{
if (_Server == null) _Server = new NetServer();
_Server.Log = cfg.ShowLog ? BizLog : Logger.Null;
_Server.SocketLog = cfg.ShowSocketLog ? BizLog : Logger.Null;
_Server.Port = port;
if (!local.Contains("所有本地")) _Server.Local.Host = local;
_Server.Received += OnReceived;
_Server.LogSend = cfg.ShowSend;
_Server.LogReceive = cfg.ShowReceive;
//// 加大会话超时时间到1天
//_Server.SessionTimeout = 24 * 3600;
_Server.Start();
//"正在监听{0}".F(port).SpeechTip();
}
//pnlSetting.Sensitive = false;
btnConnect.Label = "关闭";
cfg.Save();
_timer = new TimerX(ShowStat, null, 5000, 5000) { Async = true };
}
void Disconnect()
{
if (_Client != null)
{
_Client.Dispose();
_Client = null;
//"关闭连接".SpeechTip();
}
if (_Server != null)
{
//"停止监听{0}".F(_Server.Port).SpeechTip();
_Server.Dispose();
_Server = null;
}
if (_timer != null)
{
_timer.Dispose();
_timer = null;
}
pnlSetting.Sensitive = true;
btnConnect.Label = "打开";
}
TimerX _timer;
String _lastStat;
void ShowStat(Object state)
{
if (!NetConfig.Current.ShowStat) return;
var msg = "";
if (_Client != null)
msg = _Client.GetStat();
else if (_Server != null)
msg = _Server.GetStat();
if (!msg.IsNullOrEmpty() && msg != _lastStat)
{
_lastStat = msg;
BizLog.Info(msg);
}
}
private void btnConnect_Click(Object sender, EventArgs e)
{
SaveConfig();
var btn = sender as Button;
if (btn.Label == "打开")
Connect();
else
Disconnect();
}
void OnReceived(Object sender, ReceivedEventArgs e)
{
var session = sender as ISocketSession;
if (session == null)
{
var ns = sender as INetSession;
if (ns == null) return;
session = ns.Session;
}
if (NetConfig.Current.ShowReceiveString)
{
var line = e.Packet.ToStr();
//XTrace.WriteLine(line);
BizLog.Info(line);
}
}
Int32 _pColor = 0;
Int32 BytesOfReceived = 0;
Int32 BytesOfSent = 0;
Int32 lastReceive = 0;
Int32 lastSend = 0;
//private void timer1_Tick(Object sender, EventArgs e)
//{
// //if (!pnlSetting.Enabled)
// {
// var rcount = BytesOfReceived;
// var tcount = BytesOfSent;
// if (rcount != lastReceive)
// {
// gbReceive.Text = (gbReceive.Tag + "").Replace("0", rcount + "");
// lastReceive = rcount;
// }
// if (tcount != lastSend)
// {
// gbSend.Text = (gbSend.Tag + "").Replace("0", tcount + "");
// lastSend = tcount;
// }
// var cfg = NetConfig.Current;
// if (cfg.ColorLog) txtReceive.ColourDefault(_pColor);
// _pColor = txtReceive.TextLength;
// }
//}
private Task _Send;
private void btnSend_Click(Object sender, EventArgs e)
{
var str = txtSend.Buffer.Text;
if (String.IsNullOrEmpty(str))
{
var md = new MessageDialog(TooltipWindow,
DialogFlags.DestroyWithParent, MessageType.Warning,
ButtonsType.Close, "发送内容不能为空!");
md.Run();
md.Dispose();
//MessageBox.Show("发送内容不能为空!", MediaTypeNames.Text);
//txtSend.Focus();
return;
}
// 多次发送
var count = (Int32)numMutilSend.Value;
var sleep = (Int32)numSleep.Value;
var ths = (Int32)numThreads.Value;
if (count <= 0) count = 1;
if (sleep <= 0) sleep = 1;
SaveConfig();
var cfg = NetConfig.Current;
// 处理换行
str = str.Replace("\n", "\r\n");
var buf = cfg.HexSend ? str.ToHex() : str.GetBytes();
var pk = new Packet(buf);
if (_Client != null)
{
if (ths <= 1)
{
_Client.SendMulti(pk, count, sleep);
}
else
{
var any = _Client.Local.Address.IsAny();
var list = new List<ISocketClient>();
for (var i = 0; i < ths; i++)
{
var client = _Client.Remote.CreateRemote();
if (!any) client.Local.EndPoint = new IPEndPoint(_Client.Local.Address, 2000 + i);
client.StatSend = _Client.StatSend;
client.StatReceive = _Client.StatReceive;
//client.SendMulti(buf, count, sleep);
list.Add(client);
}
var ts = new List<Task>();
for (var i = 0; i < ths; i++)
{
var task = list[i].SendConcurrency(pk, count, sleep);
ts.Add(task);
}
_Send = TaskEx.WhenAll(ts);
}
}
#if !NET4
else if (_Server != null)
{
TaskEx.Run(async () =>
{
BizLog.Info("准备向[{0}]个客户端发送[{1}]次[{2}]的数据", _Server.SessionCount, count, buf.Length);
for (var i = 0; i < count && _Server != null; i++)
{
var sw = Stopwatch.StartNew();
var cs = await _Server.SendAllAsync(buf);
sw.Stop();
BizLog.Info("{3}/{4} 已向[{0}]个客户端发送[{1}]数据 {2:n0}ms", cs, buf.Length, sw.ElapsedMilliseconds, i + 1, count);
if (sleep > 0) await TaskEx.Delay(sleep);
}
});
}
#endif
}
#endregion
#region 右键菜单
private void mi清空_Click(Object sender, EventArgs e)
{
txtReceive.Buffer.Clear();
BytesOfReceived = 0;
}
private void mi清空2_Click(Object sender, EventArgs e)
{
txtSend.Buffer.Clear();
BytesOfSent = 0;
}
//private void mi显示应用日志_Click(Object sender, EventArgs e)
//{
// var mi = sender as ToolStripMenuItem;
// mi.Checked = !mi.Checked;
//}
//private void mi显示网络日志_Click(Object sender, EventArgs e)
//{
// var mi = sender as ToolStripMenuItem;
// mi.Checked = !mi.Checked;
//}
//private void mi显示发送数据_Click(Object sender, EventArgs e)
//{
// var mi = sender as ToolStripMenuItem;
// mi.Checked = !mi.Checked;
//}
//private void mi显示接收数据_Click(Object sender, EventArgs e)
//{
// var mi = sender as ToolStripMenuItem;
// mi.Checked = !mi.Checked;
//}
//private void mi显示统计信息_Click(Object sender, EventArgs e)
//{
// var mi = sender as ToolStripMenuItem;
// NetConfig.Current.ShowStat = mi.Checked = !mi.Checked;
//}
//private void mi显示接收字符串_Click(Object sender, EventArgs e)
//{
// var mi = sender as ToolStripMenuItem;
// NetConfig.Current.ShowReceiveString = mi.Checked = !mi.Checked;
//}
//private void miHex发送_Click(Object sender, EventArgs e)
//{
// var mi = sender as ToolStripMenuItem;
// NetConfig.Current.HexSend = mi.Checked = !mi.Checked;
//}
//private void 查看Tcp参数ToolStripMenuItem_Click(Object sender, EventArgs e)
//{
// NetHelper2.ShowTcpParameters();
//}
//private void 设置最大TcpToolStripMenuItem_Click(Object sender, EventArgs e)
//{
// NetHelper2.SetTcpMax();
//}
//private void mi日志着色_Click(Object sender, EventArgs e)
//{
// var mi = sender as ToolStripMenuItem;
// mi.Checked = !mi.Checked;
//}
#endregion
private void cbMode_SelectedIndexChanged(Object sender, EventArgs e)
{
var mode = GetMode();
if (mode == 0) return;
switch (mode)
{
case WorkModes.TCP_Client:
case WorkModes.UDP_Client:
break;
default:
case WorkModes.UDP_TCP:
case WorkModes.UDP_Server:
case WorkModes.TCP_Server:
break;
case (WorkModes)0xFF:
// 端口
var ns = GetServer(cbMode.GetActiveObject().ToString());
if (ns != null && ns.Port > 0) numPort.Value = ns.Port;
break;
}
}
WorkModes GetMode()
{
var mode = cbMode.GetActiveObject().ToString();
if (String.IsNullOrEmpty(mode)) return 0;
var list = EnumHelper.GetDescriptions<WorkModes>().Where(kv => kv.Value == mode).ToList();
if (list.Count == 0) return (WorkModes)0xFF;
return list[0].Key;
}
static String[] GetIPs()
{
var list = NetHelper.GetIPs().Select(e => e.ToString()).ToList();
list.Insert(0, "所有本地IPv4/IPv6");
list.Insert(1, IPAddress.Any.ToString());
list.Insert(2, IPAddress.IPv6Any.ToString());
return list.ToArray();
}
static Dictionary<String, Type> _ns;
static Dictionary<String, Type> GetNetServers()
{
if (_ns != null) return _ns;
lock (typeof(FrmMain))
{
if (_ns != null) return _ns;
var dic = new Dictionary<String, Type>();
foreach (var item in typeof(NetServer).GetAllSubclasses(true))
{
try
{
var ns = item.CreateInstance() as NetServer;
if (ns != null) dic.Add(item.GetDisplayName() ?? ns.Name, item);
}
catch { }
}
return _ns = dic;
}
}
static NetServer GetServer(String name)
{
if (!GetNetServers().TryGetValue(name, out var t)) return null;
return t.CreateInstance() as NetServer;
}
}
}

493
XCoderLinux/XNet/FrmMain.designer.cs

@ -0,0 +1,493 @@
using Gtk;
namespace XNet
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Windows 窗体设计器生成的代码
/// <summary>
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.gbReceive = new Frame();
this.txtReceiveScrolledWindow = new ScrolledWindow();
this.txtReceive = new TextView();
//this.menuReceive = new ContextMenuStrip(this.components);
//this.toolStripMenuItem1 = new ToolStripMenuItem();
//this.mi日志着色 = new ToolStripMenuItem();
//this.toolStripMenuItem3 = new ToolStripSeparator();
//this.mi显示应用日志 = new ToolStripMenuItem();
//this.mi显示编码日志 = new ToolStripMenuItem();
//this.mi显示发送数据 = new ToolStripMenuItem();
//this.mi显示接收数据 = new ToolStripMenuItem();
//this.mi显示统计信息 = new ToolStripMenuItem();
//this.menuSend = new ContextMenuStrip(this.components);
//this.mi清空2 = new ToolStripMenuItem();
this.btnConnect = new Button();
//this.timer1 = new Timer(this.components);
//this.fontDialog1 = new FontDialog();
//this.colorDialog1 = new ColorDialog();
this.label1 = new Label();
this.lbAddr = new Label();
this.cbMode = new ComboBox(new string[]{});
this.cbLocal = new ComboBox(new string[] { });
this.cbRemote = ComboBoxText.NewWithEntry();
this.pnlSetting = new HBox();
this.numPort = new SpinButton(1, 63353, 1);
this.label5 = new Label();
this.cbAction = new ComboBoxText();
this.gbSend = new Frame();
this.boxSend = new VBox();
this.boxSendSetting = new HBox();
this.numThreads = new SpinButton(1, 100000, 1);
this.numSleep = new SpinButton(1000, 1000000, 1);
this.txtSendScrolledWindow = new ScrolledWindow();
this.txtSend = new TextView();
this.btnSend = new Button();
this.numMutilSend = new SpinButton(1, 1000000, 1);
this.label2 = new Label();
this.label7 = new Label();
this.label8 = new Label();
//this.toolTip1 = new ToolTip(this.components);
this.label3 = new Label();
//this.menuReceive.SuspendLayout();
//this.menuSend.SuspendLayout();
//this.SuspendLayout();
//
// gbReceive
//
this.gbReceive.Add(this.txtReceiveScrolledWindow);
this.gbReceive.Margin = 6;
this.gbReceive.Name = "gbReceive";
this.gbReceive.SetSizeRequest(878, 298);
// gbReceive.Margin = 10;
this.gbReceive.Label = "接收区:已接收0字节";
this.gbReceive.Halign = Align.Fill;
this.gbReceive.Valign = Align.Fill;
this.gbReceive.ShadowType = ShadowType.Out;
//
// txtReceiveScrolledWindow
//
this.txtReceiveScrolledWindow.Add(this.txtReceive);
this.txtReceiveScrolledWindow.CanFocus = true;
this.txtReceiveScrolledWindow.ShadowType = ShadowType.In;
this.txtReceiveScrolledWindow.Vexpand = true;
//
// txtReceive
//
// this.txtReceive.ContextMenuStrip = this.menuReceive;
// this.txtReceive.Dock = DockStyle.Fill;
// this.txtReceive.HideSelection = false;
// this.txtReceive.Location = new System.Drawing.Point(4, 25);
this.txtReceive.Margin = 4;
this.txtReceive.Name = "txtReceive";
// this.txtReceive.Size = new System.Drawing.Size(970, 269);
this.txtReceive.Editable = false;
// 滚动方法 https://stackoverflow.com/questions/37824865/gtk-textview-auto-scroll-when-text-is-added-to-text-buffer
this.txtReceive.SizeAllocated += TxtReceive_SizeAllocated;
////
//// menuReceive
////
//this.menuReceive.ImageScalingSize = new System.Drawing.Size(32, 32);
//this.menuReceive.Items.AddRange(new ToolStripItem[] {
//this.toolStripMenuItem1,
//this.mi日志着色,
//this.toolStripMenuItem3,
//this.mi显示应用日志,
//this.mi显示编码日志,
//this.mi显示发送数据,
//this.mi显示接收数据,
//this.mi显示统计信息});
//this.menuReceive.Name = "menuSend";
//this.menuReceive.Size = new System.Drawing.Size(189, 206);
////
//// toolStripMenuItem1
////
//this.toolStripMenuItem1.Name = "toolStripMenuItem1";
//this.toolStripMenuItem1.Size = new System.Drawing.Size(188, 28);
//this.toolStripMenuItem1.Text = "清空";
//this.toolStripMenuItem1.Click += new System.EventHandler(this.mi清空_Click);
////
//// mi日志着色
////
//this.mi日志着色.Name = "mi日志着色";
//this.mi日志着色.Size = new System.Drawing.Size(188, 28);
//this.mi日志着色.Text = "日志着色";
//this.mi日志着色.Click += new System.EventHandler(this.miCheck_Click);
////
//// toolStripMenuItem3
////
//this.toolStripMenuItem3.Name = "toolStripMenuItem3";
//this.toolStripMenuItem3.Size = new System.Drawing.Size(185, 6);
////
//// mi显示应用日志
////
//this.mi显示应用日志.Name = "mi显示应用日志";
//this.mi显示应用日志.Size = new System.Drawing.Size(188, 28);
//this.mi显示应用日志.Text = "显示应用日志";
//this.mi显示应用日志.Click += new System.EventHandler(this.miCheck_Click);
////
//// mi显示编码日志
////
//this.mi显示编码日志.Name = "mi显示编码日志";
//this.mi显示编码日志.Size = new System.Drawing.Size(188, 28);
//this.mi显示编码日志.Text = "显示编码日志";
//this.mi显示编码日志.Click += new System.EventHandler(this.miCheck_Click);
////
//// mi显示发送数据
////
//this.mi显示发送数据.Name = "mi显示发送数据";
//this.mi显示发送数据.Size = new System.Drawing.Size(188, 28);
//this.mi显示发送数据.Text = "显示发送数据";
//this.mi显示发送数据.Click += new System.EventHandler(this.miCheck_Click);
////
//// mi显示接收数据
////
//this.mi显示接收数据.Name = "mi显示接收数据";
//this.mi显示接收数据.Size = new System.Drawing.Size(188, 28);
//this.mi显示接收数据.Text = "显示接收数据";
//this.mi显示接收数据.Click += new System.EventHandler(this.miCheck_Click);
////
//// mi显示统计信息
////
//this.mi显示统计信息.Name = "mi显示统计信息";
//this.mi显示统计信息.Size = new System.Drawing.Size(188, 28);
//this.mi显示统计信息.Text = "显示统计信息";
//this.mi显示统计信息.Click += new System.EventHandler(this.miCheck_Click);
////
//// menuSend
////
//this.menuSend.ImageScalingSize = new System.Drawing.Size(32, 32);
//this.menuSend.Items.AddRange(new ToolStripItem[] {
//this.mi清空2});
//this.menuSend.Name = "menuSend";
//this.menuSend.Size = new System.Drawing.Size(117, 32);
////
//// mi清空2
////
//this.mi清空2.Name = "mi清空2";
//this.mi清空2.Size = new System.Drawing.Size(116, 28);
//this.mi清空2.Text = "清空";
//this.mi清空2.Click += new System.EventHandler(this.mi清空2_Click);
//
// btnConnect
//
// this.btnConnect.Location = new System.Drawing.Point(748, 12);
this.btnConnect.Margin = 4;
this.btnConnect.Name = "btnConnect";
// this.btnConnect.Size = new System.Drawing.Size(100, 44);
// this.btnConnect.TabIndex = 3;
this.btnConnect.Label = "打开";
this.btnConnect.Clicked += new System.EventHandler(this.btnConnect_Click);
////
//// timer1
////
//this.timer1.Enabled = true;
//this.timer1.Interval = 300;
//this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label1
//
//this.label1.AutoSize = true;
this.label1.Xalign = 0.8F;
this.label1.Yalign = 0.5F;
this.label1.MarginTop = 4;
this.label1.MarginBottom = 4;
this.label1.Name = "label1";
this.label1.WidthRequest = 62;
this.label1.HeightRequest = 18;
this.label1.Text = "模式:";
//
// lbAddr
//
// this.lbAddr.AutoSize = true;
// this.lbAddr.Location = new System.Drawing.Point(374, 14);
this.lbAddr.Xalign = 0.8F;
this.lbAddr.Yalign = 0.5F;
this.lbAddr.MarginTop = 4;
this.lbAddr.MarginBottom = 4;
this.lbAddr.Name = "lbAddr";
this.lbAddr.WidthRequest = 62;
this.lbAddr.HeightRequest = 18;
this.lbAddr.Text = "远程:";
//
// cbMode
//
//this.cbMode.DropDownStyle = ComboBoxStyle.DropDownList;
//this.cbMode.FormattingEnabled = true;
//this.cbMode.Location = new System.Drawing.Point(72, 11);
//this.cbMode.Margin = 4;
this.cbMode.Active = 1;
this.cbMode.Name = "cbMode";
//this.cbMode.SetSizeRequest(1, 1);
this.cbMode.Changed += new System.EventHandler(this.cbMode_SelectedIndexChanged);
//
// cbLocal
//
//this.cbLocal.Active = 1;
this.cbLocal.Name = "cbLocal";
//this.cbLocal.SetSizeRequest(1, 1);
//this.cbLocal.Changed += new System.EventHandler(this.cbLocal_SelectedIndexChanged);
//
// cbRemote
//
//this.cbRemote.Margin = 4;
this.cbRemote.Name = "cbRemote";
this.cbRemote.SetSizeRequest(200, 18);
// this.cbRemote.Size = new System.Drawing.Size(247, 26);
this.cbRemote.Sensitive = true;
//this.cbRemote.
//
// pnlSetting
//
this.pnlSetting.PackStart(this.label1, false, false, 2);
this.pnlSetting.PackStart(this.cbMode, false, false, 2);
this.pnlSetting.PackStart(this.label5, false, false, 2);
this.pnlSetting.PackStart(this.cbLocal, false, false, 2);
this.pnlSetting.PackStart(this.lbAddr, false, false, 2);
this.pnlSetting.PackStart(this.cbRemote, false, false, 2);
this.pnlSetting.PackStart(this.numPort, false, false, 2);
this.pnlSetting.PackEnd(this.btnConnect, false, false, 2);
//this.pnlSetting.Add();
//this.pnlSetting.Position = 5;// .Location = new System.Drawing.Point(14, 12);
this.pnlSetting.Margin = 4;
this.pnlSetting.Name = "pnlSetting";
// this.pnlSetting.Valign = Align.Fill;
// this.pnlSetting.Halign = Align.Fill;
// this.pnlSetting.SetSizeRequest(708, 20);
// pnlSetting.Orientation = Orientation.Horizontal;
//this.pnlSetting.Size = new System.Drawing.Size(708, 46);
//this.pnlSetting.TabIndex = 13;
//
// numPort
//
// this.numPort.Location = new System.Drawing.Point(270, 10);
this.numPort.Margin = 4;
this.numPort.Name = "numPort";
this.numPort.Value = 8080;
this.numPort.SetSizeRequest(94, 28);
//
// label5
//
//this.label5.AutoSize = true;
//this.label5.Location = new System.Drawing.Point(218, 14);
this.label5.Xalign = 0.8F;
this.label5.Yalign = 0.5F;
this.label5.MarginTop = 4;
this.label5.MarginBottom = 4;
this.label5.Name = "label5";
this.label5.SetSizeRequest(62, 18);
this.label5.Text = "本地:";
//
// cbAction
//
this.cbAction.Margin = 4;
this.cbAction.Name = "cbAction";
//this.cbAction.Size = new System.Drawing.Size(470, 26);
this.cbAction.Visible = false;
//this.cbAction.Changed += new System.EventHandler(this.cbAction_SelectedIndexChanged);
//
// gbSend
//
this.gbSend.Add(this.boxSend);
// this.gbSend.Controls.Add(this.numThreads);
// this.gbSend.Controls.Add(this.numSleep);
// this.gbSend.Controls.Add(this.btnSend);
// this.gbSend.Controls.Add(this.numMutilSend);
// this.gbSend.Controls.Add(this.label2);
// this.gbSend.Controls.Add(this.label7);
// this.gbSend.Location = new System.Drawing.Point(14, 424);
this.gbSend.Margin = 4;
this.gbSend.Name = "gbSend";
this.gbSend.SetSizeRequest(778, 126);
this.gbSend.Label = "发送区:已发送0字节";
//
// boxSend
//
this.boxSend.PackStart(this.txtSendScrolledWindow, false, false, 2);
this.boxSend.PackStart(this.boxSendSetting, false, false, 2);
// this.boxSend.Orientation = Orientation.Vertical;
this.boxSend.Margin = 4;
this.boxSend.Name = "boxSend";
//
// boxSendSetting
//
this.boxSendSetting.PackStart(this.label7, false, false, 2);
this.boxSendSetting.PackStart(this.numMutilSend, false, false, 2);
this.boxSendSetting.PackStart(this.label8, false, false, 2);
this.boxSendSetting.PackStart(this.numThreads, false, false, 2);
this.boxSendSetting.PackStart(this.label2, false, false, 2);
this.boxSendSetting.PackStart(this.numSleep, false, false, 2);
this.boxSendSetting.PackStart(this.btnSend, false, false, 2);
this.boxSendSetting.Margin = 4;
this.boxSendSetting.Name = "sendSetting";
//
// numThreads
//
this.numThreads.Margin = 4;
this.numThreads.Name = "numThreads";
this.numThreads.SetSizeRequest(78, 28);
// this.toolTip1.SetToolTip(this.numThreads, "模拟多客户端发送,用于压力测试!");
//
// numSleep
//
this.numSleep.Margin = 4;
this.numSleep.Name = "numSleep";
this.numSleep.SetSizeRequest(109, 28);
//
// txtSendScrolledWindow
//
this.txtSendScrolledWindow.CanFocus = true;
this.txtSendScrolledWindow.ShadowType = ShadowType.In;
this.txtSendScrolledWindow.Vexpand = true;
this.txtSendScrolledWindow.Add(this.txtSend);
//
// txtSend
//
// this.txtSend.ContextMenuStrip = this.menuSend;
// this.txtSend.Location = new System.Drawing.Point(0, 28);
this.txtSend.Margin = 4;
this.txtSend.Name = "txtSend";
this.txtSend.SetSizeRequest(621, 86);
this.txtSend.WrapMode = WrapMode.Word;
//this.txtSend.Editable = false;
//
// btnSend
//
this.btnSend.Margin = 4;
this.btnSend.Name = "btnSend";
this.btnSend.SetSizeRequest(75, 45);
this.btnSend.Label = "发送";
this.btnSend.Clicked += new System.EventHandler(this.btnSend_Click);
//
// numMutilSend
//
this.numMutilSend.Margin = 4;
this.numMutilSend.Name = "numMutilSend";
this.numMutilSend.SetSizeRequest(109, 28);
//
// label2
//
// this.label2.Location = new System.Drawing.Point(729, 87);
this.label2.Margin = 4;
this.label2.Name = "label2";
this.label2.SetSizeRequest(62, 18);
this.label2.Text = "间隔:";
//
// label7
//
// this.label7.Location = new System.Drawing.Point(729, 39);
this.label7.Margin = 4;
this.label7.Name = "label7";
this.label7.SetSizeRequest(62, 18);
this.label7.Text = "次数:";
//
// label8
//
this.label8.Margin = 4;
this.label8.Name = "label8";
this.label8.SetSizeRequest(62, 18);
this.label8.Text = "线程:";
//
// label3
//
// this.label3.AutoSize = true;
// this.label3.Location = new System.Drawing.Point(15, 74);
this.label3.Xalign = 0.04F;
// this.label3.MarginTop = 4;
// this.label3.MarginBottom = 4;
this.label3.Name = "label3";
this.label3.SetSizeRequest(62, 18);
this.label3.Text = "服务:";
////
//// FrmMain
////
//this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
//this.AutoScaleMode = AutoScaleMode.Font;
//this.ClientSize = new System.Drawing.Size(1000, 568);
this.PackStart(this.pnlSetting, false, false, 2);
this.PackStart(this.label3, false, false, 2);
this.PackStart(this.cbAction, false, false, 2);
this.PackStart(this.gbReceive, false, false, 2);
this.PackStart(this.gbSend, false, false, 2);
//this.Margin = new Padding(4);
//this.Name = "FrmMain";
//this.StartPosition = FormStartPosition.CenterScreen;
//this.Text = "Api调试";
this.Shown += new System.EventHandler(this.FrmMain_Load);
//this.menuReceive.ResumeLayout(false);
//this.menuSend.ResumeLayout(false);
//this.pnlSetting.ResumeLayout(false);
//this.pnlSetting.PerformLayout();
//((System.ComponentModel.ISupportInitialize)(this.numPort)).EndInit();
//((System.ComponentModel.ISupportInitialize)(this.numThreads)).EndInit();
//((System.ComponentModel.ISupportInitialize)(this.numSleep)).EndInit();
//((System.ComponentModel.ISupportInitialize)(this.numMutilSend)).EndInit();
//this.ResumeLayout(false);
//this.PerformLayout();
this.Fill = true;
this.Halign = Align.Fill;
this.Valign = Align.Fill;
this.Orientation = Orientation.Vertical;
}
private void TxtReceive_SizeAllocated(System.Object o, SizeAllocatedArgs args)
{
var s = o as TextView;
s.ScrollToIter(s.Buffer.EndIter, 0, false, 0, 0);
}
#endregion
private Frame gbReceive;
private Button btnConnect;
//private Timer timer1;
//private ContextMenuStrip menuSend;
//private ToolStripMenuItem mi清空2;
private ScrolledWindow txtReceiveScrolledWindow;
private TextView txtReceive;
//private FontDialog fontDialog1;
//private ColorDialog colorDialog1;
private Label label1;
private Label lbAddr;
private ComboBox cbMode;
private ComboBox cbLocal;
private ComboBoxText cbRemote;
private HBox pnlSetting;
//private ContextMenuStrip menuReceive;
//private ToolStripMenuItem toolStripMenuItem1;
//private ToolStripSeparator toolStripMenuItem3;
private Frame gbSend;
private VBox boxSend;
private HBox boxSendSetting;
private SpinButton numSleep;
private ScrolledWindow txtSendScrolledWindow;
private TextView txtSend;
private Button btnSend;
private SpinButton numMutilSend;
private Label label2;
private Label label7;
private Label label8;
//private ToolStripMenuItem mi显示统计信息;
private SpinButton numThreads;
//private ToolStripMenuItem mi显示应用日志;
//private ToolStripMenuItem mi显示编码日志;
//private ToolTip toolTip1;
private ComboBoxText cbAction;
//private ToolStripMenuItem mi日志着色;
private SpinButton numPort;
private Label label5;
private Label label3;
//private ToolStripMenuItem mi显示发送数据;
//private ToolStripMenuItem mi显示接收数据;
}
}
Loading…
Cancel
Save