예제 #1
0
        private void GetProportions(int leftWidgetIndex,
                                    out Proportion leftProportion,
                                    out Proportion rightProportion)
        {
            var baseIndex = leftWidgetIndex * 2;

            leftProportion = Orientation == Orientation.Horizontal
                                ? InternalChild.ColumnsProportions[baseIndex]
                                : InternalChild.RowsProportions[baseIndex];
            rightProportion = Orientation == Orientation.Horizontal
                                ? InternalChild.ColumnsProportions[baseIndex + 2]
                                : InternalChild.RowsProportions[baseIndex + 2];
        }
예제 #2
0
        public void Reset()
        {
            // Clear
            InternalChild.Widgets.Clear();
            _handles.Clear();
            _handlesSize = 0;

            InternalChild.ColumnsProportions.Clear();
            InternalChild.RowsProportions.Clear();

            var i = 0;

            var handleSize = 0;
            var asImage    = HandleStyle.Background as IImage;

            if (asImage != null)
            {
                handleSize = Orientation == Orientation.Horizontal
                                        ? asImage.Size.X
                                        : asImage.Size.Y;
            }

            foreach (var w in _widgets)
            {
                Proportion proportion;
                if (i > 0)
                {
                    // Add splitter
                    var handle = new ImageButton(null)
                    {
                        ReleaseOnTouchLeft = false
                    };

                    if (Orientation == Orientation.Horizontal)
                    {
                        handle.VerticalAlignment = VerticalAlignment.Stretch;
                    }
                    else
                    {
                        handle.HorizontalAlignment = HorizontalAlignment.Stretch;
                    }

                    handle.ApplyButtonStyle(HandleStyle);

                    handle.PressedChanged += HandleOnPressedChanged;

                    proportion = new Proportion(ProportionType.Auto);

                    if (Orientation == Orientation.Horizontal)
                    {
                        _handlesSize     += handleSize;
                        handle.GridColumn = i * 2 - 1;
                        InternalChild.ColumnsProportions.Add(proportion);
                    }
                    else
                    {
                        _handlesSize  += handleSize;
                        handle.GridRow = i * 2 - 1;
                        InternalChild.RowsProportions.Add(proportion);
                    }

                    InternalChild.Widgets.Add(handle);
                    _handles.Add(handle);
                }

                proportion = i < _widgets.Count - 1
                                        ? new Proportion(ProportionType.Part, 1.0f)
                                        : new Proportion(ProportionType.Fill, 1.0f);

                // Set grid coord and add widget itself
                if (Orientation == Orientation.Horizontal)
                {
                    w.GridColumn = i * 2;
                    InternalChild.ColumnsProportions.Add(proportion);
                }
                else
                {
                    w.GridRow = i * 2;
                    InternalChild.RowsProportions.Add(proportion);
                }

                InternalChild.Widgets.Add(w);

                ++i;
            }

            foreach (var h in _handles)
            {
                if (Orientation == Orientation.Horizontal)
                {
                    h.Width  = handleSize;
                    h.Height = null;
                }
                else
                {
                    h.Width  = null;
                    h.Height = handleSize;
                }
            }

            FireProportionsChanged();
        }