public void PageEnter() { 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 { 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 } }); }; TitleGrid.BeginAnimation(OpacityProperty, OpacityAnimation); TitleGrid.BeginAnimation(MarginProperty, MarginAnimation); }
private void PaggingTimer_Tick(object sender, EventArgs e) { ContentGrid.Children.Clear(); BindPage(GetNextPageData()); DoubleAnimation opacityAnimation2 = new DoubleAnimation(); opacityAnimation2.From = 0; //透明度初始值 opacityAnimation2.To = 1; //透明度值 opacityAnimation2.Duration = new Duration(TimeSpan.FromSeconds(2)); ContentGrid.BeginAnimation(Grid.OpacityProperty, opacityAnimation2); }
public void Expand() { ((SolidColorBrush)EllipseBackground.Fill).Color = Colors.Black; DiceText.Visibility = Visibility.Hidden; DispatcherTimer Timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(0.3) }; Timer.Tick += delegate { ContentGrid.Visibility = Visibility.Visible; DoubleAnimation OpacityAnimation = new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }; OpacityAnimation.Completed += delegate { Begin(); }; ContentGrid.BeginAnimation(OpacityProperty, OpacityAnimation); Timer.Stop(); }; this.BeginAnimation(HeightProperty, new DoubleAnimation() { From = 0, To = 200, Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); this.BeginAnimation(WidthProperty, new DoubleAnimation() { From = 0, To = 200, Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); Timer.Start(); }
//Close Window with fade out animation private async void CloseSnap(bool result, int delay) { DoubleAnimation anim = new DoubleAnimation(0, TimeSpan.FromSeconds(0.25)); anim.Completed += delegate { try { DialogResult = result; } catch { // ignored } }; anim.From = ContentGrid.Opacity; anim.To = 0; //Wait delay (ms) and then begin animation await Task.Delay(TimeSpan.FromMilliseconds(delay)); ContentGrid.BeginAnimation(OpacityProperty, anim); }
private async Task Logout() { var hiddenDaV = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.5))); var showDaV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5))); var unscratchWidthDaV = new DoubleAnimation(673, 473, new Duration(TimeSpan.FromSeconds(0.25))); var unscratchHeightDaV = new DoubleAnimation(328, 228, new Duration(TimeSpan.FromSeconds(0.25))); UserName.Text = Connection.Logout(); UpdateListBoxContent($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {UserName.Text} 在服务端注销", null, false); await Dispatcher.BeginInvoke(new Action(() => { LoginGrid.Visibility = Visibility.Visible; ContentGrid.Visibility = Visibility.Hidden; Operations.Items.Clear(); })); ContentGrid.BeginAnimation(OpacityProperty, hiddenDaV); BeginAnimation(WidthProperty, unscratchWidthDaV); await Task.Run(() => { Thread.Sleep(300); }); BeginAnimation(HeightProperty, unscratchHeightDaV); LoginGrid.BeginAnimation(OpacityProperty, showDaV); }
public void Collapse() { this.BeginAnimation(HeightProperty, new DoubleAnimation() { From = 200, To = 0, Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }); this.BeginAnimation(WidthProperty, new DoubleAnimation() { From = 200, To = 0, Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }); DoubleAnimation OpacityAnimation = new DoubleAnimation() { From = 1, To = 0, Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }; OpacityAnimation.Completed += delegate { ContentGrid.Visibility = Visibility.Hidden; }; ContentGrid.BeginAnimation(OpacityProperty, OpacityAnimation); }
private void OnOpened(object sender, EventArgs e) { Keyboard.Focus(SearchBox); switch (taskbarEdge) { case Edge.Top: Placement = PlacementMode.Bottom; PopupBorder.BorderThickness = new Thickness(1); PopupMarginBorder.Margin = new Thickness(10, 0, 10, 10); break; case Edge.Left: Placement = PlacementMode.Right; PopupBorder.BorderThickness = new Thickness(1); PopupMarginBorder.Margin = new Thickness(0, 10, 10, 10); break; case Edge.Right: Placement = PlacementMode.Left; PopupBorder.BorderThickness = new Thickness(1); PopupMarginBorder.Margin = new Thickness(10, 10, 0, 10); break; case Edge.Bottom: Placement = PlacementMode.Top; PopupBorder.BorderThickness = new Thickness(1, 1, 1, 0); PopupMarginBorder.Margin = new Thickness(10, 10, 10, 0); break; } Height = Properties.Settings.Default.popupSize.Height; Width = Properties.Settings.Default.popupSize.Width; QuinticEase ease = new QuinticEase { EasingMode = EasingMode.EaseOut }; int modifier = taskbarEdge == Edge.Right || taskbarEdge == Edge.Bottom ? 1 : -1; Duration duration = TimeSpan.FromSeconds(Properties.Settings.Default.isAnimationsDisabled ? 0 : 0.4); DoubleAnimation outer = new DoubleAnimation(modifier * 150, 0, duration) { EasingFunction = ease }; DependencyProperty outerProp = taskbarEdge == Edge.Bottom || taskbarEdge == Edge.Top ? TranslateTransform.YProperty : TranslateTransform.XProperty; translateTransform?.BeginAnimation(outerProp, outer); DoubleAnimation opacity = new DoubleAnimation(0, 1, duration) { EasingFunction = ease }; PopupBorder?.BeginAnimation(OpacityProperty, opacity); duration = TimeSpan.FromSeconds(Properties.Settings.Default.isAnimationsDisabled ? 0 : 0.8); ThicknessAnimation inner = new ThicknessAnimation(new Thickness(0), duration) { EasingFunction = ease }; if (taskbarEdge == Edge.Top) { inner.From = new Thickness(0, -50, 0, 50); } else if (taskbarEdge == Edge.Right) { inner.From = new Thickness(50, 0, -50, 0); } else if (taskbarEdge == Edge.Bottom) { inner.From = new Thickness(0, 50, 0, -50); } else if (taskbarEdge == Edge.Left) { inner.From = new Thickness(-50, 0, 50, 0); } ContentGrid?.BeginAnimation(MarginProperty, inner); }
public void PageLeave() { DoubleAnimation OpacityAnimation = new DoubleAnimation() { From = 1, To = 0, Duration = TimeSpan.FromSeconds(0.75), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }; ThicknessAnimation MarginAnimation = new ThicknessAnimation() { From = ContentGrid.Margin, To = new Thickness( ContentGrid.Margin.Left + 50, ContentGrid.Margin.Top, ContentGrid.Margin.Right - 50, ContentGrid.Margin.Bottom), Duration = TimeSpan.FromSeconds(0.75), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }; MarginAnimation.Completed += delegate { DispatcherTimer Timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(0.5) }; Timer.Tick += delegate { DoubleAnimation FadeAnimation = new DoubleAnimation() { From = 1, To = 0, Duration = TimeSpan.FromSeconds(1), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }; FadeAnimation.Completed += delegate { LeaveAction?.Invoke(); }; this.BeginAnimation(OpacityProperty, FadeAnimation); Timer.Stop(); }; TitleGrid.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 1, To = 0, Duration = TimeSpan.FromSeconds(0.75), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }); TitleGrid.BeginAnimation(MarginProperty, new ThicknessAnimation() { From = TitleGrid.Margin, To = new Thickness( TitleGrid.Margin.Left + 50, TitleGrid.Margin.Top, TitleGrid.Margin.Right - 50, TitleGrid.Margin.Bottom), Duration = TimeSpan.FromSeconds(0.75), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }); Timer.Start(); }; ContentGrid.BeginAnimation(OpacityProperty, OpacityAnimation); ContentGrid.BeginAnimation(MarginProperty, MarginAnimation); }
public void PageEnter(Battlefield Battlefield) { this.Battlefield = Battlefield; for (int i = 0; i < ContentGrid.Children.Count; i++) { var NaviControl = new NavigationControl() { Index = i, Height = 10, Width = 10, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(-5 * ContentGrid.Children.Count - 2.5 * (ContentGrid.Children.Count - 1) + 15 * i, 0, 5 * ContentGrid.Children.Count + 2.5 * (ContentGrid.Children.Count - 1) - 15 * i, 0), RelatedGrid = ContentGrid.Children[i] as Grid }; NaviControl.SelectAction = delegate { if (NavigationGrid.Children.OfType <NavigationControl>().Any(O => O.IsSelected)) { var Before = NavigationGrid.Children.OfType <NavigationControl>().First(O => O.IsSelected); var After = NaviControl; var Timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) }; Timer.Tick += delegate { Before.RelatedGrid.Visibility = Visibility.Hidden; After.RelatedGrid.Visibility = Visibility.Visible; After.RelatedGrid.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(1), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); After.RelatedGrid.BeginAnimation(MarginProperty, new ThicknessAnimation() { From = After.Index >= Before.Index ? new Thickness( After.RelatedGrid.Margin.Left - 100, After.RelatedGrid.Margin.Top, After.RelatedGrid.Margin.Right + 100, After.RelatedGrid.Margin.Bottom) : new Thickness( After.RelatedGrid.Margin.Left + 100, After.RelatedGrid.Margin.Top, After.RelatedGrid.Margin.Right - 100, After.RelatedGrid.Margin.Bottom), To = After.RelatedGrid.Margin, Duration = TimeSpan.FromSeconds(1), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut }, }); Timer.Stop(); }; Before.RelatedGrid.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 1, To = 0, Duration = TimeSpan.FromSeconds(1), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn } }); Before.RelatedGrid.BeginAnimation(MarginProperty, new ThicknessAnimation() { From = Before.RelatedGrid.Margin, To = After.Index >= Before.Index ? new Thickness( Before.RelatedGrid.Margin.Left + 100, Before.RelatedGrid.Margin.Top, Before.RelatedGrid.Margin.Right - 100, Before.RelatedGrid.Margin.Bottom) : new Thickness( Before.RelatedGrid.Margin.Left - 100, Before.RelatedGrid.Margin.Top, Before.RelatedGrid.Margin.Right + 100, Before.RelatedGrid.Margin.Bottom), Duration = TimeSpan.FromSeconds(1), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn }, FillBehavior = FillBehavior.Stop }); Timer.Start(); Before.Unselect(); } else { var After = NaviControl; After.RelatedGrid.Visibility = Visibility.Visible; After.RelatedGrid.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(1), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); After.RelatedGrid.BeginAnimation(MarginProperty, new ThicknessAnimation() { From = new Thickness( After.RelatedGrid.Margin.Left - 100, After.RelatedGrid.Margin.Top, After.RelatedGrid.Margin.Right + 100, After.RelatedGrid.Margin.Bottom), To = After.RelatedGrid.Margin, Duration = TimeSpan.FromSeconds(1), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); } if (NavigationGrid.Children.OfType <NavigationControl>().All(O => O.IsViewed)) { ContinueButton.IsEnabled = true; } }; NavigationGrid.Children.Add(NaviControl); } WinnersDisplayPanel.Width = 150 * Battlefield.GetWinnerGroup().Participants.Length; Battlefield.GetWinnerGroup().Participants.ToList() .ForEach(O => { var TempControl = new ParticipantDisplayXLarge() { Height = 150, Width = 150, Opacity = 0 }; TempControl.Init(O); WinnersDisplayPanel.Children.Add(TempControl); }); Battlefield.SetStatisticsRatio(); PlayersListBox.ItemsSource = Battlefield.Room.Groups.SelectMany(O => O.Participants); PlayersListBox.SelectedIndex = 0; 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 { DispatcherTimer Timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(0.75) }; Timer.Tick += delegate { ShowWinners(); Timer.Stop(); }; 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 } }); ((NavigationControl)NavigationGrid.Children[0]).Select(); Timer.Start(); }; TitleGrid.BeginAnimation(OpacityProperty, OpacityAnimation); TitleGrid.BeginAnimation(MarginProperty, MarginAnimation); }
public void PageEnter() { BattleTypeComboBox.Items.Add(new BattleTypeItem() { Height = 100, Width = 780, Image = { Source = Resources["OneVsOne"] as BitmapImage }, TypeText = { Text = "One Vs One" }, DescriptionText = { Text = "进行单独的一对一对决。" }, BattleType = BattleType.OneVsOne }); BattleTypeComboBox.Items.Add(new BattleTypeItem() { Height = 100, Width = 780, Image = { Source = Resources["TriangleMess"] as BitmapImage }, TypeText = { Text = "Triangle Mess" }, DescriptionText = { Text = "进行三角混战的骰子对战。" }, BattleType = BattleType.TriangleMess }); BattleTypeComboBox.Items.Add(new BattleTypeItem() { Height = 100, Width = 780, Image = { Source = Resources["SquareMess"] as BitmapImage }, TypeText = { Text = "Square Mess" }, DescriptionText = { Text = "进行四角混战的骰子对战。" }, BattleType = BattleType.SquareMess }); BattleTypeComboBox.Items.Add(new BattleTypeItem() { Height = 100, Width = 780, Image = { Source = Resources["TwinningFight"] as BitmapImage }, TypeText = { Text = "Twinning Fight" }, DescriptionText = { Text = "结成一个二人组与对方对抗。" }, BattleType = BattleType.TwinningFight }); 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 { 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 } }); }; TitleGrid.BeginAnimation(OpacityProperty, OpacityAnimation); TitleGrid.BeginAnimation(MarginProperty, MarginAnimation); }
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); }
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(); }
private async void LoginButton_ClickAsync(object sender, RoutedEventArgs e) { LoginButton.IsEnabled = false; var res = await Connection.Login(UserName.Text, Password.Password); switch (res) { case 1: { MessageBox.Show("用户名或密码错误", "提示", MessageBoxButton.OK, MessageBoxImage.Error); break; } default: { if (res != 0) { MessageBox.Show("未知错误", "提示", MessageBoxButton.OK, MessageBoxImage.Error); } break; } } LoginButton.IsEnabled = true; if (res != 0) { return; } UpdateListBoxContent( $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {UserHelper.CurrentUser.UserName} 欢迎登录 hjudge 服务端", null, false); UserName.Clear(); Password.Password = string.Empty; LoginGrid.Visibility = Visibility.Hidden; ContentGrid.Visibility = Visibility.Visible; var hiddenDaV = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.5))); var showDaV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5))); var scratchWidthDaV = new DoubleAnimation(473, 673, new Duration(TimeSpan.FromSeconds(0.25))); var scratchHeightDaV = new DoubleAnimation(228, 328, new Duration(TimeSpan.FromSeconds(0.25))); LoginGrid.BeginAnimation(OpacityProperty, hiddenDaV); BeginAnimation(WidthProperty, scratchWidthDaV); await Task.Run(() => { Thread.Sleep(300); }); BeginAnimation(HeightProperty, scratchHeightDaV); ContentGrid.BeginAnimation(OpacityProperty, showDaV); switch (UserHelper.CurrentUser.Type) { case 1: SetEnvironmentForBoss(); break; case 2: SetEnvironmentForAdministrator(); break; case 3: SetEnvironmentForTeacher(); break; case 4: SetEnvironmentForStudent(); break; } }