Пример #1
0
        /// <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));
            }
        }
Пример #2
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
        }