private void button1_Click(object sender, EventArgs e) { Document document = new Document(); document.LoadFile(@"C:\Users\Administrator\Desktop\test.txt"); CSS.IM.XMPP.protocol.client.Message top_msg = (CSS.IM.XMPP.protocol.client.Message)document.RootElement; ElementList properte_list =top_msg.SelectElements("properties"); int count = properte_list.Item(0).SelectElements("property").Count; MqMessage mqMsg = new MqMessage(); for (int i = 0; i < count; i++) { string nameValue = ""; string keyValue = ""; #region 获取property值 try { nameValue = properte_list.Item(0).SelectElements("property").Item(i).SelectElements("name").Item(0).Value; } catch (Exception) { break; } try { keyValue = properte_list.Item(0).SelectElements("property").Item(i).SelectElements("value").Item(0).Value; } catch (Exception) { } #endregion switch (nameValue) { case "isopen": mqMsg.IsOpen = keyValue; break; case "token": mqMsg.Token = keyValue; break; case "herf": mqMsg.Herf = keyValue; break; case "msg": mqMsg.Msg = keyValue; break; case "url": mqMsg.Url = keyValue; break; default: break; } } MessageBox.Show(mqMsg.ToString()); }
/// <summary> /// 声音和提醒 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_sound_Click(object sender, EventArgs e) { #region 初使化设置信息 doc_setting = new Document(); config = new Settings.Settings(); 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; bool enable = false; txt_MsgPath.Texts = path.MsgPath; enable = path.SelectSingleElement("MsgPath").GetAttributeBool("Enable"); if (enable) btn_MsgPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked; else btn_MsgPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; txt_SystemPath.Texts = path.SystemPath; enable = path.SelectSingleElement("SystemPath").GetAttributeBool("Enable"); if (enable) btn_SystemPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked; else btn_SystemPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; txt_CallPath.Texts = path.CallPath; enable = path.SelectSingleElement("CallPath").GetAttributeBool("Enable"); if (enable) btn_CallPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked; else btn_CallPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; txt_FolderPath.Texts = path.FolderPath; enable = path.SelectSingleElement("FolderPath").GetAttributeBool("Enable"); if (enable) btn_FolderPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked; else btn_FolderPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; txt_GlobalPath.Texts = path.GlobalPath; enable = path.SelectSingleElement("GlobalPath").GetAttributeBool("Enable"); if (enable) btn_GlobalPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked; else btn_GlobalPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; txt_InputAlertPath.Texts = path.InputAlertPath; enable = path.SelectSingleElement("InputAlertPath").GetAttributeBool("Enable"); if (enable) btn_InputAlertPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked; else btn_InputAlertPathOpen.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; chb_ReceiveSystem.CheckState = path.ReveiveSystemNotification == true ? CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked : CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; chb_ChatOpen.CheckState = path.ChatOpen == true ? CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked : CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; #endregion panel_info.Visible = false; panel_basice.Visible = false; panel_sendfile.Visible = false; panel_fastreply.Visible = false; panel_sound.Visible = true; panel_hotkey.Visible = false; }
/// <summary> /// 热键设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_hotkey_Click(object sender, EventArgs e) { #region 加载数据 doc_setting = new Document(); config = new Settings.Settings(); 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; if (path.GetOutMsgKeyTYpe == "W+ Control+ Alt")//默认获取消息快捷按键 { rdb_default_msg.Checked = true; txt_custom_msg.Texts = "W+ Control+ Alt"; txt_custom_msg.Enabled = false; txt_custom_msg.ReadOn = true; } else { rdb_costom_msg.Checked = true; txt_custom_msg.Enabled = true; txt_custom_msg.ReadOn = true; txt_custom_msg.Texts = path.GetOutMsgKeyTYpe; } if(path.ScreenKeyTYpe == "S+ Control+ Alt")//默认截图快捷按键 { rdb_default_image.Checked = true; txt_custom_image.Texts = "S+ Control+ Alt"; txt_custom_image.Enabled = false; txt_custom_image.ReadOn = true; } else { rdb_custom_image.Checked = true; txt_custom_image.Enabled = true; txt_custom_image.ReadOn = true; txt_custom_image.Texts = path.ScreenKeyTYpe; } if (path.SendKeyType==1) { rdb_enter.Checked = true; rdb_ctrl_enter.Checked = false; } else { rdb_enter.Checked = false; rdb_ctrl_enter.Checked = true; } #endregion panel_info.Visible = false; panel_basice.Visible = false; panel_sendfile.Visible = false; panel_fastreply.Visible = false; panel_sound.Visible = false; panel_hotkey.Visible = true; txt_custom_msg.Focus(); txt_custom_msg.IsFocused = true; }
/// <summary> /// 常规 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_basice_Click(object sender, EventArgs e) { #region 初使化是否自动登录 doc_login = new Document(); settings = new Settings.Verify(); doc_login.LoadFile(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, Program.UserName)); login = doc_login.RootElement.SelectSingleElement(typeof(Settings.Login)) as Settings.Login; chb_autoLogin.Checked = login.Auto;//自动登录 //是否开机启动 if (login.InitIal) chb_auto.CheckState= CSS.IM.UI.Control.BasicCheckBox.CheckStates.Checked; else chb_auto.CheckState = CSS.IM.UI.Control.BasicCheckBox.CheckStates.Unchecked; #endregion panel_info.Visible = false; panel_basice.Visible = true; panel_sendfile.Visible = false; panel_fastreply.Visible = false; panel_sound.Visible = false; panel_hotkey.Visible = false; }
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="user"></param> private void login_Login_Event(User user) { XmppCon.Username = user.UserName; XmppCon.Password = user.PassWord; waiting = new LoginWaiting(); try { waiting.Show(); } catch (Exception) { } Document doc_login = new Document(); Settings.Verify settings = new Settings.Verify(); doc_login.LoadFile(CSS.IM.UI.Util.Path.SettingsFilename); Settings.ServerInfo serverInfo = serverInfo = doc_login.RootElement.SelectSingleElement(typeof(Settings.ServerInfo)) as Settings.ServerInfo; if (serverInfo.ServerPort == null || serverInfo.ServerIP == null) { MsgBox.Show(waiting, "CSS&IM", "服务器地址错误!", MessageBoxButtons.OK); waiting.Hide(); LogOut(false, false); return; } XmppCon.Port = int.Parse(serverInfo.ServerPort.ToString()); XmppCon.Server = serverInfo.ServerIP; this.Hide(); this.ShowInTaskbar = false; new Thread(new ThreadStart(OpenSocket)).Start(); }
/// <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)); }
/// <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="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)); } }
private void LoginFrom_Load(object sender, EventArgs e) { /*key验证杜宾用*/ //int iCertNum = 0; //GetCert.GetCertNum(out iCertNum); //if (iCertNum == 0) //{ // MsgBox.Show(this, "CSS&IM", "请插入启动钥匙后在启动程序。", MessageBoxButtons.OK); // Application.Exit(); // return; //} /*key验证杜宾用*/ /* 省政府用的key验证 */ txt_name.Focus(); if (System.IO.File.Exists(CSS.IM.UI.Util.Path.HistoryFilename)) { Document load_doc = new Document(); load_doc.LoadFile(CSS.IM.UI.Util.Path.HistoryFilename); Settings.HistoryLogin HLlgin = load_doc.RootElement as Settings.HistoryLogin; HistoryFilename = HLlgin.LoginName; } chb_autu.Enabled = true; chb_save.Enabled = true; txt_name.Enabled = true; txt_pswd.Enabled = true; if (HistoryFilename.Trim().Length > 0) { LoadSettings(); } btn_login.Enabled = true; btn_setings.Enabled = true; }
private void LoadSettings() { /*key验证杜宾用*/ //int iCertNum = 0; //GetCert.GetCertNum(out iCertNum); //if (iCertNum == 0) //{ // MsgBox.Show(this, "CSS&IM", "请插入启动钥匙后在启动程序。", MessageBoxButtons.OK); // Application.Exit(); // return; //} /*key验证杜宾用*/ if (System.IO.File.Exists(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, HistoryFilename))) { Document login_doc = new Document(); login_doc.LoadFile(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, HistoryFilename)); Settings.Login login = login_doc.RootElement.SelectSingleElement(typeof(Settings.Login)) as Settings.Login; Settings.ServerInfo serverInfo = login_doc.RootElement.SelectSingleElement(typeof(Settings.ServerInfo)) as Settings.ServerInfo; if (login.Save) { txt_name.Texts = login.Jid == null ? "" : login.Jid.ToString(); txt_pswd.Texts = login.Password == null ? "" : login.Password; if (ISAutoLogin) { chb_autu.Checked = login.Auto; } else { chb_autu.Checked = false; } chb_save.Checked = login.Save; } Program.ServerIP = serverInfo.ServerIP; Program.Port = serverInfo.ServerPort; CSS.IM.UI.Util.Path.Initial = login.InitIal; } if (System.IO.File.Exists(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, HistoryFilename))) { Document local_doc = new Document(); local_doc.LoadFile(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, HistoryFilename)); Settings.Paths local_path = local_doc.RootElement.SelectSingleElement(typeof(Settings.Paths)) as Settings.Paths; CSS.IM.UI.Util.Path.MsgPath = local_path.MsgPath; CSS.IM.UI.Util.Path.MsgSwitch = local_path.SelectSingleElement("MsgPath").GetAttributeBool("Enable"); CSS.IM.UI.Util.Path.SystemPath = local_path.SystemPath; CSS.IM.UI.Util.Path.SystemSwitch = local_path.SelectSingleElement("SystemPath").GetAttributeBool("Enable"); CSS.IM.UI.Util.Path.CallPath = local_path.CallPath; CSS.IM.UI.Util.Path.CallSwitch = local_path.SelectSingleElement("CallPath").GetAttributeBool("Enable"); CSS.IM.UI.Util.Path.FolderPath = local_path.FolderPath; CSS.IM.UI.Util.Path.FolderSwitch = local_path.SelectSingleElement("FolderPath").GetAttributeBool("Enable"); CSS.IM.UI.Util.Path.GlobalPath = local_path.GlobalPath; CSS.IM.UI.Util.Path.GlobalSwitch = local_path.SelectSingleElement("GlobalPath").GetAttributeBool("Enable"); CSS.IM.UI.Util.Path.InputAlertPath = local_path.InputAlertPath; CSS.IM.UI.Util.Path.InputAlertSwitch = local_path.SelectSingleElement("InputAlertPath").GetAttributeBool("Enable"); CSS.IM.UI.Util.Path.ReveiveSystemNotification = local_path.ReveiveSystemNotification; CSS.IM.UI.Util.Path.ChatOpen = local_path.ChatOpen; CSS.IM.UI.Util.Path.SendKeyType = local_path.SendKeyType; CSS.IM.UI.Util.Path.GetOutMsgKeyTYpe = local_path.GetOutMsgKeyTYpe; CSS.IM.UI.Util.Path.ScreenKeyTYpe = local_path.ScreenKeyTYpe; CSS.IM.UI.Util.Path.FriendContainerType = local_path.FriendContainerType; CSS.IM.UI.Util.Path.DefaultURL = local_path.DefaultURL; CSS.IM.UI.Util.Path.EmailURL = local_path.EmailURL; SFont font1 = local_doc.RootElement.SelectSingleElement(typeof(Settings.SFont)) as Settings.SFont; System.Drawing.FontStyle fontStyle = new System.Drawing.FontStyle(); System.Drawing.Font ft = null; #region 获取字体 if (font1 != null) { try { if (font1.Bold) { fontStyle = System.Drawing.FontStyle.Bold; } if (font1.Italic) { fontStyle = fontStyle | System.Drawing.FontStyle.Italic; } if (font1.Strikeout) { fontStyle = fontStyle | System.Drawing.FontStyle.Strikeout; } if (font1.Underline) { fontStyle = fontStyle | System.Drawing.FontStyle.Underline; } ft = new System.Drawing.Font(font1.Name, font1.Size, fontStyle); } catch (Exception) { ft = txt_name.Font; } } else { ft = txt_name.Font; } #endregion CSS.IM.UI.Util.Path.SFong = ft; SColor color1 = local_doc.RootElement.SelectSingleElement(typeof(Settings.SColor)) as Settings.SColor; #region 获取颜色 Color cl; if (color1 != null) { try { byte[] cby = new byte[4]; cby[0] = color1.CA; cby[1] = color1.CR; cby[2] = color1.CG; cby[3] = color1.CB; cl = Color.FromArgb(BitConverter.ToInt32(cby, 0)); } catch { cl = txt_name.ForeColor; } } else { cl = txt_name.ForeColor; } #endregion CSS.IM.UI.Util.Path.SColor = cl; } Util.RunWhenStart(CSS.IM.UI.Util.Path.Initial, "CSS&IM", Application.StartupPath + @"\CSSIM.exe"); /*key验证杜宾用*/ //try //{ // StringBuilder names = new StringBuilder(""); // GetCert.GetCertName(0, 100, names); // txt_name.ReadOn = true; // txt_pswd.ReadOn = true; // txt_name.Texts = names.ToString(); // txt_pswd.Texts = "1"; // chb_autu.Checked = true; // chb_save.Checked = true; // timer_keyLogin.Enabled = true; //} //catch (Exception) //{ //} /*key验证杜宾用*/ }
/// <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; } }