📄 formmain.cs
字号:
//
// butSendFile
//
this.butSendFile.Name = "butSendFile";
this.butSendFile.Text = "发送文件(&F)";
this.butSendFile.Visible = false;
this.butSendFile.Click += new System.EventHandler(this.butSendFile_Click);
//
// butOpenShared
//
this.butOpenShared.Name = "butOpenShared";
this.butOpenShared.Text = "打开收件箱";
this.butOpenShared.Visible = false;
this.butOpenShared.Click += new System.EventHandler(this.butOpenShared_Click);
//
// butMeState
//
this.butMeState.BeginGroup = true;
this.butMeState.Image = ((System.Drawing.Image)(resources.GetObject("butMeState.Image")));
this.butMeState.Name = "butMeState";
this.butMeState.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] {
this.buttonItemState1,
this.buttonItemState2,
this.buttonItemState3,
this.buttonItemState4,
this.buttonItemState5,
this.buttonItemState6});
this.butMeState.Text = "我的状态";
//
// buttonItemState1
//
this.buttonItemState1.Checked = true;
this.buttonItemState1.Name = "buttonItemState1";
this.buttonItemState1.Text = "联机";
this.buttonItemState1.Click += new System.EventHandler(this.buttonItemState1_Click);
//
// buttonItemState2
//
this.buttonItemState2.Name = "buttonItemState2";
this.buttonItemState2.Text = "忙碌";
this.buttonItemState2.Click += new System.EventHandler(this.buttonItemState2_Click);
//
// buttonItemState3
//
this.buttonItemState3.Name = "buttonItemState3";
this.buttonItemState3.Text = "接听电话";
this.buttonItemState3.Click += new System.EventHandler(this.buttonItemState3_Click);
//
// buttonItemState4
//
this.buttonItemState4.Name = "buttonItemState4";
this.buttonItemState4.Text = "离开";
this.buttonItemState4.Click += new System.EventHandler(this.buttonItemState4_Click);
//
// buttonItemState5
//
this.buttonItemState5.Name = "buttonItemState5";
this.buttonItemState5.Text = "外出就餐";
this.buttonItemState5.Click += new System.EventHandler(this.buttonItemState5_Click);
//
// buttonItemState6
//
this.buttonItemState6.Name = "buttonItemState6";
this.buttonItemState6.Text = "脱机";
this.buttonItemState6.Visible = false;
//
// butMsgSendGourp
//
this.butMsgSendGourp.BeginGroup = true;
this.butMsgSendGourp.Image = ((System.Drawing.Image)(resources.GetObject("butMsgSendGourp.Image")));
this.butMsgSendGourp.Name = "butMsgSendGourp";
this.butMsgSendGourp.Text = "群发消息";
this.butMsgSendGourp.Click += new System.EventHandler(this.butMsgSendGourp_Click);
//
// butMsgMis
//
this.butMsgMis.Icon = ((System.Drawing.Icon)(resources.GetObject("butMsgMis.Icon")));
this.butMsgMis.Name = "butMsgMis";
this.butMsgMis.Text = "信息管理器";
this.butMsgMis.Click += new System.EventHandler(this.butMsgMis_Click);
//
// butForFormSetting
//
this.butForFormSetting.Image = ((System.Drawing.Image)(resources.GetObject("butForFormSetting.Image")));
this.butForFormSetting.Name = "butForFormSetting";
this.butForFormSetting.Text = "设置";
this.butForFormSetting.Visible = false;
//
// buttonItemClose
//
this.buttonItemClose.Name = "buttonItemClose";
this.buttonItemClose.Text = "关闭";
this.buttonItemClose.Visible = false;
//
// butMenuMainExit
//
this.butMenuMainExit.Name = "butMenuMainExit";
this.butMenuMainExit.Text = "退出";
this.butMenuMainExit.Visible = false;
this.butMenuMainExit.Click += new System.EventHandler(this.butMenuMainExit_Click);
//
// ButAbout
//
this.ButAbout.BeginGroup = true;
this.ButAbout.Name = "ButAbout";
this.ButAbout.Text = "关于";
this.ButAbout.Click += new System.EventHandler(this.ButAbout_Click);
//
// ribbonTabItemGroup1
//
this.ribbonTabItemGroup1.Color = DevComponents.DotNetBar.eRibbonTabGroupColor.Orange;
this.ribbonTabItemGroup1.GroupTitle = "Tab Group";
//
// ribbonTabItemGroup1.Style
//
this.ribbonTabItemGroup1.Style.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(240)), ((System.Byte)(158)), ((System.Byte)(159)));
this.ribbonTabItemGroup1.Style.BackColor2 = System.Drawing.Color.FromArgb(((System.Byte)(249)), ((System.Byte)(225)), ((System.Byte)(226)));
this.ribbonTabItemGroup1.Style.BackColorGradientAngle = 90;
this.ribbonTabItemGroup1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.ribbonTabItemGroup1.Style.BorderBottomWidth = 1;
this.ribbonTabItemGroup1.Style.BorderColor = System.Drawing.Color.FromArgb(((System.Byte)(154)), ((System.Byte)(58)), ((System.Byte)(59)));
this.ribbonTabItemGroup1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.ribbonTabItemGroup1.Style.BorderLeftWidth = 1;
this.ribbonTabItemGroup1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.ribbonTabItemGroup1.Style.BorderRightWidth = 1;
this.ribbonTabItemGroup1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
this.ribbonTabItemGroup1.Style.BorderTopWidth = 1;
this.ribbonTabItemGroup1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
this.ribbonTabItemGroup1.Style.TextColor = System.Drawing.Color.Black;
this.ribbonTabItemGroup1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.White;
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Location = new System.Drawing.Point(2, 48);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(4, 277);
this.panel1.TabIndex = 12;
//
// panel2
//
this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
this.panel2.Location = new System.Drawing.Point(170, 48);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(4, 277);
this.panel2.TabIndex = 13;
//
// panel3
//
this.panel3.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(6, 48);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(164, 4);
this.panel3.TabIndex = 14;
//
// TvUsers
//
this.TvUsers.BackColor = System.Drawing.Color.White;
this.TvUsers.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.TvUsers.Dock = System.Windows.Forms.DockStyle.Fill;
this.TvUsers.ImageIndex = 14;
this.TvUsers.ImageList = this.imageList1;
this.TvUsers.ItemHeight = 20;
this.TvUsers.Location = new System.Drawing.Point(6, 52);
this.TvUsers.Name = "TvUsers";
this.TvUsers.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("部门(0/0)"),
new System.Windows.Forms.TreeNode("未知(0/0)")});
this.TvUsers.SelectedImageIndex = 15;
this.TvUsers.ShowLines = false;
this.TvUsers.ShowRootLines = false;
this.TvUsers.Size = new System.Drawing.Size(164, 273);
this.TvUsers.TabIndex = 27;
this.TvUsers.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.TvUsers_AfterCheck);
this.TvUsers.DoubleClick += new System.EventHandler(this.TvUsers_DoubleClick);
this.TvUsers.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TvUsers_AfterSelect);
this.TvUsers.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TvUsers_MouseMove);
//
// imageListFace
//
this.imageListFace.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this.imageListFace.ImageSize = new System.Drawing.Size(20, 20);
this.imageListFace.TransparentColor = System.Drawing.Color.White;
//
// timerCheckOnlinState
//
this.timerCheckOnlinState.Interval = 56000;
this.timerCheckOnlinState.Tick += new System.EventHandler(this.timerCheckOnlinState_Tick);
//
// sockUDP1
//
this.sockUDP1.Server = ((System.Net.IPEndPoint)(resources.GetObject("sockUDP1.Server")));
this.sockUDP1.DataArrival += new LanMsg.Controls.SockUDP.DataArrivalEventHandler(this.sockUDP1_DataArrival);
//
// NotifyIcon
//
this.NotifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));
this.NotifyIcon.Text = "LanMsg";
this.NotifyIcon.Visible = true;
this.NotifyIcon.Click += new System.EventHandler(this.NotifyIcon_Click);
//
// FormMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(176, 344);
this.Controls.Add(this.TvUsers);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.ribbonControl1);
this.Controls.Add(this.bar1);
this.DockPadding.Bottom = 2;
this.DockPadding.Left = 2;
this.DockPadding.Right = 2;
this.DockPadding.Top = 2;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(160, 344);
this.Name = "FormMain";
this.Opacity = 0;
this.ShowInTaskbar = false;
this.Text = "设计院LanMsg";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Closing += new System.ComponentModel.CancelEventHandler(this.FormMain_Closing);
this.SizeChanged += new System.EventHandler(this.FormMain_SizeChanged);
this.Load += new System.EventHandler(this.FormMain_Load);
((System.ComponentModel.ISupportInitialize)(this.bar1)).EndInit();
this.ribbonControl1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void sockUDP1_DataArrival(byte[] Data, System.Net.IPAddress Ip, int Port)
{
DataArrivaldelegate outdelegate = new DataArrivaldelegate( DataArrival);
this.BeginInvoke (outdelegate, new object[]{ Data,Ip,Port});
}
private delegate void DataArrivaldelegate(byte[] Data, System.Net.IPAddress Ip, int Port);
private void DataArrival(byte[] Data, System.Net.IPAddress Ip, int Port)
{
LanMsg.Controls.ClassMsg msg=new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(Data))) as LanMsg.Controls.ClassMsg;
switch(msg.MsgInfoClass)
{
case 0://有用户离线
userSingnOut(msg.ID );//处理用户离线
break;
case 1://服务器告诉自己已经登录,登录过程
SuccessLogin(msg);
break;
case 2://服务器告诉用户自己目前在线
updateSelfState();//更新当前用户在线状态
break;
case 3://服务器告诉用户有新的联系人登录
NewUserLogin(new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(msg.MsgContent ))) as ClassUserInfo );//添加新登录的用户资料
break;
case 4://收到用户部分联系人的资料
UsersDataArrival((new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(msg.MsgContent ))) as Controls.ClassUsers));//收到用户所有联系人的资料
break;
case 5://收到用户联系人发送来的对话消息
UserChatArrival(msg,Ip,Port);//处理对话消息
break;
case 6://联系人返回已经收到刚才发送的对话消息
returnChatArrival(msg.ID );//联系人返回已经收到刚才发送的对话消息
break;
case 7:
//收到联系人发送来的群发通知消息
noticeArrival(msg,Ip,Port);//处理联系人发送来的群发通知消息
break;
case 8://对方要求UDP打洞
UDPNatTranslators(msg,Ip,Port);
break;
case 10://收到联系人发出发送文件请求
sendFileRequest(msg,Ip,Port);
break;
case 11://收到联系人发送来的gif图片流
UserGifArrival(msg,Ip,Port);//处理gif图片消息
break;
case 12://收到用户发送来的文本消息
UserTextChatArrival(msg,Ip,Port);//处理用户发送来的文本消息
break;
case 13://收到视频对话请求
//MessageBox.Show("视频对话请求"+ Ip.ToString() +":"+ Port.ToString());
UserAVRequestArrival(msg,Ip,Port);
break;
case 14://对方告诉自己开始视频对话
//MessageBox.Show("开始视频对话"+ Ip.ToString() +":"+ Port.ToString());
UserBeginAV(msg,Ip,Port);
break;
case 15://对方已经取消息视频对话
CancelAV(msg.ID );//取消视频对话
break;
case 16://服务器通知升级到最新版本的LanMsg
update();
break;
}
}
private void update()
{
LanMsg.FormUpdate f=new FormUpdate();
f.ShowDialog(this);
}
private void CancelAV(string userID)//对方已经取消息视频对话,取消视频对话
{
ClassUserInfo userinfo =this.findUser(userID);
if (userinfo!=null)
{
foreach(System.Windows.Forms.Form form in forms)
if (form.Tag.ToString() == userinfo.ID )
{
FormSendMsg f=(form as FormSendMsg );
f.CancelAV();
f.Activate ();
return;
}
}
}
private void UserBeginAV(LanMsg.Controls.ClassMsg msg, System.Net.IPAddress Ip, int Port)//对方要求立即进行视频对话
{
ClassUserInfo userinfo =this.findUser(msg.ID);
if (userinfo!=null)
{
foreach(System.Windows.Forms.Form form in forms)
if (form.Tag.ToString() == userinfo.ID )
{
FormSendMsg f=(form as FormSendMsg );
f.BeginAV(Ip,Port);
f.Activate ();
return;
}
}
}
private void UDPNatTranslators(LanMsg.Controls.ClassMsg msg, System.Net.IPAddress Ip, int Port)//对方要求UDP打洞
{
LanMsg.ClassUserInfo userinfo=this.findUser(msg.ID );
if(userinfo!=null)
{
userinfo.IP=Ip;
userinfo.Port=Port;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -