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
 /// <summary>
 /// 加载该用户所有角色
 /// </summary>
 void LoadRoles(string userName)
 {
     LoginManager.loading.Show();
     WCFServiceClient wcfServiceClient = new WCFServiceClient();
     wcfServiceClient.GetRoleByUserNameAsync(userName);
     wcfServiceClient.GetRoleByUserNameCompleted += (s1, e1) => {
         int count = 0;
         roles.Clear();
         foreach (Role role in e1.Result) {
             roles.Add(role);
             roleList[count].Text = string.Format("{0}\r{1} {2} {3}", role.RoleName, ProfessionName((Professions)role.Occupation), role.RoleLevel, GetLanguagePackContent(55));
             roleList[count].Tag = role.RoleName;
             if (count == 0) {
                 LoginManager.RoleName = role.RoleName;
                 ChangeRole(role);
             }
             count++;
         }
         for (int i = count; i < roleMax; i++) {
             roleList[i].Text = "";
             roleList[count].Tag = "";
         }
         wcfServiceClient.CloseAsync();
         LoginManager.loading.Hide();
     };
 }
Exemplo n.º 3
0
        void queueDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            this.Width = 910;
            this.Height = 590;

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

            avatarSelector = new AnimationBase() { Code = 70, Loop = true, Z = 10, IsHitTestVisible = false };
            this.Children.Add(avatarSelector);
            avatarSelector.HeartStart();

            for (int i = 0; i <= avatar.GetUpperBound(0); i++) {
                avatar[i] = new ImageButton() {
                    Code = i,
                    TotalWidth = 74,
                    TotalHeight = 74,
                    BodyHasEffect = true,
                    BodyEffectColor = Colors.Blue,
                };
                this.Children.Add(avatar[i]);
                Canvas.SetLeft(avatar[i], 40);
                Canvas.SetTop(avatar[i], 130 + i * 85);
                Canvas.SetZIndex(avatar[i], 3);
                avatar[i].MouseLeftButtonDown += (s1, e1) => {
                    ImageButton obj =s1 as ImageButton;
                    faceCode = obj.Code;
                    avatarSelector.Visibility = Visibility.Visible;
                    avatarSelector.IsVisible = true;
                    avatarSelector.Position = obj.Position;
                };
            }
            ShowSexFace(Sex.male);
            avatarSelector.Position = avatar[0].Position;

            light = new AnimationBase { Code = 72, Loop = true, Z = 4, IsHitTestVisible = false };
            this.Children.Add(light);
            light.HeartStart();
            light.Position = new Point(190, 75);

            this.Children.Add(maleModel);
            Canvas.SetLeft(maleModel, 80);
            Canvas.SetTop(maleModel, 120);
            maleModel.MouseLeftButtonDown += (s1, e1) => {
                //waiting.Show(); Canvas.SetLeft(waiting, -400); Canvas.SetTop(waiting, 100);
                ShowSexFace(Sex.male);
                ShowRoleModel(profession, Sex.male);
                light.Position = new Point(190, 75);
            };
            this.Children.Add(femaleModel);
            Canvas.SetLeft(femaleModel, 270);
            Canvas.SetTop(femaleModel, 120);
            ShowRoleModel(profession, Sex.male);
            femaleModel.MouseLeftButtonDown += (s1, e1) => {
                //waiting.Show(); Canvas.SetLeft(waiting, -200); Canvas.SetTop(waiting, 100);
                ShowSexFace(Sex.female);
                ShowRoleModel(profession, Sex.female);
                light.Position = new Point(385, 75);
            };

            for (int i = 0; i <= professionSelector.GetUpperBound(0); i++) {
                professionSelector[i] = new ImageButton() {
                    Tag = i,
                    TotalWidth = 153,
                    TotalHeight = 32,
                    Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/5.png", UriType.Web), Stretch = Stretch.None },
                    TextStyle = Application.Current.Resources["TextStyle3"] as Style,
                    TextHasEffect = true,
                    TextEffectColor = Colors.Red,
                    TextBrush = new SolidColorBrush(Colors.White),
                    TextHoverBrush = new SolidColorBrush(Colors.Yellow),
                    Z  = 3,
                };
                this.Children.Add(professionSelector[i]);
                professionSelector[i].Position = new Point(600, 70 + 50 * i);
                professionSelector[0].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/9.png", UriType.Web) };
                professionSelector[i].Click += (s1, e1) => {
                    for (int j = 0; j <= professionSelector.GetUpperBound(0); j++) {
                        professionSelector[j].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/5.png", UriType.Web) };
                    }
                    ImageButton obj = s1 as ImageButton;
                    obj.Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/9.png", UriType.Web) };
                    ShowRoleModel((Professions)obj.Tag, sex);
                };
            }
            professionSelector[0].Text = GetLanguagePackContent(28);
            professionSelector[1].Text = GetLanguagePackContent(27);
            professionSelector[2].Text = GetLanguagePackContent(26);
            professionSelector[3].Text = GetLanguagePackContent(29);

            Image descriptionHead = new Image() { Source = GlobalMethod.GetImage("UI/6.png", UriType.Web) };
            Grid descriptionBody = new Grid() {
                Width = 221,
                Height = 220,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/7.png", UriType.Web) }
            };
            descriptionBody.Children.Add(description);
            Image descriptionFoot = new Image() { Source = GlobalMethod.GetImage("UI/8.png", UriType.Web) };
            this.Children.Add(descriptionHead);
            this.Children.Add(descriptionFoot);
            this.Children.Add(descriptionBody);
            Canvas.SetLeft(descriptionHead, 570);
            Canvas.SetTop(descriptionHead, 280);
            Canvas.SetLeft(descriptionBody, 570);
            Canvas.SetTop(descriptionBody, 285);
            Canvas.SetLeft(descriptionFoot, 570);
            Canvas.SetTop(descriptionFoot, 455);

            TextBlock text0 = new TextBlock() { Text = GetLanguagePackContent(30), Foreground = new SolidColorBrush(Colors.White), FontSize = 18, FontWeight = FontWeights.SemiBold };
            this.Children.Add(text0);
            Canvas.SetLeft(text0, 200);
            Canvas.SetTop(text0, 545);
            TextBox roleName = new TextBox() { Width = 240, Background = new SolidColorBrush(Color.FromArgb(255, 57, 57, 57)), Style = Application.Current.Resources["TextStyle2"] as Style };
            this.Children.Add(roleName);
            Canvas.SetLeft(roleName, 285);
            Canvas.SetTop(roleName, 548);

            ImageButton createRole = new ImageButton() {
                TotalWidth = 80,
                TotalHeight = 25,
                Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/3.png", UriType.Web), Stretch = Stretch.None },
                Text = GetLanguagePackContent(31),
                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),
            };
            this.Children.Add(createRole);
            Canvas.SetLeft(createRole, 550);
            Canvas.SetTop(createRole, 547);
            //创建角色
            createRole.MouseLeftButtonDown += (s1, e1) => {
                if (roleName.Text.Trim().Equals("") || roleName.Text.Trim().Length > 20) { LoginManager.loginTip.Show(GetLanguagePackContent(40), LoginTipMode.TipOnly); return; }
                LoginManager.loading.Show();
                WCFServiceClient wcfServiceClient = new WCFServiceClient();
                wcfServiceClient.CheckRoleExistAsync(roleName.Text.Trim());
                wcfServiceClient.CheckRoleExistCompleted += (s2, e2) => {
                    if (e2.Result == 0) {
                        wcfServiceClient.InsertRoleAsync(LoginManager.UserName, roleName.Text.Trim(), (byte)faceCode, (byte)sex, (byte)profession, 1, 0, 1, Application.Current.Host.InitParams["ClientIP"], "");
                        wcfServiceClient.InsertRoleCompleted += (s3, e3) => {
                            LoginManager.loading.Hide();
                            if (e3.Result != 0) {
                                LoginManager.loginTip.Show(string.Format("{0} {1}", roleName.Text.Trim(), GetLanguagePackContent(58)), LoginTipMode.TipOnly);
                                MouseButtonEventHandler handler = null;
                                LoginManager.loginTip.OK += handler = delegate {
                                    LoginManager.loginTip.OK -= handler;
                                    Dispose(this, null);
                                    if (RoleCreated != null) { RoleCreated(this, null); }
                                };
                                e1.Handled = true;
                            } else {
                                LoginManager.loginTip.Show(GetLanguagePackContent(38), LoginTipMode.TipOnly);
                            }
                        };
                    } else {
                        LoginManager.loading.Hide();
                        LoginManager.loginTip.Show(GetLanguagePackContent(39), LoginTipMode.TipOnly);
                    }
                    wcfServiceClient.CloseAsync();
                };
            };
            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),
            };
            this.Children.Add(cannel);
            Canvas.SetLeft(cannel, 650);
            Canvas.SetTop(cannel, 547);
            cannel.Click += (s1, e1) => {
                Dispose(this, null);
                if (Cannel != null) {  Cannel(this, e1); }
            };
            base.OnResourceReady(this, e);
        }
