Exemplo n.º 1
0
        public MainPage()
        {
            InitializeComponent();
            var home = new FadeLabel
            {
                Content = "home",
                Margin  = new Thickness(5, 0, 0, 0)
            };

            home.MouseDown += HomeButton_OnMouseDown;
            Header.Children.Add(home);

            var play = new FadeLabel
            {
                Content = "play",
                Margin  = new Thickness(5, 0, 0, 0)
            };

            play.MouseDown += PlayButton_OnMouseDown;
            Header.Children.Add(play);

            var profile = new FadeLabel
            {
                Content = "profile",
                Margin  = new Thickness(5, 0, 0, 0)
            };

            profile.MouseDown += NotReadyFeature;
            Header.Children.Add(profile);

            var shop = new FadeLabel
            {
                Content = "shop",
                Margin  = new Thickness(5, 0, 0, 0)
            };

            shop.MouseDown += NotReadyFeature;
            Header.Children.Add(shop);

            var settings = new FadeLabel
            {
                Content = "settings",
                Margin  = new Thickness(5, 0, 0, 0)
            };

            settings.MouseDown += NotReadyFeature;
            Header.Children.Add(settings);

            if (StaticVars.AccountInfo.IsDev)
            {
                var devLabel = new FadeLabel
                {
                    Content = "dev",
                    Margin  = new Thickness(5, 0, 0, 0)
                };
                devLabel.MouseDown += DevLabel_MouseDown;
                Header.Children.Add(devLabel);
            }

            UserInterfaceCore.MainPage = this;
            Load();
            foreach (var player in StaticVars.ActiveClient.Players)
            {
                var chatItem = new SmallChatItem
                {
                    PlayerNameLabel = { Content = player.Username },
                    StatusLabel     = { Content = player.Status },
                    Tag             = player
                };
                chatItem.MouseDoubleClick += item_MouseDoubleClick;

                if (player.Mobile)
                {
                    chatItem.StatusEllipse.Fill = Brushes.Orange;
                }
                else if (player.IsOnline && player.IsAway)
                {
                    chatItem.StatusEllipse.Fill = Brushes.Red;
                }
                else if (player.IsOnline)
                {
                    chatItem.StatusEllipse.Fill = Brushes.Green;
                }
                else
                {
                    chatItem.StatusEllipse.Fill = Brushes.Gray;
                }
                ChatStackPanel.Children.Add(chatItem);
            }
            StaticVars.ActiveClient.OnUpdatePlayer += OnUpdatePlayer;
        }
Exemplo n.º 2
0
        void OnUpdatePlayer(object sender, ChatPlayerItem e)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() =>
            {
                SmallChatItem item = null;
                foreach (SmallChatItem items in ChatStackPanel.Children)
                {
                    if ((string)items.PlayerNameLabel.Content == e.Username)
                    {
                        item = items;
                    }
                }

                if (item == null)
                {
                    item = new SmallChatItem {
                        Tag = e
                    };
                    item.MouseDoubleClick += item_MouseDoubleClick;
                    ChatStackPanel.Children.Add(item);
                }

                item.PlayerNameLabel.Content = e.Username;
                item.StatusLabel.Content = e.Status;
                var converter = new BrushConverter();

                if (!e.IsOnline)
                {
                    ChatStackPanel.Children.Remove(item);
                }
                else if (e.GameStatus == "outOfGame" && !e.IsAway)
                {
                    item.StatusEllipse.Fill = (Brush)converter.ConvertFromString("#2ecc71");
                }
                else
                {
                    item.StatusEllipse.Fill = (Brush)converter.ConvertFromString("#e74c3c");
                }

                foreach (PlayerChatControl items in PlayerChatStackPanel.Children)
                {
                    if ((string)items.PlayerNameLabel.Content == e.Username)
                    {
                        items.StatusEllipse.Stroke = null;
                        if (e.Mobile)
                        {
                            items.StatusEllipse.Fill = Brushes.Orange;
                        }
                        else if (!e.IsOnline)
                        {
                            items.StatusEllipse.Fill = (Brush)converter.ConvertFromString("#02000000");
                            items.StatusEllipse.Stroke = (Brush)converter.ConvertFromString("#FFA0A0A0");
                        }
                        else if (e.GameStatus == "outOfGame" && !e.IsAway)
                        {
                            items.StatusEllipse.Fill = (Brush)converter.ConvertFromString("#2ecc71");
                        }
                        else
                        {
                            items.StatusEllipse.Fill = (Brush)converter.ConvertFromString("#e74c3c");
                        }
                    }
                }
            }));
        }