Пример #1
0
        public void Save(XScreen topScreen)
        {
            var xScreenStore = new XScreenStore();

            xScreenStore.TopScreen = topScreen;

            xScreenStore.SaveToFile("screens.xml");
        }
Пример #2
0
        public virtual void Unload()
        {
            this.RootComponent.Dispose();
            this.RootComponent = null;

            this.spriteBatch.Dispose();
            this.spriteBatch = null;

            this.Content.Unload();
            this.Content.Dispose();
            this.Content = null;

            this.obstacles = null;
        }
Пример #3
0
        public virtual void Initialize()
        {
            PerfMon.Reset();

            this.oldRootComponent = this.RootComponent;

            this.IsInitialized = false;

            PerfMon.Start("ScreenInitialize");

            PerfMon.Start("LoadXml");
            if (xmlContent == null)
            {
                xmlContent = (XScreen)GameEngine.LoadXml(this.FileName, this.RootComponentType);
            }

            this.RootComponent = (XScreen)xmlContent.Copy();
            this.RootComponent.ScreenEngine = this;
            this.InsertSystemSubcomponents();
            PerfMon.Stop("LoadXml");

            this.CurrentEvents.Clear();
            this.tapAreas.Clear();
            this.obstacles.Clear();

            PerfMon.Start("InitHierarchy");
            this.RootComponent.InitHierarchy();
            PerfMon.Stop("InitHierarchy");

            PerfMon.Start("Initialize");
            game.InvokeOnMainThread(() => {
                this.RootComponent.InitializeMainThread(this.initializeParameters);
            });

            this.RootComponent.Initialize(this.initializeParameters);
            PerfMon.Stop("Initialize");

            PerfMon.Stop("ScreenInitialize");

            PerfMon.Dump();

            this.IsInitialized = true;

            if (this.oldRootComponent != null)
            {
                this.oldRootComponent.Dispose();
                this.oldRootComponent = null;
            }
        }
