private void TabItem_PreviewMouseDown(object sender, MouseButtonEventArgs e) { var selected = sender as TabItem; if (selected != null) { selected.IsSelected = true; } if (Math.Abs(_border.ActualHeight - 100) < 0) { return; } var animation = new DoubleAnimation(_border.ActualHeight, 100, new Duration(new TimeSpan(0, 0, 0, 1))); animation.EasingFunction = new PowerEase() { Power = 8 }; _border.BeginAnimation(HeightProperty, animation); var opacityAnimation = new DoubleAnimation(_border.Opacity, 1, new Duration(new TimeSpan(0, 0, 0, 1))); opacityAnimation.EasingFunction = new PowerEase() { Power = 8 }; _border.BeginAnimation(OpacityProperty, opacityAnimation); var visibilityAnimation = new ObjectAnimationUsingKeyFrames(); visibilityAnimation.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5)))); _button.BeginAnimation(VisibilityProperty, visibilityAnimation); }
/// <summary> /// Warn user if they try to click on screenshot /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onClick(object sender, EventArgs e) { var visKeyFrames = new ObjectKeyFrameCollection { new DiscreteObjectKeyFrame { KeyTime = TimeSpan.FromSeconds(0), Value = Visibility.Visible }, new DiscreteObjectKeyFrame { KeyTime = TimeSpan.FromSeconds(2.5), Value = Visibility.Collapsed } }; var opKeyFrames = new DoubleKeyFrameCollection { new DiscreteDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(0), Value = 1 }, new LinearDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(2), Value = 1 }, new LinearDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(2.5), Value = 0 }, }; bdClick.BeginAnimation(TextBlock.VisibilityProperty, new ObjectAnimationUsingKeyFrames() { KeyFrames = visKeyFrames }); bdClick.BeginAnimation(TextBlock.OpacityProperty, new DoubleAnimationUsingKeyFrames() { KeyFrames = opKeyFrames }); }
private void OnTabSelected(object s, RoutedEventArgs e) { SelectedItem = (TabSelectorItem)e.OriginalSource; var tabStep = ActualWidth / Tabs.Count; var leftMargin = 0.0; var trace = 0; foreach (var t in Tabs) { if (Equals(t, e.OriginalSource)) { leftMargin = trace * tabStep; } else { t.IsSelected = false; } trace++; } PART_activeindicator.BeginAnimation(WidthProperty, new DoubleAnimation( tabStep, new Duration(TimeSpan.FromMilliseconds(300))) { }); PART_activeindicator.BeginAnimation(MarginProperty, new ThicknessAnimation( new Thickness(leftMargin, 0, 0, 0), new Duration(TimeSpan.FromMilliseconds(300))) { EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }, }); //SelectedItem.DocumentTab.RequestViewTab(); RaiseEvent(new RoutedEventArgs(TabSelectedEvent, e.OriginalSource)); }
/// <summary> /// Shows flyout. /// </summary> private void ShowInternal() { if (isOpening) { return; } // Try get currently focused element, use it to restore focus once flyout is closed var window = Window.GetWindow(this); previouslyFocusedElement = window != null?FocusManager.GetFocusedElement(window) : null; isOpening = true; Visibility = Visibility.Visible; // Automatically focus flyout. Do not set focus once expanded, as it will override custom focus from within content control, if set // If flyout is not focused, escape key will not work. Focus(); if (contentSite != null) { contentSite.BeginAnimation(MarginProperty, InAnimation); } else { isOpening = false; } }
async private void Add_Helper_Number(double value) { Border border = new Border() { Style = FindResource("BorderForHelpLabel") as Style, Opacity = 0 }; Label label = new Label() { Content = value.ToString().Replace('.', ','), Style = FindResource("HelpBottomLabel") as Style }; label.MouseDoubleClick += Number_MouseDoubleClick; border.Child = label; SavedNumbersPanel.Children.Add(border); await Task.Delay(20); var actualWidth = border.ActualWidth; SavedNumbersPanel.Children.Remove(border); StackHelpers.Children.Add(border); DoubleAnimation da = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.3))); border.BeginAnimation(OpacityProperty, da); DoubleAnimation da1 = new DoubleAnimation(0, actualWidth, new Duration(TimeSpan.FromSeconds(0.25))); border.BeginAnimation(WidthProperty, da1); }
private void Header_MouseEnter(object sender, MouseEventArgs e) { DoubleAnimation da = new DoubleAnimation { Duration = TimeSpan.FromMilliseconds(0), To = 8, }; header.BeginAnimation(Orientation == Orientation.Vertical ? Border.HeightProperty : Border.WidthProperty, da, HandoffBehavior.SnapshotAndReplace); }
public void BeginEnterAnimation() { _notificationsCollection.Add(_border); _border.BeginAnimation(UIElement.OpacityProperty, _enterAnimation); if (_type != DialogType.BusyWaiting && _type != DialogType.ProgressManualUpdate) { _dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); _dispatcherTimer.Tick += dispatcherTimer_Tick; _interval = 100; _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, _interval); _progressBar.Value = 0; _progressBar.Maximum = (int)_time; _dispatcherTimer.Start(); } }
public static void BeginAnimation(Border _BS, byte _Size, byte _TOSize) { DoubleAnimation _DABorder = new DoubleAnimation { From = _Size, To = _TOSize, Duration = TimeSpan.FromSeconds(0.3) }; _BS.Dispatcher.Invoke(new Action(delegate { _BS.BeginAnimation(Border.WidthProperty, _DABorder); _BS.BeginAnimation(Border.HeightProperty, _DABorder); })); }
private void ExpendAnimal(double k1, double k2, Border b = null) { if (dgObject.SelectedItem != null) { TB_PROJECT proj = dgObject.SelectedItem as TB_PROJECT; ucPreview uc = new ucPreview(proj.Id); this.ExpenseListPanel.Children.Clear(); this.ExpenseListPanel.Children.Add(uc); if (b == null) { if (this.spBorder.Width == k2) { DoubleAnimation wAnimation = new DoubleAnimation(k1, k2, new Duration(TimeSpan.FromSeconds(0.3))); this.spBorder.BeginAnimation(DockPanel.WidthProperty, wAnimation, HandoffBehavior.Compose); } } else { if (b.Width == k1) { DoubleAnimation wAnimation = new DoubleAnimation(k1, k2, new Duration(TimeSpan.FromSeconds(0.3))); b.BeginAnimation(DockPanel.WidthProperty, wAnimation, HandoffBehavior.Compose); } else if (this.spBorder.Width == k2) { DoubleAnimation wAnimation = new DoubleAnimation(k2, k1, new Duration(TimeSpan.FromSeconds(0.3))); this.spBorder.BeginAnimation(DockPanel.WidthProperty, wAnimation, HandoffBehavior.Compose); } } } }
/* * 查看大图 * * 加载动画 */ public static void showAnimation(Border borderBg, Canvas currElement, DControlDto ctl, double toTranslateTransformX, double toTranslateTransformY) { //淡入 borderBg.RenderTransformOrigin = new Point(0.5, 0.5); DoubleAnimation da = new DoubleAnimation(0, borderBg.Opacity, new Duration(TimeSpan.FromMilliseconds(300))); borderBg.BeginAnimation(UIElement.OpacityProperty, da); //放大 TransformGroup group = (TransformGroup)currElement.RenderTransform; ScaleTransform scaleTransform = TransformGroupUtil.GetScaleTransform(group); DoubleAnimation da1 = new DoubleAnimation(scaleTransform.ScaleX, 1.0, new Duration(TimeSpan.FromMilliseconds(300))); scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1); DoubleAnimation da2 = new DoubleAnimation(scaleTransform.ScaleY, 1.0, new Duration(TimeSpan.FromMilliseconds(300))); scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da2); // 平移 TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group); DoubleAnimation da3 = new DoubleAnimation(0, toTranslateTransformX, new Duration(TimeSpan.FromMilliseconds(300))); translateTransform.BeginAnimation(TranslateTransform.XProperty, da3); DoubleAnimation da4 = new DoubleAnimation(0, toTranslateTransformY, new Duration(TimeSpan.FromMilliseconds(300))); translateTransform.BeginAnimation(TranslateTransform.YProperty, da4); }
/// <summary> /// 显示对话框 /// </summary> /// <param name="owner"></param> /// <returns></returns> public bool Invoke(string message, string caption, Window owner = null) { // 设置父窗口 Owner = owner; // 初始化数据 _message = message; _caption = caption; // 设置数据上下文 DataContext = this; if (Owner != null) { // 获取主Grid _mainGrid = GetChildObjects <Grid>(Owner, null).FirstOrDefault(); if (null == _mainGrid) { return(false); } // 初始化遮罩 var marking = new Border { Name = "Masking", BorderThickness = new Thickness(0), Opacity = 0.0, Background = Brushes.Black }; marking.SetBinding(WidthProperty, new Binding("Width") { Source = _mainGrid }); marking.SetBinding(HeightProperty, new Binding("Height") { Source = _mainGrid }); // 将遮罩置顶 Panel.SetZIndex(marking, 99); // 设置遮罩在Grid的布局 if (_mainGrid.RowDefinitions.Count > 0) { Grid.SetRowSpan(marking, _mainGrid.RowDefinitions.Count); } if (_mainGrid.ColumnDefinitions.Count > 0) { Grid.SetColumnSpan(marking, _mainGrid.ColumnDefinitions.Count); } _mainGrid.Children.Add(marking); // 开启淡入效果 marking.BeginAnimation(Border.OpacityProperty, new DoubleAnimation(0.5, new Duration(TimeSpan.FromMilliseconds(500)))); } else { WindowStartupLocation = WindowStartupLocation.CenterScreen; } return(ShowDialog().Value); }
/// <summary> /// This function will change the state of the playing letter /// </summary> public void MouseEnterLetter(object sender, EventArgs e) { Border bdrPlayingLetter = (Border)sender; Label lblPlayingLetter = (Label)bdrPlayingLetter.Child; var bc = new BrushConverter(); DoubleAnimation da = new DoubleAnimation { From = 85, To = 95, Duration = TimeSpan.FromMilliseconds(100) }; DoubleAnimation daFontSize = new DoubleAnimation { From = 50, To = 60, Duration = TimeSpan.FromMilliseconds(100) }; ThicknessAnimation ta = new ThicknessAnimation { From = new Thickness(10), To = new Thickness(5), Duration = TimeSpan.FromMilliseconds(100) }; if (bdrPlayingLetter.Background == Brushes.Red) { // Do no thing } else if (bdrPlayingLetter.Background.ToString() == "#FF00E676") { // Do no thing } else { bdrPlayingLetter.Background = (Brush)bc.ConvertFrom("#EEEEEE"); bdrPlayingLetter.BeginAnimation(Border.HeightProperty, da); bdrPlayingLetter.BeginAnimation(Border.WidthProperty, da); bdrPlayingLetter.BeginAnimation(Border.MarginProperty, ta); lblPlayingLetter.BeginAnimation(Label.FontSizeProperty, daFontSize); } }
private void TabItem_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (sender is TabItem selected) { selected.IsSelected = true; } if (Math.Abs(_border.ActualHeight - 100) < 0) { return; } var animation = new DoubleAnimation(_border.ActualHeight, 100, new Duration(new TimeSpan(0, 0, 0, 1))) { EasingFunction = new PowerEase { Power = 8 } }; _border.BeginAnimation(HeightProperty, animation); var opacityAnimation = new DoubleAnimation(_border.Opacity, 1, new Duration(new TimeSpan(0, 0, 0, 1))) { EasingFunction = new PowerEase { Power = 8 } }; _border.BeginAnimation(OpacityProperty, opacityAnimation); var visibilityAnimation = new ObjectAnimationUsingKeyFrames(); visibilityAnimation.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5)))); _hideButton.BeginAnimation(VisibilityProperty, visibilityAnimation); //Marging = 5,5,0,-1 var marginAnimation = new ThicknessAnimation(_tabPanel.Margin, new Thickness(5, 5, 0, -1), new Duration(new TimeSpan(0, 0, 0, 0, 1))) { EasingFunction = new PowerEase { Power = 8 } }; _tabPanel.BeginAnimation(MarginProperty, marginAnimation); }
} // method // кнопка добавления для блюд с гарнирами private void setAddButtonState(bool setActive) { if (_hasGarnishes == false) { return; } // активация кнопки if (setActive == true) { // _btnAddDish.Visibility = Visibility.Visible; // _btnInvitation.Visibility = Visibility.Hidden; // если кнопка Добавить неактивна, то активировать if (_btnAddDish.Opacity == 0d) { _isAnimating = _isAnimating.SetBit(2); _btnAddDish.BeginAnimation(UIElement.OpacityProperty, _daAddBtnShow); _btnInvitation.BeginAnimation(UIElement.OpacityProperty, _daAddBtnHide); } // иначе (если в том же блюде) просто анимировать текст else { animateAddButtonAfterSelectGarnish(); } } // деактивация кнопки else { // если была активирована полностью, то деактивировать с анимацией //if (!_isAnimating.IsSetBit(2) && !_isAnimating.IsSetBit(3)) //{ _isAnimating = _isAnimating.SetBit(2); _btnAddDish.BeginAnimation(UIElement.OpacityProperty, _daAddBtnHide); _btnInvitation.BeginAnimation(UIElement.OpacityProperty, _daAddBtnShow); //} //// а если была активирована не полностью, то деактивировать без анимации //else //{ // _btnAddDish.Opacity = 0d; // _btnInvitation.Opacity = 1d; //} } } // method
/* * 关闭大图 * * 动画,回到原位,移除大图 */ public static void closeAnimation(Canvas bigImageCanvas, Border borderBg, Canvas innerCanvas, DControlDto ctl, Grid mainContainer) { //1.淡出 borderBg.RenderTransformOrigin = new Point(0.5, 0.5); DoubleAnimation da = new DoubleAnimation(borderBg.Opacity, 0, new Duration(TimeSpan.FromMilliseconds(300))); borderBg.BeginAnimation(UIElement.OpacityProperty, da); //触摸缩放后 double backToScaleX = ctl.width / innerCanvas.Width; double backToScaleY = ctl.height / innerCanvas.Height; Transform transform = innerCanvas.RenderTransform; TransformGroup group = null; if (transform is TransformGroup) { group = (TransformGroup)innerCanvas.RenderTransform; } else { group = new TransformGroup(); TranslateTransform translateTransform1 = new TranslateTransform(); MatrixTransform matrixTransform = (MatrixTransform)innerCanvas.RenderTransform; translateTransform1.X = matrixTransform.Matrix.OffsetX; translateTransform1.Y = matrixTransform.Matrix.OffsetY; group.Children.Add(translateTransform1); ScaleTransform scaleTransform1 = new ScaleTransform(); scaleTransform1.ScaleX = matrixTransform.Matrix.M11; scaleTransform1.ScaleY = matrixTransform.Matrix.M22; group.Children.Add(scaleTransform1); innerCanvas.RenderTransform = group; } //2.缩放 ScaleTransform scaleTransform = TransformGroupUtil.GetScaleTransform(group); DoubleAnimation da1 = new DoubleAnimation(scaleTransform.ScaleX, backToScaleX, new Duration(TimeSpan.FromMilliseconds(300))); scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1); DoubleAnimation da2 = new DoubleAnimation(scaleTransform.ScaleY, backToScaleY, new Duration(TimeSpan.FromMilliseconds(300))); scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da2); // 3.平移 TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group); DoubleAnimation da3 = new DoubleAnimation(translateTransform.X, 0, new Duration(TimeSpan.FromMilliseconds(300))); translateTransform.BeginAnimation(TranslateTransform.XProperty, da3); DoubleAnimation da4 = new DoubleAnimation(translateTransform.Y, 0, new Duration(TimeSpan.FromMilliseconds(300))); da4.Completed += (sender, e) => closeBigImageAnimation_Completed(bigImageCanvas, mainContainer); translateTransform.BeginAnimation(TranslateTransform.YProperty, da4); }
protected override void OnContentChanged(object oldContent, object newContent) { if (paintArea != null && mainContent != null) { borderSeparator.BeginAnimation(OpacityProperty, CreateSeparatorAnimation(0.0, 1.0, Separator_Displayed)); BeginAnimateContentReplacement(); } base.OnContentChanged(oldContent, newContent); }
async private void Remove_SavedNumber_Click(object sender, MouseButtonEventArgs e) { Label label = sender as Label; StackPanel sp = label.Parent as StackPanel; Border border = sp.Parent as Border; SqliteDataAccess.Delete_Number(((Label)sp.Children[0]).Content.ToString()); Console.WriteLine(border.ActualWidth); DoubleAnimation doubleAnimation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.3))); DoubleAnimation doubleAnimation1 = new DoubleAnimation(border.ActualWidth, 0, new Duration(TimeSpan.FromSeconds(0.3))); border.BeginAnimation(OpacityProperty, doubleAnimation); border.BeginAnimation(WidthProperty, doubleAnimation1); await Task.Delay(300); SavedNumbersPanel.Children.Remove(border); }
private void Control_Panel_Animation_func(Border control_figure, double to, double duration) { var Animation = new DoubleAnimation { From = control_figure.Height, To = to, Duration = TimeSpan.FromMilliseconds(duration) }; control_figure.BeginAnimation(HeightProperty, Animation); }
private void HideAppMenu() { Border sp = AppMenu as Border; DoubleAnimation db = new DoubleAnimation(); //db.From = 12; db.To = 25; db.Duration = TimeSpan.FromSeconds(0.5); db.AutoReverse = false; db.RepeatBehavior = new RepeatBehavior(1); sp.BeginAnimation(StackPanel.HeightProperty, db); }
private void StackPanel_MouseLeave(object sender, MouseEventArgs e) { Border sp = sender as Border; DoubleAnimation db = new DoubleAnimation(); //db.From = 12; db.To = 12; db.Duration = TimeSpan.FromSeconds(0.5); db.AutoReverse = false; db.RepeatBehavior = new RepeatBehavior(1); sp.BeginAnimation(StackPanel.HeightProperty, db); }
public void GameOverEvent_Click(object sender, EventArgs e) { Border Border_GameOver = new Border(); Border_GameOver.Opacity = 0; Border_GameOver.Width = this.Width; Border_GameOver.Height = this.Height; Border_GameOver.HorizontalAlignment = HorizontalAlignment.Center; Border_GameOver.VerticalAlignment = VerticalAlignment.Center; Border_GameOver.Background = new ImageBrush(new BitmapImage(new Uri("Gameover.jpg", UriKind.Relative))); Grid_General.Children.Add(Border_GameOver); Border_GameOver.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1))); }
async private void Save_Number(String number) { Border border = new Border() { Style = FindResource("SavedNumberBorder") as Style, Opacity = 0 }; StackPanel sp = new StackPanel() { Orientation = Orientation.Horizontal }; Label labelNumber = new Label() { Style = FindResource("SavedNumberLabel") as Style, Content = number }; Label labelX = new Label() { Style = FindResource("RemoveSavedNumberLabel") as Style }; labelNumber.MouseDown += SavedNumber_Click; labelX.MouseDown += Remove_SavedNumber_Click; sp.Children.Add(labelNumber); sp.Children.Add(labelX); border.Child = sp; SavedNumbersPanel.Children.Add(border); await Task.Delay(30); var actualWidth = border.ActualWidth; DoubleAnimation da = new DoubleAnimation(0, actualWidth, new Duration(TimeSpan.FromSeconds(0.3))); DoubleAnimation da1 = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.3))); border.BeginAnimation(WidthProperty, da); border.BeginAnimation(OpacityProperty, da1); }
// 播放动画 public void PlayAnimation() { if (frontBar != null) { DoubleAnimation animation = new DoubleAnimation(); animation.From = 0; animation.To = frontBar.ActualWidth; animation.Duration = new Duration(TimeSpan.FromMilliseconds(500)); animation.EasingFunction = new CircleEase(); animation.FillBehavior = FillBehavior.Stop; frontBar.BeginAnimation(Border.WidthProperty, animation); } }
private void OnLoaded_SlideLeftAnimation(object sender, RoutedEventArgs e) { var animation = new DoubleAnimation(Canvas.Width, 0, new Duration(TimeSpan.FromSeconds(AnimationDuration))); animation.Completed += (o, args) => { if (!_viewModel.ShownCommand.CanExecute(null)) { return; } _viewModel.ShownCommand.Execute(null); }; Border.BeginAnimation(Canvas.LeftProperty, animation); }
private void OnClosingBalloon_SlideRightAnimation(object sender, EventArgs eventArgs) { // Prevent animation from getting triggered multiple times if CloseCommand is executed more than once _viewModel.Closing -= OnClosingBalloon_SlideRightAnimation; _timer.Stop(); var animation = new DoubleAnimation(Canvas.GetLeft(Border), Canvas.Width, new Duration(TimeSpan.FromSeconds(AnimationDuration))); animation.Completed += (o, args) => { ClosingAnimationCompleted?.Invoke(this, EventArgs.Empty); }; Border.BeginAnimation(Canvas.LeftProperty, animation); }
/// <summary> /// Open the page with specified index. /// </summary> /// <param name="indexBorderSlideIn"></param> private void OpenFormPage(int indexBorderSlideIn) { Border borderSlideIn = bordersList[indexBorderSlideIn]; if (borderSlideIn.ActualHeight == 0 + borderSlideIn.Padding.Top + borderSlideIn.Padding.Bottom) { DoubleAnimation dbIn = new DoubleAnimation(); dbIn.From = 0; dbIn.To = mainGrid.ActualHeight; dbIn.Duration = TimeSpan.FromSeconds(0.5); dbIn.BeginTime = TimeSpan.FromSeconds(0.5); borderSlideIn.BeginAnimation(Border.HeightProperty, dbIn); } }
public static void BigDataSearchPanelAnimation(ToggleButton btnExpand, Grid GridSearch, Border SearchPanel) { System.Windows.Media.Animation.DoubleAnimation ta = new System.Windows.Media.Animation.DoubleAnimation(); ta.EasingFunction = new BackEase() { EasingMode = EasingMode.EaseInOut }; if (btnExpand.IsChecked == true) { GridSearch.Visibility = Visibility.Hidden; // ta.Completed += (a, b) => { }; ta.To = 37; ta.Duration = (Duration)Application.Current.Resources["TInOutDuration"]; SearchPanel.BeginAnimation(Border.WidthProperty, ta); } else { ta.Completed += (a, b) => { GridSearch.Visibility = Visibility.Visible; }; ta.To = 315; ta.Duration = (Duration)Application.Current.Resources["TInOutDuration"]; SearchPanel.BeginAnimation(Border.WidthProperty, ta); } }
private void CollapsedPages() { for (int i = 0; i < _namesAddition.Count(); i++) { Border findedBorder = GetFindedBorderByPageID(i); DoubleAnimation animation = new DoubleAnimation(0d, new Duration(TimeSpan.FromMilliseconds(0))) { EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }, }; findedBorder.BeginAnimation(WidthProperty, animation); findedBorder.Visibility = Visibility.Collapsed; } }
/* * 关闭大图 * * 动画,回到原位,移除大图 */ public static void closeAnimation(Canvas frameDialogCanvas, Border borderBg, Canvas innerCanvas, DControl dControlDto, Grid mainContainer) { double scaleX = dControlDto.width / innerCanvas.Width; double scaleY = dControlDto.height / innerCanvas.Height; if (scaleX / scaleY > 2 || scaleY / scaleX > 2) { scaleX = 0.1; scaleY = 0.1; } //1.淡出 borderBg.RenderTransformOrigin = new Point(0.5, 0.5); DoubleAnimation da = new DoubleAnimation(borderBg.Opacity, 0, new Duration(TimeSpan.FromMilliseconds(300))); borderBg.BeginAnimation(UIElement.OpacityProperty, da); //2.缩放 TransformGroup group = (TransformGroup)innerCanvas.RenderTransform; // innerCanvas.RenderTransformOrigin = new Point(0.5, 0.5); ScaleTransform scaleTransform = TransformGroupUtil.GetScaleTransform(group); DoubleAnimation da2 = new DoubleAnimation(scaleTransform.ScaleY, scaleY, new Duration(TimeSpan.FromMilliseconds(300))); da2.Completed += (sender, e) => closeAnimation_Completed(frameDialogCanvas, innerCanvas, mainContainer); scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da2); DoubleAnimation da22 = new DoubleAnimation(scaleTransform.ScaleX, scaleX, new Duration(TimeSpan.FromMilliseconds(300))); scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da22); // 平移 TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group); DoubleAnimation da31 = new DoubleAnimation(translateTransform.X, 0, new Duration(TimeSpan.FromMilliseconds(300))); translateTransform.BeginAnimation(TranslateTransform.XProperty, da31); DoubleAnimation da32 = new DoubleAnimation(translateTransform.Y, 0, new Duration(TimeSpan.FromMilliseconds(300))); translateTransform.BeginAnimation(TranslateTransform.YProperty, da32); // 淡出模式 DoubleAnimation da4 = new DoubleAnimation(innerCanvas.Opacity, 0, new Duration(TimeSpan.FromMilliseconds(300))); da4.Completed += (sender, e) => closeAnimation_Completed(frameDialogCanvas, innerCanvas, mainContainer); innerCanvas.BeginAnimation(UIElement.OpacityProperty, da4); }
void ClipChanged(Clip newClip) { if (inTransition) { waitingClip = newClip; return; } MediaElement oldMedia = currentMediaElement; currentMediaElement = new MediaElement() { Source = new Uri(newClip.FilePath), LoadedBehavior = MediaState.Manual, Volume = 0 }; if (firstTime) { currentBorder.Child = currentMediaElement; currentMediaElement.Volume = 1; //currentMediaElement.Play(); firstTime = false; return; } inTransition = true; Duration animationDuration = new Duration(CrossfadeTime - TimeSpan.FromSeconds(0.2)); DoubleAnimation animation = new DoubleAnimation(0, 1, animationDuration); animation.Completed += new EventHandler(animation_Completed); nextBorder.BeginAnimation(MediaElement.OpacityProperty, animation); currentMediaElement.BeginAnimation(MediaElement.VolumeProperty, new DoubleAnimation(0, 1, animationDuration)); oldMedia.BeginAnimation(MediaElement.VolumeProperty, new DoubleAnimation(1, 0, animationDuration)); nextBorder.Child = currentMediaElement; currentMediaElement.Play(); IsPlaying = true; Border temp = currentBorder; currentBorder = nextBorder; nextBorder = temp; }