Example #1
0
        /// <summary>
        /// 将指定键值的用户删除
        /// </summary>
        /// <param name="Keyi">要删除的用户的键值,也就是IP地址</param>
        public static void RemoveUser(this Form1 f1, string ip)
        {
            UserData user = Method.GetUser(ip);

            //判断控件字典中是否已有与该用户的会话窗口
            if (user == null)
            {
                return;
            }
            try
            {
                if (f1.NowUserData.IP.Equals(ip))
                {
                    Method.ShowPrompt("当前用户已下线", 2000);
                    return;
                }
                //将其从ListBox中删除
                f1.bs_ListBoxOnline.Remove(user);
                if (f1.panel_left.Controls.Contains(user.TalkPanel))
                {
                    f1.panel_left.Controls.Remove(user.TalkPanel);
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("Method-RemoveUser:从列表中删除用户时出现异常!");
            }
            f1.UpdateScollBarMaxValue();
        }
Example #2
0
 /// <summary>
 /// 将文件消息添加到窗口
 /// </summary>
 public static void AppendFileMes(this Form1 f1, string path, UserData data)
 {
     try
     {
         data.TalkPanel.AppendFileMes(path, data);
     }
     catch (Exception)
     {
         Method.ShowPrompt("当前用户已下线", 1000);
     }
 }
Example #3
0
 private void bt_Save_Click(object sender, EventArgs e)
 {
     Settings1.Default.输设置  = Get传输设置();
     Settings1.Default.常规设置 = Get常规设置();
     Settings1.Default.用户管理 = Get用户管理();
     Settings1.Default.提醒设置 = Get提醒设置();
     Settings1.Default.Save();
     Options.Update();
     this.OnInstallOver();
     Method.ShowPrompt("设置已经保存", 1000);
 }
Example #4
0
        private void 用户管理_bt_备注修改_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(用户管理_tb_备注名.Text.Trim()))
            {
                Method.ShowPrompt("备注名不能为空", 1000);
                this.用户管理_tb_备注名.Text = string.Empty;
            }
            IPRemarks rk = 用户管理_lb_备注列表.Items[用户管理_lb_备注列表.SelectedIndex].Tag as IPRemarks;

            rk = new IPRemarks(rk.IP, 用户管理_tb_备注名.Text);
            用户管理_lb_备注列表.Items[用户管理_lb_备注列表.SelectedIndex].Text = rk.ToString();
            用户管理_lb_备注列表.Items[用户管理_lb_备注列表.SelectedIndex].Tag  = rk;
        }
Example #5
0
 private void AddControl(Control control)
 {
     if (control is MS_Label)
     {
         (control as MS_Label).AtUserEvent += (sender, e) => { this.AtUserEvent(sender, e); };
     }
     try {
         this.panel_sub.Controls.Add(control);
     }catch (Exception ex)
     {
         Method.ShowPrompt("由于某些原因,消息添加失败!\n附加信息:" + ex.Message, 1000, 30);
     }
 }
Example #6
0
 // 点击用户头像时跳转到其会话界面
 private void HeadImage_Click(object sender, MouseEventArgs e)
 {
     if (We || e.Button != MouseButtons.Left)
     {
         return;
     }
     if (!KeyData.Activity.UserStruchOnline.Contains(this.user))
     {
         Method.ShowPrompt("该用户已下线!");
         return;
     }
     KeyData.form1.SetKinetic(this.user);
 }
Example #7
0
 /// <summary>
 /// 发送文件
 /// </summary>
 /// <param name="f1"></param>
 /// <param name="path"></param>
 public static void SendFileInfo(this Form1 f1, string path)
 {
     if (f1.NowUserData.IsPub)
     {
         if (new FileInfo(path).Length > 1024 * 1024 * 10)
         {
             Method.ShowPrompt("不支持在公共会话频道内传输大于10MB的文件", 1000);
             return;
         }
         f1.AppendFileMes(path, KeyData.Activity.UserStruchOnline[0]);
         Transmitters.Sender.SendFileData(path);
     }
     else
     {
         f1.AppendFileMes(path, f1.NowUserData);
         Transmitters.Sender.SendFileMessage(f1.NowUserData.IP, path);
     }
 }
Example #8
0
        /// <summary>
        /// 发送图片
        /// </summary>
        public static void SendPicInfo(this Form1 f1, Image img)
        {
            long len = Method.ImageToBytes(img).Length;

            if (img.Size.Width > 5000 || img.Size.Height > 5000 || len >= 1024 * 1024 * 3)
            {
                Method.ShowPrompt("图片尺寸过大或文件大小过大,不支持发送", 1000);
                return;
            }
            ImgMesKey mes = new ImgMesKey()
            {
                User     = f1.NowUserData,
                Img      = img,
                Type     = MsType.本地消息,
                isPublic = false
            };
            var f = new Image_Send(f1.NowUserData, img);

            f.AddImage += e => f1.AppendPicMessage(e);
            f.AddText  += e => f1.AppendMessage(e);
            f.ShowDialog();
            f.Dispose();
        }