예제 #1
0
파일: Blit.cs 프로젝트: gatm50/monoberry
        public static void Fill(Context ctx, Buffer src, UInt32 color, int dstX = 0, int dstY = 0, int transparency = (int)TransparencyTypes.SCREEN_TRANSPARENCY_NONE, int globalAlpha = 255, int scaleQuality = (int)ScaleQualityType.SCREEN_QUALITY_NORMAL)
        {
            var attribs = new int[] {
                (int)BlitAttribute.SCREEN_BLIT_COLOR,
                (int)color,
                (int)BlitAttribute.SCREEN_BLIT_DESTINATION_X,
                dstX,
                (int)BlitAttribute.SCREEN_BLIT_DESTINATION_Y,
                dstY,
                //(int)BlitAttribute.SCREEN_BLIT_TRANSPARENCY, //Error
                //transparency,
                (int)BlitAttribute.SCREEN_BLIT_GLOBAL_ALPHA,
                globalAlpha,
                //(int)BlitAttribute.SCREEN_BLIT_SCALE_QUALITY, //Error
                //scaleQuality,
                (int)BlitAttribute.SCREEN_BLIT_END
            };

            if (src == null)
                throw new Exception("Error blitting. The CurrentBuffer is null.");

            int res = screen_fill(ctx.Handle, src.Handle, attribs);
            if (res != 0)
                throw new Exception("Error blitting. Error: " + res);
        }
예제 #2
0
        public void Run()
        {
            BBUtil _util;
            using (var nav = new Navigator())
            using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT))
            using (var win = new Window(ctx))
            {
                _util = new BBUtil(ctx);

                Egl.QuerySurface(_util.Display, _util.Surface, Egl.WIDTH, out viewportWidth);
                Egl.QuerySurface(_util.Display, _util.Surface, Egl.HEIGHT, out viewportHeight);

                Console.WriteLine("viewportWidth: " + viewportWidth);
                Console.WriteLine("viewportHeight: " + viewportHeight);

                this.OnLoad(_util);

                nav.OnExit += () =>
                {
                    Console.WriteLine("I am asked to shutdown!?!");
                    PlatformServices.Shutdown(0);
                };

                PlatformServices.Run(null);
            }
        }
예제 #3
0
        public void Run()
        {
            using (var nav = new Navigator())
            using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT))
            using (var win = new Window(ctx))
            {
                win.Usage = UsageFlagType.SCREEN_USAGE_NATIVE;
                win.CreateBuffers(2);
                var bufs = win.Buffers;
                var pic = bufs[0];
                var brush = bufs[1];

                Blits.Fill(ctx, pic, 64441078);
                Blits.Fill(ctx, brush, 0xffff0000 );
                win.Render(pic);

                nav.OnSwipeDown += (() => Dialog.Alert ("#MonoBerry", "Another Event Loop", new Button ("Ack")));
                ctx.OnFingerTouch += (x, y) =>
                {
                    Blits.Blit(ctx, brush, pic, 0, 0, 10, 10, Math.Max(x - 5, 0), Math.Max(y - 5, 0));
                    win.Render(pic);
                };
                ctx.OnFingerMove = ctx.OnFingerTouch;
                ctx.OnFingerRelease = ctx.OnFingerTouch;

                nav.OnExit += () =>
                {
                    Console.WriteLine("I am asked to shutdown!?!");
                    PlatformServices.Shutdown(0);
                };

                PlatformServices.Run(null);
            }
        }
예제 #4
0
파일: Blit.cs 프로젝트: gatm50/monoberry
        public static void Blit(Context ctx, Buffer src, Buffer dst, int width, int height, int srcX = 0, int srcY = 0, int dstX = 0, int dstY = 0, int transparency = (int)TransparencyTypes.SCREEN_TRANSPARENCY_NONE, int globalAlpha = 255, int scaleQuality = (int)ScaleQualityType.SCREEN_QUALITY_NORMAL)
        {
            var attribs = new int[] {
                (int)BlitAttribute.SCREEN_BLIT_SOURCE_X,
                srcX,
                (int)BlitAttribute.SCREEN_BLIT_SOURCE_Y,
                srcY,
                (int)BlitAttribute.SCREEN_BLIT_SOURCE_WIDTH,
                width,
                (int)BlitAttribute.SCREEN_BLIT_SOURCE_HEIGHT,
                height,
                (int)BlitAttribute.SCREEN_BLIT_DESTINATION_X,
                dstX,
                (int)BlitAttribute.SCREEN_BLIT_DESTINATION_Y,
                dstY,
                (int)BlitAttribute.SCREEN_BLIT_DESTINATION_WIDTH,
                width,
                (int)BlitAttribute.SCREEN_BLIT_DESTINATION_HEIGHT,
                height,
                (int)BlitAttribute.SCREEN_BLIT_TRANSPARENCY,
                transparency,
                (int)BlitAttribute.SCREEN_BLIT_GLOBAL_ALPHA,
                globalAlpha,
                (int)BlitAttribute.SCREEN_BLIT_SCALE_QUALITY,
                scaleQuality,
                (int)BlitAttribute.SCREEN_BLIT_END
            };

            if (src == null)
                throw new Exception("Error blitting. The Buffer source cannot be null.");

            if (screen_blit(ctx.Handle, dst.Handle, src.Handle, attribs) != 0)
                throw new Exception("Error blitting.");
        }
예제 #5
0
파일: Window.cs 프로젝트: gatm50/monoberry
        public Window(Context ctx, WindowType type = WindowType.SCREEN_APPLICATION_WINDOW)
        {
            _context = ctx;

            if (type == WindowType.SCREEN_APPLICATION_WINDOW)
                this.CreateWindow();
            else
                this.CreateWindowType(type);
        }
예제 #6
0
        public void Run()
        {
            using (var nav = new Navigator())
            using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT))
            using (var win = new Window(ctx, WindowType.SCREEN_APPLICATION_WINDOW))
            {
                string groupName = "TheTeam";
                win.CreateWindowGroup(groupName);

                win.CreateBuffers(10);
                win.Identifier = "parent";

                var r = new Random();
                foreach (var b in win.Buffers)
                {
                    Blits.Fill(ctx, b, (uint)r.Next());
                    win.Render(b);
                    System.Threading.Thread.Sleep(200);
                }

                Window childWindow = new Window(ctx, WindowType.SCREEN_CHILD_WINDOW);
                childWindow.JoinWindowGroup(groupName);
                childWindow.CreateBuffer();
                childWindow.Identifier = "child";

                Blits.Fill(ctx, childWindow.Buffers[0], 50);
                childWindow.Render(childWindow.Buffers[0]);

                SoundPlayer sp = new SoundPlayer(SoundPlayer.SystemSounds.EventDeviceUntether);
                sp.PlaySound();
                VirtualKeyboard kb = new VirtualKeyboard();
                Orientation or= new Orientation();
                var run = true;
                string message=string.Format("Monoberry Runtime!. BPS Version: {0} Direction: {1}",PlatformServices.GetVersionBPS().ToString(), or.CurrentDirection.ToString());
                while (run)
                {
                    Dialog.Alert("CLOSE ME!", message,
                        //new Button ("Timer", Timer),
                        //new Button ("Camera", Cam),
                        //new Button ("Messages", () => nav.Invoke ("messages://")),
                                  //new Button("Show Keyboard", () => kb.Show()),
                                  new Button("Play Random Sound", () => this.PlaySound(sp, r)),
                                  new Button("Badge", () => nav.HasBadge = true),
                                  new Button("Browser", () => nav.Invoke("http://www.bing.com/")),
                                  new Button("Close", () => run = false));
                }
            }
        }
예제 #7
0
        private Window CreateBackgroundWindow(string groupName, Context ctx)
        {
            Window wind = new Window(ctx);
            wind.CreateWindowGroup(groupName);
            wind.IsVisible = false;

            int color = unchecked((int)13493586);
            wind.Color = color;

            wind.CreateBuffer();
            wind.SetDimensions(700, 500);

            wind.Identifier = "ID500";

            return wind;
        }
예제 #8
0
 public void Run()
 {
     _ctx = new Context(BlackberryPlatformServices.Screen.Types.ContextType.SCREEN_APPLICATION_CONTEXT);
     PlatformServices.Initialize();
     using (var win = new Window(_ctx, WindowType.SCREEN_APPLICATION_WINDOW))
     {
         _util = new BBUtil(_ctx);
         this.Initialize();
         string groupName = "TheTeam";
         win.CreateWindowGroup(groupName);
         win.CreateBuffer();
         while (true)
         {
             this.Draw();
         }
     }
 }
예제 #9
0
        public void Run()
        {
            using (var nav = new Navigator())
            using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT))
            using (var win = new Window(ctx))
            {
                _util = new BBUtil(ctx);

                this.Initialize();
                nav.RotationLock = false;
                bool exit_application = false;

                nav.OnExit = () =>
                {
                    Console.WriteLine("I am asked to shutdown!?!");
                    PlatformServices.Shutdown(0);
                    exit_application = true;
                };

                //while (!exit_application)
                //{
                    //Event e = null;
                    //for (; ; )
                    //{
                    //    PlatformServices.GetEvent(out e, 0);
                    //    if (e != null)
                    //    {
                    //        int domain = PlatformServices.GetDomainByEvent(e.Handle);

                    //        if (domain == Screen.GetDomain())
                    //            this.handleScreenEvent(e);
                    //        else if (domain == nav.Domain && (int)e.Code == (int)Navigator.EventType.NAVIGATOR_EXIT)
                    //            exit_application = true;
                    //    }
                    //    else
                    //        break;
                    //}

                    this.Render();
                //}
                PlatformServices.Run(this.Render);
                _util.Dispose();
            }
        }
예제 #10
0
        public void Run()
        {
            using (Context ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT))
            {
                Window wind = this.CreateBackgroundWindow("TheTeam", ctx);
                for (int i = 0; i < 15; i++)
                {
                    Blits.Fill(ctx, wind.Buffers[0], 68199896);
                    //wind.Buffers[0].Fill(68199896);
                    wind.Render(wind.Buffers[0]);
                    System.Threading.Thread.Sleep(200);
                }

                var run = true;
                while (run)
                {
                    Dialog.Alert("CLOSE ME!", "Monoberry Runtime XDD",
                                  new Button("Close", () => run = false));
                }
                wind.Dispose();
            }
        }
예제 #11
0
        public void Run()
        {
            _rateOfRotationPS = new float[] { 30, 45, 60 };
            _rot = new float[] { 0, 0, 0 };

            BBUtil _util;
            using (var nav = new Navigator())
            using (var ctx = new Context(ContextType.SCREEN_APPLICATION_CONTEXT))
            using (var win = new Window(ctx))
            {
                _util = new BBUtil(ctx);

                Egl.QuerySurface(_util.Display, _util.Surface, Egl.WIDTH, out _viewportWidth);
                Egl.QuerySurface(_util.Display, _util.Surface, Egl.HEIGHT, out _viewportHeight);

                this.OnLoad(_util);

                nav.OnExit += () =>
                {
                    Console.WriteLine("I am asked to shutdown!?!");
                    PlatformServices.Shutdown(0);
                };
            }
        }
예제 #12
0
파일: Context.cs 프로젝트: gatm50/monoberry
 public static Context GetInstance(ContextType type)
 {
     lock (typeof(Context))
     {
         Context ctx;
         if (!_instances.TryGetValue(type, out ctx))
         {
             ctx = new Context(type);
             _instances.Add(type, ctx);
         }
         return ctx;
     }
 }
예제 #13
0
파일: Screen.cs 프로젝트: gatm50/monoberry
 public static void RequestEvent(Context ctx)
 {
     if (screen_request_events(ctx.Handle) != (int)BPSResponse.BPS_SUCCESS)
         throw new Exception("Unable to request events from context.");
 }
예제 #14
0
 public ScreenPixmaps(Context ctx)
 {
     _context = ctx;
     if (screen_create_pixmap(out _handle, _context.Handle) != 0)
         throw new Exception("Unable to create pixmap!!");
 }
예제 #15
0
 public ScreenPixmaps(Context ctx, IntPtr buf)
 {
     _context = ctx;
     _handle = buf;
 }
예제 #16
0
 public ScreenGroup(Context ctx)
 {
     _context = ctx;
     if (screen_create_group(out _handle, _context.Handle) != 0)
         throw new Exception("Unable to create group!!");
 }
예제 #17
0
 public ScreenGroup(Context ctx, IntPtr buf)
 {
     _context = ctx;
     _handle = buf;
 }
예제 #18
0
파일: Window.cs 프로젝트: gatm50/monoberry
 public Window(Context ctx, IntPtr hnd)
 {
     _context = ctx;
     _handle = hnd;
 }
예제 #19
0
파일: Blit.cs 프로젝트: gatm50/monoberry
 public static void FlushBlits(Context ctx, int flushingType = (int)FlushingType.SCREEN_WAIT_IDLE)
 {
     if (screen_flush_blits(ctx.Handle, flushingType) != 0)
         throw new Exception("Error blitting.");
 }
예제 #20
0
파일: Device.cs 프로젝트: gatm50/monoberry
 public Device(Context ctx, EventType type)
 {
     _ctx = ctx;
     if(screen_create_device_type(out _handle, ctx.Handle, type)!=0)
         throw new Exception("Unable to create device!!");
 }
예제 #21
0
파일: Buffer.cs 프로젝트: gatm50/monoberry
 public Buffer(Context ctx)
 {
     _context = ctx;
     if (screen_create_buffer(out _handle) != 0)
         throw new Exception("Unable to create buffer!!");
 }
예제 #22
0
파일: Buffer.cs 프로젝트: gatm50/monoberry
 public Buffer(Context ctx, IntPtr buf)
 {
     _context = ctx;
     _handle = buf;
 }
예제 #23
0
파일: Screen.cs 프로젝트: gatm50/monoberry
 public static void StopEventFromContext(Context ctx)
 {
     if (screen_stop_events_from_context(ctx.Handle) != (int)BPSResponse.BPS_SUCCESS)
         throw new Exception("Unable to stop events from context.");
 }
예제 #24
0
파일: Device.cs 프로젝트: gatm50/monoberry
 public Device(Context ctx, IntPtr dev)
 {
     _ctx = ctx;
     _handle = dev;
 }