/// <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_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;
        }
Exemple #3
0
        /// <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
        }