Example #1
0
        public MainGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Initialisasi camera
            CameraManager.prepareManager(new Camera2D(this));
            Components.Add(CameraManager.getInstance().camera);

            // Set full screen
            graphics.IsFullScreen = true;
            // Set orientation & size
            graphics.SupportedOrientations     = DisplayOrientation.LandscapeLeft;
            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 480;

            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);

            // Disable autolocking
            PhoneApplicationService phoneAppService = PhoneApplicationService.Current;

            phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Disabled;
        }
        public BaseCommand()
        {
            PhoneApplicationService service = PhoneApplicationService.Current;

            service.Activated   += this.OnResume;
            service.Deactivated += this.OnPause;
        }
Example #3
0
        public AppMetadata(Application application, string name, string email, bool usesLocation = false, string mapAuthenticationToken = null, Func<string> getExtraErrorReportingInfo = null)
        {
            Name = name;
            Email = email;
            UsesLocation = usesLocation;
            MapAuthenticationToken = mapAuthenticationToken;
            GetExtraErrorReportingInfo = getExtraErrorReportingInfo;

            Current = this;

            var phoneApplicationService = new PhoneApplicationService();
            phoneApplicationService.Activated += Application_Activated;
            phoneApplicationService.Closing += Application_Closing;
            phoneApplicationService.Deactivated += Application_Deactivated;
            phoneApplicationService.Launching += Application_Launching;
            phoneApplicationService.RunningInBackground += Application_RunningInBackground;
            application.ApplicationLifetimeObjects.Add(phoneApplicationService);

            application.UnhandledException += Application_UnhandledException;

            InitializePhoneApplication();

            if (Debugger.IsAttached)
            {
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
Example #4
0
 /// <summary>
 ///   Creates an instance of <see cref = "PhoneApplicationServiceAdapter" />.
 /// </summary>
 public PhoneApplicationServiceAdapter(Frame rootFrame)
 {
     service            = PhoneApplicationService.Current;
     service.Launching += delegate { isResurrecting = false; };
     service.Activated += delegate {
         if (isResurrecting)
         {
             Resurrecting();
             NavigatedEventHandler onNavigated = null;
             onNavigated = (s2, e2) => {
                 Resurrected();
                 rootFrame.Navigated -= onNavigated;
             };
             rootFrame.Navigated += onNavigated;
             isResurrecting       = false;
         }
         else
         {
             Continuing();
             NavigatedEventHandler onNavigated = null;
             onNavigated = (s2, e2) => {
                 Continued();
                 rootFrame.Navigated -= onNavigated;
             };
             rootFrame.Navigated += onNavigated;
         }
     };
 }
Example #5
0
 /// <summary>
 ///   Creates an instance of <see cref = "PhoneApplicationServiceAdapter" />.
 /// </summary>
 public PhoneApplicationServiceAdapter(Frame rootFrame)
 {
     service            = PhoneApplicationService.Current;
     service.Activated += (sender, args) => {
         if (!args.IsApplicationInstancePreserved)
         {
             IsResurrecting = true;
             Resurrecting();
             NavigatedEventHandler onNavigated = null;
             onNavigated = (s2, e2) => {
                 IsResurrecting = false;
                 Resurrected();
                 rootFrame.Navigated -= onNavigated;
             };
             rootFrame.Navigated += onNavigated;
         }
         else
         {
             Continuing();
             NavigatedEventHandler onNavigated = null;
             onNavigated = (s2, e2) => {
                 Continued();
                 rootFrame.Navigated -= onNavigated;
             };
             rootFrame.Navigated += onNavigated;
         }
     };
 }
 public TimingViewModel()
 {
     secondSoundService      = new SoundService(secSoundFileUri);
     repeatTimeOutService    = new SoundService(repeatTimeOutFileUri);
     phoneApplicationService = App.Current.ApplicationLifetimeObjects.OfType <PhoneApplicationService>().First();
     Subscribe();
 }
Example #7
0
        public AppMetadata(Application application, string name, string version, string email, bool usesLocation = false, string mapAuthenticationToken = null, Func<string> getExtraErrorReportingInfo = null)
        {
            Resources.getResourceStreamFunc = (resourceName, assemblyName) =>
                AppDomain.CurrentDomain.GetAssemblies().First(asm => asm.GetName().Name == assemblyName).GetManifestResourceStream(resourceName);

            Name = name;
            Version = version;
            Email = email;
            UsesLocation = usesLocation;
            MapAuthenticationToken = mapAuthenticationToken;
            GetExtraErrorReportingInfo = getExtraErrorReportingInfo;

            Current = this;

            var phoneApplicationService = new PhoneApplicationService();
            phoneApplicationService.Activated += Application_Activated;
            phoneApplicationService.Closing += Application_Closing;
            phoneApplicationService.Deactivated += Application_Deactivated;
            phoneApplicationService.Launching += Application_Launching;
            phoneApplicationService.RunningInBackground += Application_RunningInBackground;
            application.ApplicationLifetimeObjects.Add(phoneApplicationService);

            application.UnhandledException += Application_UnhandledException;

            InitializePhoneApplication();

            if (Debugger.IsAttached)
            {
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
Example #8
0
        public AppMetadata(Application application, string name, string version, string email, bool usesLocation = false, string mapAuthenticationToken = null, Func <string> getExtraErrorReportingInfo = null)
        {
            Resources.getResourceStreamFunc = (resourceName, assemblyName) =>
                                              AppDomain.CurrentDomain.GetAssemblies().First(asm => asm.GetName().Name == assemblyName).GetManifestResourceStream(resourceName);

            Name                       = name;
            Version                    = version;
            Email                      = email;
            UsesLocation               = usesLocation;
            MapAuthenticationToken     = mapAuthenticationToken;
            GetExtraErrorReportingInfo = getExtraErrorReportingInfo;

            Current = this;

            var phoneApplicationService = new PhoneApplicationService();

            phoneApplicationService.Activated           += Application_Activated;
            phoneApplicationService.Closing             += Application_Closing;
            phoneApplicationService.Deactivated         += Application_Deactivated;
            phoneApplicationService.Launching           += Application_Launching;
            phoneApplicationService.RunningInBackground += Application_RunningInBackground;
            application.ApplicationLifetimeObjects.Add(phoneApplicationService);

            application.UnhandledException += Application_UnhandledException;

            InitializePhoneApplication();

            if (Debugger.IsAttached)
            {
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
Example #9
0
        //VibrateController Vibration = VibrateController.Default;

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            PhoneApplicationService phoneAppService = PhoneApplicationService.Current;

            phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Disabled;
        }
Example #10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainPage()
        {
            InitializeComponent();

            VideoCanvas.Tap += new EventHandler <GestureEventArgs>(videoCanvas_Tap);

            DataContext = _dataContext;

            _progressIndicator.IsIndeterminate = true;

            CreateAppBar();
            ApplicationBarMenuItem menuItem = new ApplicationBarMenuItem();

            menuItem.Text      = "about";
            menuItem.IsEnabled = false;
            ApplicationBar.MenuItems.Add(menuItem);
            menuItem.Click += new EventHandler(aboutMenuItem_Click);

            ApplicationBarMenuItem uploadMenuItem = new ApplicationBarMenuItem();

            uploadMenuItem.Text      = "upload settings";
            uploadMenuItem.IsEnabled = false;
            ApplicationBar.MenuItems.Add(uploadMenuItem);
            uploadMenuItem.Click += new EventHandler(uploadSettingsButton_Click);

            // Disable app sleep
            PhoneApplicationService phoneAppService = PhoneApplicationService.Current;

            phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Disabled;
        }
 /// <summary>
 ///   Creates an instance of <see cref = "PhoneApplicationServiceAdapter" />.
 /// </summary>
 public PhoneApplicationServiceAdapter(Frame rootFrame) {
     service = PhoneApplicationService.Current;
     service.Launching += delegate { isResurrecting = false; };
     service.Activated += delegate {
         if(isResurrecting) {
             Resurrecting();
             NavigatedEventHandler onNavigated = null;
             onNavigated = (s2, e2) => {
                 Resurrected();
                 rootFrame.Navigated -= onNavigated;
             };
             rootFrame.Navigated += onNavigated;
             isResurrecting = false;
         }
         else {
             Continuing();
             NavigatedEventHandler onNavigated = null;
             onNavigated = (s2, e2) => {
                 Continued();
                 rootFrame.Navigated -= onNavigated;
             };
             rootFrame.Navigated += onNavigated;
         }
     };
 }
Example #12
0
        public CordovaView()
        {
            InitializeComponent();

            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }


            StartupMode mode = PhoneApplicationService.Current.StartupMode;

            if (mode == StartupMode.Launch)
            {
                PhoneApplicationService service = PhoneApplicationService.Current;
                service.Activated   += new EventHandler <Microsoft.Phone.Shell.ActivatedEventArgs>(AppActivated);
                service.Launching   += new EventHandler <LaunchingEventArgs>(AppLaunching);
                service.Deactivated += new EventHandler <DeactivatedEventArgs>(AppDeactivated);
                service.Closing     += new EventHandler <ClosingEventArgs>(AppClosing);
            }
            else
            {
            }

            // initializes native execution logic
            this.nativeExecution = new NativeExecution(ref this.CordovaBrowser);
            this.bmHelper        = new BrowserMouseHelper(ref this.CordovaBrowser);
        }
Example #13
0
        public PGView()
        {
            InitializeComponent();

            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }

            StartupMode mode = PhoneApplicationService.Current.StartupMode;

            Debug.WriteLine("StartupMode mode =" + mode.ToString());

            if (mode == StartupMode.Activate)
            {
                PhoneApplicationService service = PhoneApplicationService.Current;
                service.Activated   += new EventHandler <Microsoft.Phone.Shell.ActivatedEventArgs>(AppActivated);
                service.Launching   += new EventHandler <LaunchingEventArgs>(AppLaunching);
                service.Deactivated += new EventHandler <DeactivatedEventArgs>(AppDeactivated);
                service.Closing     += new EventHandler <ClosingEventArgs>(AppClosing);
            }
            else
            {
            }

            // initializes native execution logic
            this.nativeExecution = new NativeExecution(ref this.GapBrowser);
        }
Example #14
0
        public BaseCommand()
        {
            ResultHandlers = new Dictionary <string, EventHandler <PluginResult> >();
            PhoneApplicationService service = PhoneApplicationService.Current;

            service.Activated   += this.OnResume;
            service.Deactivated += this.OnPause;
        }
Example #15
0
        private void RscClockSaverV10_Unloaded(object sender, System.Windows.RoutedEventArgs e)
        {
            m_tmr.Stop();

            PhoneApplicationService phoneAppService = PhoneApplicationService.Current;

            phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Enabled;
        }
        public override void SaveStateTo(IDictionary <string, object> state)
        {
            PhoneApplicationService phoneAppService = PhoneApplicationService.Current;

            phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Enabled;

            base.SaveStateTo(state);
        }
        public void Dispose()
        {
            PhoneApplicationService service = PhoneApplicationService.Current;

            service.Activated   -= this.OnResume;
            service.Deactivated -= this.OnPause;
            this.OnCommandResult = null;
        }
Example #18
0
        protected override void OnNavigatedFrom(NavigationEventArgs args)
        {
            PhoneApplicationService service = PhoneApplicationService.Current;

            service.State["stopWatchRunning"]     = (bool)startStopToggle.IsChecked;
            service.State["suspensionAdjustment"] = suspensionAdjustment + stopwatch.Elapsed;
            service.State["tombstoneBeginTime"]   = DateTime.Now;

            base.OnNavigatedFrom(args);
        }
Example #19
0
        private void SaveState()
        {
            PhoneApplicationService phoneAppServeice = PhoneApplicationService.Current;
            IsolatedStorageSettings settings         = IsolatedStorageSettings.ApplicationSettings;

            if (phoneAppServeice.State.ContainsKey("username"))
            {
                settings["username"] = phoneAppServeice.State["username"];
            }
        }
        protected void PrepareApplication()
        {
            _phoneService = new PhoneApplicationService();
            _phoneService.Activated += OnActivated;
            _phoneService.Deactivated += OnDeactivated;
            _phoneService.Launching += OnLaunching;
            _phoneService.Closing += OnClosing;

            Application.ApplicationLifetimeObjects.Add(_phoneService);
        }
        protected void PrepareApplication()
        {
            _phoneService              = new PhoneApplicationService();
            _phoneService.Activated   += OnActivated;
            _phoneService.Deactivated += OnDeactivated;
            _phoneService.Launching   += OnLaunching;
            _phoneService.Closing     += OnClosing;

            Application.ApplicationLifetimeObjects.Add(_phoneService);
        }
        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (!m_bIsNavigating)
            {
                return;
            }
            PhoneApplicationService appService = PhoneApplicationService.Current;

            appService.State["viewModelDetails"] = m_viewmodelDetails;
            base.OnNavigatedFrom(e);
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            PhoneApplicationService appService = PhoneApplicationService.Current;

            if (appService.State.ContainsKey("viewModelDetails"))
            {
                this.DataContext = (ViewModelDetails)appService.State["viewModelDetails"];
            }

            base.OnNavigatedTo(e);
        }
        protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            settings.RadioButtonSoftCustomBoiled = radSoftBoiledCustom.IsChecked.Value;
            settings.RadioButtonHardCustomBoiled = radHardBoiledCustom.IsChecked.Value;
            settings.RadioButtonHardBoiled       = radBoiledHard.IsChecked.Value;
            settings.RadioButtonSoftBoiled       = radBoiledSoft.IsChecked.Value;
            settings.RadioButtonNormalPoached    = radPoachedStandard.IsChecked.Value;
            settings.RadioButtonCustomPoached    = radPoachedCustom.IsChecked.Value;
            PhoneApplicationService phoneAppService = PhoneApplicationService.Current;

            phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Enabled;
            base.OnNavigatingFrom(e);
        }
Example #25
0
        public DGGeofencing()
        {
            PhoneApplicationService service = PhoneApplicationService.Current;

            service.RunningInBackground += this.Application_RunningInBackground;
            if (DGGeofencing.Geolocator == null)
            {
                DGGeofencing.Geolocator = new Geolocator();
                DGGeofencing.Geolocator.DesiredAccuracy   = PositionAccuracy.High;
                DGGeofencing.Geolocator.MovementThreshold = 10; // The units are meters.
                DGGeofencing.Geolocator.PositionChanged  += geolocator_PositionChanged;
            }
        }
Example #26
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            PhoneApplicationService phoneAppService = PhoneApplicationService.Current;

            phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Disabled;

            DispatcherTimer timer = new DispatcherTimer();

            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }
