private void AnimationUp(Grid grid) { ThicknessAnimation ta = new ThicknessAnimation(); ta.From = grid.Margin; ta.To = new Thickness(grid.Margin.Left, RowHeight + SpaceBetweenGrids, 0, 0); ta.Duration = new Duration(TimeSpan.FromSeconds(0.5)); grid.BeginAnimation(Grid.MarginProperty, ta); }
private void InitalizeTab(UIElement content) { CloseableTab myTab = new CloseableTab(); int newTab = MasterTabs.Items.Count + 1; myTab.Title = ((IMainTab)content).TabCaption; myTab.Picture = new BitmapImage(new Uri(((IMainTab)content).TabIcon)); AttachEventHandlersToTab((IMainTab)content); Grid tabGrid = new Grid(); tabGrid.SizeChanged += Grid_SizeChanged; tabGrid.Children.Add(content); //Fade in the Grid Content DoubleAnimation fadeInAnimation = new DoubleAnimation(); fadeInAnimation.To = 1; fadeInAnimation.From = 0; fadeInAnimation.EasingFunction = new CubicEase(); fadeInAnimation.Duration = TimeSpan.FromSeconds(0.5); myTab.Content = tabGrid; MasterTabs.Items.Add(myTab); MasterTabs.SelectedIndex = MasterTabs.Items.Count-1; tabGrid.BeginAnimation(Grid.OpacityProperty, fadeInAnimation); InitializeSidePanels(); //ActionPaneDock.Children.Add(((IMainTab)content).ActionPaneContent); //TreePaneDock.Children.Add(((IMainTab)content).TreePaneContent); }
/// <summary> /// OnBusyStateChanged /// </summary> /// <param name="d"></param> /// <param name="e"></param> private static void OnBusyStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { bool isBusy = (bool)e.NewValue; bool wasBusy = (bool)e.OldValue; if (isBusy == wasBusy) { return; } var hostGridObject = (GetTargetVisual(d) ?? d); Debug.Assert(hostGridObject != null); var hostGrid = hostGridObject as Grid; if (hostGrid == null) { throw new InvalidCastException( string.Format( "The object being attached to must be of type {0}. Try embedding your visual inside a {0} control, and attaching the behavior to the {0} instead.", typeof(Grid).Name)); } if (isBusy) { Debug.Assert(LogicalTreeHelper.FindLogicalNode(hostGrid, "BusyIndicator") == null); bool dimBackground = GetDimBackground(d); var grid = new Grid { Name = "BusyIndicator", Opacity = 0.0 }; if (dimBackground) { grid.Cursor = Cursors.Wait; grid.ForceCursor = true; InputManager.Current.PreProcessInput += OnPreProcessInput; } grid.SetBinding(FrameworkElement.WidthProperty, new Binding("ActualWidth") { Source = hostGrid }); grid.SetBinding(FrameworkElement.HeightProperty, new Binding("ActualHeight") { Source = hostGrid }); for (int i = 1; i <= 3; ++i) { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } ProgressIndicator = new BusyIndicator() { Width = 150, Height = 120 }; var viewbox = new Viewbox { HorizontalAlignment = HorizontalAlignment.Center, Stretch = Stretch.Uniform, StretchDirection = StretchDirection.Both, Child = ProgressIndicator }; grid.SetValue(Panel.ZIndexProperty, 1000); grid.SetValue(Grid.RowSpanProperty, Math.Max(1, hostGrid.RowDefinitions.Count)); grid.SetValue(Grid.ColumnSpanProperty, Math.Max(1, hostGrid.ColumnDefinitions.Count)); if (GetAddMargins(d)) { viewbox.SetValue(Grid.RowProperty, 1); viewbox.SetValue(Grid.ColumnProperty, 1); } else { viewbox.SetValue(Grid.RowSpanProperty, 3); viewbox.SetValue(Grid.ColumnSpanProperty, 3); } viewbox.SetValue(Panel.ZIndexProperty, 1); var dimmer = new Rectangle { Name = "Dimmer", Opacity = GetDimmerOpacity(d), Fill = GetDimmerBrush(d), Visibility = (dimBackground ? Visibility.Visible : Visibility.Collapsed) }; dimmer.SetValue(Grid.RowSpanProperty, 3); dimmer.SetValue(Grid.ColumnSpanProperty, 3); dimmer.SetValue(Panel.ZIndexProperty, 0); grid.Children.Add(dimmer); grid.Children.Add(viewbox); grid.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(1.0, GetDimTransitionDuration(d))); hostGrid.Children.Add(grid); } else { var grid = (Grid)LogicalTreeHelper.FindLogicalNode(hostGrid, "BusyIndicator"); Debug.Assert(grid != null); if (grid != null) { grid.Name = string.Empty; var fadeOutAnimation = new DoubleAnimation(0.0, GetDimTransitionDuration(d)); fadeOutAnimation.Completed += (sender, args) => OnFadeOutAnimationCompleted(d, hostGrid, grid); grid.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation); } } }
public void CreateHeader() { // string header = @" __ _ _ /// _\ ___ | | _____ | |__ __ _ _ __ //\ \ / _ \| |/ / _ \| '_ \ / _` | '_ \ //_\ \ (_) | < (_) | |_) | (_| | | | | //\__/\___/|_|\_\___/|_.__/ \__,_|_| |_|"; string header = "SOKOBAN"; Header = new Grid(); TextBlock text = new TextBlock(); text.Text = header; text.FontSize = 30; text.FontFamily = new FontFamily("Comic Sans"); text.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; text.VerticalAlignment = System.Windows.VerticalAlignment.Top; Header.Children.Add(text); Header.Margin = new Thickness(0, 10, 0, 0); DoubleAnimation myDoubleAnimation = new DoubleAnimation(); myDoubleAnimation.From = 1.0; myDoubleAnimation.To = 0.4; myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(2)); myDoubleAnimation.AutoReverse = true; myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever; // myStoryboard = new Storyboard(); // myStoryboard.Children.Add(myDoubleAnimation); Header.BeginAnimation(UIElement.OpacityProperty, myDoubleAnimation); //Storyboard.SetTargetName(myDoubleAnimation, Header.Opacity); //////myStoryboard.Begin(); }
private void hideShowGrid(Grid g, DoubleAnimation animation) { g.BeginAnimation(Grid.OpacityProperty, animation); }
private void animationFadeGrid(Grid grid, double from, double to, int duration) { DoubleAnimation animationFade = new DoubleAnimation(); animationFade.From = from; animationFade.To = to; animationFade.Duration = new Duration(TimeSpan.FromMilliseconds(duration)); grid.BeginAnimation(Grid.OpacityProperty, animationFade); }
public static void FadeGridElement(double fromValue, double toValue, Grid control) { DoubleAnimation da = new DoubleAnimation(fromValue, toValue, time); da.DecelerationRatio = acceleration; control.BeginAnimation(Grid.OpacityProperty, da); }
static public void GridAnimation(DoubleAnimation animation, Grid grid, DependencyProperty dp, int size) { animation.To = size; grid.BeginAnimation(dp, animation, HandoffBehavior.Compose); }