Exemplo n.º 1
0
        void queueDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            this.Width = Application.Current.Host.Content.ActualWidth;
            this.Height = Application.Current.Host.Content.ActualHeight;

            ImageButton faceList = new ImageButton() {
                TotalWidth = 162,
                TotalHeight = 27,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/18.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(42),
                TextStyle = Application.Current.Resources["TextStyle5"] as Style,
                TextHasEffect = false,
                TextBrush = new SolidColorBrush(Colors.Black),
            };
            this.Children.Add(faceList);
            Canvas.SetLeft(faceList, 15);
            Canvas.SetTop(faceList, 85);

            for (int i = 0; i < roleMax; i++) {
                roleList[i] = new ImageButton() {
                    Tag = "",
                    TotalWidth = 168,
                    TotalHeight = 54,
                    Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/4.png", UriType.Web), Stretch = Stretch.None },
                    TextStyle = Application.Current.Resources["TextStyle6"] as Style,
                    TextHasEffect = true,
                    TextEffectColor = Colors.Red,
                    TextBrush = new SolidColorBrush(Colors.White),
                    TextHoverBrush = new SolidColorBrush(Colors.Yellow),
                };
                this.Children.Add(roleList[i]);
                Canvas.SetLeft(roleList[i], 10);
                Canvas.SetTop(roleList[i], 120 + 56 * i);
                Canvas.SetZIndex(roleList[i], 3);
                roleList[0].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/20.png", UriType.Web) };
                roleList[i].Click += (s1, e1) => {
                    ImageButton obj = s1 as ImageButton;
                    if (obj.Tag.ToString().Equals("")) { return; }
                    for (int j = 0; j <= roleList.GetUpperBound(0); j++) {
                        roleList[j].TextBrush = new SolidColorBrush(Colors.White);
                        roleList[j].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/4.png", UriType.Web), };
                    }
                    obj.TextBrush = new SolidColorBrush(Color.FromArgb(255, 172, 255, 140));
                    obj.Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/20.png", UriType.Web), };

                    LoginManager.RoleName = obj.Tag.ToString();
                    ChangeRole(roles.Single(X => X.RoleName == LoginManager.RoleName));
                };
            }
            roleList[0].TextBrush = new SolidColorBrush(Color.FromArgb(255, 172, 255, 140));

            aura = new AnimationBase() { Code = 71, Loop = true, IsHitTestVisible = false, Position =new Point(258,380)  };
            this.Children.Add(aura);
            aura.HeartStart();

            this.Children.Add(roleModel);
            Canvas.SetLeft(roleModel, 220);
            Canvas.SetTop(roleModel, 100);

            Image roleData = new Image() { Source = GlobalMethod.GetImage("UI/19.png", UriType.Web), };
            this.Children.Add(roleData);
            Canvas.SetLeft(roleData, 582);
            Canvas.SetTop(roleData, 40);

            this.Children.Add(avatar);
            Canvas.SetLeft(avatar, 654);
            Canvas.SetTop(avatar, 70);

            TextBlock text0 = new TextBlock() { Text = GetLanguagePackContent(43), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text1 = new TextBlock() { Text = GetLanguagePackContent(44), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text2 = new TextBlock() { Text = GetLanguagePackContent(45), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text3 = new TextBlock() { Text = GetLanguagePackContent(46), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text4 = new TextBlock() { Text = GetLanguagePackContent(47), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text5 = new TextBlock() { Text = GetLanguagePackContent(48), Style = Application.Current.Resources["TextStyle7"] as Style };
            TextBlock text6 = new TextBlock() { Text = GetLanguagePackContent(49), Style = Application.Current.Resources["TextStyle7"] as Style };
            this.Children.Add(text0); Canvas.SetLeft(text0, 680); Canvas.SetTop(text0, 158);
            this.Children.Add(text1); Canvas.SetLeft(text1, 645); Canvas.SetTop(text1, 192);
            this.Children.Add(text2); Canvas.SetLeft(text2, 714); Canvas.SetTop(text2, 192);
            this.Children.Add(text3); Canvas.SetLeft(text3, 680); Canvas.SetTop(text3, 226);
            this.Children.Add(text4); Canvas.SetLeft(text4, 680); Canvas.SetTop(text4, 258);
            this.Children.Add(text5); Canvas.SetLeft(text5, 670); Canvas.SetTop(text5, 292);
            this.Children.Add(text6); Canvas.SetLeft(text6, 658); Canvas.SetTop(text6, 326);

            Grid grid0 = new Grid() { Width = 130 }; this.Children.Add(grid0); Canvas.SetLeft(grid0, 626); Canvas.SetTop(grid0, 173);
            Grid grid1 = new Grid() { Width = 60 }; this.Children.Add(grid1); Canvas.SetLeft(grid1, 626); Canvas.SetTop(grid1, 207);
            Grid grid2 = new Grid() { Width = 60 }; this.Children.Add(grid2); Canvas.SetLeft(grid2, 694); Canvas.SetTop(grid2, 207);
            Grid grid3 = new Grid() { Width = 130 }; this.Children.Add(grid3); Canvas.SetLeft(grid3, 626); Canvas.SetTop(grid3, 241);
            Grid grid4 = new Grid() { Width = 130 }; this.Children.Add(grid4); Canvas.SetLeft(grid4, 626); Canvas.SetTop(grid4, 273);
            Grid grid5 = new Grid() { Width = 130 }; this.Children.Add(grid5); Canvas.SetLeft(grid5, 626); Canvas.SetTop(grid5, 307);
            Grid grid6 = new Grid() { Width = 130 }; this.Children.Add(grid6); Canvas.SetLeft(grid6, 626); Canvas.SetTop(grid6, 341);
            roleName = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            occupation = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            level = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            experience = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            map = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            time = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            ip = new TextBlock() { Style = Application.Current.Resources["TextStyle8"] as Style };
            grid0.Children.Add(roleName);
            grid1.Children.Add(occupation);
            grid2.Children.Add(level);
            grid3.Children.Add(experience);
            grid4.Children.Add(map);
            grid5.Children.Add(time);
            grid6.Children.Add(ip);

            ImageButton startGame = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(50),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            startGame.Click += (s1, e1) => {
                Dispose(this,null);
                if (GameStart != null) { GameStart(this, e1); }
            };
            ImageButton cannel = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(51),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            cannel.Click += (s1, e1) => {
                Dispose(this, null);
                if (Cannel != null) { Cannel(this, e1); }
            };
            ImageButton newRole = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(52),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            newRole.Click += (s1, e1) => {
                LoginManager.loading.Show();
                WCFServiceClient wcf1 = new WCFServiceClient();
                wcf1.GetUserRoleNumAsync(LoginManager.UserName);
                wcf1.GetUserRoleNumCompleted += (s2, e2) => {
                    if (e2.Result == 6) {
                        LoginManager.loginTip.Show(GetLanguagePackContent(53), LoginTipMode.TipOnly);
                        LoginManager.loading.Hide();
                    } else {
                        Dispose(this, null);
                        if (CreateRole != null) { CreateRole(this, e1); }
                    }
                    wcf1.CloseAsync();
                };
            };
            delRole = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(54),
                TextStyle = Application.Current.Resources["TextStyle1"] as Style,
                TextHasEffect = true,
                TextEffectColor = Colors.Black,
                TextBrush = new SolidColorBrush(Color.FromArgb(255, 48, 83, 96)),
                TextHoverBrush = new SolidColorBrush(Colors.White),
            };
            delRole.Click += (s1, e1) => {
                if (roles.Count() == 0) { return; }
                LoginManager.loginTip.Show(GetLanguagePackContent(59), LoginTipMode.ConfirmOrCannel);
                LoginManager.loginTip.OK += new MouseButtonEventHandler(dialog_OK);
            };
            this.Children.Add(startGame); Canvas.SetLeft(startGame, 650); Canvas.SetTop(startGame, 380);
            this.Children.Add(cannel); Canvas.SetLeft(cannel, 650); Canvas.SetTop(cannel, 415);
            this.Children.Add(newRole); Canvas.SetLeft(newRole, 650); Canvas.SetTop(newRole, 450);
            this.Children.Add(delRole); Canvas.SetLeft(delRole, 650); Canvas.SetTop(delRole, 485);

            base.OnResourceReady(this, e);
            LoadRoles(LoginManager.UserName);
        }
Exemplo n.º 2
0
 //成功登陆后如果用户还未创建过任何角色则进入角色创建界面,否则进入角色选择界面
 void EnterRoleManager(object sender, MouseButtonEventArgs e)
 {
     this.Children.Remove(sender as WindowBase);
     WCFServiceClient wcfServiceClient = new WCFServiceClient();
     wcfServiceClient.GetUserRoleNumAsync(UserName);
     wcfServiceClient.GetUserRoleNumCompleted += (wcfs, wcfe) => {
         if (wcfe.Result == 0) {
             ShowCreateRole();
         } else {
             ShowSelectRole();
         }
         wcfServiceClient.CloseAsync();
     };
 }