Exemplo n.º 1
0
        public void SizeTrackerNegativeTest()
        {
            NuGenRatioSizeTracker sizeTracker = new NuGenRatioSizeTracker(new Size(-5, -10));

            Assert.AreEqual(0.5, sizeTracker.Ratio);

            sizeTracker.Width = 20;
            Assert.AreEqual(40, sizeTracker.Height);
        }
        public void SizeTrackerDoNotMaintainAspectRatioTest()
        {
            NuGenRatioSizeTracker sizeTracker = new NuGenRatioSizeTracker(new Size(800, 600));

            sizeTracker.Height = 480;
            Assert.AreEqual(800, sizeTracker.Width);

            sizeTracker.Width = 100;
            Assert.AreEqual(480, sizeTracker.Height);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CanvasSizeControl"/> class.
        /// </summary>
        public CanvasSizeControl()
        {
            InitializeComponent();
            NuGenSmoothColorTable colorTable = new NuGenSmoothColorTable();

            BackColor    = colorTable.ToolStripPanelGradientEnd;
            _sizeTracker = new NuGenRatioSizeTracker(new Size(_widthSpin.Value, _heightSpin.Value));
            _sizeTracker.HeightChanged += _sizeTracker_HeightChanged;
            _sizeTracker.WidthChanged  += _sizeTracker_WidthChanged;
        }
        public void UpdateSizeTrackerTest()
        {
            NuGenRatioSizeTracker sizeTracker = new NuGenRatioSizeTracker(new Size(512, 512));

            Assert.AreEqual(1.0, sizeTracker.Ratio);

            sizeTracker.Width  = 1024;
            sizeTracker.Height = 768;

            sizeTracker.UpdateRatio();
            Assert.AreEqual(1024.0 / 768.0, sizeTracker.Ratio);
        }
        public void SizeTrackerEmptyTest()
        {
            NuGenRatioSizeTracker sizeTracker = new NuGenRatioSizeTracker(Size.Empty);

            Assert.AreEqual(1.0, sizeTracker.Ratio);

            sizeTracker.Height = 0;
            sizeTracker.Width  = 0;
            Assert.AreEqual(1.0, sizeTracker.Ratio);

            sizeTracker.Width = 5;
            Assert.AreEqual(1.0, sizeTracker.Ratio);
        }
Exemplo n.º 6
0
        public void SizeTrackerEventTest()
        {
            NuGenRatioSizeTracker sizeTracker = new NuGenRatioSizeTracker(new Size(800, 600));
            SizeTrackerEventSink  eventSink   = new SizeTrackerEventSink(sizeTracker);

            eventSink.ExpectedWidth  = 640;
            eventSink.ExpectedHeight = 480;
            eventSink.ExpectedHeightChangedCallsCount = 1;
            eventSink.ExpectedWidthChangedCallsCount  = 0;

            sizeTracker.Width = 640;
            Assert.AreEqual(new Size(640, 480), sizeTracker.Size);

            eventSink.Verify();
        }
        public void SizeTrackerDoNotMaintainAspectRatioEventTest()
        {
            NuGenRatioSizeTracker sizeTracker = new NuGenRatioSizeTracker(new Size(800, 600));
            SizeTrackerEventSink  eventSink   = new SizeTrackerEventSink(sizeTracker);

            eventSink.ExpectedHeightChangedCallsCount = 0;
            eventSink.ExpectedWidthChangedCallsCount  = 0;

            sizeTracker.Height = 800;
            Assert.AreEqual(new Size(800, 800), sizeTracker.Size);

            sizeTracker.Width = 480;
            Assert.AreEqual(new Size(480, 800), sizeTracker.Size);

            eventSink.Verify();
        }
Exemplo n.º 8
0
        public void SizeTrackerMaintainAspectRatioTest()
        {
            NuGenRatioSizeTracker sizeTracker = new NuGenRatioSizeTracker(new Size(800, 600));

            Assert.AreEqual(800.0 / 600.0, sizeTracker.Ratio);

            sizeTracker.Height = 480;
            Assert.AreEqual(640, sizeTracker.Size.Width);

            sizeTracker.Width = 1280;
            Assert.AreEqual(960, sizeTracker.Size.Height);

            sizeTracker.Height = 240;
            Assert.AreEqual(320, sizeTracker.Size.Width);

            sizeTracker.Width = 100;
            Assert.AreEqual(75, sizeTracker.Size.Height);
        }
Exemplo n.º 9
0
            public SizeTrackerEventSink(NuGenRatioSizeTracker sizeTracker)
            {
                if (sizeTracker == null)
                {
                    throw new ArgumentNullException("sizeTracker");
                }

                _sizeTracker = sizeTracker;

                _sizeTracker.HeightChanged += delegate
                {
                    _expectedHeight.Actual = _sizeTracker.Height;
                    _expectedWidth.Actual  = _sizeTracker.Width;
                    _expectedHeightChangedCallsCount.Inc();
                };

                _sizeTracker.WidthChanged += delegate
                {
                    _expectedWidth.Actual  = _sizeTracker.Width;
                    _expectedHeight.Actual = _sizeTracker.Width;
                    _expectedWidthChangedCallsCount.Inc();
                };
            }