示例#1
0
        private async void toolStripDropDownButton1_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            OnlineState state = (OnlineState)Convert.ToInt32(e.ClickedItem.Tag);

            lbStatus.Text = state.ToString();
            tmrTriggerRefresh.Start();

            switch (state)
            {
            case OnlineState.Online:
                await DMLClient.Client.SetStatusAsync(UserStatus.Online);

                break;

            case OnlineState.Idle:
                await DMLClient.Client.SetStatusAsync(UserStatus.Idle);

                break;

            case OnlineState.DoNotDisturb:
                await DMLClient.Client.SetStatusAsync(UserStatus.DoNotDisturb);

                break;

            case OnlineState.Invisible:
                await DMLClient.Client.SetStatusAsync(UserStatus.Invisible);

                break;
            }
        }
示例#2
0
        // 某客户端用户的状态改变后,通知其他用户
        private void UserStateNotify(string userID, OnlineState ustate)
        {
            try
            {
                //用户状态契约类
                UserStateContract userState = new UserStateContract();
                userState.UserID = userID;
                userState.OnLine = ustate;
                IList <ShortGuid> allUserID;

                lock (syncLocker)
                {
                    //获取所有用户字典中的用户链接标识
                    allUserID = new List <ShortGuid>(userManager.Values);
                }

                //给所有用户发送某用户的在线状态
                foreach (ShortGuid netID in allUserID)
                {
                    List <Connection> result = NetworkComms.GetExistingConnection(netID, ConnectionType.TCP);

                    if (result.Count > 0 && result[0].ConnectionInfo.NetworkIdentifier == netID)
                    {
                        result[0].SendObject("UserStateNotify", userState);
                    }
                }
            }
            catch (Exception ex)
            {
                LogTools.LogException(ex, "MainForm.UserStateNotify");
            }
        }
示例#3
0
 public ThreatReference(ThreatManager mgr, Unit victim)
 {
     _owner  = mgr._owner as Creature;
     _mgr    = mgr;
     _victim = victim;
     Online  = ShouldBeSuppressed() ? OnlineState.Suppressed : OnlineState.Online;
 }
示例#4
0
        // Delegate called when the user goes on/offline with the Last.fm API
        private void OnlineStatusUpdated(OnlineState currentState, UserInfo latestUserInfo)
        {
            base.CurrentUser = latestUserInfo;
            RefreshOnlineStatus(currentState);

            CheckLastResponseError();
        }
示例#5
0
 private void OnIsCommand(BotShell bot, CommandArgs e)
 {
     foreach (string username in e.Args)
     {
         UInt32      userid = bot.GetUserID(username);
         OnlineState state  = bot.FriendList.IsOnline(userid);
         if (state == OnlineState.Timeout)
         {
             bot.SendReply(e, "Request timed out. Please try again later");
             return;
         }
         if (state == OnlineState.Unknown)
         {
             bot.SendReply(e, "No such user: "******"Online");
         if (state == OnlineState.Offline)
         {
             append = HTML.CreateColorString(RichTextWindow.ColorRed, "Offline");
             Int64 seen = bot.FriendList.Seen(username);
             if (seen > 1)
             {
                 append += " and was last seen online at " + HTML.CreateColorString(bot.ColorHeaderHex, Format.DateTime(seen, FormatStyle.Large) + " GMT");
             }
         }
         bot.SendReply(e, String.Format("{0} is currently {1}", Format.UppercaseFirst(username), append));
     }
 }
示例#6
0
 public ThreatReference(ThreatManager mgr, Unit victim)
 {
     _owner  = mgr._owner as Creature;
     _mgr    = mgr;
     _victim = victim;
     Online  = OnlineState.Offline;
 }
示例#7
0
 public ThreatReference(ThreatManager mgr, Unit victim, float amount)
 {
     _owner      = mgr._owner;
     _mgr        = mgr;
     _victim     = victim;
     _baseAmount = amount;
     _online     = SelectOnlineState();
 }
示例#8
0
        void User_OnlineStateChanged(User sender, OnlineState oldState, OnlineState newState)
        {
            if ((oldState == OnlineState.Offline || oldState == OnlineState.Hide)
                &&
                (newState == OnlineState.Away || newState == OnlineState.Busy || newState == OnlineState.Online || newState == OnlineState.Quiet)
                )
            {
                User user = this.offlineList.Find(uc => uc.UserID.Trim().ToLower() == sender.UserID.Trim().ToLower());
                this.offlineList.Remove(user);

                bool hasAdded = false;
                for (int i = 0; i < this.onlineList.Count; i++)
                {
                    if (string.CompareOrdinal(this.onlineList[i].UserName, sender.Name) > 0)
                    {
                        this.onlineList.Insert(i, user);
                        hasAdded = true;
                        break;
                    }
                }
                if (!hasAdded)
                {
                    this.onlineList.Add(user);
                }

                this.resetLocation();                                       //排序

                this.Invalidate(new Rectangle(18, 0, this.Width - 18, 21)); //刷新显示人数
            }
            else if ((oldState == OnlineState.Away || oldState == OnlineState.Busy || oldState == OnlineState.Online || oldState == OnlineState.Quiet)
                     &&
                     (newState == OnlineState.Hide || newState == OnlineState.Offline)
                     )
            {
                User user = this.onlineList.Find(u => u.UserID.Trim().ToLower() == sender.UserID.Trim().ToLower());
                this.onlineList.Remove(user);

                bool hasAdded = false;
                for (int i = 0; i < this.offlineList.Count; i++)
                {
                    if (string.CompareOrdinal(this.offlineList[i].UserName, sender.Name) > 0)
                    {
                        this.offlineList.Insert(i, user);
                        hasAdded = true;
                        break;
                    }
                }
                if (!hasAdded)
                {
                    this.offlineList.Add(user);
                }

                this.resetLocation();                                       //排序

                this.Invalidate(new Rectangle(18, 0, this.Width - 18, 21)); //刷新显示人数
            }
        }
示例#9
0
        static void OnOnlineStateChanged_Internal(OnlineState prevState, OnlineState newState)
        {
#if UNITY_EDITOR
            if (PrintOnlineStateChangeDebug)
            {
                UnityEngine.Debug.Log(string.Format("OnOnlineStateChanged InvokeCount = {0}", OnOnlineStateChanged?.GetInvocationList().Length));
            }
#endif
            OnOnlineStateChanged?.Invoke(null, prevState, newState);
        }
示例#10
0
 internal Event EventOnlineStateChanged(OnlineState state)
 {
     return(new Event
     {
         FriendOnlineStateChanged = new Event_FriendOnlineStateChanged
         {
             PlayerId = permanent_id,
             OnlineState = state
         }
     });
 }
示例#11
0
 private void contacts_UserUpdateStatus(IPAddress ip, OnlineState state)
 {
     if (lbContacts.InvokeRequired)
     {
         lbContacts.Invoke(new Action <IPAddress, OnlineState>(contacts_UserUpdateStatus), ip, state);
     }
     else
     {
         lbContacts.SetState(ip, state);
         lbContacts.Refresh();
     }
 }
示例#12
0
        public void SetState(IPAddress ip, OnlineState state)
        {
            for (int i = 0; i < this.Items.Count; i++)
            {
                UserListBoxItem current = ((UserListBoxItem)this.Items[i]);

                if (current.User.UserIP.ToString() == ip.ToString())
                {
                    current.Online = state;
                    return;
                }
            }
        }
示例#13
0
        public void SetState(IPAddress ip, OnlineState state)
        {
            for (int i = 0; i < this.Items.Count; i++)
            {
                UserListBoxItem current = ((UserListBoxItem)this.Items[i]);

                if (current.User.UserIP.ToString() == ip.ToString())
                {
                    current.Online = state;
                    return;
                }
            }
        }
        public async Task <IActionResult> ChangePretendOffline([FromBody] ChangePretendOffline.Request req)
        {
            var db = PDBSM.PersonalDBContext(SelfHost.playerInfo.playerId);

            var pbi = await db.PlayerBasicInformations.FindAsync(SelfHost.playerInfo.playerId);

            if (pbi == null)
            {
                return(BuildErrorResponse(Error.LowCode.ServerInternalError));
            }

            pbi.pretendOffline = req.enabled.Value;
            await db.SaveChangesAsync();

            Logger.Logging(
                new LogObj().AddChild(new LogModels.ChangePretendOffline
            {
                PlayerId       = pbi.playerId,
                Date           = DateTime.UtcNow,
                PretendOffline = pbi.pretendOffline,
            })
                );

            var session = new Session(SelfHost.sessionId);

            session.Model.pretendedOffline = req.enabled.Value;
            await session.SaveAsync();

            if (session.Model.pretendedOffline)
            {
                var onlineState = new OnlineState(SelfHost.playerInfo.playerId);
                await onlineState.DeleteAsync();
            }
            else
            {
                var onlineState = new OnlineState(SelfHost.playerInfo.playerId);
                onlineState.Model.state     = req.onlineState;
                onlineState.Model.sessionId = SelfHost.sessionId;
                await onlineState.SaveAsync();
            }

            await new Player(SelfHost.playerInfo.playerId).Invalidate();

            return(Ok(new ChangePretendOffline.Response
            {
                enabled = req.enabled.Value,
            }));
        }
示例#15
0
        protected override void Update(GameTime gameTime)
        {
            G.update_input();

            switch (state)
            {
            case OnlineState.AskingRole:
                if (G.ks.IsKeyDown(Keys.H))
                {
                    onlineGame = new HostOnlineGame(6666);
                    state      = OnlineState.Connecting;
                    onlineGame.OnConnection += OnlineGame_OnConnection;
                    imMisterH = true;
                }
                else if (G.ks.IsKeyDown(Keys.J))
                {
                    onlineGame = new JoinOnlineGame("127.0.0.1", 6666);
                    state      = OnlineState.Connecting;
                    onlineGame.OnConnection += OnlineGame_OnConnection;
                    imMisterH = false;
                }
                break;

            case OnlineState.Connecting:
                Window.Title = "connecting";
                //on connection invoke for the characters
                //start the background thread for the two player
                // change state for playing
                break;

            case OnlineState.Playing:
                onlineGame.hostChar.update();
                onlineGame.joinChar.update();
                if (G.ks.IsKeyDown(Keys.A))
                {
                    G.zoom = MH.Lerp(G.zoom, 0.1f, 0.01f);
                }

                if (G.ks.IsKeyDown(Keys.D))
                {
                    G.zoom = MH.Lerp(G.zoom, 5f, 0.001f);
                }
                break;
            }


            base.Update(gameTime);
        }
示例#16
0
        public OnlineState IsOnline(UInt32 friend)
        {
            if (friend < 1)
            {
                return(OnlineState.Unknown);
            }

            string      user   = this.Parent.GetUserName(friend);
            OnlineState result = OnlineState.Timeout;
            bool        lookup = true;

            for (int i = 0; i < 15; i++)
            {
                lock (this.OfflineFriends)
                    if (this.OfflineFriends.ContainsKey(friend))
                    {
                        result = OnlineState.Offline;
                    }

                lock (this.OnlineFriends)
                    if (this.OnlineFriends.ContainsKey(friend))
                    {
                        result = OnlineState.Online;
                    }

                if (result == OnlineState.Timeout && lookup == true)
                {
                    this.Add("tmp", user);
                    lookup = false;
                }
                if (result == OnlineState.Timeout)
                {
                    Thread.Sleep(1000);
                }
                else
                {
                    break;
                }
            }
            if (lookup == false)
            {
                this.Remove("tmp", user);
            }

            return(result);
        }
示例#17
0
        public void UpdateOnlineState()
        {
            OnlineState onlineState = SelectOnlineState();

            if (onlineState == _online)
            {
                return;
            }

            _online = onlineState;
            ListNotifyChanged();

            if (!IsAvailable())
            {
                _owner.GetThreatManager().SendRemoveToClients(_victim);
            }
        }
示例#18
0
        public async Task <IActionResult> ReportOnlineState([FromBody] ReportOnlineState.Request req)
        {
            var onlineState = new OnlineState(SelfHost.playerInfo.playerId);

            if (SelfHost.playerInfo.pretendedOffline)
            {
                await onlineState.DeleteAsync();
            }
            else
            {
                onlineState.Model.state     = req.state;
                onlineState.Model.sessionId = SelfHost.sessionId;
                await onlineState.SaveAsync();
            }

            var res = new ReportOnlineState.Response();

            return(Ok(res));
        }
示例#19
0
        public void UpdateOffline()
        {
            bool shouldBeOffline = ShouldBeOffline();

            if (shouldBeOffline == IsOffline())
            {
                return;
            }

            if (shouldBeOffline)
            {
                Online = OnlineState.Offline;
                ListNotifyChanged();
                _mgr.SendRemoveToClients(_victim);
            }
            else
            {
                Online = ShouldBeSuppressed() ? OnlineState.Suppressed : OnlineState.Online;
                ListNotifyChanged();
            }
        }
示例#20
0
        // Delegate method used to update the User Interface with the current state of the user session
        public void RefreshOnlineStatus(OnlineState currentState)
        {
            this.BeginInvoke(new MethodInvoker(() =>
            {
                // Hide the (obsolete) 'Log In' link
                linkLogIn.Visible = false;

                // If the current state shows that the user has a connection to the Last.fm API
                if (currentState == OnlineState.Online)
                {
                    // Display the current sign in name
                    if (!string.IsNullOrEmpty(base.CurrentUser?.Name))
                    {
                        lblSignInName.Text = string.Format(LocalizationStrings.ScrobblerUi_UserLoggedInText, base.CurrentUser?.Name);
                    }
                }
                // Or, if the user has previously authorised the application
                else if (!string.IsNullOrEmpty(Core.Settings.Username))
                {
                    // Display the last known username, but indicating that the session is 'Offline'
                    lblSignInName.Text = String.Format(LocalizationStrings.ScrobblerUi_UserOffline, base.CurrentUser?.Name);
                }
                else
                {
                    // Otherwise just display the name of the application
                    lblSignInName.Text = $"{Core.APPLICATION_TITLE}";
                    linkLogIn.Visible  = true;
                    SetStatus(LocalizationStrings.ScrobblerUi_Status_NotLoggedIn);
                }

                // Show or hide various Ui elements based on the online status
                linkProfile.Visible = currentState == OnlineState.Online;
                linkLogOut.Visible  = currentState == OnlineState.Online;

                // Reset the 'Love Track' Ui status
                base.RefreshLoveTrackState();
            }));
        }
示例#21
0
        //protected override void Draw(GameTime gameTime)
        //{
        //    //if (OnlineState.AskingRole == state || OnlineState.Connecting == state)
        //    //    Tools.DrawSingle(startScreen);
        //    //else
        //    //{
        //    //    startScreen.kill();
        //    GraphicsDevice.Clear(Color.CornflowerBlue);
        //    Tools.sb.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend,
        //        null, null, null, null, Global.cam.Mat);
        //    Event_Draw?.Invoke();//draw hapend
        //    Tools.sb.End();
        //    //}

        //    base.Draw(gameTime);
        //}
        void onlineGame_OnConnection()
        {
            state = OnlineState.Playing;
        }
示例#22
0
 public UserListBoxItem(User user)
 {
     _user = user;
     _online = OnlineState.Unknown;
     _onlineStatus = new Bitmap(Properties.Resources.unknown);
 }
示例#23
0
 public void ReturnOfflineResult(string mac, OnlineState state)
 {
     OnOnlineStateChanged(this, new OnlineStateEventArgs(mac, state));
 }
示例#24
0
文件: Form1.cs 项目: qq5013/cabinet
 public void ReturnOnlineResult(string mac, OnlineState state)
 {
     throw new NotImplementedException();
 }
示例#25
0
        private bool Listener_OnCommand(UserInfo user, string message)
        {
            // !online
            if (message.ToLower() == "!online")
            {
                string   reply  = string.Empty;
                string[] online = this.Bot.FriendList.Online("notify");
                if (online.Length == 0)
                {
                    reply += "No users online.";
                }
                else
                {
                    reply += "Online: " + string.Join(", ", online) + ".";
                }

                if (this.RelayMode == "guest" || this.RelayMode == "both")
                {
                    Dictionary <UInt32, Friend> list = this.Bot.PrivateChannel.List();
                    List <string> guests             = new List <string>();
                    foreach (KeyValuePair <UInt32, Friend> guest in list)
                    {
                        guests.Add(Format.UppercaseFirst(guest.Value.User));
                    }
                    if (guests.Count > 0)
                    {
                        reply += " Guests: " + string.Join(", ", guests.ToArray());
                    }
                }
                IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, reply));
                return(true);
            }

            // !is and !whois
            if (message.Trim().Contains(" "))
            {
                string[] parts    = message.Trim().Split(' ');
                string   command  = parts[0];
                string   username = parts[1];
                switch (command)
                {
                case "!is":
                    UInt32      userid = this.Bot.GetUserID(username);
                    OnlineState state  = this.Bot.FriendList.IsOnline(userid);
                    if (state == OnlineState.Timeout)
                    {
                        IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, "Request timed out. Please try again later"));
                        return(true);
                    }
                    if (state == OnlineState.Unknown)
                    {
                        IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, "No such user: "******"Online";
                    if (state == OnlineState.Offline)
                    {
                        append = "Offline";
                        Int64 seen = this.Bot.FriendList.Seen(username);
                        if (seen > 1)
                        {
                            append += " and was last seen online at " + Format.DateTime(seen, FormatStyle.Large) + " GMT";
                        }
                    }
                    IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, String.Format("{0} is currently {1}", Format.UppercaseFirst(username), append)));
                    break;

                case "!whois":
                    if (this.Bot.GetUserID(username) < 100)
                    {
                        IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, "No such user: "******"Unable to gather information on that user"));
                        return(true);
                    }
                    IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, Format.Whois(whois, FormatStyle.Large)));
                    break;
                }
            }
            return(false);
        }
示例#26
0
        async Task GetFriendsResponse(GetFriends.Response res)
        {
            var lists = new GetFriends.Lists();

            res.lists = lists;

            var selfPersonalDB = PDBSM.PersonalDBContext(SelfHost.playerInfo.playerId);

            var dateLog = await selfPersonalDB.DateLogs.FindAsync(SelfHost.playerInfo.playerId);

            if (dateLog == null)
            {
                dateLog = new DateLog(SelfHost.playerInfo.playerId);
            }
            res.FriendRequestPageLastView = dateLog.FriendRequestPageLastView;

            lists.Friends     = new List <GetFriends.FriendPlayer>();
            lists.Requests    = new List <GetFriends.RequestPlayer>();
            lists.MutePlayers = new List <GetFriends.MutePlayer>();

            {
                var friends = await Common2DB.Friends.Where(f => f.playerIdL == SelfHost.playerInfo.playerId).ToListAsync();

                for (int i = 0; i < friends.Count; i++)
                {
                    var state       = "";
                    var onlineState = new OnlineState(friends[i].playerIdR);
                    if (await onlineState.FetchAsync() && await new Session(onlineState.Model.sessionId).ExistsAsync())
                    {
                        state = onlineState.Model.state;
                    }

                    var onlineStamp = new OnlineStamp(friends[i].playerIdR);
                    if (!await onlineStamp.FetchAsync())
                    {
                        onlineStamp.Model.date = DateTime.MinValue;

                        var reco = await PDBSM.PersonalDBContext(friends[i].playerIdR).DateLogs.FindAsync(friends[i].playerIdR);

                        if (reco != null)
                        {
                            onlineStamp.Model.date = reco.OnlineStamp;
                        }
                        await onlineStamp.SaveAsync();
                    }

                    lists.Friends.Add(new GetFriends.FriendPlayer()
                    {
                        playerId    = friends[i].playerIdR,
                        lastLogin   = onlineStamp.Model.date,
                        onlineState = state,
                    });
                }
            }
            {
                var friends = await Common2DB.Friends.Where(f => f.playerIdR == SelfHost.playerInfo.playerId).ToListAsync();

                for (int i = 0; i < friends.Count; i++)
                {
                    var state       = "";
                    var onlineState = new OnlineState(friends[i].playerIdL);
                    if (await onlineState.FetchAsync() && await new Session(onlineState.Model.sessionId).ExistsAsync())
                    {
                        state = onlineState.Model.state;
                    }

                    var onlineStamp = new OnlineStamp(friends[i].playerIdL);
                    if (!await onlineStamp.FetchAsync())
                    {
                        onlineStamp.Model.date = DateTime.MinValue;

                        var reco = await PDBSM.PersonalDBContext(friends[i].playerIdL).DateLogs.FindAsync(friends[i].playerIdL);

                        if (reco != null)
                        {
                            onlineStamp.Model.date = reco.OnlineStamp;
                        }
                        await onlineStamp.SaveAsync();
                    }

                    lists.Friends.Add(new GetFriends.FriendPlayer()
                    {
                        playerId    = friends[i].playerIdL,
                        lastLogin   = onlineStamp.Model.date,
                        onlineState = state,
                    });
                }
            }
            var favorites = await selfPersonalDB.FavoriteFriends.Where(r => r.playerId == SelfHost.playerInfo.playerId).ToListAsync();

            lists.Friends.ForEach(friend =>
            {
                var idx = favorites.FindIndex(favorite => favorite.playerId == friend.playerId);
                if (0 <= idx)
                {
                    friend.favorite = true;
                    favorites.RemoveAt(idx);
                }
            });
            if (0 < favorites.Count)
            {
                selfPersonalDB.RemoveRange(favorites);
                await selfPersonalDB.SaveChangesAsync();
            }


            var requests = await selfPersonalDB.FriendRequests.Where(r => r.playerIdDst == SelfHost.playerInfo.playerId).ToListAsync();

            for (int i = 0; i < requests.Count; i++)
            {
                var player = new Player(requests[i].playerIdSrc);
                if (await player.Validate(PDBSM))
                {
                    lists.Requests.Add(new GetFriends.RequestPlayer()
                    {
                        playerId        = player.playerId,
                        applicationDate = requests[i].timeStamp,
                    });
                }
            }

            var mutePlayers = await selfPersonalDB.MutePlayers.Where(f => f.playerIdSrc == SelfHost.playerInfo.playerId).ToListAsync();

            for (int i = 0; i < mutePlayers.Count; i++)
            {
                var mutePlayer = mutePlayers[i];
                lists.MutePlayers.Add(new GetFriends.MutePlayer()
                {
                    playerId = mutePlayer.playerIdDst,
                    text     = mutePlayer.text,
                    voice    = mutePlayer.voice,
                });
            }
        }
示例#27
0
        protected override void Update(GameTime gameTime)
        {
            Global.gameTime = gameTime; //assiging the global gametime with the main game instance gametime to use in other classes

            switch (currentGameState)   //switching between the game states
            {
            case GameState.MainMenu:
                if (!menuSongPlaying)     //making sure that the menu song is only played once
                {
                    MediaPlayer.Play(menuSong);
                    menuSongPlaying         = true;
                    MediaPlayer.IsRepeating = true;
                }

                //getting the mouse coordinates
                mouse      = Mouse.GetState();
                mouseRec.X = mouse.X;
                mouseRec.Y = mouse.Y;

                //switching states according to the button the was pressed
                if (pvpButton.isClicked)
                {
                    currentGameState = GameState.Playing1v1;
                }
                if (onlineButton.isClicked)
                {
                    currentGameState = GameState.PlayingOnline;
                }
                if (aiButton.isClicked)
                {
                    currentGameState = GameState.PlayingVsAI;
                }
                if (instructionsButton.isClicked)
                {
                    currentGameState = GameState.Instructions;
                }

                break;

            case GameState.Playing1v1:

                //when enter is played, play the chant and allow the players to move
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !player1.isInputAllowed && !player2.isInputAllowed)
                {
                    MediaPlayer.IsRepeating = false;
                    player1.isInputAllowed  = true;
                    player2.isInputAllowed  = true;
                    gameStarted             = true;
                    didChantPlay            = true;
                    MediaPlayer.Play(fight);
                }

                //when the chant is played, use the timer to wait until its over and then play the battle song
                if (didChantPlay)
                {
                    battleSongTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                    if (battleSongTimer > fightChantRate)
                    {
                        didChantPlay    = false;  // we turn this to false because we dont want to enter this again, even though the chant already played
                        battleSongTimer = 0;
                        MediaPlayer.Play(battleSong);
                        MediaPlayer.IsRepeating = true;
                    }
                }

                //if the players bump into each other we only allow them to move away from each other, unless one of them is above the other
                if (player1.Position.X - player2.Position.X <= minDistance && player1.Position.X - player2.Position.X > 0 && Math.Abs(player1.Position.Y - player2.Position.Y) < 125)
                {
                    player1.isMovementAllowedRight = true;
                    player1.isMovementAllowedLeft  = false;
                    player2.isMovementAllowedRight = false;
                    player2.isMovementAllowedLeft  = true;
                }
                //if the players bump into each other we only allow them to move away from each other, unless one of them is above the other
                else if (player2.Position.X - player1.Position.X <= minDistance && player2.Position.X - player1.Position.X > 0 && Math.Abs(player1.Position.Y - player2.Position.Y) < 125)
                {
                    player2.isMovementAllowedRight = true;
                    player2.isMovementAllowedLeft  = false;
                    player1.isMovementAllowedRight = false;
                    player1.isMovementAllowedLeft  = true;
                }
                //if the players have not reached the min distance from each other we allow them to move freely
                else
                {
                    player1.isMovementAllowedRight = true;
                    player1.isMovementAllowedLeft  = true;
                    player2.isMovementAllowedRight = true;
                    player2.isMovementAllowedLeft  = true;
                }

                //if a player lands on another player this part of the code makes sure to push them apart (each one gets pushed 50 pixels to the back)
                if (Math.Abs(player1.Position.X - player2.Position.X) < minDistance - 10 && Math.Abs(player1.Position.Y - player2.Position.Y) < 125)
                {
                    if (player1.Position.X < player2.Position.X)
                    {
                        player1.Position -= new Vector2(50, 0);
                        player2.Position += new Vector2(50, 0);
                    }
                    else
                    {
                        player1.Position += new Vector2(50, 0);
                        player2.Position -= new Vector2(50, 0);
                    }
                }

                //aligning the player indicator with the player position
                p1BannerPos = new Vector2(player1.Position.X, player1.Position.Y - 140);
                p2BannerPos = new Vector2(player2.Position.X, player2.Position.Y - 140);

                p1Indicator.Position = p1BannerPos;
                p2Indicator.Position = p2BannerPos;

                //changing the directions to which the characters face according to the location of their enemy
                if (player1.Position.X < player2.Position.X)
                {
                    player2.flipCharachter("left");
                    player1.flipCharachter("right");
                }
                else
                {
                    player1.flipCharachter("left");
                    player2.flipCharachter("right");
                }

                //if a player has an internal hit registered
                if (player1.HitCount == p1HitCount + 1)
                {
                    if (Math.Abs(player1.Position.X - player2.Position.X) < 100 && !player2.isDucking && Math.Abs(player1.Position.Y - player2.Position.Y) < 50) // if the enemy is close enough an is not ducking
                    {
                        p1HitCount++;                                                                                                                            // change the external hit count
                        p2HealthBar.rectangle.Width -= 250 / maxHitCount;                                                                                        // make the enemy's health bar get smaller accordingly to the max hit count
                    }
                    else                                                                                                                                         // if the enemy is too far away or is ducking
                    {
                        player1.cancelHit();                                                                                                                     //cancel the internal hit for the player
                    }
                }

                //same process but for the other player
                if (player2.HitCount == p2HitCount + 1)
                {
                    if (Math.Abs(player1.Position.X - player2.Position.X) < 100 && !player1.isDucking && Math.Abs(player1.Position.Y - player2.Position.Y) < 50)
                    {
                        p2HitCount++;
                        p1HealthBar.rectangle.Width -= 250 / maxHitCount;
                    }
                    else
                    {
                        player2.cancelHit();
                    }
                }

                //if a player had reached the max hit count
                if (player1.HitCount == maxHitCount && player1.isInputAllowed && player2.isInputAllowed)
                {
                    player2.loseSequence();   //make the enemy get into a losing sequence
                    player1.winSequence();    //make the player go into a winning sequence
                    //disallow inputs to keep the characters in place
                    player1.isInputAllowed = false;
                    player2.isInputAllowed = false;
                    //make the health bar of the losing player disappear
                    //this is needed because sometimes the width of the health bar divided by the max hit count does not produce a full number therefore the health bar might not go all the way to 0 when the max hit count is achieved
                    p2HealthBar.rectangle.Width = 0;

                    gameOver = true;           //mark the game being over
                    MediaPlayer.Play(winSong); //play the winning song
                }

                //same process for the other player
                if (player2.HitCount == maxHitCount && player1.isInputAllowed && player2.isInputAllowed)
                {
                    player1.loseSequence();
                    player2.winSequence();
                    player1.isInputAllowed      = false;
                    player2.isInputAllowed      = false;
                    p1HealthBar.rectangle.Width = 0;
                    gameOver = true;
                    MediaPlayer.Play(winSong);
                }

                //if in the middle of the game the back to menu button is clicked
                if (midGameExit.isClicked)
                {
                    gameOver = false;                      //mark that the game is in play
                    LoadContent();                         //reset all variables
                    currentGameState = GameState.MainMenu; //go back to menu
                }

                //if the game is over
                if (gameOver)
                {
                    if (resetGame.isClicked)                   //when the reset button is clicked
                    {
                        gameOver = false;                      //mark that the game is in play
                        LoadContent();                         //reset all variables
                        currentGameState = GameState.MainMenu; //go back to menu
                    }
                }

                break;

            case GameState.PlayingOnline:

                switch (onlineState)
                {
                case OnlineState.AskingRole:

                    if (midGameExit.isClicked)
                    {
                        LoadContent();
                        currentGameState = GameState.MainMenu;
                    }

                    if (Keyboard.GetState().IsKeyDown(Keys.H))
                    {
                        onlineGame = new HostOnlineGame(int.Parse(File.ReadAllText("port.txt")));
                        onlineGame.OnConnection += new OnConnectionHandler(onlineGame_OnConnection);
                        onlineGame.Init();

                        onlineState = OnlineState.Connecting;
                    }
                    else if (Keyboard.GetState().IsKeyDown(Keys.J))
                    {
                        onlineGame = new JoinOnlineGame(File.ReadAllText("ip.txt"), int.Parse(File.ReadAllText("port.txt")));
                        onlineGame.OnConnection += new OnConnectionHandler(onlineGame_OnConnection);
                        onlineGame.Init();

                        onlineState = OnlineState.Connecting;
                    }
                    break;

                case OnlineState.Connecting:
                    break;

                case OnlineState.Playing:
                    onlineGame.hostChar.update();
                    onlineGame.joinChar.update();

                    //from here until the break of the online game state the process is the same as in playing1v1
                    if (onlineGame.hostChar.Position.X - onlineGame.joinChar.Position.X <= minDistance && onlineGame.hostChar.Position.X - onlineGame.joinChar.Position.X > 0 && Math.Abs(onlineGame.hostChar.Position.Y - onlineGame.joinChar.Position.Y) < 125)
                    {
                        onlineGame.hostChar.isMovementAllowedRight = true;
                        onlineGame.hostChar.isMovementAllowedLeft  = false;
                        onlineGame.joinChar.isMovementAllowedRight = false;
                        onlineGame.joinChar.isMovementAllowedLeft  = true;
                    }
                    else if (onlineGame.joinChar.Position.X - onlineGame.hostChar.Position.X <= minDistance && onlineGame.joinChar.Position.X - onlineGame.hostChar.Position.X > 0 && Math.Abs(onlineGame.hostChar.Position.Y - onlineGame.joinChar.Position.Y) < 125)
                    {
                        onlineGame.joinChar.isMovementAllowedRight = true;
                        onlineGame.joinChar.isMovementAllowedLeft  = false;
                        onlineGame.hostChar.isMovementAllowedRight = false;
                        onlineGame.hostChar.isMovementAllowedLeft  = true;
                    }
                    else
                    {
                        onlineGame.hostChar.isMovementAllowedRight = true;
                        onlineGame.hostChar.isMovementAllowedLeft  = true;
                        onlineGame.joinChar.isMovementAllowedRight = true;
                        onlineGame.joinChar.isMovementAllowedLeft  = true;
                    }

                    if (Math.Abs(onlineGame.hostChar.Position.X - onlineGame.joinChar.Position.X) < minDistance - 10 && Math.Abs(onlineGame.hostChar.Position.Y - onlineGame.joinChar.Position.Y) < 125)
                    {
                        if (onlineGame.hostChar.Position.X < onlineGame.joinChar.Position.X)
                        {
                            onlineGame.hostChar.Position -= new Vector2(50, 0);
                            onlineGame.joinChar.Position += new Vector2(50, 0);
                        }
                        else
                        {
                            onlineGame.hostChar.Position += new Vector2(50, 0);
                            onlineGame.joinChar.Position -= new Vector2(50, 0);
                        }
                    }

                    p1BannerPos = new Vector2(onlineGame.hostChar.Position.X, onlineGame.hostChar.Position.Y - 140);
                    p2BannerPos = new Vector2(onlineGame.joinChar.Position.X, onlineGame.joinChar.Position.Y - 140);

                    p1Indicator.Position = p1BannerPos;
                    p2Indicator.Position = p2BannerPos;


                    if (onlineGame.hostChar.Position.X < onlineGame.joinChar.Position.X)
                    {
                        onlineGame.joinChar.flipCharachter("left");
                        onlineGame.hostChar.flipCharachter("right");
                    }
                    else
                    {
                        onlineGame.hostChar.flipCharachter("left");
                        onlineGame.joinChar.flipCharachter("right");
                    }

                    if (onlineGame.hostChar.HitCount == p1HitCount + 1)
                    {
                        if (Math.Abs(onlineGame.hostChar.Position.X - onlineGame.joinChar.Position.X) < 100 && !onlineGame.joinChar.isDucking && Math.Abs(onlineGame.hostChar.Position.Y - onlineGame.joinChar.Position.Y) < 50)
                        {
                            p1HitCount++;
                            p2HealthBar.rectangle.Width -= 250 / maxHitCount;
                        }
                        else
                        {
                            onlineGame.hostChar.cancelHit();
                        }
                    }

                    if (onlineGame.joinChar.HitCount == p2HitCount + 1)
                    {
                        if (Math.Abs(onlineGame.hostChar.Position.X - onlineGame.joinChar.Position.X) < 100 && !onlineGame.hostChar.isDucking && Math.Abs(onlineGame.hostChar.Position.Y - onlineGame.joinChar.Position.Y) < 50)
                        {
                            p2HitCount++;
                            p1HealthBar.rectangle.Width -= 250 / maxHitCount;
                        }
                        else
                        {
                            onlineGame.joinChar.cancelHit();
                        }
                    }

                    if (onlineGame.hostChar.HitCount == maxHitCount && onlineGame.hostChar.isInputAllowed && onlineGame.joinChar.isInputAllowed)
                    {
                        onlineGame.joinChar.loseSequence();
                        onlineGame.hostChar.winSequence();
                        onlineGame.hostChar.isInputAllowed = false;
                        onlineGame.joinChar.isInputAllowed = false;
                        p2HealthBar.rectangle.Width        = 0;
                        gameOver = true;
                        MediaPlayer.Play(winSong);
                    }

                    if (onlineGame.joinChar.HitCount == maxHitCount && onlineGame.hostChar.isInputAllowed && onlineGame.joinChar.isInputAllowed)
                    {
                        onlineGame.hostChar.loseSequence();
                        onlineGame.joinChar.winSequence();
                        onlineGame.hostChar.isInputAllowed = false;
                        onlineGame.joinChar.isInputAllowed = false;
                        p1HealthBar.rectangle.Width        = 0;
                        gameOver = true;
                        MediaPlayer.Play(winSong);
                    }

                    if (midGameExit.isClicked)
                    {
                        gameOver = false;
                        LoadContent();
                        currentGameState = GameState.MainMenu;
                    }

                    if (gameOver)
                    {
                        if (resetGame.isClicked)
                        {
                            gameOver = false;
                            LoadContent();
                            currentGameState = GameState.MainMenu;
                        }
                    }

                    break;
                }

                this.Window.Title = onlineState.ToString();

                break;

            case GameState.PlayingVsAI:

                //from here until the break it is the same process as in playing1v1 but instead of using player2 for the enemy of player1 we use the ai object
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !player1.isInputAllowed && !ai.isInputAllowed)
                {
                    MediaPlayer.IsRepeating = false;
                    player1.isInputAllowed  = true;
                    ai.isInputAllowed       = true;
                    gameStarted             = true;
                    didChantPlay            = true;
                    MediaPlayer.Play(fight);
                }

                if (didChantPlay)
                {
                    battleSongTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                    if (battleSongTimer > fightChantRate)
                    {
                        didChantPlay    = false;
                        battleSongTimer = 0;
                        MediaPlayer.Play(battleSong);
                        MediaPlayer.IsRepeating = true;
                    }
                }

                if (player1.Position.X - ai.Position.X <= minDistance && player1.Position.X - ai.Position.X > 0 && Math.Abs(player1.Position.Y - ai.Position.Y) < 125)
                {
                    player1.isMovementAllowedRight = true;
                    player1.isMovementAllowedLeft  = false;
                    ai.isMovementAllowedRight      = false;
                    ai.isMovementAllowedLeft       = true;
                }
                else if (ai.Position.X - player1.Position.X <= minDistance && ai.Position.X - player1.Position.X > 0 && Math.Abs(player1.Position.Y - ai.Position.Y) < 125)
                {
                    ai.isMovementAllowedRight      = true;
                    ai.isMovementAllowedLeft       = false;
                    player1.isMovementAllowedRight = false;
                    player1.isMovementAllowedLeft  = true;
                }
                else
                {
                    player1.isMovementAllowedRight = true;
                    player1.isMovementAllowedLeft  = true;
                    ai.isMovementAllowedRight      = true;
                    ai.isMovementAllowedLeft       = true;
                }

                if (Math.Abs(player1.Position.X - ai.Position.X) < minDistance - 10 && Math.Abs(player1.Position.Y - ai.Position.Y) < 125)
                {
                    if (player1.Position.X < ai.Position.X)
                    {
                        player1.Position -= new Vector2(50, 0);
                        ai.Position      += new Vector2(50, 0);
                    }
                    else
                    {
                        player1.Position += new Vector2(50, 0);
                        ai.Position      -= new Vector2(50, 0);
                    }
                }

                p1BannerPos = new Vector2(player1.Position.X, player1.Position.Y - 140);
                aiBannerPos = new Vector2(ai.Position.X, ai.Position.Y - 140);

                p1Indicator.Position = p1BannerPos;
                p2Indicator.Position = aiBannerPos;


                if (player1.Position.X < ai.Position.X)
                {
                    ai.flipCharachter("left");
                    player1.flipCharachter("right");
                }
                else
                {
                    player1.flipCharachter("left");
                    ai.flipCharachter("right");
                }

                if (player1.HitCount == p1HitCount + 1)
                {
                    if (Math.Abs(player1.Position.X - ai.Position.X) < 100 && !ai.isDucking && Math.Abs(player1.Position.Y - ai.Position.Y) < 50)
                    {
                        p1HitCount++;
                        p2HealthBar.rectangle.Width -= 250 / maxHitCount;
                    }
                    else
                    {
                        player1.cancelHit();
                    }
                }

                if (ai.HitCount == p2HitCount + 1)
                {
                    if (Math.Abs(player1.Position.X - ai.Position.X) < 100 && !player1.isDucking && Math.Abs(player1.Position.Y - ai.Position.Y) < 50)
                    {
                        p2HitCount++;
                        p1HealthBar.rectangle.Width -= 250 / maxHitCount;
                    }
                    else
                    {
                        ai.cancelHit();
                    }
                }

                if (player1.HitCount == maxHitCount && player1.isInputAllowed && ai.isInputAllowed)
                {
                    ai.loseSequence();
                    player1.winSequence();
                    player1.isInputAllowed      = false;
                    ai.isInputAllowed           = false;
                    p2HealthBar.rectangle.Width = 0;
                    gameOver = true;
                    MediaPlayer.Play(winSong);
                }


                if (ai.HitCount == maxHitCount && player1.isInputAllowed && ai.isInputAllowed)
                {
                    player1.loseSequence();
                    ai.winSequence();
                    player1.isInputAllowed      = false;
                    ai.isInputAllowed           = false;
                    p1HealthBar.rectangle.Width = 0;
                    gameOver = true;
                    MediaPlayer.Play(winSong);
                }

                if (midGameExit.isClicked)
                {
                    LoadContent();
                    currentGameState = GameState.MainMenu;
                }

                if (gameOver)
                {
                    if (resetGame.isClicked)
                    {
                        gameOver = false;
                        LoadContent();
                        currentGameState = GameState.MainMenu;
                    }
                }

                break;

            case GameState.Instructions:
                if (menuButton.isClicked)
                {
                    currentGameState = GameState.MainMenu;
                }
                break;
            }

            if (event_update != null) //if the update event is not empty
            {
                event_update();       //call all of the functions that registered to the update event
            }

            base.Update(gameTime);
        }
