Skip to content

Commit

Permalink
Merge pull request #35 from Planshit/dev
Browse files Browse the repository at this point in the history
修复离开状态时动画报错的问题
  • Loading branch information
noberumotto authored Apr 11, 2020
2 parents 4ecf570 + 32c4499 commit 5f5de84
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions src/Local/Project1.UI/Controls/Project1UIWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ public Project1UIWindow()
//HandleAnimationSetting();

Loaded += new RoutedEventHandler(window_Loaded);

//动画
var transformGroup = new TransformGroup();
RenderTransform = transformGroup;
}

///// <summary>
Expand Down Expand Up @@ -321,25 +325,27 @@ public void CloseNavigationView()

private void CreateWindowOpenAnimation()
{

Opacity = 0;
openWindowStoryboard = new Storyboard();
var duration = TimeSpan.FromSeconds(1);
var transformGroup = new TransformGroup();
this.RenderTransform = transformGroup;

var translateTF = new TranslateTransform()
{
X = 0,
Y = 0
};

var scaleTF = new ScaleTransform()
{
CenterX = ActualWidth,
CenterY = ActualHeight,
ScaleX = 0,
ScaleY = 0
};
transformGroup.Children.Add(translateTF);
transformGroup.Children.Add(scaleTF);

(RenderTransform as TransformGroup).Children.Add(translateTF);
(RenderTransform as TransformGroup).Children.Add(scaleTF);



Expand Down Expand Up @@ -393,25 +399,22 @@ private void CreateWindowCloseAnimation()
{
closeWindowStoryboard = new Storyboard();
var duration = TimeSpan.FromSeconds(1);
if (RenderTransform == null)

var translateTF = new TranslateTransform()
{
var transformGroup = new TransformGroup();
RenderTransform = transformGroup;
var translateTF = new TranslateTransform()
{
X = 0,
Y = 0
};
var scaleTF = new ScaleTransform()
{
CenterX = ActualWidth / 2,
CenterY = ActualHeight / 2,
ScaleX = 0,
ScaleY = 0
};
transformGroup.Children.Add(translateTF);
transformGroup.Children.Add(scaleTF);
}
X = 0,
Y = 0
};
var scaleTF = new ScaleTransform()
{
CenterX = ActualWidth / 2,
CenterY = ActualHeight / 2,
ScaleX = 0,
ScaleY = 0
};
(RenderTransform as TransformGroup).Children.Add(translateTF);
(RenderTransform as TransformGroup).Children.Add(scaleTF);


//位移动画

Expand Down Expand Up @@ -573,7 +576,7 @@ private void AnimationHide(CompletedActionType completedAction)
{
if (IsAnimation)
{
if (RenderTransform == null)
if ((RenderTransform as TransformGroup).Children.Count == 0)
{
CreateWindowOpenAnimation();
CreateWindowCloseAnimation();
Expand All @@ -595,9 +598,9 @@ private void AnimationHide(CompletedActionType completedAction)
}
else
{
if (RenderTransform != null)
if ((RenderTransform as TransformGroup).Children.Count != 0)
{
RenderTransform = null;
(RenderTransform as TransformGroup).Children.Clear();
}
Opacity = 0;
CompletedAction(completedAction);
Expand All @@ -613,7 +616,7 @@ private void AnimationShow(CompletedActionType completedAction)
{
if (IsAnimation)
{
if (RenderTransform == null)
if ((RenderTransform as TransformGroup).Children.Count == 0)
{
CreateWindowOpenAnimation();
CreateWindowCloseAnimation();
Expand All @@ -629,9 +632,9 @@ private void AnimationShow(CompletedActionType completedAction)
}
else
{
if (RenderTransform != null)
if ((RenderTransform as TransformGroup).Children.Count != 0)
{
RenderTransform = null;
(RenderTransform as TransformGroup).Children.Clear();
}
Opacity = 1;
CompletedAction(completedAction);
Expand Down

0 comments on commit 5f5de84

Please sign in to comment.