예제 #1
0
파일: Main.cs 프로젝트: zendbit/monoberry
        public static void Main(string[] args)
        {
            using (var nav = new Navigator())
                using (var ctx = Context.GetInstance(ContextType.Application)) {
                    nav.OnInvokeResult = (InvokeTargetReply e) => {
                        var info = new StringBuilder();
                        info.AppendLine(String.Format("Id: {0}", e.Id));
                        info.AppendLine(String.Format("Code: {0}", e.Code));
                        info.AppendLine(String.Format("Error Message: {0}", e.ErrorMessage));
                        info.AppendLine(String.Format("Error: {0}", e.Error));
                        var i = e.Invocation;
                        Dialog.Alert("Got InvokeTargetReply", info + "\n\n" + (i == null ? "?" : i.MimeType),
                                     new Button("Quit", () => PlatformServices.Stop()));
                    };

                    using (var req = new InvokeRequest()) {
                        req.Source = "com.burningsoda.monoberry.samples.invocation";
                        req.Action = "bb.action.CAPTURE";
                        req.Target = "sys.camera.card";
                        //req.Data = new System.Text.ASCIIEncoding ().GetBytes ("photo");
                        //req.Action = "";
                        //req.MimeType = "image/jpeg";
                        nav.Invoke(req);
                    }

                    PlatformServices.Run();
                    PlatformServices.Shutdown(0);
                }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            using (var nav = new Navigator())
                using (var ctx = new Context())
                    using (var win = new Window(ctx)) {
                        win.Usage = Usage.SCREEN_USAGE_NATIVE;
                        win.AddBuffers(2);
                        var bufs  = win.Buffers;
                        var pic   = bufs[0];
                        var brush = bufs[1];

                        pic.Fill(0xffff0000);
                        brush.Fill(0xff000000);
                        win.Render(pic);

                        //nav.OnSwipeDown = () => Dialog.Alert ("#MonoBerry", "Another Event Loop", new Button ("Ack"));
                        ctx.OnFingerTouch = (x, y) => {
                            pic.Blit(brush, 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;

                        PlatformServices.Run();
                    }
        }
예제 #3
0
        protected void OnLoad(BBUtil util)
        {
            GL.Enable(All.CullFace);
            GL.ShadeModel(All.Smooth);

            GL.Hint(All.PerspectiveCorrectionHint, All.Nicest);

            // Run the render loop
            PlatformServices.Run(delegate
            {
                for (int j = 0; j < 3; j++)
                {
                    _rot[j] += (float)(_rateOfRotationPS[j] * 0.02);
                }
                this.RenderCube(util);
            });
        }
예제 #4
0
파일: Main.cs 프로젝트: zendbit/monoberry
        public static void Main(string[] args)
        {
            using (var nav = new Navigator())
                using (var ctx = Context.GetInstance(ContextType.Application))
                    using (var win = new Window(ctx)) {
                        win.AddBuffers(2);
                        var bufs   = win.Buffers;
                        var buffer = bufs [0];
                        var brush  = bufs [1];
                        var queue  = new BlockingCollection <Point> ();

                        buffer.Fill(WHITE);
                        brush.Fill(BLACK);
                        win.Render(buffer);

                        var paintThread = new Thread(() => {
                            for (;;)
                            {
                                Point point;
                                Rectangle dirty;
                                int taken;
                                for (taken = 0; taken < 10 && queue.TryTake(out point); taken++)
                                {
                                    var dst_x = Math.Min(win.Width - 10, point.X);
                                    var dst_y = Math.Min(win.Height - 10, point.Y);
                                    try {
                                        buffer.Blit(brush, 0, 0, 10, 10, dst_x, dst_y);
                                    } catch (Exception e) {
                                        Console.WriteLine(e.Message);
                                    }
                                    if (taken == 0)
                                    {
                                        dirty = new Rectangle(dst_x, dst_y, 10, 10);
                                    }
                                    else
                                    {
                                        dirty.X      = Math.Min(dirty.Left, dst_x);
                                        dirty.Width  = Math.Max(dirty.Width, (dst_x + 10) - dirty.X);
                                        dirty.Y      = Math.Min(dirty.Top, dst_y);
                                        dirty.Height = Math.Max(dirty.Height, (dst_y + 10) - dirty.Y);
                                    }
                                }
                                if (taken < 1)
                                {
                                    continue;
                                }
                                //Console.WriteLine ("Blitted {0} times before rendering", taken);
                                try {
                                    win.Render(buffer, dirty, Flushing.SCREEN_WAIT_IDLE);
                                } catch (Exception e) {
                                    Console.WriteLine(e.Message);
                                }
                            }
                        });
                        paintThread.Start();

                        nav.OnSwipeDown = () => Dialog.Alert("#MonoBerry", "Mem: " + GC.GetTotalMemory(false),
                                                             new Button("White", () => {
                            try {
                                buffer.Fill(WHITE);
                                win.Render(buffer);
                            } catch (Exception e) {
                                Console.WriteLine(e.Message);
                            }
                        }),
                                                             new Button("Red", () => {
                            try {
                                buffer.Fill(RED);
                                win.Render(buffer);
                            } catch (Exception e) {
                                Console.WriteLine(e.Message);
                            }
                        }));
                        win.OnCreate      = () => Console.WriteLine("win created.");
                        win.OnClose       = () => Console.WriteLine("win closed.");
                        ctx.OnFingerTouch = (x, y) => {
                            queue.Add(new Point(x, y));
                        };
                        ctx.OnFingerMove    = ctx.OnFingerTouch;
                        ctx.OnFingerRelease = ctx.OnFingerTouch;

                        nav.OnExit = () => {
                            Console.WriteLine("I am asked to shutdown!?!");
                            PlatformServices.Shutdown(0);
                        };
                        PlatformServices.Run();
                        Console.WriteLine("Event handler stopped. WTH?");
                        PlatformServices.Shutdown(1);
                    }
        }