예제 #1
0
        public void Constructors()
        {
            bool draw1 = false;
            bool draw2 = false;
            SPView view = new SPView(UIScreen.MainScreen.Bounds);

            SPTexture t1 = new SPTexture(200.0f, 100.0f, delegate(CGContext context) {
                // draw a string
                context.SetFillColor(1.0f, 1.0f);
                string text = "Hello Core Graphics";
                // You need a UIView instance to properly draw a string with MonoTouch
                view.DrawString(text, new PointF(20.0f, 20.0f),
                                                UIFont.FromName("Arial", 25.0f));
                draw1 = true;
            });

            SPTexture t2 = new SPTexture(200.0f, 100.0f, 2.0f, SPColorSpace.RGBA, delegate(CGContext context) {
                // draw a string
                context.SetFillColor(1.0f, 1.0f);
                string text = "Hello Core Graphics";
                // You need a UIView instance to properly draw a string with MonoTouch
                view.DrawString(text, new PointF(20.0f, 20.0f),
                                                UIFont.FromName("Arial", 25.0f));
                draw2 = true;
            });

            SPTexture t3 = new SPTexture("Media/logo.png");
            SPTexture t4 = new SPTexture(UIImage.FromBundle("Media/logo.png"));
            SPTexture t5 = new SPTexture(new SPRectangle(10.0f, 10.0f, 300.0f, 90.0f), t4);
            SPTexture t6 = SPTexture.EmptyTexture();

            Assert.True(t1.Handle != IntPtr.Zero);
            Assert.True(t2.Handle != IntPtr.Zero);
            Assert.True(t3.Handle != IntPtr.Zero);
            Assert.True(t4.Handle != IntPtr.Zero);
            Assert.True(t5.Handle != IntPtr.Zero);
            Assert.True(t6.Handle != IntPtr.Zero);
            Assert.True(draw1);
            Assert.True(draw2);
        }