Esempio n. 1
0
        public void TestTranslate()
        {
            var offset = new CGPoint(5.6, 7.8);
            var result = _rect.Translate(offset);

            AssertUtilsIOS.AreEqualCGRect(new CGRect(_rect.X + offset.X, _rect.Y + offset.Y, _rect.Width, _rect.Height),
                                          result);
        }
        public override void Layout()
        {
            base.Layout();

            if (Frame.IsEmpty || Frame.IsInfinite() || double.IsNaN(Frame.X) || double.IsInfinity(Frame.X))
            {
                return;
            }

            nfloat maxLabelWidth = this.hexLabel.Cell.CellSizeForBounds(Frame).Width;

            for (int i = 0; i < Editors.Length; i++)
            {
                CGSize size = Editors[i].Label.Cell.CellSizeForBounds(Frame);
                if (size.Width > maxLabelWidth)
                {
                    maxLabelWidth = size.Width;
                }
            }

            maxLabelWidth = (nfloat)Math.Ceiling(maxLabelWidth);

            var frame       = Bounds;
            var labelFrame  = new CGRect(frame.X, frame.Height - DefaultControlHeight, maxLabelWidth, DefaultControlHeight);
            var editorFrame = new CGRect(labelFrame.Right, labelFrame.Y, frame.Width - labelFrame.Right, DefaultControlHeight);
            var yOffset     = DefaultControlHeight + DefaultGradientHeight + 3;

            for (int i = 0; i < Editors.Length; i++)
            {
                var channelGroup = Editors[i];

                channelGroup.Label.Frame  = labelFrame;
                channelGroup.Editor.Frame = editorFrame;
                channelGroup.Editor.Layout();

                channelGroup.Gradient.Frame = new CGRect(
                    editorFrame.X + .5f,
                    editorFrame.Y - DefaultGradientHeight + 1,
                    channelGroup.Editor.Subviews[0].Frame.Width - 1f, DefaultGradientHeight);

                channelGroup.Gradient.BorderColor   = NSColor.DisabledControlText.CGColor;
                channelGroup.Gradient.ContentsScale = Window?.Screen?.BackingScaleFactor ?? NSScreen.MainScreen.BackingScaleFactor;
                labelFrame  = labelFrame.Translate(0, -yOffset);
                editorFrame = editorFrame.Translate(0, -yOffset);
            }

            this.hexLabel.Frame  = new CGRect(frame.X, 0, maxLabelWidth, DefaultControlHeight);
            this.hexEditor.Frame = new CGRect(
                labelFrame.Right,
                0,
                frame.Width - labelFrame.Right - 16,
                DefaultControlHeight);
        }