protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            // If the scroll view has changed size because of soft keyboard dismissal
            // (while WindowSoftInputModeAdjust is set to Resize), then we may need to request a
            // layout of the ScrollViewContainer
            bool requestContainerLayout = bottom > _previousBottom;

            _previousBottom = bottom;

            base.OnLayout(changed, left, top, right, bottom);
            if (_view.Content != null && _hScrollView != null)
            {
                _hScrollView.Layout(0, 0, right - left, Math.Max(bottom - top, (int)Context.ToPixels(_view.Content.Height)));
            }
            else if (_view.Content != null && requestContainerLayout)
            {
                _container?.RequestLayout();
            }

            // if the target sdk >= 17 then setting the LayoutDirection on the scroll view natively takes care of the scroll
            if (Context.TargetSdkVersion() < 17 && !_checkedForRtlScroll && _hScrollView != null && Element is IVisualElementController controller && controller.EffectiveFlowDirection.IsRightToLeft())
            {
                _hScrollView.ScrollX = _container.MeasuredWidth - _hScrollView.MeasuredWidth - _hScrollView.ScrollX;
            }

            _checkedForRtlScroll = true;
        }
Пример #2
0
        protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            // If the scroll view has changed size because of soft keyboard dismissal
            // (while WindowSoftInputModeAdjust is set to Resize), then we may need to request a
            // layout of the ScrollViewContainer
            bool requestContainerLayout = bottom > _previousBottom;

            _previousBottom = bottom;

            _container?.Measure(MeasureSpecFactory.MakeMeasureSpec(right - left, MeasureSpecMode.Unspecified),
                                MeasureSpecFactory.MakeMeasureSpec(bottom - top, MeasureSpecMode.Unspecified));
            base.OnLayout(changed, left, top, right, bottom);
            if (_view.Content != null && _hScrollView != null)
            {
                _hScrollView.Layout(0, 0, right - left, Math.Max(bottom - top, (int)Context.ToPixels(_view.Content.Height)));
            }
            else if (_view.Content != null && requestContainerLayout)
            {
                _container?.RequestLayout();
            }

            // if the target sdk >= 17 then setting the LayoutDirection on the scroll view natively takes care of the scroll
            if (!_checkedForRtlScroll && _hScrollView != null && Element is IVisualElementController controller && controller.EffectiveFlowDirection.IsRightToLeft())
            {
                Device.BeginInvokeOnMainThread(() => UpdateScrollPosition(_hScrollView.ScrollX, ScrollY));
            }

            _checkedForRtlScroll = true;
        }
Пример #3
0
 protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
 {
     base.OnLayout(changed, left, top, right, bottom);
     if (_view.Content != null && _hScrollView != null)
     {
         _hScrollView.Layout(0, 0, right - left, Math.Max(bottom - top, (int)Context.ToPixels(_view.Content.Height)));
     }
 }
Пример #4
0
        public override View GetPropertyWindowLayout(Context context)
        {
            LinearLayout gridLinearLayout = new LinearLayout(context)
            {
                Orientation = Android.Widget.Orientation.Vertical
            };

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            layoutParams.TopMargin            = (int)(25 * currentDensity);
            gridLinearLayout.LayoutParameters = layoutParams;
            gridLinearLayout.SetBackgroundResource(Resource.Drawable.LinearLayout_Border);

            int width = (int)(context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.Density) / 3;

            LinearLayout linearLayout4 = new LinearLayout(context);

            linearLayout4.Orientation = Android.Widget.Orientation.Vertical;
            linearLayout4.SetMinimumHeight((int)(190 * currentDensity));
            linearLayout4.SetMinimumWidth(width);

            TextView selectText = new TextView(context)
            {
                Text     = "Layout Schema",
                Gravity  = GravityFlags.Start,
                TextSize = 5 * currentDensity
            };

            selectText.SetMinimumHeight((int)(50 * currentDensity));
            selectText.SetWidth((int)(width * 0.4 * currentDensity));

            linearLayout4.AddView(selectText);

            //Here theme styles starts
            HorizontalScrollView horizontalScroll = new HorizontalScrollView(context);

            //horizontalScroll.SetPadding(0, (int)(10 * currentDensity), 0, (int)(10 * currentDensity));
            horizontalScroll.FillViewport = true;
            horizontalScroll.HorizontalScrollBarEnabled = true;
            horizontalScroll.SetMinimumHeight((int)(205 * currentDensity));
            horizontalScroll.Layout(0, (int)(30 * currentDensity), (int)(175 * currentDensity * 4), (int)(180 * currentDensity));
            scrollLayout = new LinearLayout(context);
            scrollLayout.SetPadding((int)(10 * currentDensity), (int)(10 * currentDensity), (int)(10 * currentDensity), (int)(10 * currentDensity));
            scrollLayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
            horizontalScroll.AddView(scrollLayout);
            linearLayout4.AddView(horizontalScroll);
            AddThemes();

            gridLinearLayout.AddView(linearLayout4);

            return(gridLinearLayout);
        }
Пример #5
0
        protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            // If the scroll view has changed size because of soft keyboard dismissal
            // (while WindowSoftInputModeAdjust is set to Resize), then we may need to request a
            // layout of the ScrollViewContainer
            bool requestContainerLayout = bottom > _previousBottom;

            _previousBottom = bottom;

            base.OnLayout(changed, left, top, right, bottom);
            if (_view.Content != null && _hScrollView != null)
            {
                _hScrollView.Layout(0, 0, right - left, Math.Max(bottom - top, (int)Context.ToPixels(_view.Content.Height)));
            }
            else if (_view.Content != null && requestContainerLayout)
            {
                _container?.RequestLayout();
            }
        }
Пример #6
0
        public override View GetPropertyWindowLayout(Context context)
        {
            LinearLayout gridLinearLayout = new LinearLayout(context)
            {
                Orientation = Android.Widget.Orientation.Vertical
            };

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            layoutParams.TopMargin            = (int)(25 * currentDensity);
            gridLinearLayout.LayoutParameters = layoutParams;
            gridLinearLayout.SetBackgroundResource(Resource.Drawable.LinearLayout_Border);

            int width = (int)(context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.Density) / 3;

            LinearLayout linearLayout4 = new LinearLayout(context);

            linearLayout4.Orientation = Android.Widget.Orientation.Vertical;
            linearLayout4.SetMinimumHeight((int)(70 * currentDensity));
            linearLayout4.SetMinimumWidth(width);

            TextView selectText = new TextView(context)
            {
                Text     = "Grid Color",
                Gravity  = GravityFlags.Start,
                TextSize = 5 * currentDensity
            };

            selectText.SetMinimumHeight((int)(20 * currentDensity));
            selectText.SetWidth((int)(width * 0.4 * currentDensity));

            HorizontalScrollView horizontalScroll = new HorizontalScrollView(context);

            horizontalScroll.SetPadding(0, (int)(10 * currentDensity), 0, (int)(10 * currentDensity));
            horizontalScroll.FillViewport = true;
            horizontalScroll.HorizontalScrollBarEnabled = true;
            horizontalScroll.SetMinimumHeight((int)(60 * currentDensity));
            horizontalScroll.Layout(0, (int)(20 * currentDensity), (int)(80 * currentDensity * 14), (int)(60 * currentDensity));
            scrollLayout = new LinearLayout(context);
            scrollLayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
            horizontalScroll.AddView(scrollLayout);

            AddColors();

            linearLayout4.AddView(selectText);
            linearLayout4.AddView(horizontalScroll);

            LinearLayout linearLayout1 = new LinearLayout(context);

            linearLayout1.SetPadding(0, (int)(10 * currentDensity), 0, (int)(10 * currentDensity));
            linearLayout1.SetMinimumHeight((int)(30 * currentDensity));

            TextView showGrid = new TextView(context)
            {
                Text     = "Show Grid",
                Gravity  = GravityFlags.Start,
                TextSize = 5 * currentDensity
            };

            showGrid.SetMinimumHeight((int)(20 * currentDensity));
            showGrid.SetWidth((int)(width * 0.4 * currentDensity));

            Switch showGridSwitch = new Switch(context);

            showGridSwitch.CheckedChange += ShowGridSwitch_CheckedChange;
            showGridSwitch.Gravity        = GravityFlags.Right;
            showGridSwitch.SetMinimumHeight((int)(20 * currentDensity));
            showGridSwitch.SetWidth((int)(width * 0.4 * currentDensity));

            linearLayout1.AddView(showGrid);
            linearLayout1.AddView(showGridSwitch);

            LinearLayout linearLayout2 = new LinearLayout(context);

            linearLayout2.SetPadding(0, (int)(10 * currentDensity), 0, (int)(10 * currentDensity));
            linearLayout2.SetMinimumHeight((int)(30 * currentDensity));

            TextView snapToGrid = new TextView(context)
            {
                Text     = "Snap To Grid",
                Gravity  = GravityFlags.Start,
                TextSize = 5 * currentDensity
            };

            snapToGrid.SetMinimumHeight((int)(20 * currentDensity));
            snapToGrid.SetWidth((int)(width * 0.4 * currentDensity));

            snapToGridSwitch                = new Switch(context);
            snapToGridSwitch.Enabled        = false;
            snapToGridSwitch.CheckedChange += SnapToGridSwitch_CheckedChange;
            snapToGridSwitch.Gravity        = GravityFlags.Right;
            snapToGridSwitch.SetMinimumHeight((int)(20 * currentDensity));
            snapToGridSwitch.SetWidth((int)(width * 0.4 * currentDensity));

            linearLayout2.AddView(snapToGrid);
            linearLayout2.AddView(snapToGridSwitch);

            LinearLayout linearLayout3 = new LinearLayout(context);

            linearLayout3.SetPadding(0, (int)(10 * currentDensity), 0, (int)(10 * currentDensity));
            linearLayout3.SetMinimumHeight((int)(60 * currentDensity));

            TextView connectorSize = new TextView(context)
            {
                Text     = "Size",
                Gravity  = GravityFlags.CenterVertical,
                TextSize = 5 * currentDensity
            };

            connectorSize.SetMinimumHeight((int)(20 * currentDensity));
            connectorSize.SetWidth((int)(width * 0.4 * currentDensity));

            LinearLayout plusMinus = new LinearLayout(context);

            plusMinus.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent);
            plusMinus.SetMinimumHeight((int)(40 * currentDensity));
            plusMinus.SetMinimumWidth((int)((width - (int)(width * 0.4)) * currentDensity));

            ImageButton minusButton = new ImageButton(context);

            minusButton.SetMinimumHeight((int)(20 * currentDensity));
            minusButton.Click += MinusButton_Click;
            string imageId = "diagramsub.png";

            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                minusButton.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            plusMinus.AddView(minusButton);

            label               = new TextView(context);
            label.Text          = "12";
            label.TextAlignment = TextAlignment.Center;
            label.Gravity       = GravityFlags.Center;
            label.SetMinimumHeight((int)(60 * currentDensity));
            label.SetWidth((int)(50 * currentDensity));
            plusMinus.AddView(label);

            ImageButton plusButton = new ImageButton(context);

            imageId                  = "diagramplus.png";
            plusButton.Click        += PlusButton_Click;
            plusButton.TextAlignment = TextAlignment.ViewEnd;
            if (imageId != null)
            {
                var imageData = LoadResource(imageId).ToArray();
                plusButton.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length));
            }
            plusMinus.AddView(plusButton);

            linearLayout3.AddView(connectorSize);
            linearLayout3.AddView(plusMinus);

            gridLinearLayout.AddView(linearLayout4);
            gridLinearLayout.AddView(linearLayout1);
            gridLinearLayout.AddView(linearLayout2);
            gridLinearLayout.AddView(linearLayout3);

            return(gridLinearLayout);
        }