Esempio n. 1
0
        bool IsValidFoldFeature(IDisplayFeature displayFeature)
        {
            var ff = displayFeature.JavaCast <IFoldingFeature>();

            if (ff != null)
            {
                if (ff.IsSeparating)
                {
                    return(SampleTools.GetFeaturePositionInViewRect(ff, this) != null);
                }
                else
                {
                    return(false); // if not separating, ignore it as a fold
                }
            }
            return(false);
        }
Esempio n. 2
0
        Rect[] SplitViewPositions(View startView, View endView)
        {
            //TODO:
            if (windowLayoutInfo == null || startView == null || endView == null)
            {
                return(null);
            }

            // Calculate the area for view's content with padding
            var paddedWidth  = Width - PaddingLeft - PaddingRight;
            var paddedHeight = Height - PaddingTop - PaddingBottom;

            var df = windowLayoutInfo.DisplayFeatures.FirstOrDefault();

            if (IsValidFoldFeature(df))
            {
                var feature = df.JavaCast <IFoldingFeature>();
                var it      = SampleTools.GetFeaturePositionInViewRect(df, this);

                if (feature.Bounds.Left == 0)
                { // Horizontal layout
                    var topRect = new Rect(
                        PaddingLeft, PaddingTop,
                        PaddingLeft + paddedWidth, it.Top
                        );
                    var bottomRect = new Rect(
                        PaddingLeft, it.Bottom,
                        PaddingLeft + paddedWidth, PaddingTop + paddedHeight
                        );

                    if (MeasureAndCheckMinSize(topRect, startView) &&
                        MeasureAndCheckMinSize(bottomRect, endView)
                        )
                    {
                        return(new Rect[] { topRect, bottomRect });
                    }
                }
                else if (feature.Bounds.Top == 0)
                { // Vertical layout
                    var leftRect = new Rect(
                        PaddingLeft, PaddingTop,
                        it.Left, PaddingTop + paddedHeight
                        );
                    var rightRect = new Rect(
                        it.Right, PaddingTop,
                        PaddingLeft + paddedWidth, PaddingTop + paddedHeight
                        );

                    if (MeasureAndCheckMinSize(leftRect, startView) &&
                        MeasureAndCheckMinSize(rightRect, endView)
                        )
                    {
                        return(new Rect[] { leftRect, rightRect });
                    }
                }
            }
            // We have tried to fit the children and measured them previously. Since they didn't fit,
            // we need to measure again to update the stored values.
            Measure(lastWidthMeasureSpec, lastHeightMeasureSpec);
            return(null);
        }