Exemplo n.º 4
0
 //删除角色
 void dialog_OK(object s, MouseButtonEventArgs e)
 {
     LoginManager.loginTip.OK -= dialog_OK;
     LoginManager.loading.Show();
     WCFServiceClient wcf2 = new WCFServiceClient();
     wcf2.DeleteRoleAsync(LoginManager.RoleName);
     wcf2.DeleteRoleCompleted += (s2, e2) => {
         if (e2.Result == 1) {
             LoginManager.loginTip.Show(string.Format("{0} {1}", LoginManager.RoleName, GetLanguagePackContent(41)), LoginTipMode.TipOnly);
             for (int i = 0; i <= roleList.GetUpperBound(0); i++) {
                 roleList[i].TextBrush = new SolidColorBrush(Colors.White);
                 roleList[i].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/4.png", UriType.Web), };
             }
             roleList[0].TextBrush = new SolidColorBrush(Color.FromArgb(255, 172, 255, 140));
             roleList[0].Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/20.png", UriType.Web), };
             roleModel.Content = null;
             avatar.Source = null;
             roleName.Text = "";
             occupation.Text = "";
             level.Text = "";
             experience.Text = "";
             map.Text = "";
             time.Text = "";
             ip.Text = "";
             LoadRoles(LoginManager.UserName);
         } else {
             LoginManager.loginTip.Show(GetLanguagePackContent(60), LoginTipMode.TipOnly);
         }
         wcf2.CloseAsync();
         LoginManager.loading.Hide();
     };
 }
Exemplo n.º 5
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();
     };
 }