Example #27
0
 public App()
 {
     base.add_UnhandledException(new EventHandler <ApplicationUnhandledExceptionEventArgs>(this, this.Application_UnhandledException));
     this.InitializeComponent();
     this.InitializePhoneApplication();
     if (Debugger.get_IsAttached())
     {
         Application.get_Current().get_Host().get_Settings().set_EnableFrameRateCounter(true);
         PhoneApplicationService.get_Current().set_UserIdleDetectionMode(1);
     }
     skin  = new SettRule();
     marks = MarkList.Load();
 }
Example #28
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (App.skin.IsLight)
     {
         Guide.set_IsScreenSaverEnabled(false);
         if (PhoneApplicationService.get_Current().get_ApplicationIdleDetectionMode() == 1)
         {
             PhoneApplicationService.get_Current().set_ApplicationIdleDetectionMode(0);
         }
     }
     base.set_Foreground(new SolidColorBrush(App.skin.FontColor));
 }
Example #29
0
        protected override void OnActivated(object sender, EventArgs args)
        {
            PhoneApplicationService appService = PhoneApplicationService.Current;

            if (appService.State.ContainsKey("xOrigin") &&
                appService.State.ContainsKey("yOrigin") &&
                appService.State.ContainsKey("resolution"))
            {
                PixelInfo.xPixelCoordAtComplexOrigin = (double)appService.State["xOrigin"];
                PixelInfo.yPixelCoordAtComplexOrigin = (double)appService.State["yOrigin"];
                PixelInfo.unitsPerPixel = (double)appService.State["resolution"];
            }
            else
            {
                // Program running from beginning
                PixelInfo.xPixelCoordAtComplexOrigin = 2 * viewport.Width / 3f;
                PixelInfo.yPixelCoordAtComplexOrigin = viewport.Height / 2;
                PixelInfo.unitsPerPixel = Math.Max(2.5 / viewport.Height,
                                                   3.0 / viewport.Width);
            }

            UpdateCoordinateText();

            // Restore bitmap from tombstoning or recreate it
            texture = Texture2DExtensions.LoadFromPhoneServiceState(this.GraphicsDevice,
                                                                    "mandelbrotBitmap");
            if (texture == null)
            {
                texture = new Texture2D(this.GraphicsDevice, viewport.Width, viewport.Height);
            }

            // Get texture information and pixels array
            PixelInfo.pixelWidth  = texture.Width;
            PixelInfo.pixelHeight = texture.Height;
            int numPixels = PixelInfo.pixelWidth * PixelInfo.pixelHeight;

            pixels = new uint[numPixels];
            texture.GetData <uint>(pixels);

            // Create and initialize PixelInfo array
            pixelInfos = new PixelInfo[numPixels];
            InitializePixelInfo(pixels);

            // Start up the calculation thread
            Thread thread = new Thread(PixelSetterThread);

            thread.Start();

            base.OnActivated(sender, args);
        }
        private void CordovaBrowser_Unloaded(object sender, RoutedEventArgs e)
        {
            PhoneApplicationService service = PhoneApplicationService.Current;

            service.Activated   -= new EventHandler <Microsoft.Phone.Shell.ActivatedEventArgs>(AppActivated);
            service.Launching   -= new EventHandler <LaunchingEventArgs>(AppLaunching);
            service.Deactivated -= new EventHandler <DeactivatedEventArgs>(AppDeactivated);
            service.Closing     -= new EventHandler <ClosingEventArgs>(AppClosing);

            foreach (IBrowserDecorator iBD in browserDecorators.Values)
            {
                iBD.DetachNativeHandlers();
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string thePageNum;

            NavigationContext.QueryString.TryGetValue("goto", out thePageNum);
            myPivot.SelectedIndex = Convert.ToInt32(thePageNum);
            PhoneApplicationService phoneAppService = PhoneApplicationService.Current;

            phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            RestoreSavedContents();
            ConvertEggSelectionToTime();
            txbBoiledTimer.Text = string.Format(string.Format("{0}:{1:0#}", anyTime / 60, anyTime % 60));
            base.OnNavigatedTo(e);
        }
Example #32
0
        protected override void OnDeactivated(object sender, EventArgs args)
        {
            PhoneApplicationService appService = PhoneApplicationService.Current;

            // Save piles integers
            List <int>[] piles = new List <int> [8];

            for (int i = 0; i < piles.Length; i++)
            {
                piles[i] = new List <int>();

                foreach (CardInfo cardInfo in this.piles[i])
                {
                    piles[i].Add(13 * cardInfo.Suit + cardInfo.Rank);
                }
            }
            appService.State["piles"] = piles;

            // Save finals integers
            List <int>[] finals = new List <int> [4];

            for (int i = 0; i < finals.Length; i++)
            {
                finals[i] = new List <int>();

                foreach (CardInfo cardInfo in this.finals[i])
                {
                    finals[i].Add(13 * cardInfo.Suit + cardInfo.Rank);
                }
            }
            appService.State["finals"] = finals;

            // Save holds integers
            int[] holds = new int[4];

            for (int i = 0; i < holds.Length; i++)
            {
                if (this.holds[i] == null)
                {
                    holds[i] = -1;
                }
                else
                {
                    holds[i] = 13 * this.holds[i].Suit + this.holds[i].Rank;
                }
            }
            appService.State["holds"] = holds;

            base.OnDeactivated(sender, args);
        }
Example #33
0
        public CordovaView()
        {
            InitializeComponent();

            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }


            StartupMode mode = PhoneApplicationService.Current.StartupMode;

            if (mode == StartupMode.Launch)
            {
                PhoneApplicationService service = PhoneApplicationService.Current;
                service.Activated   += new EventHandler <Microsoft.Phone.Shell.ActivatedEventArgs>(AppActivated);
                service.Launching   += new EventHandler <LaunchingEventArgs>(AppLaunching);
                service.Deactivated += new EventHandler <DeactivatedEventArgs>(AppDeactivated);
                service.Closing     += new EventHandler <ClosingEventArgs>(AppClosing);
            }
            else
            {
            }

            configHandler = new ConfigHandler();
            configHandler.LoadAppPackageConfig();

            if (configHandler.ContentSrc != null)
            {
                if (Uri.IsWellFormedUriString(configHandler.ContentSrc, UriKind.Absolute))
                {
                    this.StartPageUri = new Uri(configHandler.ContentSrc, UriKind.Absolute);
                }
                else
                {
                    this.StartPageUri = new Uri(AppRoot + "www/" + configHandler.ContentSrc, UriKind.Relative);
                }
            }

            ApplyConfigurationPreferences();

            browserDecorators = new Dictionary <string, IBrowserDecorator>();

            // initializes native execution logic
            nativeExecution = new NativeExecution(ref this.CordovaBrowser);
            bmHelper        = new BrowserMouseHelper(ref this.CordovaBrowser);

            CreateDecorators();
        }