Пример #4
0
        public WindowResizeTest()
        {
            t = new Timer();

            dpy     = new XDisplay(IntPtr.Zero);
            s       = new XScreen(dpy);
            ev      = new XEvent(dpy);
            pointer = new XPointer(dpy);
            gc      = new XGC(dpy);

            //XShape shape = new XShape(dpy);
            //shape.Query();
            //Console.WriteLine("Shape Event Type Number = {0}", shape.Type.ToString());

            //atom = new XAtom (dpy, "_MAJYK_HINT", false);

            // Used to test the XPM function that reads a pixmap from a char**
//      pix_data = new string[] {
//            "16 16 16 1",
//            "   c None",
//            ". c #323232",
//            "+  c #535353",
//            "@  c #4A8A8E",
//            "#  c #DEE2E2",
//            "$  c #7E827A",
//            "%  c #8A9292",
//            "&  c #D6D6D6",
//            "*  c #36767E",
//            "=  c #9E9E9E",
//            "-  c #FAFAFA",
//            ";  c #B2B2B2",
//            ">  c #DEEEEA",
//            ",  c #464646",
//            "'  c #5EA2A2",
//            ")  c #52969A",
//            "                ",
//            "                ",
//            " --#>>>>>>#-#-; ",
//            " -&%')))))=&=&+ ",
//            " >;$@*****=;%;+ ",
//            " &$$$$$$$$$$$$, ",
//            " &;;;;;;;;;;;;+ ",
//            " &;;;;;;;;;;;;+ ",
//            " #;;;;;;;;;;;;+ ",
//            " &;;;;;;;;;;;;+ ",
//            " #;;;;;;;;;;;;+ ",
//            " #;;;;;;;;;;;;+ ",
//            " &;;;;;;;;;;;;+ ",
//            " $............. ",
//            "                ",
//            "                "
//      };

            bg_color     = new XColor(dpy, "#AAAAAA");
            handle_color = new XColor(dpy, "#FF0000");

            //bg_color = new XColor(dpy, Color.FromArgb(200, 200, 200));
            //handle_color = new XColor(dpy, Color.FromArgb(0, 255, 0));

            main_win = new XWindow(dpy, new Rectangle(5, 5, 640, 480), 0, s.BlackPixel(), s.WhitePixel());

            main_win.Name = "Window Resize Test";
            main_win.SelectInput(XEventMask.KeyPressMask | XEventMask.ExposureMask);

            resize_main_win         = new XWindow(dpy, main_win, new Rectangle(resize_win_x, resize_win_y, resize_win_width, resize_win_height), 1, s.BlackPixel(), bg_color.Pixel);
            resize_top_left_win     = new XWindow(dpy, resize_main_win, new Rectangle(0, 0, resize_handle_width, resize_handle_height), 1, s.BlackPixel(), handle_color.Pixel);
            resize_top_right_win    = new XWindow(dpy, resize_main_win, new Rectangle(0, 0, resize_handle_width, resize_handle_height), 1, s.BlackPixel(), handle_color.Pixel);
            resize_bottom_left_win  = new XWindow(dpy, resize_main_win, new Rectangle(0, 0, resize_handle_width, resize_handle_height), 1, s.BlackPixel(), handle_color.Pixel);
            resize_bottom_right_win = new XWindow(dpy, resize_main_win, new Rectangle(0, 0, resize_handle_width, resize_handle_height), 1, s.BlackPixel(), handle_color.Pixel);

            //string foo="MAJYK!";
            //resize_main_win.ChangeProperty(atom, atom, 8, PropMode.PropModeReplace, Marshal.StringToHGlobalAnsi(foo), foo.Length);

            //int return_type=0;
            //int actual_format=0;
            //int nitems=0;
            //int bytes_return=0;
            //IntPtr data = IntPtr.Zero;

            //resize_main_win.GetProperty(atom, 0, 2, false, atom, out return_type, out actual_format, out nitems, out bytes_return, out data);

            //string z = Marshal.PtrToStringAnsi(data);
            //Console.WriteLine("nitems = {0}, z = {1}", nitems, z);

            //pix = new XPixmap (dpy);

            //if (pix.ReadPixmapFromData (resize_main_win, pix_data)) {
            //  resize_main_win.SetBackgroundPixmap (pix);

            //  Console.WriteLine ("pixmap w = {0} | h = {1}", pix.Width.ToString (), pix.Height.ToString ());
            //}

            resize_main_win.SetBackgroundColor(Color.Gray);

            // Test TransientFor
            //resize_main_win.SetTransientForHint(main_win);
            //Window foo = resize_main_win.GetTransientForHint();
            //Console.WriteLine("resize_main_win = {0} | foo.transient_for = {1} | main_win = {2}", resize_main_win.ID.ToString(), foo.ID.ToString(), main_win.ID.ToString());

            XEventMask mask = XEventMask.ButtonPressMask | XEventMask.ButtonReleaseMask;

            resize_main_win.SelectInput(mask);
            resize_top_left_win.SelectInput(mask);
            resize_top_right_win.SelectInput(mask);
            resize_bottom_left_win.SelectInput(mask);
            resize_bottom_right_win.SelectInput(mask);

            PlaceHandles();

            resize_main_win.MapSubwindows();
            main_win.MapSubwindows();
            main_win.Map();

            ev.KeyPressHandlerEvent      += new KeyPressHandler(HandleKeyPress);
            ev.MotionNotifyHandlerEvent  += new MotionNotifyHandler(HandleMotionNotify);
            ev.ButtonPressHandlerEvent   += new ButtonPressHandler(HandleButtonPress);
            ev.ButtonReleaseHandlerEvent += new ButtonReleaseHandler(HandleButtonRelease);
            ev.ExposeHandlerEvent        += new ExposeHandler(HandleExpose);

            t.Interval = 1000;
            t.Enabled  = true;
            t.Elapsed += new ElapsedEventHandler(UpdateClock);
            t.Start();

            ev.Loop();
        }
Пример #5
0
        private void Initialize()
        {
            Name          = "blis";
            xeventsRunner = true;
            SelectInput(XEventMask.KeyPressMask
                        | XEventMask.VisibilityChangeMask
                        | XEventMask.KeyReleaseMask
                        | XEventMask.ButtonPressMask
                        | XEventMask.ButtonReleaseMask
                        | XEventMask.EnterWindowMask
                        | XEventMask.LeaveWindowMask
                        | XEventMask.PointerMotionMask
                        | XEventMask.Button1MotionMask
                        | XEventMask.Button2MotionMask
                        | XEventMask.Button3MotionMask
                        | XEventMask.Button4MotionMask
                        | XEventMask.Button5MotionMask
                        | XEventMask.ButtonMotionMask
                        | XEventMask.ExposureMask
                        | XEventMask.StructureNotifyMask
                        | XEventMask.FocusChangeMask
                        | XEventMask.PropertyChangeMask
                        | XEventMask.ColormapChangeMask
                        //| XEventMask.PointerMotionHintMask
                        //| XEventMask.KeymapStateMask
                        //| XEventMask.SubstructureNotifyMask
                        //| XEventMask.SubstructureRedirectMask
                        //| XEventMask.ResizeRedirectMask
                        );

            Screen  = new XScreen(Display);
            Pointer = new XPointer(Display);
            GC      = new XGC(Display);

            xevents = new XEvent(Display);
            xevents.ShapeHandlerEvent += (xevent, window) =>
            {
                if (ShapeHandlerEvent != null)
                {
                    ShapeHandlerEvent(xevent, window);
                }
            };
            xevents.KeyPressHandlerEvent += (xevent, window, root, subwindow) =>
            {
                if (KeyPressHandlerEvent != null)
                {
                    KeyPressHandlerEvent(xevent, window, root, subwindow);
                }
            };
            xevents.KeyReleaseHandlerEvent += (xevent, window, root, subwindow) =>
            {
                if (KeyReleaseHandlerEvent != null)
                {
                    KeyReleaseHandlerEvent(xevent, window, root, subwindow);
                }
            };
            xevents.ButtonPressHandlerEvent += (xevent, window, root, subwindow) =>
            {
                if (ButtonPressHandlerEvent != null)
                {
                    ButtonPressHandlerEvent(xevent, window, root, subwindow);
                }
            };
            xevents.ButtonReleaseHandlerEvent += (xevent, window, root, subwindow) =>
            {
                if (ButtonReleaseHandlerEvent != null)
                {
                    ButtonReleaseHandlerEvent(xevent, window, root, subwindow);
                }
            };
            xevents.ExposeHandlerEvent += (xevent, window) =>
            {
                if (ExposeHandlerEvent != null)
                {
                    ExposeHandlerEvent(xevent, window);
                }
            };
            xevents.EnterNotifyHandlerEvent += (xevent, window, root, subwindow) =>
            {
                if (EnterNotifyHandlerEvent != null)
                {
                    EnterNotifyHandlerEvent(xevent, window, root, subwindow);
                }
            };
            xevents.LeaveNotifyHandlerEvent += (xevent, window, root, subwindow) =>
            {
                if (LeaveNotifyHandlerEvent != null)
                {
                    LeaveNotifyHandlerEvent(xevent, window, root, subwindow);
                }
            };
            xevents.MotionNotifyHandlerEvent += (xevent, window, root, subwindow) =>
            {
                if (MotionNotifyHandlerEvent != null)
                {
                    MotionNotifyHandlerEvent(xevent, window, root, subwindow);
                }
            };
            xevents.FocusInHandlerEvent += (xevent, window) =>
            {
                if (FocusInHandlerEvent != null)
                {
                    FocusInHandlerEvent(xevent, window);
                }
            };
            xevents.FocusOutHandlerEvent += (xevent, window) =>
            {
                if (FocusOutHandlerEvent != null)
                {
                    FocusOutHandlerEvent(xevent, window);
                }
            };
            xevents.KeymapNotifyHandlerEvent += (xevent, window) =>
            {
                if (KeymapNotifyHandlerEvent != null)
                {
                    KeymapNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.GraphicsExposeHandlerEvent += (xevent, window) =>
            {
                if (GraphicsExposeHandlerEvent != null)
                {
                    GraphicsExposeHandlerEvent(xevent, window);
                }
            };
            xevents.NoExposeHandlerEvent += (xevent, window) =>
            {
                if (NoExposeHandlerEvent != null)
                {
                    NoExposeHandlerEvent(xevent, window);
                }
            };
            xevents.VisibilityNotifyHandlerEvent += (xevent, window) =>
            {
                if (VisibilityNotifyHandlerEvent != null)
                {
                    VisibilityNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.CreateNotifyHandlerEvent += (xevent, window, root) =>
            {
                if (CreateNotifyHandlerEvent != null)
                {
                    CreateNotifyHandlerEvent(xevent, window, root);
                }
            };
            xevents.DestroyNotifyHandlerEvent += (xevent, window) =>
            {
                if (DestroyNotifyHandlerEvent != null)
                {
                    DestroyNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.UnmapNotifyHandlerEvent += (xevent, window) =>
            {
                if (UnmapNotifyHandlerEvent != null)
                {
                    UnmapNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.MapNotifyHandlerEvent += (xevent, window) =>
            {
                if (MapNotifyHandlerEvent != null)
                {
                    MapNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.MapRequestHandlerEvent += (xevent, window, root) =>
            {
                if (MapRequestHandlerEvent != null)
                {
                    MapRequestHandlerEvent(xevent, window, root);
                }
            };
            xevents.ReparentNotifyHandlerEvent += (xevent, window, root) =>
            {
                if (ReparentNotifyHandlerEvent != null)
                {
                    ReparentNotifyHandlerEvent(xevent, window, root);
                }
            };
            xevents.ConfigureNotifyHandlerEvent += (xevent, window) =>
            {
                if (ConfigureNotifyHandlerEvent != null)
                {
                    ConfigureNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.ConfigureRequestHandlerEvent += (xevent, window) =>
            {
                if (ConfigureRequestHandlerEvent != null)
                {
                    ConfigureRequestHandlerEvent(xevent, window);
                }
            };
            xevents.GravityNotifyHandlerEvent += (xevent, window) =>
            {
                if (GravityNotifyHandlerEvent != null)
                {
                    GravityNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.ResizeRequestHandlerEvent += (xevent, window) =>
            {
                if (ResizeRequestHandlerEvent != null)
                {
                    ResizeRequestHandlerEvent(xevent, window);
                }
            };
            xevents.CirculateNotifyHandlerEvent += (xevent, window) =>
            {
                if (CirculateNotifyHandlerEvent != null)
                {
                    CirculateNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.CirculateRequestHandlerEvent += (xevent, window, root) =>
            {
                if (CirculateRequestHandlerEvent != null)
                {
                    CirculateRequestHandlerEvent(xevent, window, root);
                }
            };
            xevents.PropertyNotifyHandlerEvent += (xevent, window) =>
            {
                if (PropertyNotifyHandlerEvent != null)
                {
                    PropertyNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.SelectionClearHandlerEvent += (xevent, window) =>
            {
                if (SelectionClearHandlerEvent != null)
                {
                    SelectionClearHandlerEvent(xevent, window);
                }
            };
            xevents.SelectionRequestHandlerEvent += (xevent, window, root, subwindow) =>
            {
                if (SelectionRequestHandlerEvent != null)
                {
                    SelectionRequestHandlerEvent(xevent, window, root, subwindow);
                }
            };
            xevents.SelectionNotifyHandlerEvent += (xevent, window, root) =>
            {
                if (SelectionNotifyHandlerEvent != null)
                {
                    SelectionNotifyHandlerEvent(xevent, window, root);
                }
            };
            xevents.ColormapNotifyHandlerEvent += (xevent, window) =>
            {
                if (ColormapNotifyHandlerEvent != null)
                {
                    ColormapNotifyHandlerEvent(xevent, window);
                }
            };
            xevents.ClientMessageHandlerEvent += (xevent, window) =>
            {
                if (ClientMessageHandlerEvent != null)
                {
                    ClientMessageHandlerEvent(xevent, window);
                }
            };
            xevents.MappingNotifyHandlerEvent += (xevent, window) =>
            {
                if (MappingNotifyHandlerEvent != null)
                {
                    MappingNotifyHandlerEvent(xevent, window);
                }
            };

            Map();

            WindowsThread = new Thread(() => { while (xeventsRunner)
                                               {
                                                   xevents.Refresh();
                                               }
                                       });
            WindowsThread.Start();

            OnInitialized();
        }
Пример #6
0
 private IEnumerable <XScreen> XScreenToEnumerable(XScreen xScreen)
 {
     return(Ex.ToEnumerable <XScreen>(xScreen, x => x.Screens));
 }