public static GridLength UserSizeValueCache(DefinitionBase def)
 {
     if (def is RowDefinition)
     {
         return((GridLength)def.GetValue(RowDefinition.HeightProperty));
     }
     else
     {
         return((GridLength)def.GetValue(ColumnDefinition.WidthProperty));
     }
 }
 public static double UserMaxSizeValueCache(DefinitionBase def)
 {
     if (def is RowDefinition)
     {
         return((double)def.GetValue(RowDefinition.MaxHeightProperty));
     }
     else
     {
         return((double)def.GetValue(ColumnDefinition.MaxWidthProperty));
     }
 }
Esempio n. 3
0
    public static void GridSplitterOpeningBounce(this DefinitionBase rowColDefinition, bool opening = false, int openToSize = 0, Action <bool> afterCompleted = null)
    {
        if (rowColDefinition == null)
        {
            return;                       //for when events fire before everything is initialized
        }
        var isRow = (rowColDefinition.GetType() == typeof(RowDefinition));

        Storyboard story;

        if (!GridSplitterPositions.TryGetValue(rowColDefinition, out story))
        {
            var animation = new GridLengthAnimation {
                To = new GridLength(openToSize), Duration = new TimeSpan(0, 0, 1)
            };

            Storyboard.SetTarget(animation, rowColDefinition);
            Storyboard.SetTargetProperty(animation, new PropertyPath(isRow ? "Height" : "Width"));

            GridSplitterPositions[rowColDefinition] = story = new Storyboard();
            story.Children.Add(animation);
            if (afterCompleted != null)
            {
                story.Completed += (s, e) => afterCompleted(opening);
            }
        }

        var currentPositionProperty = isRow ? RowDefinition.HeightProperty : ColumnDefinition.WidthProperty;

        if (opening)
        {
            //only bugger with popping open if not already opened by user
            if (((GridLength)rowColDefinition.GetValue(currentPositionProperty)).Value <= 0.0)
            {
                story.Begin();
            }
        }
        else
        {
            story.Stop();

            //save the current position in the animation's "To" property so it opens back to where it was before we closed it
            var current = (GridLength)rowColDefinition.GetValue(currentPositionProperty);
            if (current.GridUnitType != GridUnitType.Star && current.Value > 0)
            {
                ((GridLengthAnimation)story.Children[0]).To = current;
            }

            rowColDefinition.SetValue(currentPositionProperty, new GridLength(0, GridUnitType.Pixel));
        }
    }
Esempio n. 4
0
    public static void GridSplitterOpeningBounce(DefinitionBase RowColDefinition, int InitialSize, bool Opening)
    {
        if (RowColDefinition == null)
        {
            return;                       //for when events fire before everything is initialized
        }
        bool IsRow = (RowColDefinition.GetType() == typeof(RowDefinition));

        Storyboard story;

        if (!GridSplitterPositions.TryGetValue(RowColDefinition, out story))
        {
            GridLengthAnimation animation = new GridLengthAnimation();
            animation.To       = new GridLength(InitialSize);
            animation.Duration = new TimeSpan(0, 0, 1);

            Storyboard.SetTarget(animation, RowColDefinition);
            Storyboard.SetTargetProperty(animation, new PropertyPath(IsRow ? "Height" : "Width"));

            GridSplitterPositions[RowColDefinition] = story = new Storyboard();
            story.Children.Add(animation);
        }

        if (Opening)
        {
            story.Begin();
        }
        else
        {
            story.Stop();

            DependencyProperty CurrentPositionProperty = IsRow ? RowDefinition.HeightProperty : ColumnDefinition.WidthProperty;

            //save the current position in the animation's "To" property so it opens back to where it was before we closed it
            (story.Children[0] as GridLengthAnimation).To = (GridLength)RowColDefinition.GetValue(CurrentPositionProperty);

            RowColDefinition.SetValue(CurrentPositionProperty, new GridLength(0, GridUnitType.Pixel));
        }
    }
Esempio n. 5
0
 private static GridLength GetUserSize(DefinitionBase definition)
 {
     return((GridLength)definition.GetValue(definition is ColumnDefinition ? ColumnDefinition.WidthProperty : RowDefinition.HeightProperty));
 }
Esempio n. 6
0
 private static double GetUserMaxSize(DefinitionBase definition)
 {
     return((double)definition.GetValue(definition is ColumnDefinition ? ColumnDefinition.MaxWidthProperty : RowDefinition.MaxHeightProperty));
 }
Esempio n. 7
0
 private static bool GetIsAuto(this DefinitionBase element)
 {
     return((bool)element.GetValue(IsAutoProperty));
 }