示例#28
0
 void onlineGame_OnConnection()
 {
     onlineState = OnlineState.Playing; //when a connection is achieved, start playing the online game
 }
示例#29
0
        private void OnWhoisCommand(BotShell bot, CommandArgs e, AoLib.Net.Server dimension, Boolean showDimension)
        {
            if (!showDimension && dimension == AoLib.Net.Server.Test)
            {
                bot.SendReply(e, "The whois command is not available on the test server.");
                return;
            }
            if (dimension == bot.Dimension)
            {
                if (bot.GetUserID(e.Args[0]) < 100)
                {
                    bot.SendReply(e, "No such user: "******": ");
                }
                error += "Unable to gather information on that user " + this.TimeoutError;
                bot.SendReply(e, error);
                return;
            }

            RichTextWindow window  = new RichTextWindow(bot);
            StringBuilder  builder = new StringBuilder();

            if (showDimension)
            {
                builder.Append(HTML.CreateColorString(bot.ColorHeaderHex, dimension.ToString() + ": "));
            }

            builder.Append(String.Format("{0} (Level {1}", whois.Name.Nickname, whois.Stats.Level));
            window.AppendTitle(whois.Name.ToString());

            window.AppendHighlight("Breed: ");
            window.AppendNormal(whois.Stats.Breed);
            window.AppendLineBreak();

            window.AppendHighlight("Gender: ");
            window.AppendNormal(whois.Stats.Gender);
            window.AppendLineBreak();

            window.AppendHighlight("Profession: ");
            window.AppendNormal(whois.Stats.Profession);
            window.AppendLineBreak();

            window.AppendHighlight("Level: ");
            window.AppendNormal(whois.Stats.Level.ToString());
            window.AppendLineBreak();

            if (whois.Stats.DefenderLevel != 0)
            {
                window.AppendHighlight("Defender Rank: ");
                window.AppendNormal(String.Format("{0} ({1})", whois.Stats.DefenderRank, whois.Stats.DefenderLevel));
                window.AppendLineBreak();

                builder.Append(" / Defender Rank " + whois.Stats.DefenderLevel);
            }

            if (dimension == bot.Dimension)
            {
                window.AppendHighlight("Status: ");
                UInt32      userid = bot.GetUserID(whois.Name.Nickname);
                OnlineState state  = bot.FriendList.IsOnline(userid);
                switch (state)
                {
                case OnlineState.Online:
                    window.AppendColorString(RichTextWindow.ColorGreen, "Online");
                    break;

                case OnlineState.Offline:
                    window.AppendColorString(RichTextWindow.ColorRed, "Offline");
                    Int64 seen = bot.FriendList.Seen(whois.Name.Nickname);
                    if (seen > 0)
                    {
                        window.AppendLineBreak();
                        window.AppendHighlight("Last Seen: ");
                        window.AppendNormal(Format.DateTime(seen, FormatStyle.Compact));
                    }
                    break;

                default:
                    window.AppendColorString(RichTextWindow.ColorOrange, "Unknown");
                    break;
                }
                window.AppendLineBreak();
            }

            builder.Append(")");
            builder.Append(String.Format(" is a {0} {1}", whois.Stats.Faction, whois.Stats.Profession));

            window.AppendHighlight("Alignment: ");
            window.AppendNormal(whois.Stats.Faction);
            window.AppendLineBreak();

            if (whois.InOrganization)
            {
                window.AppendHighlight("Organization: ");
                window.AppendNormal(whois.Organization.Name);
                window.AppendLineBreak();

                window.AppendHighlight("Organization Rank: ");
                window.AppendNormal(whois.Organization.Rank);
                window.AppendLineBreak();

                builder.AppendFormat(", {0} of {1}", whois.Organization.Rank, whois.Organization.Name);
            }

            window.AppendHighlight("Last Updated: ");
            window.AppendNormal(whois.LastUpdated);
            window.AppendLineBreak(2);

            if (dimension == bot.Dimension)
            {
                window.AppendHeader("Options");
                window.AppendCommand("Add to Friendlist", "/cc addbuddy " + whois.Name.Nickname);
                window.AppendLineBreak();
                window.AppendCommand("Remove from Friendlist", "/cc rembuddy " + whois.Name.Nickname);
                window.AppendLineBreak();
                window.AppendBotCommand("Character History", "history " + whois.Name.Nickname);
                window.AppendLineBreak();
                if (whois.Organization != null && whois.Organization.Name != null)
                {
                    window.AppendBotCommand("Organization Information", "organization " + whois.Name.Nickname);
                    window.AppendLineBreak();
                }
                window.AppendLineBreak();
            }

            window.AppendHeader("Links");
            window.AppendCommand("Official Character Website", "/start " + string.Format(this.CharWebsite, (int)dimension, whois.Name.Nickname));
            window.AppendLineBreak();
            if (whois.Organization != null && whois.Organization.Name != null)
            {
                window.AppendCommand("Official Organization Website", "/start " + string.Format(this.OrgWebsite, (int)dimension, whois.Organization.ID));
                window.AppendLineBreak();
            }
            window.AppendCommand("Auno's Character Website", "/start " + string.Format(this.CharAunoWebsite, (int)dimension, whois.Name.Nickname));
            window.AppendLineBreak();
            if (whois.Organization != null && whois.Organization.Name != null)
            {
                window.AppendCommand("Auno's Organization Website", "/start " + string.Format(this.OrgAunoWebsite, (int)dimension, whois.Organization.Name.Replace(' ', '+')));
                window.AppendLineBreak();
            }

            builder.Append(" »» " + window.ToString("More Information"));
            bot.SendReply(e, builder.ToString());
        }
