-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 64 additions & 1 deletion
65
src/Shared/HandyControlDemo_Shared/UserControl/Main/MainWindowContent.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,72 @@ | ||
namespace HandyControlDemo.UserControl; | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Animation; | ||
using HandyControl.Tools; | ||
using HandyControl.Tools.Extension; | ||
|
||
namespace HandyControlDemo.UserControl; | ||
|
||
public partial class MainWindowContent | ||
{ | ||
private GridLength _columnDefinitionWidth; | ||
|
||
public MainWindowContent() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void OnLeftMainContentShiftOut(object sender, RoutedEventArgs e) | ||
{ | ||
ButtonShiftOut.Collapse(); | ||
GridSplitter.IsEnabled = false; | ||
|
||
double targetValue = -ColumnDefinitionLeft.Width.Value; | ||
_columnDefinitionWidth = ColumnDefinitionLeft.Width; | ||
|
||
DoubleAnimation animation = AnimationHelper.CreateAnimation(targetValue, milliseconds: 100); | ||
animation.FillBehavior = FillBehavior.Stop; | ||
animation.Completed += OnAnimationCompleted; | ||
LeftMainContent.RenderTransform.BeginAnimation(TranslateTransform.XProperty, animation); | ||
|
||
void OnAnimationCompleted(object _, EventArgs args) | ||
{ | ||
animation.Completed -= OnAnimationCompleted; | ||
LeftMainContent.RenderTransform.SetCurrentValue(TranslateTransform.XProperty, targetValue); | ||
|
||
Grid.SetColumn(MainContent, 0); | ||
Grid.SetColumnSpan(MainContent, 2); | ||
|
||
ColumnDefinitionLeft.MinWidth = 0; | ||
ColumnDefinitionLeft.Width = new GridLength(); | ||
ButtonShiftIn.Show(); | ||
} | ||
} | ||
|
||
private void OnLeftMainContentShiftIn(object sender, RoutedEventArgs e) | ||
{ | ||
ButtonShiftIn.Collapse(); | ||
GridSplitter.IsEnabled = true; | ||
|
||
double targetValue = ColumnDefinitionLeft.Width.Value; | ||
|
||
DoubleAnimation animation = AnimationHelper.CreateAnimation(targetValue, milliseconds: 100); | ||
animation.FillBehavior = FillBehavior.Stop; | ||
animation.Completed += OnAnimationCompleted; | ||
LeftMainContent.RenderTransform.BeginAnimation(TranslateTransform.XProperty, animation); | ||
|
||
void OnAnimationCompleted(object _, EventArgs args) | ||
{ | ||
animation.Completed -= OnAnimationCompleted; | ||
LeftMainContent.RenderTransform.SetCurrentValue(TranslateTransform.XProperty, targetValue); | ||
|
||
Grid.SetColumn(MainContent, 1); | ||
Grid.SetColumnSpan(MainContent, 1); | ||
|
||
ColumnDefinitionLeft.MinWidth = 240; | ||
ColumnDefinitionLeft.Width = _columnDefinitionWidth; | ||
ButtonShiftOut.Show(); | ||
} | ||
} | ||
} |