Beispiel #1
0
        public void ComplexClipping()
        {
            IVwGraphicsWin32 vwGraphics = VwGraphicsWin32Class.Create();

            Assert.IsNotNull(vwGraphics);

            using (var gr = new GraphicsObjectFromImage())
            {
                vwGraphics.Initialize(gr.Graphics.GetHdc());

                // Test on a single push
                int left, top, right, bottom;

                vwGraphics.PushClipRect(new Utils.Rect(50, 60, 500, 510));
                vwGraphics.GetClipRect(out left, out top, out right, out bottom);
                Assert.AreEqual(50, left, "Left doesn't match");
                Assert.AreEqual(60, top, "Top doesn't match");
                Assert.AreEqual(500, right, "Right doesn't match");
                Assert.AreEqual(510, bottom, "Bottom doesn't match");

                // Test on a second push
                vwGraphics.PushClipRect(new Utils.Rect(1, 1, 300, 310));
                vwGraphics.GetClipRect(out left, out top, out right, out bottom);
                Assert.AreEqual(50, left, "Left doesn't match");
                Assert.AreEqual(60, top, "Top doesn't match");
                Assert.AreEqual(300, right, "Right doesn't match");
                Assert.AreEqual(310, bottom, "Bottom doesn't match");

                vwGraphics.PopClipRect();
                vwGraphics.GetClipRect(out left, out top, out right, out bottom);
                Assert.AreEqual(50, left, "Left doesn't match");
                Assert.AreEqual(60, top, "Top doesn't match");
                Assert.AreEqual(500, right, "Right doesn't match");
                Assert.AreEqual(510, bottom, "Bottom doesn't match");
                vwGraphics.PopClipRect();
                vwGraphics.GetClipRect(out left, out top, out right, out bottom);
                Assert.AreEqual(0, left, "Left doesn't match");
                Assert.AreEqual(0, top, "Top doesn't match");
                Assert.AreEqual(1000, right, "Right doesn't match");
                Assert.AreEqual(1000, bottom, "Bottom doesn't match");

                vwGraphics.ReleaseDC();
                gr.Graphics.ReleaseHdc();
            }
        }
Beispiel #2
0
        public void GetClipRect()
        {
            IVwGraphicsWin32 vwGraphics = VwGraphicsWin32Class.Create();

            Assert.IsNotNull(vwGraphics);

            using (var gr = new GraphicsObjectFromImage())
            {
                vwGraphics.Initialize(gr.Graphics.GetHdc());

                var rect1 = new Utils.Rect(0, 0, 1000, 1000);
                var rect2 = new Utils.Rect(500, 500, 700, 700);

                vwGraphics.PushClipRect(rect1);

                int left, top, right, bottom;
                vwGraphics.GetClipRect(out left, out top, out right, out bottom);

                Assert.IsTrue(left == rect1.left, "First push failed: left");
                Assert.IsTrue(right == rect1.right, "First push failed: right");
                Assert.IsTrue(top == rect1.top, "First push failed: top");
                Assert.IsTrue(bottom == rect1.bottom, "First push failed: bottom");

                // try a second rectangle
                vwGraphics.PushClipRect(rect2);

                vwGraphics.GetClipRect(out left, out top, out right, out bottom);
                Assert.IsTrue(left == rect2.left, "Second push failed: left");
                Assert.IsTrue(right == rect2.right, "Second push failed: right");
                Assert.IsTrue(top == rect2.top, "Second push failed: top");
                Assert.IsTrue(bottom == rect2.bottom, "Second push failed: bottom");

                vwGraphics.PopClipRect();
                vwGraphics.PopClipRect();

                vwGraphics.ReleaseDC();
                gr.Graphics.ReleaseHdc();
            }
        }
Beispiel #3
0
        public void SetClipRect()
        {
            IVwGraphicsWin32 vwGraphics = VwGraphicsWin32Class.Create();

            Assert.IsNotNull(vwGraphics);

            using (var gr = new GraphicsObjectFromImage())
            {
                vwGraphics.Initialize(gr.Graphics.GetHdc());

                int left, top, right, bottom;

                var rect = new Utils.Rect(50, 25, 1000, 1000);
                vwGraphics.SetClipRect(ref rect);
                vwGraphics.GetClipRect(out left, out top, out right, out bottom);

                Assert.AreEqual(50, left, "Left doesn't match");
                Assert.AreEqual(25, top, "Top doesn't match");
                Assert.AreEqual(1000, right, "Right doesn't match");
                Assert.AreEqual(1000, bottom, "Bottom doesn't match");
            }
        }
Beispiel #4
0
        protected void ProcessGetClipRect()
        {
            int unused1, unused2, unused3, unused4;

            m_vwGraphics32.GetClipRect(out unused1, out unused2, out unused3, out unused4);
        }