示例#30
0
 private void OnlineGame_OnConnection()
 {
     Window.Title = "playing";
     state        = OnlineState.Playing;
 }
示例#31
0
 public UserListBoxItem(User user)
 {
     _user         = user;
     _online       = OnlineState.Unknown;
     _onlineStatus = new Bitmap(Properties.Resources.unknown);
 }
示例#32
0
        public User(string ID, string Name, string Underwrite, UserSex Sex, Bitmap Head, string Mobile, string Email, OnlineState onlineState)
        {
            //样式控制
            base.AutoSize  = false;
            base.Text      = string.Empty;
            base.Anchor    = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            base.BackColor = Color.White;

            //屏闭系统绘制
            this.SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.UserPaint, true);
            this.UpdateStyles();
            this.DoubleBuffered = true;

            //初始化
            this.userID     = ID;
            this.userName   = Name;
            this.Underwrite = "(" + Underwrite + ")";
            this.sex        = Sex;
            this.head       = Head;
            this.mobile     = Mobile;
            this.email      = Email;
            this.state      = onlineState;

            this.ForeColor = Color.FromArgb(40, 40, 40);

            //头像跳动
            this.headTimer          = new System.Timers.Timer();
            this.headTimer.Interval = 300;
            this.headTimer.Elapsed += delegate
            {
                if (this.headToRight)
                {
                    this.headX += 2;
                    if (this.headX == 6)
                    {
                        this.headToRight = false;
                    }
                }
                else
                {
                    this.headX -= 2;
                    if (this.headX == 2)
                    {
                        this.headToRight = true;
                    }
                }
                this.headY = this.headX == 4 ? 3 : 5;
                this.Invalidate(new Rectangle(0, 0, 34, 34));
            };

            this.Messages = new UserMessage();

            this.Messages.CountChanged += delegate
            {
                if (this.Messages.Count == 0)
                {
                    this.headTimer.Enabled = false;
                    this.headX             = this.headY = 4;
                    this.Invalidate(new Rectangle(0, 0, 34, 34));
                }
                else
                {
                    this.headTimer.Enabled = true;
                }
            };

            //提示
            this.toolTip = new ToolTip();
            this.toolTip.UseAnimation = true;
            this.toolTip.UseFading    = true;
            this.toolTip.ShowAlways   = true;

            //设置可用工具
            this.toolList = new List <ToolSwitch>();
            this.toolList.Add(ToolSwitch.IM_Chat);
            this.toolList.Add(ToolSwitch.IM_Speech);
            if (this.Mobile != null && this.Mobile.Trim().Length > 0)
            {
                this.toolList.Add(ToolSwitch.IM_Message);
            }
            if (this.Email != null && this.Email.Trim().Length > 0)
            {
                this.toolList.Add(ToolSwitch.IM_Email);
            }
        }
示例#33
0
 public UserStateContract(string userID, OnlineState online)
 {
     this.UserID = userID;
     this.OnLine = online;
 }
示例#34
0
 private void contacts_UserUpdateStatus(IPAddress ip, OnlineState state)
 {
     if (lbContacts.InvokeRequired)
     {
         lbContacts.Invoke(new Action<IPAddress, OnlineState>(contacts_UserUpdateStatus), ip, state);
     }
     else
     {
         lbContacts.SetState(ip, state);
         lbContacts.Refresh();
     }
 }
示例#35
0
 public OnlineStateEventArgs(string mac, OnlineState state)
 {
     this.Mac = mac;
     this.State = state;
 }