コード例 #1
0
ファイル: GridExpander.cs プロジェクト: xCMNx/Units-translate
        private void ChangeState(bool collapse)
        {
            if (_isAnimating || _isChanging)
            {
                return;
            }
            DefinitionBase definition = GetDefinition();

            if (definition == null)
            {
                return;
            }

            var    byRow      = _gridCollapseDirection == GridCollapseOrientation.Rows;
            var    actionProp = byRow ? RowDefinition.HeightProperty : ColumnDefinition.WidthProperty;
            double curVal     = ActualValue(definition);

            if (collapse)
            {
                if (curVal == 0)
                {
                    return;
                }
                _savedGridLength  = byRow ? (definition as RowDefinition).Height : (definition as ColumnDefinition).Width;
                _savedActualValue = curVal;
                // Collapse
                if (IsAnimated)
                {
                    AnimateCollapse(definition);
                }
                else
                {
                    definition.SetValue(actionProp, new GridLength(0));
                }
                // Raise the Collapsed event.
                OnCollapsed(EventArgs.Empty);
            }
            else
            {
                if (_savedActualValue == 0 || curVal == _savedActualValue)
                {
                    return;
                }
                // Expand
                if (IsAnimated)
                {
                    AnimateExpand(definition);
                }
                else
                {
                    definition.SetValue(actionProp, _savedGridLength);
                }
                // Raise the Expanded event.
                OnExpanded(EventArgs.Empty);
            }

            // Activate the background so the splitter can be dragged again.
            _elementGridExpanderBackground.IsHitTestVisible = !collapse;
        }
コード例 #2
0
ファイル: WPFHelpers.cs プロジェクト: sbunlimited/itraacv2-1
    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));
        }
    }
コード例 #3
0
ファイル: WPFHelpers.cs プロジェクト: Beej126/yasbe
    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));
        }
    }
コード例 #4
0
 private static void SetDefinitionLength(DefinitionBase definition, GridLength length)
 {
     definition.SetValue((definition is ColumnDefinition) ? ColumnDefinition.WidthProperty : RowDefinition.HeightProperty, length);
 }
コード例 #5
0
 private void SetDefinitionLength(DefinitionBase definition, GridLength length)
 {
     definition.SetValue(definition is ColumnDefinition ? ColumnDefinition.WidthProperty : RowDefinition.HeightProperty, (object)length);
 }
コード例 #6
0
ファイル: Grid.cs プロジェクト: forki/Gu.Wpf.PropertyGrid
 private static void SetIsAuto(this DefinitionBase element, bool value)
 {
     element.SetValue(IsAutoProperty, BooleanBoxes.Box(value));
 }