📄 formsendmsg.cs
字号:
IMLibrary.FormCapture cf = new IMLibrary.FormCapture();
cf.ShowDialog();
if (cf.Image != null)
{
//System.IO.MemoryStream Ms = new System.IO.MemoryStream();
//cf.Image.Save(Ms, System.Drawing.Imaging.ImageFormat.Gif);
IMLibrary.MyPicture pic = new IMLibrary.MyPicture();
pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
pic.BackColor = this.RTBSend.BackColor;
pic.Image = cf.Image;//System.Drawing.Image.FromStream(Ms);
//Ms.Close();
System.Random R = new Random();
pic.Tag = R.Next(200, 2147483627);
System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(Application.StartupPath + "\\sendImage");
if (!dInfo.Exists)
dInfo.Create();
cf.Image.Save(Application.StartupPath + "\\sendImage\\" + pic.Tag.ToString() + ".gif");
this.RTBSend.InsertMyControl(pic);
this.SendGifs.add(pic);
}
cf.Dispose();
}
#endregion
#region 添加GIF图片控件到richtextbox
/// <summary>
/// 添加GIF图片控件到richtextbox
/// </summary>
/// <param name="gifID">gifID</param>
/// <returns>返回gif控件</returns>
private IMLibrary.MyPicture addGifControl(string gifID,string resourceName)
{
IMLibrary.MyPicture pic = this.findPic(gifID,this.faceGifs );
if (pic == null)
{
pic = new MyPicture();
pic.BackColor = this.RTBRecord.BackColor;
pic.Tag = gifID;
pic.Image = (System.Drawing.Image)FormAccess.resourceManager.GetObject(resourceName);
pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
pic.Invalidate();
this.panelGif.Controls.Add(pic);
}
return pic;
}
void pic_MouseClick(object sender, MouseEventArgs e)
{
//MessageBox.Show(((MyPicture) sender).Tag.ToString ());
}
#endregion
#region 表情菜单 单击事件
private void item_Click(object sender, EventArgs e)//表情单击事件代码
{
DevComponents.DotNetBar.ButtonItem butItem = sender as DevComponents.DotNetBar.ButtonItem ;
this.RTBSend.InsertMyControl( addGifControl(butItem.Tooltip, butItem.Tag.ToString()));
}
#endregion
#region 初始化表情菜单
private void IniFace()
{
int j = 0;
DevComponents.DotNetBar.ItemContainer itemCon = null;
for (int i = 0; i < 195; i++)
{
DevComponents.DotNetBar.ButtonItem item = new DevComponents.DotNetBar.ButtonItem();
item.Tag = "_" + i.ToString();
item.Tooltip = i.ToString();
item.Size = new Size(16, 16);
item.Image = FormAccess.formMain.imageListFace.Images[i];//FormAccess.faceGifImages[i].Image;//(System.Drawing.Image)FormAccess.resourceManager.GetObject("_" + i.ToString());
if (i % 20 == 0)
{
DevComponents.DotNetBar.ItemContainer itemC = new DevComponents.DotNetBar.ItemContainer();
this.trtFaceSet.SubItems.Add(itemC,j);
itemCon = itemC;
itemCon.Name = i.ToString();
itemCon.MinimumSize = new Size(0, 0);
j++;
}
itemCon.SubItems.Add(item, i % 20);
item.Click += new EventHandler(item_Click);
}
}
#endregion
#region 视频对话部分
/// <summary>
/// 对方要求开始视频对话
/// </summary>
/// <param name="Ip">对方IP</param>
/// <param name="Port">对方端口</param>
public void BeginAV(System.Net.IPAddress Ip, int Port)//对方要求开始视频对话
{
this.myAV1.serverIp = this.currUserInfo.IP;
this.myAV1.serverPort = this.currUserInfo.Port;
this.myAV1.Connect(Ip.ToString(),Port);
AppendSystemRtf("已经与对方建立UDP连接...");
}
/// <summary>
/// AV对话请求
/// </summary>
/// <param name="Ip">对方IP</param>
/// <param name="Port">对方端口</param>
public void AVrequest(System.Net.IPAddress Ip, int Port)//AV对话请求
{//参数为对方IP与端口,使用P2P方式传送AV数据
this.currUserInfo=FormAccess.findUser (this.Tag.ToString());
if (this.currUserInfo != null)
{
this.panelRightNotice.Width = 300;
this.Width = this.Width + 150;
this.exPanelAV.Visible = true;
this.exPanelNotice.Visible = false;
this.ButAV.Enabled = false;
this.myAV1.sendId = FormAccess.selfInfo.UserID;
this.myAV1.serverIp = this.currUserInfo.IP;
this.myAV1.serverPort = this.currUserInfo.Port;
this.myAV1.linkLabelReceve.Visible = true;
AppendSystemRtf("对方请求与您进行视频对话,请接收请求或取消视频对话...");
}
}
private void myAV1_AVCancel(object sender, bool isSelf)
{
if (isSelf)
{
AppendSystemRtf("您已经取消了与对方的视频对话!");
}
else
{
AppendSystemRtf("对方已经取消了与您的视频对话!");
}
this.ButAV.Enabled = true;
this.Width = this.Width - this.panelRightNotice.Width + 150;
this.panelRightNotice.Width = 175;
this.exPanelNotice.Visible = true;
this.exPanelAV.Visible = false;
this.myAV1.ColseAV();
this.currUserInfo= FormAccess.findUser (this.Tag.ToString());
if (this.currUserInfo != null)
FormAccess.sendMsgToOneUser(22, new IMLibrary.clientMsg(), this.currUserInfo);//告诉对方已经取消了视频对话
}
/// <summary>
/// 对方取消AV对话
/// </summary>
public void CancelAV()
{
AppendSystemRtf("对方已经取消了与您的视频对话!");
this.ButAV.Enabled = true;
this.Width = this.Width - this.panelRightNotice.Width + 150;
this.panelRightNotice.Width = 175;
this.exPanelNotice.Visible = true;
this.exPanelAV.Visible = false;
this.myAV1.ColseAV();
}
private void myAV1_AVReceve(object sender, bool isSelf)
{
if (isSelf)
{
AppendSystemRtf("您已经接收了对方的视频对话请求!");
}
else
{
AppendSystemRtf("对方已经接收了您的视频对话请求!");
}
}
private void ButAV_Click(object sender, EventArgs e)
{
this.currUserInfo = FormAccess.findUser(this.Tag.ToString());
if (this.currUserInfo != null)
{
this.panelRightNotice.Width = 300;
this.Width = this.Width + 150;
this.exPanelAV.Visible = true;
this.exPanelNotice.Visible = false;
this.ButAV.Enabled = false;
this.myAV1.SetParameter(this.currUserInfo.IP,this.currUserInfo.Port,FormAccess.selfInfo.UserID);
AppendSystemRtf("您请求了与对方进行视频对话,请等待对方接收请求或取消视频对话...");
}
}
#endregion
private void RTBRecord_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && this.RTBRecord.SelectedText!="")
this.RTBRecord.DoDragDrop(Text, DragDropEffects.Copy);
}
#region 关联菜单
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
switch(e.ClickedItem.Name)
{
case "MenuItemCopy":
this.RTBSend.Copy();
break;
case "MenuItemPaset":
this.RTBSend.Paste();
break;
case "MenuItemCut":
this.RTBSend.Cut();
break;
case "MenuItemDel":
this.RTBSend.SelectedText = "";
break;
case "MenuItemSelAll":
this.Focus();
this.RTBSend.SelectAll();
break;
}
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
bool t=true;
if (this.RTBSend.SelectedText.Length == 0)
t = false;
this.MenuItemCopy.Visible = t;
this.MenuItemCut.Visible = t;
this.MenuItemDel.Visible = t;
}
private void contextMenuStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
switch (e.ClickedItem.Name)
{
case "MenuItemCopy2":
this.RTBRecord.Copy();
break;
case "MenuItemSelAll2":
this.Focus();
this.RTBRecord.SelectAll();
break;
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -