示例#1
0
        internal static void SetZoomScale(Control control, float scale)
        {
            if (scale.EqualsFloat(0))
            {
                return;
            }

            if (control is IZoomScale ctrl)
            {
                if (ctrl.ZoomScaleDisabled)
                {
                    return;
                }

                //设置控件的缩放参数
                ctrl.ZoomScaleRect = UIZoomScale.Create(control);

                //设置自定义的缩放,例如UIAvatar
                ctrl.SetZoomScale(scale);

                if (control.Dock == DockStyle.Fill)
                {
                    return;
                }

                var rect = ctrl.ZoomScaleRect;
                switch (control.Dock)
                {
                case DockStyle.None:
                    control.Height = Calc(rect.Height, scale);
                    control.Width  = Calc(rect.Width, scale);

                    if (control.Parent != null)
                    {
                        if ((control.Anchor & AnchorStyles.Left) == AnchorStyles.Left)
                        {
                            control.Left = Calc(rect.Left, scale);
                        }

                        if ((control.Anchor & AnchorStyles.Right) == AnchorStyles.Right)
                        {
                            int right = Calc(rect.Left, scale);
                            control.Left = control.Parent.Width - right - control.Width;
                        }

                        if ((control.Anchor & AnchorStyles.Top) == AnchorStyles.Top)
                        {
                            if (control.Parent is UIForm form && form.ShowTitle)
                            {
                                control.Top = Calc(rect.Top - form.TitleHeight, scale) + form.TitleHeight;
                            }
                            else
                            {
                                control.Top = Calc(rect.Top, scale);
                            }
                        }

                        if ((control.Anchor & AnchorStyles.Bottom) == AnchorStyles.Bottom)
                        {
                            int bottom = Calc(rect.Top, scale);
                            control.Top = control.Parent.Height - bottom - control.Height;
                        }
                    }

                    break;
示例#2
0
 public override void SetZoomScale(float scale)
 {
     base.SetZoomScale(scale);
     circleSize = UIZoomScale.Calc(baseCircleSize, scale);
 }
示例#3
0
 public virtual void SetZoomScale(float scale)
 {
     radius = UIZoomScale.Calc(baseRadius, scale);
 }
示例#4
0
 public void SetZoomScale(float scale)
 {
     _nodeInterval = UIZoomScale.Calc(baseNodeInterval, scale);
     nodeSize      = UIZoomScale.Calc(baseNodeSize, scale);
     Invalidate();
 }