diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-04-12 04:37:11 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-04-12 04:37:11 +0300 |
| commit | e1802508c00e0cede200d3914c5b6e4587cb6963 (patch) | |
| tree | ec6d74dc182ec77cf4e94c58cdcb983d12a921bf /Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs | |
| parent | 2c68ed841941d4e1b27815a52ca841d6abc4e806 (diff) | |
| download | Tango-e1802508c00e0cede200d3914c5b6e4587cb6963.tar.gz Tango-e1802508c00e0cede200d3914c5b6e4587cb6963.zip | |
Working on FSE TUP.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs | 237 |
1 files changed, 122 insertions, 115 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs index c2d544042..879401c1b 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs @@ -457,165 +457,172 @@ namespace Tango.SharedUI.Controls private void NavigationThread() { - while (true) + try { - var item = _navigationQueue.BlockDequeue(); + while (true) + { + var item = _navigationQueue.BlockDequeue(); - var navigationCompleted = false; + var navigationCompleted = false; - NavigationElement fromElement = item.FromElement; - NavigationElement toElement = item.ToElement; + NavigationElement fromElement = item.FromElement; + NavigationElement toElement = item.ToElement; - Dispatcher.BeginInvoke(new Action(() => - { - if (toElement == null || toElement == fromElement) + Dispatcher.BeginInvoke(new Action(() => { + if (toElement == null || toElement == fromElement) + { //navigationCompleted = true; Debug.WriteLine("NavigationControl: THIS MIGHT CAUSE PROBLEMS !!"); - } + } - if (fromElement != null) - { - DoubleAnimation toAnimation = new DoubleAnimation(); - toAnimation.Duration = TransitionDuration; + if (fromElement != null) + { + DoubleAnimation toAnimation = new DoubleAnimation(); + toAnimation.Duration = TransitionDuration; - DoubleAnimation fromAnimation = new DoubleAnimation(); - fromAnimation.Duration = TransitionDuration; + DoubleAnimation fromAnimation = new DoubleAnimation(); + fromAnimation.Duration = TransitionDuration; - int fromIndex = Elements.IndexOf(fromElement.Element); - int toIndex = Elements.IndexOf(toElement.Element); + int fromIndex = Elements.IndexOf(fromElement.Element); + int toIndex = Elements.IndexOf(toElement.Element); - fromElement.Reset(); - toElement.Reset(); + fromElement.Reset(); + toElement.Reset(); - fromAnimation.Completed += (_, __) => - { - fromElement.Deactivate(!KeepElementsAttached); - }; + fromAnimation.Completed += (_, __) => + { + fromElement.Deactivate(!KeepElementsAttached); + }; - bool completed = false; + bool completed = false; - toAnimation.Completed += (_, __) => - { - if (!completed) + toAnimation.Completed += (_, __) => { - completed = true; + if (!completed) + { + completed = true; - INavigationView fromNavigationView = fromElement.Element as INavigationView; - INavigationView toNavigationView = toElement.Element as INavigationView; + INavigationView fromNavigationView = fromElement.Element as INavigationView; + INavigationView toNavigationView = toElement.Element as INavigationView; - if (fromNavigationView != null) - { - fromNavigationView.OnNavigatedFrom(); - } - if (toNavigationView != null) - { - toNavigationView.OnNavigatedTo(); + if (fromNavigationView != null) + { + fromNavigationView.OnNavigatedFrom(); + } + if (toNavigationView != null) + { + toNavigationView.OnNavigatedTo(); + } + + INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel; + INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; + + if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom(); + if (toVM != null) toVM.OnNavigatedTo(); + + navigationCompleted = true; } + }; - INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel; - INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; + switch (TransitionType) + { + case TransitionTypes.Fade: + fromAnimation.From = 1; + fromAnimation.To = 0; - if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom(); - if (toVM != null) toVM.OnNavigatedTo(); + toAnimation.From = 0; + toAnimation.To = 1; - navigationCompleted = true; - } - }; + fromElement.AnimateOpacity(fromAnimation); + toElement.AnimateOpacity(toAnimation); - switch (TransitionType) - { - case TransitionTypes.Fade: - fromAnimation.From = 1; - fromAnimation.To = 0; + break; + case TransitionTypes.Zoom: + fromAnimation.From = 1; + fromAnimation.To = 0; - toAnimation.From = 0; - toAnimation.To = 1; + toAnimation.From = 0; + toAnimation.To = 1; - fromElement.AnimateOpacity(fromAnimation); - toElement.AnimateOpacity(toAnimation); + fromElement.AnimateScale(fromAnimation); + toElement.AnimateScale(toAnimation); - break; - case TransitionTypes.Zoom: - fromAnimation.From = 1; - fromAnimation.To = 0; + break; + case TransitionTypes.Slide: - toAnimation.From = 0; - toAnimation.To = 1; + if (toIndex > fromIndex) + { + fromAnimation.From = 0; + fromAnimation.To = -ActualWidth; - fromElement.AnimateScale(fromAnimation); - toElement.AnimateScale(toAnimation); + toAnimation.From = ActualWidth; + toAnimation.To = 0; + } + else + { + fromAnimation.From = 0; + fromAnimation.To = ActualWidth; - break; - case TransitionTypes.Slide: + toAnimation.From = -ActualWidth; + toAnimation.To = 0; + } - if (toIndex > fromIndex) - { - fromAnimation.From = 0; - fromAnimation.To = -ActualWidth; + fromElement.AnimateTranslateX(fromAnimation); + toElement.AnimateTranslateX(toAnimation); - toAnimation.From = ActualWidth; - toAnimation.To = 0; - } - else - { - fromAnimation.From = 0; - fromAnimation.To = ActualWidth; + break; + } - toAnimation.From = -ActualWidth; - toAnimation.To = 0; - } + if (TransitionAlwaysFades && TransitionType != TransitionTypes.Fade) + { + DoubleAnimation fromFadeAnimation = new DoubleAnimation(); + fromFadeAnimation.From = 1; + fromFadeAnimation.To = 0; + fromFadeAnimation.Duration = TransitionDuration; - fromElement.AnimateTranslateX(fromAnimation); - toElement.AnimateTranslateX(toAnimation); + DoubleAnimation toFadeAnimation = new DoubleAnimation(); + toFadeAnimation.From = 0; + toFadeAnimation.To = 1; + toFadeAnimation.Duration = TransitionDuration; - break; - } + fromElement.AnimateOpacity(fromFadeAnimation); + toElement.AnimateOpacity(toFadeAnimation); + } - if (TransitionAlwaysFades && TransitionType != TransitionTypes.Fade) + fromElement.Activate(); + toElement.Activate(); + } + else { - DoubleAnimation fromFadeAnimation = new DoubleAnimation(); - fromFadeAnimation.From = 1; - fromFadeAnimation.To = 0; - fromFadeAnimation.Duration = TransitionDuration; + toElement.Activate(); + toElement.Reset(); - DoubleAnimation toFadeAnimation = new DoubleAnimation(); - toFadeAnimation.From = 0; - toFadeAnimation.To = 1; - toFadeAnimation.Duration = TransitionDuration; + INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; + if (toVM != null) toVM.OnNavigatedTo(); - fromElement.AnimateOpacity(fromFadeAnimation); - toElement.AnimateOpacity(toFadeAnimation); + navigationCompleted = true; } + })); - fromElement.Activate(); - toElement.Activate(); - } - else + for (int i = 0; i < 30; i++) { - toElement.Activate(); - toElement.Reset(); - - INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; - if (toVM != null) toVM.OnNavigatedTo(); - - navigationCompleted = true; + if (navigationCompleted) + { + break; + } + Thread.Sleep(100); } - })); - for (int i = 0; i < 30; i++) - { - if (navigationCompleted) + Dispatcher.BeginInvoke(new Action(() => { - break; - } - Thread.Sleep(100); + NavigationCompleted?.Invoke(); + })); } - - Dispatcher.BeginInvoke(new Action(() => - { - NavigationCompleted?.Invoke(); - })); + } + catch + { + } } |