Example #34
0
        private void StartRuntime()
        {
            // ----- Silverlight-specific initialization.
            Application          = Application.Current;
            Application.Startup += OnStartup;
            Application.Exit    += OnExit;

#if !DEBUG
#if SILVERLIGHT || WINDOWS_PHONE
            Application.UnhandledException += OnUnhandledException;
#else
            if (!Debugger.IsAttached)
            {
                Application.DispatcherUnhandledException += OnUnhandledException;
            }
#endif
#endif

#if WINDOWS_PHONE
            // ----- Windows Phone-specific initialization.
            _phoneService              = new PhoneApplicationService();
            _phoneService.Launching   += OnLaunch;
            _phoneService.Activated   += OnActivate;
            _phoneService.Deactivated += OnDeactivate;
            _phoneService.Closing     += OnClose;
            Application.ApplicationLifetimeObjects.Add(_phoneService);
#endif

            // ----- Application-specific initialization.
            OnConfigure();

#if WINDOWS_PHONE
            // ----- Initialize navigation frame.
            // Avoid double-initialization. (I have no idea why this is necessary, but it
            // is in all Microsoft samples/templates? -- MartinG)
            if (_phoneApplicationInitialized)
            {
                return;
            }

            // Create the frame but don't set it as RootVisual yet; this allows the splash
            // screen to remain active until the application is ready to render.
            RootFrame                   = CreatePhoneApplicationFrame();
            RootFrame.Navigated        += OnNavigated;
            RootFrame.NavigationFailed += OnNavigationFailed;

            _phoneApplicationInitialized = true;
#endif
        }
