예제 #1
0
        private void ShowFriendOperatorWith()
        {
            if (selectedOperator == "Все" || selectedOperator == null)
            {
                return;
            }

            PhoneOperator phoneOperator = null;

            foreach (var item in PhoneOperators)
            {
                if (item.Name == selectedOperator)
                {
                    phoneOperator = item;
                }
            }
            if (phoneOperator == null)
            {
                return;
            }
            var tempList = CopyCollection(FriendsList);

            FriendsList.Clear();
            foreach (var friend in tempList)
            {
                if (phoneOperator.IsCodeContains(friend.NumberCode))
                {
                    FriendsList.Add(friend);
                }
            }
        }
예제 #2
0
        private void ShowFriendSelectedMonth()
        {
            if (selectedMonth == "Все" || selectedMonth == null)
            {
                return;
            }
            int month;

            try
            {
                month = Convert.ToInt32(selectedMonth);
            } catch
            {
                return;
            }
            var tempList = CopyCollection(FriendsList);

            FriendsList.Clear();
            foreach (var friend in tempList)
            {
                if (friend.Month == month)
                {
                    FriendsList.Add(friend);
                }
            }
        }
 public void ResetCache()
 {
     GiveAwayCount = 0;
     FriendsList.Clear();
     ApplyList.Clear();
     TodayRobList.Clear();
 }
예제 #4
0
 private void ApplyFilters()
 {
     FriendsList.Clear();
     FriendsList = DbConnection.SelectAll();
     ShowFriendsWithNumber();
     ShowFriendSelectedMonth();
     ShowFriendOperatorWith();
 }
예제 #5
0
 private void ShowFriendsWithNumber()
 {
     if (isWithNumberOnly)
     {
         var tempList = CopyCollection(FriendsList);
         FriendsList.Clear();
         foreach (var friend in tempList)
         {
             if (friend.Number != 0)
             {
                 FriendsList.Add(friend);
             }
         }
     }
 }
예제 #6
0
        public async void UpdateFollowedUsers()
        {
            FriendsList.Clear();

            var user = App.User;

            foreach (var friendId in user.GetFollowedUsers())
            {
                var friend = await UserManager.Instance.GetUsersWhere(x => x.ID == friendId);

                if (friend[0] != null)
                {
                    var friendToAdd = friend[0];
                    FriendsList.Add(friendToAdd);
                }
            }
        }
예제 #7
0
        public void SendMessage(string msg)
        {
            if (!msg.StartsWith("/"))
            {
                bnetConnection.SendMessage(msg);

                var chatMsg = new BnetEvent();
                chatMsg.EventId   = 0x18;
                chatMsg.Message   = msg;
                chatMsg.Username  = bnetAccount.Username;
                chatMsg.TimeStamp = DateTime.Now;
                ChatMessages.Add(chatMsg);

                Messenger.Default.Send <ScrollDownMessage>(new ScrollDownMessage()
                {
                    Source = this
                });
            }
            else
            {
                if (msg.ToLower() == "/reconnect")
                {
                    ChannelUsers.Clear();
                    ChannelList.Clear();
                    FriendsList.Clear();

                    ChattingStatus = "disconnected";
                    Connect();
                }
                else if (msg.ToLower() == "/version")
                {
                    bnetConnection.SendMessage("/me is using Superiority.NET Beta5 (www.BNET.cc).");
                }
                else
                {
                    bnetConnection.SendMessage(msg);
                }
            }
        }
예제 #8
0
        /// <summary>
        /// BnetConnection dispatches a message to us on every Bnet Event.
        /// </summary>
        /// <param name="msg">BnetEvent sent to us by BnetConnection</param>
        public void BnetEventReceived(BnetEvent[] messages)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                foreach (var msg in messages)
                {
                    if (ChatMessages.Count > 120)
                    {
                        var cache = new ObservableCollection <BnetEvent>();
                        for (int i = 100; i < ChatMessages.Count; i++)
                        {
                            cache.Add(ChatMessages[i]);
                        }

                        ChatMessages = new ObservableCollection <BnetEvent>(cache);
                    }

                    if (msg.EventId != 0x01 || msg.EventId != 0x09 || msg.EventId != 0x21 || msg.EventId != 0x22)
                    {
                        ChatMessages.Add(msg);
                        Messenger.Default.Send <ScrollDownMessage>(new ScrollDownMessage()
                        {
                            Source = this
                        });
                    }

                    if (msg.EventId == 0x21)
                    {
                        ChannelUsers.Clear();
                        ChannelList.Clear();
                        FriendsList.Clear();

                        ChattingStatus = "disconnected";
                        Connect();
                    }

                    if (msg.EventId == 0x22) // EID_CHANNELUSER
                    {
                        // We use a List<> because ChannelList is only requested once per connection ..
                        ChannelList.Add(new BnetUser()
                        {
                            Username = msg.Username
                        });
                    }

                    if (msg.EventId == 0x07)
                    {
                        ChattingStatus = string.Format("chatting in {0}", msg.Message.ToLower());

                        ChannelUsers.Clear();
                    }

                    if (msg.EventId == 0x03)
                    {
                        foreach (var user in ChannelUsers)
                        {
                            if (user.Username == msg.Username)
                            {
                                ChannelUsers.Remove(user);
                                break;
                            }
                        }
                    }

                    if (msg.EventId == 0x01 || msg.EventId == 0x02)
                    {
                        BnetProduct p;

                        if (msg.Message.Length == 0)
                        {
                            return;
                        }

                        switch (msg.Message.Substring(0, 4))
                        {
                        case "RATS":
                            p = BnetProduct.Starcraft;
                            break;

                        case "PXES":
                            p = BnetProduct.BroodWar;
                            break;

                        case "NB2W":
                            p = BnetProduct.Warcraft2;
                            break;

                        case "VD2D":
                            p = BnetProduct.Diablo2;
                            break;

                        case "PX2D":
                            p = BnetProduct.LordOfDest;
                            break;

                        case "3RAW":
                            p = BnetProduct.Warcraft3;
                            break;

                        case "PX3W":
                            p = BnetProduct.FrozenThrone;
                            break;

                        default:
                            p = BnetProduct.BroodWar;
                            break;
                        }

                        BnetUser usr    = new BnetUser();
                        usr.Username    = msg.Username;
                        usr.DisplayName = msg.Username.Split('@')[0];
                        usr.Product     = p;
                        usr.Flags       = msg.Flags;

                        ChannelUsers.Add(usr);
                    }

                    if (msg.EventId == 0x09)
                    {
                        // Process flag update
                        foreach (var user in ChannelUsers)
                        {
                            if (user.Username == msg.Username)
                            {
                                user.Flags = msg.Flags;
                                break;
                            }
                        }
                    }
                }
            });
        }