Exemple #1
0
        public void PageEnter(Room Target)
        {
            CurrentRoom = Target;
            if (CurrentRoom.IsHost(App.CurrentUser))
            {
                App.Server.AcceptCompleted += ServerAccepted;
            }
            ChatWindow.Closing += HideSyncAction;

            RoomNameLabel.Content   = Target.Name;
            BattleTypeLabel.Content = BattleTypeDictionary[Target.BattleType];
            if (CurrentRoom.IsHost(App.CurrentUser))
            {
                ChatWindow.Title       = Target.Name;
                ChatWindow.CurrentRoom = CurrentRoom;
                HostNameBox.Text       = Target.Host.Name;
                HostIntroBox.Text      = Target.Host.Introduction;
                if (Target.Host.Avator != null)
                {
                    using (MemoryStream Stream = new MemoryStream())
                    {
                        Target.Host.Avator.Save(Stream, ImageFormat.Png);
                        BitmapImage Temp = new BitmapImage();
                        Temp.BeginInit();
                        Temp.CacheOption  = BitmapCacheOption.OnLoad;
                        Temp.StreamSource = Stream;
                        Temp.EndInit();
                        AvatorImage.ImageSource = Temp;
                    }
                }
                DescriptionBlock.Text = Target.Description;

                GroupStack.Children.Clear();
                foreach (var Group in Target.Groups)
                {
                    var GroupItem = new Components.GroupItem();
                    GroupItem.JoinSyncAction = delegate(Player TargetUser)
                    {
                        foreach (var TempGroupItem in GroupStack.Children.OfType <Components.GroupItem>())
                        {
                            foreach (var ParticipantItem in TempGroupItem.ParticipantStack.Children.OfType <ParticipantItem>())
                            {
                                if ((ParticipantItem.Participant != null &&
                                     ParticipantItem.Participant.Id != TargetUser.Id) ||
                                    (CurrentRoom.Host.Id == App.CurrentUser.Id && ParticipantItem.Participant == null))
                                {
                                    ParticipantItem.ActionButton.Visibility = Visibility.Hidden;
                                }
                                else
                                {
                                    ParticipantItem.ActionButton.Visibility = Visibility.Visible;
                                }
                            }
                        }
                    };
                    GroupItem.QuitSyncAction = delegate
                    {
                        foreach (var TempGroupItem in GroupStack.Children.OfType <Components.GroupItem>())
                        {
                            foreach (var ParticipantItem in TempGroupItem.ParticipantStack.Children.OfType <ParticipantItem>())
                            {
                                if (ParticipantItem.Participant == null ||
                                    (ParticipantItem.Participant != null && CurrentRoom.Host.Id == App.CurrentUser.Id))
                                {
                                    ParticipantItem.ActionButton.Visibility = Visibility.Visible;
                                }
                                else
                                {
                                    ParticipantItem.ActionButton.Visibility = Visibility.Hidden;
                                }
                            }
                        }
                    };
                    GroupItem.Init(Group, Target);
                    GroupItem.Padding = new Thickness(0, 10, 0, 0);
                    GroupStack.Children.Add(GroupItem);
                }
            }
            else if (App.Client["ReadyToReceive"] != null && (bool)App.Client["ReadyToReceive"])
            {
                App.Client.Send(Encoding.UTF8.GetBytes("ReadyToReceive"));
                App.Client["ReadyToReceive"] = null;
                App.Client.ReceiveCompleted += BeginUpdateRoom;
            }
            else
            {
                App.Client.ReceiveCompleted += ReadyToUpdateRoom;
            }

            DoubleAnimation OpacityAnimation = new DoubleAnimation()
            {
                From           = 0,
                To             = 1,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };
            ThicknessAnimation MarginAnimation = new ThicknessAnimation()
            {
                From = new Thickness(
                    TitleGrid.Margin.Left - 50,
                    TitleGrid.Margin.Top,
                    TitleGrid.Margin.Right + 50,
                    TitleGrid.Margin.Bottom),
                To             = TitleGrid.Margin,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };

            MarginAnimation.Completed += delegate
            {
                if (CurrentRoom.IsHost(App.CurrentUser))
                {
                    ContentGrid.Visibility = Visibility.Visible;
                    ContentGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                    {
                        From           = 0,
                        To             = 1,
                        Duration       = TimeSpan.FromSeconds(0.75),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                    ContentGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                    {
                        From = new Thickness(
                            ContentGrid.Margin.Left - 50,
                            ContentGrid.Margin.Top,
                            ContentGrid.Margin.Right + 50,
                            ContentGrid.Margin.Bottom),
                        To             = ContentGrid.Margin,
                        Duration       = TimeSpan.FromSeconds(0.75),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                }
                else
                {
                    WaitingGrid.Visibility = Visibility.Visible;
                    WaitingGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                    {
                        From           = 0,
                        To             = 1,
                        Duration       = TimeSpan.FromSeconds(0.75),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                    WaitingGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                    {
                        From = new Thickness(
                            WaitingGrid.Margin.Left - 50,
                            WaitingGrid.Margin.Top,
                            WaitingGrid.Margin.Right + 50,
                            WaitingGrid.Margin.Bottom),
                        To             = WaitingGrid.Margin,
                        Duration       = TimeSpan.FromSeconds(0.75),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    });
                }
            };
            TitleGrid.BeginAnimation(OpacityProperty, OpacityAnimation);
            TitleGrid.BeginAnimation(MarginProperty, MarginAnimation);
        }
Exemple #2
0
        private void EndWaiting(Room Target)
        {
            ChatWindow.Title        = Target.Name;
            ChatWindow.CurrentRoom  = CurrentRoom;
            RoomNameLabel.Content   = Target.Name;
            BattleTypeLabel.Content = BattleTypeDictionary[Target.BattleType];
            HostNameBox.Text        = Target.Host.Name;
            HostIntroBox.Text       = Target.Host.Introduction;
            if (Target.Host.Avator != null)
            {
                using (MemoryStream Stream = new MemoryStream())
                {
                    Target.Host.Avator.Save(Stream, ImageFormat.Png);
                    BitmapImage Temp = new BitmapImage();
                    Temp.BeginInit();
                    Temp.CacheOption  = BitmapCacheOption.OnLoad;
                    Temp.StreamSource = Stream;
                    Temp.EndInit();
                    AvatorImage.ImageSource = Temp;
                }
            }
            DescriptionBlock.Text = Target.Description;

            foreach (var Group in Target.Groups)
            {
                var GroupItem = new Components.GroupItem();
                GroupItem.JoinSyncAction = delegate(Player TargetUser)
                {
                    foreach (var TempGroupItem in GroupStack.Children.OfType <Components.GroupItem>())
                    {
                        foreach (var ParticipantItem in TempGroupItem.ParticipantStack.Children.OfType <ParticipantItem>())
                        {
                            if ((ParticipantItem.Participant != null && ParticipantItem.Participant.Id != TargetUser.Id) ||
                                (CurrentRoom.Host.Id == App.CurrentUser.Id && ParticipantItem.Participant == null))
                            {
                                ParticipantItem.ActionButton.Visibility = Visibility.Hidden;
                            }
                            else
                            {
                                ParticipantItem.ActionButton.Visibility = Visibility.Visible;
                            }
                        }
                    }
                };
                GroupItem.QuitSyncAction = delegate
                {
                    foreach (var TempGroupItem in GroupStack.Children.OfType <Components.GroupItem>())
                    {
                        foreach (var ParticipantItem in TempGroupItem.ParticipantStack.Children.OfType <ParticipantItem>())
                        {
                            if (ParticipantItem.Participant == null ||
                                (ParticipantItem.Participant != null && CurrentRoom.Host.Id == App.CurrentUser.Id))
                            {
                                ParticipantItem.ActionButton.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                ParticipantItem.ActionButton.Visibility = Visibility.Hidden;
                            }
                        }
                    }
                };
                GroupItem.Init(Group, Target);
                GroupItem.Padding = new Thickness(0, 10, 0, 0);
                GroupStack.Children.Add(GroupItem);
            }

            DispatcherTimer Timer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(0.5)
            };

            Timer.Tick += delegate
            {
                WaitingGrid.Visibility = Visibility.Hidden;
                ContentGrid.Visibility = Visibility.Visible;
                ContentGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 0,
                    To             = 1,
                    Duration       = TimeSpan.FromSeconds(0.5),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseOut
                    }
                });
                ContentGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                {
                    From = new Thickness(
                        ContentGrid.Margin.Left - 50,
                        ContentGrid.Margin.Top,
                        ContentGrid.Margin.Right + 50,
                        ContentGrid.Margin.Bottom),
                    To             = ContentGrid.Margin,
                    Duration       = TimeSpan.FromSeconds(0.5),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseOut
                    }
                });
                Timer.Stop();
            };
            WaitingGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = 1,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                }
            });
            WaitingGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
            {
                From = WaitingGrid.Margin,
                To   = new Thickness(
                    WaitingGrid.Margin.Left - 50,
                    WaitingGrid.Margin.Top,
                    WaitingGrid.Margin.Right + 50,
                    WaitingGrid.Margin.Bottom),
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                }
            });
            Timer.Start();
        }