Example #35
0
        PhoneApplicationService appService;                    //for deactivating, launching, activated events


        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);

            appService = PhoneApplicationService.Current;
            appService.Deactivated += new EventHandler<DeactivatedEventArgs>(appService_Deactivated);
            appService.Activated += new EventHandler<ActivatedEventArgs>(appService_Activated);
        }
Example #36
0
        /// <summary>
        /// Provides an opportunity to hook into the application object.
        /// </summary>
        protected override void PrepareApplication() {
            base.PrepareApplication();

            phoneService = new PhoneApplicationService();
            phoneService.Activated += OnActivate;
            phoneService.Deactivated += OnDeactivate;
            phoneService.Launching += OnLaunch;
            phoneService.Closing += OnClose;

            Application.ApplicationLifetimeObjects.Add(phoneService);

            if (phoneApplicationInitialized)
                return;

            RootFrame = CreatePhoneApplicationFrame();
            RootFrame.Navigated += OnNavigated;

            phoneApplicationInitialized = true;
        }
Example #37
0
 public StateManager(PhoneApplicationService applicationService)
 {
     _applicationService = applicationService;
 }
 public PhoneApplicationServiceFacade(PhoneApplicationService phoneApplicationService)
 {
     this.phoneApplicationService = phoneApplicationService;
 }
