Beispiel #1
0
        public void GoToPage(string page, Action <UserInterfacePage> generator, Action <UserInterfacePage, dynamic> stateChangeHandler = null, dynamic state = null)
        {
            var pg = new UserInterfacePage(page);

            if (stateChangeHandler == null)
            {
                stateChangeHandler = delegate { }
            }
            ;
            pg.UserInterface = this;
            pg.Page.Resize(_currentWidth, _currentHeight);
            pg.Generator          = generator;
            pg.StateChangeHandler = stateChangeHandler;
            pg.StateObject        = state;
            _pages.Push(pg);
            FontManager.Instance.LoadFonts(_fontContentManager);
            //Hack: EmptyKeys stores the names for fonts as <FontName>
            //while it stores images and sounds as <folderName>/<fileName>.
            //So, we have to load from a different base directory.
            ImageManager.Instance.LoadImages(_soundAndImagesContentManager);
            SoundManager.Instance.LoadSounds(_soundAndImagesContentManager);

            generator(pg);
            if (state != null)
            {
                stateChangeHandler(pg, state);
            }
        }
Beispiel #2
0
        private void __CopyPage()
        {
            var oldPg = _pages.Pop();
            var pg    = new UserInterfacePage(oldPg.Name);

            pg.UserInterface = this;
            pg.Page.Resize(_currentWidth, _currentHeight); //This dead locks when called from another thread
            pg.Generator          = oldPg.Generator;
            pg.StateChangeHandler = oldPg.StateChangeHandler;
            pg.StateObject        = oldPg.StateObject;
            pg.Generator(pg);
            pg.StateChangeHandler(pg, pg.StateObject);
            _pages.Push(pg);

            FontManager.Instance.LoadFonts(_fontContentManager);
            ImageManager.Instance.LoadImages(_soundAndImagesContentManager);
            SoundManager.Instance.LoadSounds(_soundAndImagesContentManager);
        }