/// <summary> /// 设置发送消息的快捷键 /// </summary> /// <param name="value"></param> public void SetSendKeyType(int value) { CSS.IM.XMPP.Xml.Dom.Document doc_setting = new CSS.IM.XMPP.Xml.Dom.Document(); Settings.Settings config = new Settings.Settings(); doc_setting.LoadFile(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); Settings.Paths path = doc_setting.RootElement.SelectSingleElement(typeof(Settings.Paths), false) as Settings.Paths; path.SendKeyType = value; CSS.IM.UI.Util.Path.SendKeyType = value; config.Paths = path; config.Font = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SFont)) as Settings.SFont; config.Color = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SColor)) as Settings.SColor; doc_setting.Clear(); doc_setting.ChildNodes.Add(config); doc_setting.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); }
private void 关闭声音ToolStripMenuItem_Click(object sender, EventArgs e) { Document doc = new Document(); doc.LoadFile(CSS.IM.UI.Util.Path.ConfigFilename); Settings.Settings config = new Settings.Settings(); Settings.Paths path = doc.RootElement.SelectSingleElement(typeof(Settings.Paths)) as Settings.Paths; if (关闭声音ToolStripMenuItem.Text == "关闭所有声音") { 关闭声音ToolStripMenuItem.Text = "开启所有声音"; path.SelectSingleElement("MsgPath").SetAttribute("Enable", false); CSS.IM.UI.Util.Path.MsgSwitch = false; path.SelectSingleElement("SystemPath").SetAttribute("Enable", false); CSS.IM.UI.Util.Path.SystemSwitch = false; path.SelectSingleElement("CallPath").SetAttribute("Enable", false); CSS.IM.UI.Util.Path.CallSwitch = false; path.SelectSingleElement("FolderPath").SetAttribute("Enable", false); CSS.IM.UI.Util.Path.FolderSwitch = false; path.SelectSingleElement("GlobalPath").SetAttribute("Enable", false); CSS.IM.UI.Util.Path.GlobalSwitch = false; path.SelectSingleElement("InputAlertPath").SetAttribute("Enable", false); CSS.IM.UI.Util.Path.InputAlertSwitch = false; } else { 关闭声音ToolStripMenuItem.Text = "开启所有声音"; path.SelectSingleElement("MsgPath").SetAttribute("Enable", true); CSS.IM.UI.Util.Path.MsgSwitch = true; path.SelectSingleElement("SystemPath").SetAttribute("Enable", true); CSS.IM.UI.Util.Path.SystemSwitch = true; path.SelectSingleElement("CallPath").SetAttribute("Enable", true); CSS.IM.UI.Util.Path.CallSwitch = true; path.SelectSingleElement("FolderPath").SetAttribute("Enable", true); CSS.IM.UI.Util.Path.FolderSwitch = true; path.SelectSingleElement("GlobalPath").SetAttribute("Enable", true); CSS.IM.UI.Util.Path.GlobalSwitch = true; path.SelectSingleElement("InputAlertPath").SetAttribute("Enable", true); CSS.IM.UI.Util.Path.InputAlertSwitch = true; } config.Paths = path; doc.Clear(); doc.ChildNodes.Add(config); doc.Save(CSS.IM.UI.Util.Path.ConfigFilename); }
/// <summary> /// 选择字体事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_font_Click(object sender, EventArgs e) { using (System.Windows.Forms.FontDialog fd = new FontDialog()) { fd.Font = this.rtfSend.Font; if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK) CSS.IM.UI.Util.Path.SFong = fd.Font; this.rtfSend.Font = CSS.IM.UI.Util.Path.SFong; Document doc = new Document(); doc.LoadFile(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); Settings.Settings config = new Settings.Settings(); CSS.IM.App.Settings.SFont font = doc.RootElement.SelectSingleElement(typeof(Settings.SFont), false) as Settings.SFont; if (font==null) { font = new SFont(); } font.Name = rtfSend.Font.Name; font.Size = rtfSend.Font.Size; font.Bold = rtfSend.Font.Bold; font.Italic = rtfSend.Font.Italic; font.Strikeout = rtfSend.Font.Strikeout; config.Font = font; config.Color = doc.RootElement.SelectSingleElement(typeof(Settings.SColor), false) as Settings.SColor; config.Paths = doc.RootElement.SelectSingleElement(typeof(Settings.Paths), false) as Settings.Paths; doc.Clear(); doc.ChildNodes.Add(config); doc.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); } }
/// <summary> /// 选择字体颜色样式 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_FontColor_Click(object sender, EventArgs e) { using (System.Windows.Forms.ColorDialog cd = new ColorDialog()) { cd.Color = this.rtfSend.ForeColor; if (cd.ShowDialog() == System.Windows.Forms.DialogResult.OK) CSS.IM.UI.Util.Path.SColor = cd.Color; this.rtfSend.ForeColor = CSS.IM.UI.Util.Path.SColor; Document doc = new Document(); doc.LoadFile(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); Settings.Settings config = new Settings.Settings(); CSS.IM.App.Settings.SColor color = doc.RootElement.SelectSingleElement(typeof(Settings.SColor), false) as Settings.SColor; if (color==null) { color = new SColor(); } Color top_cl = rtfSend.ForeColor; byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb()); color.CA = top_cby[0]; color.CR = top_cby[1]; color.CG = top_cby[2]; color.CB = top_cby[3]; config.Color = color; config.Font = doc.RootElement.SelectSingleElement(typeof(Settings.SFont), false) as Settings.SFont; config.Paths = doc.RootElement.SelectSingleElement(typeof(Settings.Paths), false) as Settings.Paths; doc.Clear(); doc.ChildNodes.Add(config); doc.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); } }
/// <summary> /// 设置发送消息的快捷键 /// </summary> /// <param name="value"></param> public void SetSendKeyType(int value) { Document doc_setting = new Document(); Settings.Settings config = new Settings.Settings(); doc_setting.LoadFile(CSS.IM.UI.Util.Path.ConfigFilename); Settings.Paths path = doc_setting.RootElement.SelectSingleElement(typeof(Settings.Paths), false) as Settings.Paths; path.SendKeyType = value; CSS.IM.UI.Util.Path.SendKeyType = value; doc_setting.Clear(); config.Paths = path; doc_setting.ChildNodes.Add(config); doc_setting.Save(CSS.IM.UI.Util.Path.ConfigFilename); }
/// <summary> /// 登录成功事件 /// </summary> /// <param name="sender"></param> public void XmppCon_OnLogin(object sender) { if (InvokeRequired) { BeginInvoke(new CSS.IM.XMPP.ObjectHandler(XmppCon_OnLogin), new object[] { sender }); return; } Program.UserName = XmppCon.Username; Program.LocalHostIP = IPAddress.Parse(XmppCon.ClientSocket.LocalHostIP);//设置本地IP地址 VcardIq viq = new VcardIq(IqType.get, null, new Jid(XmppCon.MyJID.User)); XmppCon.IqGrabber.SendIq(viq, new IqCB(VcardResult), null); Program.UserName = XmppCon.MyJID.User;//保存登录的用户名 notifyIcon_MessageQueue.Visible = true; waiting.Close(); XmppCon.Show = ShowType.NONE; XmppCon.SendMyPresence(); DiscoServer();//获取各种服务器 this.NikeName = XmppCon.Username; this.ShowInTaskbar = false; this.Show(); this.WindowState = FormWindowState.Normal; listView_fd.XmppConnection = XmppCon; listView_fd.AddGroup("我的联系人"); listView_fd.UpdateLayout(3, 0); this.TopMost = true; this.Show(); this.Activate(); this.TopMost = false; #region 设置最后一次登录的用户 Document hl_doc = new Document(); Settings.HistoryLogin doc_HLlgin; if (!System.IO.File.Exists(CSS.IM.UI.Util.Path.HistoryFilename)) { doc_HLlgin = new Settings.HistoryLogin(); doc_HLlgin.LoginName = Program.UserName; } else { hl_doc.LoadFile(CSS.IM.UI.Util.Path.HistoryFilename); doc_HLlgin = hl_doc.RootElement as Settings.HistoryLogin; doc_HLlgin.LoginName = Program.UserName; hl_doc.RemoveAllChildNodes(); } hl_doc.AddChild(doc_HLlgin); FileInfo file = new FileInfo(CSS.IM.UI.Util.Path.HistoryFilename); if (!File.Exists(file.DirectoryName)) { Directory.CreateDirectory(file.DirectoryName); } hl_doc.Save(CSS.IM.UI.Util.Path.HistoryFilename); #endregion #region 创建服务配置文件 Document vy_doc = new Document(); Settings.Verify vy_doc_settings = new Settings.Verify(); Settings.Login vy_doc_login = null; Settings.ServerInfo vy_doc_serverInfo = null; if (System.IO.File.Exists(string.Format(CSS.IM.UI.Util.Path.SettingsFilename,Program.UserName))) { vy_doc.LoadFile(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, Program.UserName)); vy_doc_login = vy_doc.RootElement.SelectSingleElement(typeof(Settings.Login)) as Settings.Login; vy_doc_serverInfo = vy_doc.RootElement.SelectSingleElement(typeof(Settings.ServerInfo)) as Settings.ServerInfo; vy_doc.RemoveAllChildNodes(); } else { vy_doc_login = new Settings.Login(); vy_doc_serverInfo = new Settings.ServerInfo(); vy_doc_login.InitIal = true;//设置开机自动启动,默认为启动 } vy_doc_login.Auto = login_user.Auto; vy_doc_login.Save = login_user.Save; vy_doc_login.Jid = new Jid(login_user.UserName); vy_doc_login.Password = login_user.PassWord; vy_doc_serverInfo.ServerIP = Program.ServerIP; vy_doc_serverInfo.ServerPort = Program.Port; vy_doc_settings.ServerInfo = vy_doc_serverInfo; vy_doc_settings.Login = vy_doc_login; vy_doc.ChildNodes.Add(vy_doc_settings); vy_doc.Save(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, Program.UserName)); CSS.IM.UI.Util.Path.Initial = vy_doc_login.InitIal;//设置开机自动启动 #endregion #region 创建个人配置文件 if (!System.IO.File.Exists(string.Format(CSS.IM.UI.Util.Path.ConfigFilename,Program.UserName))) { Document doc = new Document(); Settings.Settings config = new Settings.Settings(); CSS.IM.App.Settings.Paths path = new Settings.Paths(); path.MsgPath = CSS.IM.UI.Util.Path.MsgPath; path.SelectSingleElement("MsgPath").SetAttribute("Enable", true); path.SystemPath = CSS.IM.UI.Util.Path.SystemPath; path.SelectSingleElement("SystemPath").SetAttribute("Enable", true); path.CallPath = CSS.IM.UI.Util.Path.CallPath; path.SelectSingleElement("CallPath").SetAttribute("Enable", true); path.FolderPath = CSS.IM.UI.Util.Path.FolderPath; path.SelectSingleElement("FolderPath").SetAttribute("Enable", true); path.GlobalPath = CSS.IM.UI.Util.Path.GlobalPath; path.SelectSingleElement("GlobalPath").SetAttribute("Enable", true); path.InputAlertPath = CSS.IM.UI.Util.Path.InputAlertPath; path.SelectSingleElement("InputAlertPath").SetAttribute("Enable", true); path.ReveiveSystemNotification = true; path.ChatOpen = true; path.SendKeyType = CSS.IM.UI.Util.Path.SendKeyType;//创建消息发送快捷键类型 默认为enter发送 path.GetOutMsgKeyTYpe = "W+ Control+ Alt";//默认获取消息快捷按键 path.ScreenKeyTYpe = "S+ Control+ Alt";//默认截图快捷按键 path.FriendContainerType = true;//保存是大头像还是小头像 默认为小头像 path.DefaultURL = "http://10.0.0.207:8080/bgtoa/eblueplugins/eblueim/forwardUrl.do?url=cmVkaXJlY3Q6L2luZGV4LmRv";//毛奇使用 path.EmailURL = "http://10.0.0.207:8080/bgtoa/eblueplugins/eblueim/forwardUrl.do?url=cmVkaXJlY3Q6L2luZGV4LmRv";//毛奇使用 config.Paths = path; CSS.IM.UI.Util.Path.DefaultURL = path.DefaultURL; BasicTextBox txt_temp = new BasicTextBox(); CSS.IM.App.Settings.SFont font = new Settings.SFont(); font.Name = txt_temp.Font.Name; font.Size = txt_temp.Font.Size; font.Bold = txt_temp.Font.Bold; font.Italic = txt_temp.Font.Italic; font.Strikeout = txt_temp.Font.Strikeout; config.Font = font; CSS.IM.App.Settings.SColor color = new Settings.SColor(); Color top_cl = txt_temp.ForeColor; byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb()); color.CA = top_cby[0]; color.CR = top_cby[1]; color.CG = top_cby[2]; color.CB = top_cby[3]; config.Color = color; doc.ChildNodes.Add(config); doc.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); txt_temp.Dispose(); } #endregion }
/// <summary> /// 查看联系人详细信息事件、删除、备注 /// </summary> /// <param name="sender"></param> /// <param name="item"></param> public void listView_fd_friend_qcm_MouseClickEvent(object sender, Friend item, String type) { CSS.IM.XMPP.protocol.iq.roster.RosterItem ritem = null; if (listView_fd.SelectFriend!=null) { ritem = listView_fd.SelectFriend.Ritem; } Document doc_setting = new Document(); Settings.Settings config = new Settings.Settings(); Settings.Paths path = null; switch (type) { case "vcar": if (vcardForm == null || vcardForm.IsDisposed) { vcardForm = new VcardInfoForm(ritem.Jid, XmppCon); } vcardForm.Show(); vcardForm.Activate(); break; case "chat": if (!Util.ChatForms.ContainsKey(item.Ritem.Jid.Bare)) { try { string nickName = listView_fd.GetFriendNickName(item.Ritem.Jid.Bare); ChatFromMsg chat = new ChatFromMsg(item.Ritem.Jid, XmppCon, nickName); chat.UpdateFriendOnline(item.IsOnline);//设置好友在线状态 chat.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { try { ChatFromMsg chatform = Util.ChatForms[item.Ritem.Jid.Bare] as ChatFromMsg; chatform.WindowState = FormWindowState.Normal; chatform.Activate(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; case "dele": Jid jid = item.Ritem.Jid; Friend friend = new Friend(); friend.NikeName = item.Ritem.Jid.User; friend.Description = "";//心情 friend.HeadIMG = "big1"; friend.IsSysHead = true; friend.State = 1; if (item.Ritem.GetGroups().Count > 0) { CSS.IM.XMPP.protocol.Base.Group g = (CSS.IM.XMPP.protocol.Base.Group)item.Ritem.GetGroups().Item(0); int groupID = 0; foreach (var groups in listView_fd.Groups) { if (groups.Value.Title == g.Name) { groupID = groups.Value.Id; } } //if (groupID == 0) //{ // friendListView.AddGroup(g.Name); // groupID = friendListView.Groups[g.Name].Id; // friendListView.UpdateLayout(3, groupID); //} friend.GroupID = groupID; friend.GroupName = g.Name; } else { //离线联系人 Group group = listView_fd.Groups["我的联系人"]; friend.GroupID = group.Id; friend.GroupName = group.Title; } friend.Ritem = item.Ritem; friend.IsOnline = false; DialogResult msgResult = MsgBox.Show(this, "CSS&IM", "确认要删除联系人么?", MessageBoxButtons.YesNo); if (msgResult == DialogResult.Yes) { listView_fd.RemoveFriend(friend); try { RosterIq riq = new RosterIq(); riq.Type = IqType.set; XmppCon.RosterManager.RemoveRosterItem(jid); } catch (Exception ex) { throw ex; } } break; case "move": if (moveFriendGroup == null || moveFriendGroup.IsDisposed) { moveFriendGroup = new MoveFriendGroup(); } Dictionary<string, Group> group_args = listView_fd.Groups; string[] strvalue = new string[group_args.Count]; int index = 0; foreach (String keystr in group_args.Keys) { Group groupargs = group_args[keystr]; strvalue[index] = groupargs.Title; index++; } moveFriendGroup.basicComboBox1.Items = strvalue; moveFriendGroup.basicComboBox1.SelectIndex = 0; DialogResult reslut = moveFriendGroup.ShowDialog(); String groupupdate = moveFriendGroup.basicComboBox1.SelectItem.ToString(); String Bare_move = listView_fd.SelectFriend.Ritem.Jid.Bare; if (reslut == DialogResult.Yes) { foreach (String user_key in listView_fd.Rosters.Keys) { if (listView_fd.Rosters[user_key].Ritem.Jid.Bare == Bare_move) { Friend friend_old = listView_fd.Rosters[user_key]; listView_fd.RemoveFriend(listView_fd.Rosters[user_key].Ritem.Jid.Bare); Group fgroup = listView_fd.Groups[groupupdate]; friend_old.GroupID = fgroup.Id; friend_old.GroupName = fgroup.Title; listView_fd.AddFriend(friend_old); listView_fd.RefreshGroup(); break; } } CSS.IM.XMPP.protocol.Base.Group group_move = new CSS.IM.XMPP.protocol.Base.Group(groupupdate); CSS.IM.XMPP.protocol.Base.Item item_move = new CSS.IM.XMPP.protocol.Base.Item(); item_move.Namespace = null; item_move.AddChild(group_move); item_move.SetAttribute("jid", listView_fd.SelectFriend.Ritem.Jid); item_move.SetAttribute("subscripton", "from"); CSS.IM.XMPP.protocol.Base.Query query_move = new CSS.IM.XMPP.protocol.Base.Query(); query_move.Namespace = CSS.IM.XMPP.Uri.IQ_ROSTER; query_move.AddChild(item_move); IQ iq = new IQ(IqType.set); iq.GenerateId(); iq.Namespace = null; iq.AddChild(query_move); XmppCon.IqGrabber.SendIq(iq); } break; case "g_dele": break; case "remark": //RemarkFriendGroup _RemarkFriendGroup = new RemarkFriendGroup(); //Dictionary<string, Group> group_args = friendListView.Groups; //string[] strvalue = new string[group_args.Count]; //int index = 0; //foreach (String keystr in group_args.Keys) //{ // Group groupargs = group_args[keystr]; // strvalue[index] = groupargs.Title; // index++; //} //_MoveFriendGroup.basicComboBox1.Items = strvalue; //_MoveFriendGroup.basicComboBox1.SelectIndex = 0; //DialogResult reslut = _MoveFriendGroup.ShowDialog(); //String groupupdate = _MoveFriendGroup.basicComboBox1.SelectItem.ToString(); //String name_move = friendListView.SelectedFriend.Ritem.Jid.User; //if (reslut == DialogResult.Yes) //{ // foreach (String user_key in friendListView.Rosters.Keys) // { // if (friendListView.Rosters[user_key].Ritem.Jid.User == name_move) // { // Friend friend_old = friendListView.Rosters[user_key]; // friendListView.RemoveFriend(friendListView.Rosters[user_key].Ritem.Jid.User); // Group fgroup = friendListView.Groups[groupupdate]; // friend_old.GroupID = fgroup.Id; // friend_old.GroupName = fgroup.Title; // friendListView.AddFriend(friend_old); // friendListView.UpdateLayout(3, 0); // break; // } // } // CSS.IM.XMPP.protocol.Base.Group group_move = new CSS.IM.XMPP.protocol.Base.Group(groupupdate); // CSS.IM.XMPP.protocol.Base.Item item_move = new CSS.IM.XMPP.protocol.Base.Item(); // item_move.Namespace = null; // item_move.AddChild(group_move); // item_move.SetAttribute("jid", friendListView.SelectedFriend.Ritem.Jid); // item_move.SetAttribute("subscripton", "from"); // CSS.IM.XMPP.protocol.Base.Query query_move = new CSS.IM.XMPP.protocol.Base.Query(); // query_move.Namespace = CSS.IM.XMPP.Uri.IQ_ROSTER; // query_move.AddChild(item_move); // IQ iq = new IQ(IqType.set); // iq.GenerateId(); // iq.Namespace = null; // iq.AddChild(query_move); // XmppCon.IqGrabber.SendIq(iq); break; case "HeadSmall": //listView_fd.FCType = FriendContainerType.Small; CSS.IM.UI.Util.Path.FriendContainerType = false; doc_setting.LoadFile(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); path = doc_setting.RootElement.SelectSingleElement(typeof(Settings.Paths),false) as Settings.Paths; path.FriendContainerType = CSS.IM.UI.Util.Path.FriendContainerType; config.Paths = path; config.Font = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SFont), false) as Settings.SFont; config.Color = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SColor), false) as Settings.SColor; doc_setting.Clear(); doc_setting.ChildNodes.Add(config); try { doc_setting.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); } catch (Exception) { } listView_fd.FCType = CSS.IM.UI.Util.Path.FriendContainerType == true ? FriendContainerType.Big : FriendContainerType.Small; chatHistory_lt.FCType = listView_fd.FCType; listView_gp.FCType = listView_fd.FCType; break; case "HeadBig": //listView_fd.FCType = FriendContainerType.Small; CSS.IM.UI.Util.Path.FriendContainerType = true; doc_setting.LoadFile(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); path = doc_setting.RootElement.SelectSingleElement(typeof(Settings.Paths),false) as Settings.Paths; path.FriendContainerType = CSS.IM.UI.Util.Path.FriendContainerType; config.Paths = path; config.Font = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SFont), false) as Settings.SFont; config.Color = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SColor), false) as Settings.SColor; doc_setting.Clear(); doc_setting.ChildNodes.Add(config); try { doc_setting.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName)); } catch (Exception) { } listView_fd.FCType = CSS.IM.UI.Util.Path.FriendContainerType == true ? FriendContainerType.Big : FriendContainerType.Small; chatHistory_lt.FCType = listView_fd.FCType; listView_gp.FCType = listView_fd.FCType; break; default: break; } }