Example #39
0
 /// <summary>
 ///   Creates an instance of <see cref = "PhoneApplicationServiceAdapter" />.
 /// </summary>
 public PhoneApplicationServiceAdapter(PhoneApplicationService phoneApplicationServiceservice, Frame rootFrame) {
     service = phoneApplicationServiceservice;
     service.Activated += (sender, args) => {
         if(!args.IsApplicationInstancePreserved) {
             IsResurrecting = true;
             Resurrecting();
             NavigatedEventHandler onNavigated = null;
             onNavigated = (s2, e2) => {
                 IsResurrecting = false;
                 Resurrected();
                 rootFrame.Navigated -= onNavigated;
             };
             rootFrame.Navigated += onNavigated;
         }
         else {
             Continuing();
             NavigatedEventHandler onNavigated = null;
             onNavigated = (s2, e2) => {
                 Continued();
                 rootFrame.Navigated -= onNavigated;
             };
             rootFrame.Navigated += onNavigated;
         }
     };
 }
Example #40
0
        private void StartRuntime()
        {
            // ----- Silverlight-specific initialization.
            Application = Application.Current;
            Application.Startup += OnStartup;
            Application.Exit += OnExit;

            #if !DEBUG
            #if SILVERLIGHT || WINDOWS_PHONE
            Application.UnhandledException += OnUnhandledException;
            #else
            if (!Debugger.IsAttached)
                Application.DispatcherUnhandledException += OnUnhandledException;
            #endif
            #endif

            #if WINDOWS_PHONE
            // ----- Windows Phone-specific initialization.
            _phoneService = new PhoneApplicationService();
            _phoneService.Launching += OnLaunch;
            _phoneService.Activated += OnActivate;
            _phoneService.Deactivated += OnDeactivate;
            _phoneService.Closing += OnClose;
            Application.ApplicationLifetimeObjects.Add(_phoneService);
            #endif

            // ----- Application-specific initialization.
            OnConfigure();

            #if WINDOWS_PHONE
            // ----- Initialize navigation frame.
            // Avoid double-initialization. (I have no idea why this is necessary, but it
            // is in all Microsoft samples/templates? -- MartinG)
            if (_phoneApplicationInitialized)
                return;

            // Create the frame but don't set it as RootVisual yet; this allows the splash
            // screen to remain active until the application is ready to render.
            RootFrame = CreatePhoneApplicationFrame();
            RootFrame.Navigated += OnNavigated;
            RootFrame.NavigationFailed += OnNavigationFailed;

            _phoneApplicationInitialized = true;
            #endif
        }
 /// <summary>
 /// Creates an instance of <see cref="PhoneApplicationServiceAdapter"/>.
 /// </summary>
 /// <param name="phoneService">The <see cref="PhoneApplicationService"/> to adapt.</param>
 public PhoneApplicationServiceAdapter(PhoneApplicationService phoneService)
 {
     this.phoneService = phoneService;
 }
Example #42
0
        public void Init(ApplicationDesc desc)
        {
            OS.CurrentApplication = this;
            OS.time = new Time(0);
            OS.time.Start();

            Orientation = desc.Orientation;
            UnhandledException += XAMLApplication_UnhandledException;

            this.Resources.Add("LocalizedStrings", "clr-namespace:Demo_Windows");

            var phoneApplicationService = new PhoneApplicationService();
            phoneApplicationService.Launching += Application_Launching;
            phoneApplicationService.Closing += Application_Closing;
            phoneApplicationService.Activated += Application_Activated;
            phoneApplicationService.Deactivated += Application_Deactivated;
            this.ApplicationLifetimeObjects.Add(phoneApplicationService);

            if (!phoneApplicationInitialized)
            {
                RootFrame = new PhoneApplicationFrame();
                RootFrame.UriMapper = new MainPageUriMapper();// Override the main page loader
                RootFrame.Navigated += CompleteInitializePhoneApplication;

                RootFrame.NavigationFailed += RootFrame_NavigationFailed;
                RootFrame.Navigated += CheckForResetNavigation;
                phoneApplicationInitialized = true;
            }

            if (Debugger.IsAttached)
            {
                Application.Current.Host.Settings.EnableFrameRateCounter = true;
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }