void friendListBox1_UserDoubleClicked(GGUser friend) { Form form = this.GetChatForm(friend.ID); form.Show(); form.Focus(); }
public void AddOrUpdateUser(GGUser user) { var isNew = !this.userManager.Contains(user.ID); this.userManager.Add(user.ID, user); if (this.FriendInfoChanged != null) { this.FriendInfoChanged(user); } #if Org GGGroup group = this.groupManager.Get(this.companyGroupID); if (this.currentUser.IsInOrg && group != null)//资料发生变化的可能是自己 { if (user.IsInOrg) { group.MemberList.Add(user.ID); } else { group.MemberList.Remove(user.ID); } this.GroupChanged(group, GroupChangedType.SomeoneJoin, user.ID); } #endif }
void rapidPassiveEngine_MessageReceived(string sourceUserID, int informationType, byte[] info, string tag) { if (!this.initialized) { return; } if (informationType == InformationTypes.Chat) { sourceUserID = tag; byte[] bChatBoxContent = info; if (bChatBoxContent != null) { ChatMessageRecord record = new ChatMessageRecord(sourceUserID, this.rapidPassiveEngine.CurrentUserID, bChatBoxContent, false); GlobalResourceManager.ChatMessageRecordPersister.InsertChatMessageRecord(record); } byte[] decrypted = info; if (GlobalResourceManager.Des3Encryption != null) { decrypted = GlobalResourceManager.Des3Encryption.Decrypt(info); } ChatBoxContent content = CompactPropertySerializer.Default.Deserialize <ChatBoxContent>(decrypted, 0); GGUser user = this.globalUserCache.GetUser(sourceUserID); this.notifyIcon.PushFriendMessage(sourceUserID, informationType, info, content); return; } }
public void SetUser(GGUser user) { this.lblQm.Text = user.Signature; this.skinLabel_id.Text = user.ID; this.skinLabel_name.Text = user.Name; this.pnlImgTx.BackgroundImage = GlobalResourceManager.GetHeadImageOnline((GGUser)user); }
private void AddUserItem(GGUser friend) { ChatListSubItem subItem = new ChatListSubItem(friend.UserID, friend.UserID, friend.Name, friend.Signature, GlobalResourceManager.ConvertUserStatus(friend.UserStatus), GlobalResourceManager.GetHeadImage(friend)); subItem.Tag = friend; this.chatListBox1.Items[0].SubItems.AddAccordingToStatus(subItem); }
public UpdateUserInfoForm(IRapidPassiveEngine engine, GlobalUserCache globalUserCache, GGUser user) { InitializeComponent(); this.rapidPassiveEngine = engine; this.currentUser = user; int registerPort = int.Parse(ConfigurationManager.AppSettings["RemotingPort"]); this.ggService = (IRemotingService)Activator.GetObject(typeof(IRemotingService), string.Format("tcp://{0}:{1}/RemotingService", ConfigurationManager.AppSettings["ServerIP"], registerPort));; this.skinLabel_ID.Text = user.UserID; this.skinTextBox_nickName.SkinTxt.Text = user.Name; this.skinTextBox_signature.SkinTxt.Text = user.Signature; if (user.HeadImageIndex >= 0) { this.headImageIndex = user.HeadImageIndex; this.pnlImgTx.BackgroundImage = GlobalResourceManager.GetHeadImage(user); //根据ID获取头像 } else { this.pnlImgTx.BackgroundImage = user.HeadImage; this.selfPhoto = true; } }
/// <summary> /// 被别人添加为好友。 /// </summary> public void OnFriendAdded(GGUser user) { this.userManager.Add(user.ID, user); if (this.FriendAdded != null) { this.FriendAdded(user); } }
private void btnRegister_Click(object sender, EventArgs e) { string userID = this.skinTextBox_id.SkinTxt.Text.Trim(); if (userID.Length == 0) { this.skinTextBox_id.SkinTxt.Focus(); this.DialogResult = System.Windows.Forms.DialogResult.None; MessageBoxEx.Show("帐号不能为空!"); return; } string pwd = this.skinTextBox_pwd.SkinTxt.Text; if (pwd != this.skinTextBox_pwd2.SkinTxt.Text) { MessageBoxEx.Show("两次输入的密码不一致!"); this.skinTextBox_pwd.SkinTxt.SelectAll(); this.skinTextBox_pwd.SkinTxt.Focus(); this.DialogResult = System.Windows.Forms.DialogResult.None; return; } try { GGUser user = new GGUser(userID, SecurityHelper.MD5String2(pwd), this.skinTextBox_nickName.SkinTxt.Text, "", this.skinTextBox_signature.SkinTxt.Text, this.headImageIndex, ""); if (this.selfPhoto) { user.HeadImageData = ESBasic.Helpers.ImageHelper.Convert(this.pnlImgTx.BackgroundImage); user.HeadImageIndex = -1; } RegisterResult result = ggService.Register(user); if (result == RegisterResult.Existed) { this.skinTextBox_id.SkinTxt.SelectAll(); this.skinTextBox_id.SkinTxt.Focus(); this.DialogResult = System.Windows.Forms.DialogResult.None; MessageBoxEx.Show("用户帐号已经存在!"); return; } if (result == RegisterResult.Error) { this.DialogResult = System.Windows.Forms.DialogResult.None; MessageBoxEx.Show("注册出现错误!"); return; } this.registeredUser = user; this.DialogResult = System.Windows.Forms.DialogResult.OK; } catch (Exception ee) { this.DialogResult = System.Windows.Forms.DialogResult.None; MessageBoxEx.Show("注册失败!" + ee.Message); } }
private void MainForm_Load(object sender, EventArgs e) { try { if (!this.DesignMode) { this.notifyIcon.Visible = true; } //我的好友 foreach (string friendID in this.globalUserCache.CurrentUser.GetAllFriendList()) { if (friendID == this.globalUserCache.CurrentUser.UserID) { continue; } GGUser friend = this.globalUserCache.GetUser(friendID); if (friend != null) { this.friendListBox1.AddUser(friend); } } this.friendListBox1.SortAllUser(); this.friendListBox1.ExpandRoot(); foreach (string groupid in this.globalUserCache.CurrentUser.GroupList) //初期不包含 固定群 { GGGroup group1 = this.globalUserCache.GetGroup(groupid); if (group1 != null) { this.groupListBox.AddGroup(group1); } } //加载最近联系人 int insertIndex = 0; foreach (string recentID in this.globalUserCache.GetRecentList()) { Parameter <string, bool> para = RecentListBox.ParseIDFromRecentID(recentID); IUnit unit = this.globalUserCache.GetUnit(para.Arg1, para.Arg2); if (unit == null) { continue; } this.recentListBox1.AddRecentUnit(unit, insertIndex); ++insertIndex; } this.initialized = true; } catch (Exception ee) { MessageBox.Show(ee.Message); } }
public AddFriendForm(IRapidPassiveEngine engine, IChatSupporter supporter, GGUser currentUser, string friendID) { InitializeComponent(); this.Icon = GlobalResourceManager.Icon64; this.rapidPassiveEngine = engine; this.ggSupporter = supporter; this.skinComboBox1.DataSource = currentUser.GetFriendCatalogList(); this.skinComboBox1.SelectedIndex = 0; this.skinTextBox_id.SkinTxt.Text = friendID ?? ""; }
public string GetUserName(string userID) { GGUser user = this.GetUser(userID); if (user == null) { return(null); } return(user.Name); }
void form_UserInfoChanged(GGUser user) { this.labelSignature.Text = this.globalUserCache.CurrentUser.Signature; this.skinButton_headImage.Image = GlobalResourceManager.GetHeadImage(this.globalUserCache.CurrentUser); this.labelName.Text = this.globalUserCache.CurrentUser.Name; this.globalUserCache.AddOrUpdateUser(this.globalUserCache.CurrentUser); foreach (ChatForm chatForm in this.chatFormManager.GetAllForms()) { chatForm.OnMyInfoChanged(this.globalUserCache.CurrentUser); } }
public void ChangeUserStatus(string userID, UserStatus status) { GGUser user = this.userManager.Get(userID); if (user != null) { user.UserStatus = status; if (this.FriendStatusChanged != null) { this.FriendStatusChanged(user); } } }
public GGUser GetUser(string userID) { GGUser user = this.userManager.Get(userID); if (user == null) { user = this.DoGetUser(userID); if (user != null) { this.userManager.Add(userID, user); } } return(user); }
public void OnUserInfoChanged(GGUser user) { ChatListSubItem[] items = this.chatListBox1.GetSubItemsByNicName(user.UserID); if (items == null || items.Length == 0) { return; } items[0].HeadImage = GlobalResourceManager.GetHeadImage(user); items[0].DisplayName = user.Name; items[0].PersonalMsg = user.Signature; items[0].Tag = user; this.chatListBox1.Invalidate(); }
void do_globalUserCache_FriendRTDataRefreshCompleted() { //请求离线消息 this.rapidPassiveEngine.CustomizeOutter.Send(InformationTypes.GetOfflineMessage, null); //请求离线文件 this.rapidPassiveEngine.CustomizeOutter.Send(InformationTypes.GetOfflineFile, null); //正式通知好友,自己上线 this.rapidPassiveEngine.CustomizeOutter.Send(InformationTypes.ChangeStatus, BitConverter.GetBytes((int)this.globalUserCache.CurrentUser.UserStatus)); GGUser mine = this.globalUserCache.GetUser(this.rapidPassiveEngine.CurrentUserID); this.InitializeFinished(); }
private void DoHandleReceivedMessage(string broadcasterID, int broadcastType, byte[] content, bool flash) { if (broadcastType == BroadcastTypes.BroadcastChat) { ChatBoxContent chatBoxContent = CompactPropertySerializer.Default.Deserialize <ChatBoxContent>(content, 0); GGUser user = this.globalUserCache.GetUser(broadcasterID); string talker = string.Format("{0}({1})", broadcasterID, broadcasterID); if (user != null) { talker = string.Format("{0}({1})", user.Name, user.UserID); } this.AppendChatBoxContent(talker, null, chatBoxContent, Color.Blue); this.FlashChatWindow(flash); if (this.LastWordChanged != null) { LastWordsRecord lastWordsRecord = new LastWordsRecord(broadcasterID, user == null ? broadcasterID : user.Name, false, chatBoxContent); this.LastWordChanged(true, this.currentGroup.GroupID, lastWordsRecord); } return; } else { string c = System.Text.Encoding.UTF8.GetString(content); //ChatBoxContent chatBoxContent = CompactPropertySerializer.Default.Deserialize<ChatBoxContent>(content, 0); ChatBoxContent chatBoxContent = new ChatBoxContent(); chatBoxContent.Text = c; GGUser user = this.globalUserCache.GetUser(broadcasterID); string talker = string.Format("{0}({1})", broadcasterID, broadcasterID); if (user != null) { talker = string.Format("{0}({1})", user.Name, user.UserID); } this.AppendChatBoxContent(talker, null, chatBoxContent, Color.Blue); this.FlashChatWindow(flash); if (this.LastWordChanged != null) { LastWordsRecord lastWordsRecord = new LastWordsRecord(broadcasterID, user == null ? broadcasterID : user.Name, false, chatBoxContent); this.LastWordChanged(true, this.currentGroup.GroupID, lastWordsRecord); } return; } }
public void AddFriend(string friendID) { AddFriendForm form = new AddFriendForm(this.rapidPassiveEngine, this, this.globalUserCache.CurrentUser, friendID); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.globalUserCache.CurrentUser.AddFriend(form.FriendID, form.CatalogName); GGUser user = this.globalUserCache.GetUser(form.FriendID); this.friendListBox1.AddUser(user); ChatForm chatForm = this.GetChatForm(form.FriendID); chatForm.AppendSysMessage("您已经成功将对方添加为好友,可以开始对话了..."); chatForm.Show(); chatForm.Focus(); } }
public static Image GetHeadImageOnline(GGUser user) { if (user.HeadImageIndex >= 0) { if (user.HeadImageIndex < GlobalResourceManager.headImages.Length) { return(GlobalResourceManager.headImages[user.HeadImageIndex]); } return(GlobalResourceManager.headImages[0]); } else { return(user.HeadImage); } }
void do_globalUserCache_FriendInfoChanged(GGUser user) { this.friendListBox1.UserInfoChanged(user); this.recentListBox1.UserStatusChanged(user); ChatForm form = this.chatFormManager.GetForm(user.UserID); if (form != null) { form.OnFriendInfoChanged(user); } foreach (GroupChatForm groupForm in this.groupChatFormManager.GetAllForms()) { groupForm.OnUserInfoChanged(user); } }
void recentListBox1_ChatRecordClicked(string unitID, bool isGroup) { ChatRecordForm form = null; if (isGroup) { GGGroup group = this.globalUserCache.GetGroup(unitID); form = new ChatRecordForm(GlobalResourceManager.RemotingService, GlobalResourceManager.ChatMessageRecordPersister, group.GetIDName(), this.globalUserCache.CurrentUser.GetIDName(), this.globalUserCache); form.Show(); } else { GGUser friend = this.globalUserCache.GetUser(unitID); form = new ChatRecordForm(GlobalResourceManager.RemotingService, GlobalResourceManager.ChatMessageRecordPersister, this.globalUserCache.CurrentUser.GetIDName(), friend.GetIDName()); } form.Show(); }
public GroupChatForm(IRapidPassiveEngine engine, string groupID, GlobalUserCache cache, IChatSupporter supporter) { this.rapidPassiveEngine = engine; this.globalUserCache = cache; this.mine = this.globalUserCache.GetUser(this.rapidPassiveEngine.CurrentUserID); this.ggSupporter = supporter; this.currentGroup = this.globalUserCache.GetGroup(groupID); InitializeComponent(); this.chatBoxSend.Initialize(GlobalResourceManager.EmotionDictionary); this.chatBox_history.Initialize(GlobalResourceManager.EmotionDictionary); this.chatBoxSend.Font = SystemSettings.Singleton.Font; this.chatBoxSend.ForeColor = SystemSettings.Singleton.FontColor; this.Size = SystemSettings.Singleton.ChatFormSize; this.linkLabel_softName.Text = GlobalResourceManager.SoftwareName; this.toolShow.SetToolTip(this.panelFriendHeadImage, this.currentGroup.GroupID); this.Text = string.Format("{0}({1})", this.currentGroup.Name, this.currentGroup.GroupID); this.labelGroupName.Text = this.currentGroup.Name; this.label_announce.Text = this.currentGroup.Announce; this.chatBoxSend.Focus(); this.emotionForm = new EmotionForm(); this.emotionForm.Load += new EventHandler(emotionForm_Load); this.emotionForm.Initialize(GlobalResourceManager.EmotionList); this.emotionForm.EmotionClicked += new CbGeneric <int, Image>(emotionForm_Clicked); this.emotionForm.Visible = false; this.emotionForm.LostFocus += new EventHandler(emotionForm_LostFocus); foreach (string memberID in this.currentGroup.MemberList) { GGUser friend = this.globalUserCache.GetUser(memberID); this.AddUserItem(friend); } if (SystemSettings.Singleton.LoadLastWordsWhenChatFormOpened) { LastWordsRecord record = this.currentGroup.Tag as LastWordsRecord; if (record != null) { string talker = string.Format("{0}({1})", record.SpeakerName, record.SpeakerID); this.AppendChatBoxContent(talker, record.SpeakTime, record.ChatBoxContent, Color.Blue); } } }
public static Image GetHeadImage(GGUser user, bool mine) { if (user.HeadImageIndex >= 0) { var ary = (mine ? !user.OnlineOrHide : user.OfflineOrHide) ? GlobalResourceManager.headImagesGrey : GlobalResourceManager.headImages; if (user.HeadImageIndex < GlobalResourceManager.headImages.Length) { return(ary[user.HeadImageIndex]); } return(ary[0]); } else { return((mine ? !user.OnlineOrHide : user.OfflineOrHide) ? user.HeadImageGrey : user.HeadImage); } }
private void Initialize(string curUserID, string persistencePath, string _companyGroupID, IAgileLogger _logger) { this.GroupChanged += delegate { }; this.FriendInfoChanged += delegate { }; this.FriendStatusChanged += delegate { }; this.FriendRemoved += delegate { }; this.FriendRTDataRefreshCompleted += new CbGeneric(GlobalUserCache_FriendRTDataRefreshCompleted); this.companyGroupID = _companyGroupID; this.logger = _logger; //自己的信息始终加载最新的 this.currentUser = this.DoGetUser(curUserID); this.userManager.Add(this.currentUser.ID, this.currentUser); this.persistenceFilePath = persistencePath; this.originUserLocalPersistence = UserLocalPersistence.Load(this.persistenceFilePath);//返回null,表示该登录帐号还没有任何缓存 if (this.originUserLocalPersistence != null && this.originUserLocalPersistence.FriendList != null) { foreach (var user in this.originUserLocalPersistence.FriendList) { if (user.ID == null) { continue; } if (user.ID != this.currentUser.ID) { user.UserStatus = UserStatus.OffLine; this.userManager.Add(user.ID, user); } } foreach (var group in this.originUserLocalPersistence.GroupList) { if (this.currentUser.GroupList.Contains(group.ID)) { this.groupManager.Add(group.ID, group); } } } }
private void do_globalUserCache_FriendStatusChanged(GGUser friend) { this.friendListBox1.UserStatusChanged(friend); this.recentListBox1.UserStatusChanged(friend); ChatForm form = this.chatFormManager.GetForm(friend.UserID); if (form != null) { form.FriendStateChanged(friend.UserStatus); } foreach (GroupChatForm groupForm in this.groupChatFormManager.GetAllForms()) { if (groupForm != null) { groupForm.GroupmateStateChanged(friend.UserID, friend.UserStatus); return; } } }
public void OnGroupInfoChanged(GroupChangedType type, string userID) { if (type == GroupChangedType.GroupInfoChanged) { this.Text = string.Format("{0}({1})", this.currentGroup.Name, this.currentGroup.GroupID); this.labelGroupName.Text = this.currentGroup.Name; this.label_announce.Text = this.currentGroup.Announce; return; } if (type == GroupChangedType.MemberInfoChanged) { GGUser user = this.globalUserCache.GetUser(userID); this.OnUserInfoChanged(user); return; } if (type == GroupChangedType.SomeoneJoin) { GGUser user = this.globalUserCache.GetUser(userID); this.AddUserItem(user); this.AppendSysMessage(string.Format("{0}({1})加入了该群!", user.Name, user.UserID)); return; } if (type == GroupChangedType.SomeoneQuit) { GGUser user = this.globalUserCache.GetUser(userID); ChatListSubItem[] items = this.chatListBox1.GetSubItemsByNicName(userID); if (items == null || items.Length == 0) { return; } ChatListSubItem item = items[0]; this.chatListBox1.Items[0].SubItems.Remove(item); this.chatListBox1.Invalidate(); this.AppendSysMessage(string.Format("{0}({1})退出了该群!", user.Name, user.UserID)); return; } }
void friendListBox1_RemoveUserClicked(GGUser friend) { if (this.globalUserCache.CurrentUser.UserStatus == UserStatus.OffLine) { return; } try { if (friend.ID == this.rapidPassiveEngine.CurrentUserID) { return; } if (!ESBasic.Helpers.WindowsHelper.ShowQuery(string.Format("您确定要删除好友 {0}({1}) 吗?", friend.Name, friend.ID))) { return; } //SendCertainly 发送请求,并等待Ack回复 this.rapidPassiveEngine.CustomizeOutter.SendCertainly(null, InformationTypes.RemoveFriend, System.Text.Encoding.UTF8.GetBytes(friend.ID)); this.globalUserCache.CurrentUser.RemoveFriend(friend.ID); this.friendListBox1.RemoveUser(friend.ID); // 从recent中删除 this.recentListBox1.RemoveUnit(friend); var chatForm = this.chatFormManager.GetForm(friend.ID); if (chatForm != null) { chatForm.Close(); } this.globalUserCache.RemovedFriend(friend.ID); } catch (Exception ee) { MessageBoxEx.Show("请求超时!" + ee.Message, GlobalResourceManager.SoftwareName); } }
void globalUserCache_FriendInfoChanged(GGUser user) { GlobalResourceManager.UiSafeInvoker.ActionOnUI <GGUser>(this.do_globalUserCache_FriendInfoChanged, user); }
void globalUserCache_FriendStatusChanged(GGUser friend) { GlobalResourceManager.UiSafeInvoker.ActionOnUI <GGUser>(this.do_globalUserCache_FriendStatusChanged, friend); }
void globalUserCache_FriendAdded(GGUser friend) { this.friendListBox1.AddUser(friend); }