Exemplo n.º 1
0
        /// <summary>
        /// 添加分组事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void addUserGroupMenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AddBaseRoleDialog dialog = new AddBaseRoleDialog(MyType.UserGroup);
                dialog.ShowDialog();
                string userGroupName = dialog.GetString();
                if (userGroupName == null || userGroupName.Length == 0)
                    return;

                ///判断分组是否存在

                if (DataUtil.UserGroups.FirstOrDefault<UserGroup>(new Func<UserGroup, bool>((ug) =>
                        {
                            return ug.userGroupName == userGroupName;

                        })) != null)
                {
                    MessageBox.Show("分组" + userGroupName + "已经存在");
                    return;
                }
                DataUtil.Client.AddUserGroupAsync(new UserGroup() { userGroupName = userGroupName });
            }
            catch (Exception ex)
            {
                MyLogger.Logger.Error("点击添加群组时出错",ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 建群
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addGroupMenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AddBaseRoleDialog dialog = new AddBaseRoleDialog(MyType.Group);
                dialog.ShowDialog();
                string groupName = dialog.GetString();
                if (String.IsNullOrEmpty(groupName))
                {
                    return;
                }

                if (DataUtil.IsGroupNameExist(groupName))
                {
                    MessageBox.Show("群组名字已经存在");
                    return;
                }

                Group group = new Group();
                group.Name = groupName;
                group.OwnerId = DataUtil.Member.id;

                DataUtil.Client.AddGroupAsync(group);
            }
            catch (Exception ex)
            {
                MyLogger.Logger.Error("点击添加群组菜单错误",ex);
            }

        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加好友事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addFriendMenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AddBaseRoleDialog dialog = new AddBaseRoleDialog(MyType.User);
                dialog.ShowDialog();
                string friendId = dialog.GetString();
                if (friendId == null || friendId.Length == 0)
                    return;
                ///需要添加是否已经是好友的判断

                if (DataUtil.IsFriend(friendId))
                {
                    MessageBox.Show("对方已经是您的好友");
                    return;
                }
                if (DataUtil.Member.id == friendId)
                {
                    MessageBox.Show("您不能添加自己为好友");
                    return;
                }
                DataUtil.Client.AddFriend(friendId, baseRoleId);

            }
            catch (Exception ex)
            {
                MyLogger.Logger.Error("点击添加好友菜单错误", ex);
            }
        }
Exemplo n.º 4
0
        private void addMemberToGroupMenuItem_Click(object sender, RoutedEventArgs e)
        {

            try
            {
                AddBaseRoleDialog dialog = new AddBaseRoleDialog(MyType.UserInGroup);
                dialog.ShowDialog();
                string memberId = dialog.GetString();
                if (String.IsNullOrEmpty(memberId))
                {
                    return;
                }

                if (!DataUtil.IsFriend(memberId))
                {
                    MessageBox.Show("不是好友");
                    return;
                }
                if (DataUtil.IsAlreadyMember(memberId, baseRoleId))
                {
                    MessageBox.Show("已经是组内成员");
                    return;
                }

                DataUtil.Client.AddFriend2Group(memberId, this.baseRoleId);
                P2PClient.GetP2PClient(baseRoleId).AddGroupMember(DataUtil.GetFriendById(memberId));
            }
            catch (Exception ex)
            {
                MyLogger.Logger.Error("点击添加成员到群组时出现错误",ex);
            }

        }