Ejemplo n.º 1
0
 private void Tracking_Click(object sender, RoutedEventArgs e)
 {
     if (Tracking.IsChecked == true)
     {
         _geolocator.PositionChanged += OnPositionChanged;
         if (dispRequest == null)
         {
             if (ApplicationData.Current.LocalSettings.Values["KeepScreenOn"].ToString() == "1")
             {
                 dispRequest = new Windows.System.Display.DisplayRequest();
                 dispRequest.RequestActive();
             }
         }
         Clear.IsEnabled = false;
     }
     else
     {
         _geolocator.PositionChanged -= OnPositionChanged;
         if (dispRequest != null)
         {
             dispRequest.RequestRelease();
             dispRequest = null;
         }
         Clear.IsEnabled = true;
     }
 }
Ejemplo n.º 2
0
        public MainPage()
        {
            this.InitializeComponent();

            //don't let the app go idle
            _displayRequest = new Windows.System.Display.DisplayRequest();
            _displayRequest.RequestActive();

            //===================================
            //Get values from config

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            Windows.Storage.StorageFolder            localFolder   = Windows.Storage.ApplicationData.Current.LocalFolder;

            //Some sample config getters from my other project.  A reminder to myself...
            //enableWingsCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableWings");
            //enableHeadCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableHead");
            //enableLeftEyeCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableLeftEye");
            //enableRightEyeCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableRightEye");

            _slider = new CamSliderCommander.Isaac879SliderControl();

            _slider.DeviceError   += _component_DeviceError;
            _slider.MoveCompleted += _component_MoveCompleted;

            _slider.DeviceInfoMessage += _slider_DeviceInfoMessage;

            _slider.Initialize();
        }
Ejemplo n.º 3
0
 private void Tracking_Click(object sender, RoutedEventArgs e)
 {
     if (Tracking.IsChecked == true)
     {
         _geolocator.PositionChanged += OnPositionChanged;
         if (dispRequest == null)
         {
             if (ApplicationData.Current.LocalSettings.Values["KeepScreenOn"].ToString() == "1")
             {
                 dispRequest = new Windows.System.Display.DisplayRequest();
                 dispRequest.RequestActive();
             }
         }
         Clear.IsEnabled = false;
     }
     else
     {
         _geolocator.PositionChanged -= OnPositionChanged;
         if (dispRequest != null)
         {
             dispRequest.RequestRelease();
             dispRequest = null;
         }
         Clear.IsEnabled = true;
     }
 }
Ejemplo n.º 4
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            SendLocation = !SendLocation;

            var displayRequest = new Windows.System.Display.DisplayRequest();

            displayRequest.RequestActive();

            thisIdentifier = Guid.NewGuid();

            while (SendLocation)
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("https://whenwilldaddybehome.azurewebsites.net/");
                    var location = await new Windows.Devices.Geolocation.Geolocator().GetGeopositionAsync();
                    var content  = new
                    {
                        Id   = thisIdentifier.ToString(),
                        Lat  = location.Coordinate.Point.Position.Latitude,
                        Long = location.Coordinate.Point.Position.Longitude
                    };
                    await client.PostAsync("a/updatemylocation", new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json"));

                    await Task.Delay(TimeSpan.FromSeconds(60));
                }
            }
        }
Ejemplo n.º 5
0
        public MainPage()
        {
            this.InitializeComponent();

            Windows.System.Display.DisplayRequest dr = new Windows.System.Display.DisplayRequest();
            dr.RequestActive();
        }
Ejemplo n.º 6
0
 public DisplayRequestLevel1()
 {
     if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.System.Display.DisplayRequest"))
     {
         _displayRequest = new Windows.System.Display.DisplayRequest();
         _displayRequest.RequestActive();
     }
 }
Ejemplo n.º 7
0
        private async void StartReceiverButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dispatcher = Window.Current.CoreWindow.Dispatcher;

                if (receiver == null)
                {
                    receiver = new Windows.Media.PlayTo.PlayToReceiver();
                }

                // Add Play To Receiver events and properties
                receiver.CurrentTimeChangeRequested  += receiver_CurrentTimeChangeRequested;
                receiver.MuteChangeRequested         += receiver_MuteChangeRequested;
                receiver.PauseRequested              += receiver_PauseRequested;
                receiver.PlaybackRateChangeRequested += receiver_PlaybackRateChangeRequested;
                receiver.PlayRequested         += receiver_PlayRequested;
                receiver.SourceChangeRequested += receiver_SourceChangeRequested;
                receiver.StopRequested         += receiver_StopRequested;
                receiver.TimeUpdateRequested   += receiver_TimeUpdateRequested;
                receiver.VolumeChangeRequested += receiver_VolumeChangeRequested;

                // <SnippetProperties>
                receiver.FriendlyName  = "Sample Play To Receiver";
                receiver.SupportsAudio = false;
                receiver.SupportsVideo = true;
                receiver.SupportsImage = false;
                // </SnippetProperties>

                // Add MediaElement events
                VideoPlayer.CurrentStateChanged += VideoPlayer_CurrentStateChanged;
                VideoPlayer.MediaEnded          += VideoPlayer_MediaEnded;
                VideoPlayer.MediaFailed         += VideoPlayer_MediaFailed;
                VideoPlayer.MediaOpened         += VideoPlayer_MediaOpened;
                VideoPlayer.RateChanged         += VideoPlayer_RateChanged;
                VideoPlayer.SeekCompleted       += VideoPlayer_SeekCompleted;
                VideoPlayer.VolumeChanged       += VideoPlayer_VolumeChanged;

                // <SnippetStartAsync>
                // Advertise the receiver on the local network and start receiving commands
                await receiver.StartAsync();

                // Prevent the screen from locking
                if (display == null)
                {
                    display = new Windows.System.Display.DisplayRequest();
                }
                display.RequestActive();

                StatusTextBlock.Text = "'" + receiver.FriendlyName + "' started.";
                // </SnippetStartAsync>
            }
            catch
            {
                receiver             = null;
                StatusTextBlock.Text = "Failed to start receiver.";
            }
        }
Ejemplo n.º 8
0
		private static void SetTrue()
		{
			if (_displayRequestRefCount < MAX_COUNT)
			{
				if (_appDisplayRequest == null) _appDisplayRequest = new Windows.System.Display.DisplayRequest();
				_appDisplayRequest.RequestActive();
				_displayRequestRefCount++;
			}
		}
Ejemplo n.º 9
0
		private static void SetFalse()
		{
			if (_displayRequestRefCount > 0)
			{
				if (_appDisplayRequest == null) _appDisplayRequest = new Windows.System.Display.DisplayRequest();
				_appDisplayRequest.RequestRelease();
				_displayRequestRefCount--;
			}
		}
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
         Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
         Microsoft.ApplicationInsights.WindowsCollectors.Session);
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     var displayRequest = new Windows.System.Display.DisplayRequest();
     displayRequest.RequestActive();
 }
Ejemplo n.º 11
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            //try
            //{
            //    Application.Current.Resources["DefaultBackgroundColor"] = Helper.GetColorBrush("#18227c");
            //}
            //catch (Exception ex)
            //{
            //}

            try
            {
                if (DeviceUtil.IsXbox)
                {
                    FullscreenModeInXbox();
                }
            }
            catch { }
            ChangeTileBarTheme();
            CreateCachedFilesFolder();
            NavigationService.StartService();
            ScreenOnRequest = new Windows.System.Display.DisplayRequest();
            if (!DeviceHelper.IsThisMinista())
            {
                await new MessageDialog("Oops, It seems you changed my app package to crack it.\r\n" +
                                        "Well done, now use my app, if you can:d\r\n" +
                                        "Pay the price dude, don't be cheap:d\r\n" +
                                        "Bye bye").ShowAsync();
                try
                {
                    CoreApplication.Exit();
                }
                catch
                {
                    try
                    {
                        Application.Current.Exit();
                    }
                    catch { }
                }
                return;
            }
            try
            {
                var flag = await GetLicenseState();

                if (!flag)
                {
                    PurchaseMessage();
                }
            }
            catch { }
        }
Ejemplo n.º 12
0
 async void deactivate()
 {
     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (dispRequest != null)
         {
             dispRequest.RequestRelease();
             dispRequest = null;
         }
     });
 }
Ejemplo n.º 13
0
 async void activate()
 {
     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (dispRequest == null)
         {
             dispRequest = new Windows.System.Display.DisplayRequest();
             dispRequest.RequestActive();
         }
     });
 }
Ejemplo n.º 14
0
        private void ActivateDisplay()
        {
            //create the request instance if needed
            if (_displayRequest == null)
            {
                _displayRequest = new Windows.System.Display.DisplayRequest();
            }

            //make request to put in active state
            _displayRequest.RequestActive();
        }
Ejemplo n.º 15
0
 private static void SetFalse()
 {
     if (_displayRequestRefCount > 0)
     {
         if (_appDisplayRequest == null)
         {
             _appDisplayRequest = new Windows.System.Display.DisplayRequest();
         }
         _appDisplayRequest.RequestRelease();
         _displayRequestRefCount--;
     }
 }
Ejemplo n.º 16
0
 private static void SetTrue()
 {
     if (_displayRequestRefCount < MAX_COUNT)
     {
         if (_appDisplayRequest == null)
         {
             _appDisplayRequest = new Windows.System.Display.DisplayRequest();
         }
         _appDisplayRequest.RequestActive();
         _displayRequestRefCount++;
     }
 }
Ejemplo n.º 17
0
        public BattlePage()
        {
            this.InitializeComponent();
            displayRequest = new Windows.System.Display.DisplayRequest();
            leftTrackBtnPressed = false;
            rightTrackBtnPressed = false;
            leftCaliBtnPressed = false;
            rightCaliBtnPressed = false;
            App.actionHelper.InclinometerStateChanged += ActionHelper_InclinometerStateChanged;

            logoGestureInputProcessor(logoGestureRecognizer);
            swipeAreaGestureInputProcessor(swipeAreaGestureRecognizer);
        }
Ejemplo n.º 18
0
        private async Task SetupUI()
        {
            var displayRequest = new Windows.System.Display.DisplayRequest();

            displayRequest.RequestActive();

            // If we have a phone contract, hide the status bar
            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
            {
                var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
                await statusBar.HideAsync();
            }
        }
Ejemplo n.º 19
0
        private Windows.System.Display.DisplayRequest _displayRequest; // This should make the hub always be awake

        public void ActivateDisplay()

        {
            //create the request instance if needed

            if (_displayRequest == null)
            {
                _displayRequest = new Windows.System.Display.DisplayRequest();
            }

            //make request to put in active state

            _displayRequest.RequestActive(); //Read more at https://blogs.windows.com/buildingapps/2016/05/24/how-to-prevent-screen-locks-in-your-uwp-apps/#VqWEXSXJBvGD8WzJ.99
        }
Ejemplo n.º 20
0
        public MainPage()
        {
            this.InitializeComponent();
            var keepScreenOnRequest = new Windows.System.Display.DisplayRequest();

            keepScreenOnRequest.RequestActive();
            //ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
            DispatcherHelper.Dispatcher  = CoreWindow.GetForCurrentThread().Dispatcher;
            DispatcherHelper.SyncContext = TaskScheduler.FromCurrentSynchronizationContext();

            _usb       = new UsbSerial("VID_1A86", "PID_7523");
            _bluetooth = new BluetoothSerial("TinBot");
            _body      = new Body(_usb);
            //_body = new Body(_bluetooth);
            _commands = new Operations.Commands(media, _body, Ear,
                                                new Dictionary <Storyboard, int>()
            {
                [bravo]          = 200,
                [feliz]          = 100,
                [feliz_verde]    = 100,
                [normal]         = 0,
                [piscadela]      = 0,
                [piscando]       = 0,
                [piscando_duplo] = 0,
                [triste]         = 200
            },
                                                new Dictionary <ETinBotFaces, Storyboard>()
            {
                [ETinBotFaces.Angry]       = bravo,
                [ETinBotFaces.Happy]       = feliz,
                [ETinBotFaces.HappyGreen]  = feliz_verde,
                [ETinBotFaces.Normal]      = normal,
                [ETinBotFaces.UniBlink]    = piscadela,
                [ETinBotFaces.Blink]       = piscando,
                [ETinBotFaces.BlinkDouble] = piscando_duplo,
                [ETinBotFaces.Sad]         = triste
            },

                                                new Dictionary <ETinBotToggle, int>()
            {
                [ETinBotToggle.Green] = 1,
                [ETinBotToggle.Red]   = 2,
                [ETinBotToggle.Blue]  = 3,
                [ETinBotToggle.Laser] = 4
            }
                                                );

            _body.ConnectionNotify += (sender, s) => ExecuteOnMainThread(() => Label.Text = s);
            _body.Setup();
        }
Ejemplo n.º 21
0
        public MainPage()
        {
            this.InitializeComponent();
            var keepScreenOnRequest = new Windows.System.Display.DisplayRequest();
            keepScreenOnRequest.RequestActive();
            //ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
            DispatcherHelper.Dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
            DispatcherHelper.SyncContext = TaskScheduler.FromCurrentSynchronizationContext();

            _usb = new UsbSerial("VID_1A86", "PID_7523");
            _bluetooth = new BluetoothSerial("TinBot");
            _body = new Body(_usb);
            //_body = new Body(_bluetooth);
            _commands = new Operations.Commands(media, _body, Ear,
                new Dictionary<Storyboard, int>()
                {
                    [bravo] = 200,
                    [feliz] = 100,
                    [feliz_verde] = 100,
                    [normal] = 0,
                    [piscadela] = 0,
                    [piscando] = 0,
                    [piscando_duplo] = 0,
                    [triste] = 200
                },
                new Dictionary<ETinBotFaces, Storyboard>()
                {
                    [ETinBotFaces.Angry] = bravo,
                    [ETinBotFaces.Happy] = feliz,
                    [ETinBotFaces.HappyGreen] = feliz_verde,
                    [ETinBotFaces.Normal] = normal,
                    [ETinBotFaces.UniBlink] = piscadela,
                    [ETinBotFaces.Blink] = piscando,
                    [ETinBotFaces.BlinkDouble] = piscando_duplo,
                    [ETinBotFaces.Sad] = triste
                },

                new Dictionary<ETinBotToggle, int>()
                {
                    [ETinBotToggle.Green] = 1,
                    [ETinBotToggle.Red] = 2,
                    [ETinBotToggle.Blue] = 3,
                    [ETinBotToggle.Laser] = 4
                }
                );

            _body.ConnectionNotify += (sender, s) => ExecuteOnMainThread(() => Label.Text = s);
            _body.Setup();
        }
Ejemplo n.º 22
0
 private void DisplayRequestRequestActive(bool screenStaysOn)
 {
     if (CurrDisplayRequest == null)
     {
         CurrDisplayRequest = new Windows.System.Display.DisplayRequest();
     }
     if (screenStaysOn)
     {
         CurrDisplayRequest.RequestActive();
     }
     else
     {
         CurrDisplayRequest.RequestRelease();
     }
 }
Ejemplo n.º 23
0
        public ButtonPage()
        {
            this.InitializeComponent();
            displayRequest = new Windows.System.Display.DisplayRequest();
            leftTrackBtnPressed = false;
            rightTrackBtnPressed = false;
            leftCaliBtnPressed = false;
            rightCaliBtnPressed = false;
            previousSensorMode = ActionHelper.SensorMode.JOYSTICK;
            dtapped = new bool[16];
            App.actionHelper.InclinometerStateChanged += ActionHelper_InclinometerStateChanged;

            logoGestureInputProcessor(logoGestureRecognizer);
            swipeAreaGestureInputProcessor(swipeAreaGestureRecognizer);
        }
Ejemplo n.º 24
0
        public static void ActivatePersistentDisplay()
        {
            //create the request instance if needed
            if (_displayRequest == null)
            {
                _displayRequest = new Windows.System.Display.DisplayRequest();
            }
            else if (isAlreadyRequested)
            {
                return;
            }

            //make request to put in active state
            _displayRequest.RequestActive();
            isAlreadyRequested = true;
        }
        private void OnKeepScreenOnChecked(object sender, RoutedEventArgs e)
        {
            if (CurrDisplayRequest == null)
            {
                CurrDisplayRequest = new Windows.System.Display.DisplayRequest();
            }
            var ischeck = (sender as CheckBox).IsChecked.GetValueOrDefault();

            if (ischeck)
            {
                CurrDisplayRequest.RequestActive();
            }
            else
            {
                CurrDisplayRequest.RequestRelease();
            }
        }
Ejemplo n.º 26
0
        public Translate()
        {
            this.InitializeComponent();
            speech = new SpeechSynthesizer();
            mediaplayer = new MediaElement();

            lstLanguages.ItemsSource = SpeechSynthesizer.AllVoices;
            lstLanguages.SelectedValuePath = "Language";
            lstLanguages.SelectedValue = SpeechSynthesizer.DefaultVoice.Language;

            tr = new Translator();

            lblResult.Text = instructions;

            Windows.System.Display.DisplayRequest dr = new Windows.System.Display.DisplayRequest();
            dr.RequestActive();
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

            if (_session == null)
                await PreventFromSuspending();

            if (_displayRequest == null)
            {
                _displayRequest = new Windows.System.Display.DisplayRequest();
                _displayRequest.RequestActive();
            }

        }
        public MainPage()
        {
            this.InitializeComponent();

            speech      = new SpeechSynthesizer();
            mediaplayer = new MediaElement();

            lstLanguages.ItemsSource       = SpeechSynthesizer.AllVoices;
            lstLanguages.SelectedValuePath = "Language";
            lstLanguages.SelectedValue     = SpeechSynthesizer.DefaultVoice.Language;

            tr = new Translator();

            lblResult.Text = instructions;

            Windows.System.Display.DisplayRequest dr = new Windows.System.Display.DisplayRequest();
            dr.RequestActive();
        }
        // More information on this behavior is documented here: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj152728.aspx

        /// <summary>
        /// To prevent screens going to sleep or locking during video playback, send an activation request.
        /// </summary>
        public void ActivateDisplay()
        {
            try
            {
                // Create the request instance if needed
                if (_displayRequest == null)
                {
                    _displayRequest = new Windows.System.Display.DisplayRequest();
                }

                // Make request to put in active state
                _displayRequest.RequestActive();
            }
            catch (Exception e)
            {
                Serilog.Log.Information(e, "Error sending display request");
            }
        }
Ejemplo n.º 30
0
        public MainPage()
        {
            InitializeComponent();

            #if DEBUG
            // Avoid screen locks while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                var keepActive = new Windows.System.Display.DisplayRequest();
                keepActive.RequestActive();
            }
            #endif

            SvgImageRenderer.InitializeForms();
            LoadApplication(new XamSvg.Demo.App());

            NavigationCacheMode = NavigationCacheMode.Required;
        }
Ejemplo n.º 31
0
        public MainPage()
        {
            this.InitializeComponent();

            //ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
            ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
            var displayRequest = new Windows.System.Display.DisplayRequest();

            displayRequest = new Windows.System.Display.DisplayRequest();
            displayRequest.RequestActive();


            int period = 200;

            ThreadPoolTimer PeriodicTimer =
                ThreadPoolTimer.CreatePeriodicTimer(TimerElapsedHandler,
                                                    TimeSpan.FromMilliseconds(period));

            PopUpCanvas.Margin = new Windows.UI.Xaml.Thickness(-85, -50, -97, -56);
            hostName           = new HostName("192.168.0.100");
            hostPort           = "7777";
            Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            SoftJoy.Visibility         = Windows.UI.Xaml.Visibility.Collapsed;
            SoftJoyBoundary.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            HorizontalLine.Visibility  = Windows.UI.Xaml.Visibility.Collapsed;
            VerticalLine.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
            PopUpCanvas.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
            SoftJoy.Opacity            = 0.2;
            faceCollection.Add(face1);
            faceCollection.Add(face2);
            faceCollection.Add(face3);
            faceCollection.Add(face4);
            faceCollection.Add(face5);

            //ValidIpAddressRegex = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
            //ValidIpAddressRegex = new Regex(@"([0-9]{1,3}\.){3}[0-9]{1,3}");

            //ValidHostnameRegex = new Regex(@"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$");
            ValidHostnameRegex = new Regex(@"^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$");

            RefreshHorizont();
            //faceCollection = new { face1, face2, face3, face4, face5 };
            this.NavigationCacheMode = NavigationCacheMode.Required;
        }
        public MainPage()
        {
            this.InitializeComponent();

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                StatusBar.GetForCurrentView().HideAsync();
            }

            _displayRequest = new Windows.System.Display.DisplayRequest();
            _displayRequest.RequestActive();

            AntaresNavigationView.SetRoutingService(new AntaresRoutingService());

            AntaresNavigationView.Map.MapLongClick += (sender, args) =>
            {
                AntaresNavigationView.StartNavigation(args.Point);
                AntaresNavigationView.Map.SetCenterAnchor(0.5f, 0.75f);
            };
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        internal App()
        {
            TLIB.PlatformHelper.ModelHelper.Platform  = new TLIB.Code.Uwp.UwpModelHelper();
            TLIB.PlatformHelper.StringHelper.Platform = new TLIB.Code.Uwp.UwpStringHelper();

            TAPPLICATION.IO.SharedIO.CurrentIO = new TLIB.Code.Uwp.UwpIO();
            TAPPLICATION.Model.SharedSettingsModel.PlatformSettings = new TLIB.Code.Uwp.UwpSettings();

            AppModel.Initialize();
            SettingsModel.Initialize();
            this.InitializeComponent();
            _displayRequest = new Windows.System.Display.DisplayRequest();
            _displayRequest.RequestActive();
            this.Suspending         += OnSuspending;
            this.UnhandledException += App_UnhandledExceptionAsync;
            UnhandledException      += App_UnhandledExceptionAsync;

            SharedSettingsModel.Instance.FOLDERMODE  = false;
            SharedSettingsModel.Instance.INTERN_SYNC = true;
        }
Ejemplo n.º 34
0
        private async void DownloadLoop()
        {
            var displayRequest = new Windows.System.Display.DisplayRequest();

            while (true)
            {
                await this.addSemaphore.WaitAsync();

                var current = this.waitForDownloads.Dequeue();
                await this.concurrentSemaphore.WaitAsync();

                if (this.downloading.Count == 0)
                {
                    displayRequest.RequestActive();
                }

                this.downloading.Add(current);
                _ = Task.Run(() =>
                             current.StartDownload().ContinueWith(async t =>
                {
                    await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        this.concurrentSemaphore.Release();
                        this.downloading.Remove(current);
                        this.allQueued.Remove(current);

                        if (current.Finished.IsFaulted)
                        {
                            App.Current.NotifyError(current, current.Finished.Exception);
                        }

                        if (this.downloading.Count == 0)
                        {
                            displayRequest.RequestRelease();
                        }
                    });
                }));;
            }
        }
Ejemplo n.º 35
0
 private void isDisplayRequest_Toggled(object sender, RoutedEventArgs e) //常亮按钮
 {
     if (isDisplayRequest.IsOn)
     {
         //create the request instance if needed
         if (_displayRequest == null)
         {
             _displayRequest = new Windows.System.Display.DisplayRequest();
         }
         //make request to put in active state
         _displayRequest.RequestActive();
     }
     else
     {
         //must be same instance, so quit if it doesn't exist
         if (_displayRequest == null)
         {
             return;
         }
         //undo the request
         _displayRequest.RequestRelease();
     }
     SaveSettings();
 }
Ejemplo n.º 36
0
        public MainPage()
        {
            ActionSchedule = new Dictionary <int, OwlCommand.Commands>();
            this.InitializeComponent();

            //don't let the app go idle
            _displayRequest = new Windows.System.Display.DisplayRequest();
            _displayRequest.RequestActive();

            //===================================
            //Get values from config

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            Windows.Storage.StorageFolder            localFolder   = Windows.Storage.ApplicationData.Current.LocalFolder;

            enableWingsCheckbox.IsChecked    = GetConfig_Bool(localSettings, "EnableWings");
            enableHeadCheckbox.IsChecked     = GetConfig_Bool(localSettings, "EnableHead");
            enableLeftEyeCheckbox.IsChecked  = GetConfig_Bool(localSettings, "EnableLeftEye");
            enableRightEyeCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableRightEye");

            //===================================

            _owl = new OwlMasterController.Owl(
                enableHeadCheckbox.IsChecked.GetValueOrDefault(),
                enableWingsCheckbox.IsChecked.GetValueOrDefault(),
                enableRightEyeCheckbox.IsChecked.GetValueOrDefault(),
                enableLeftEyeCheckbox.IsChecked.GetValueOrDefault());

            _owl.DeviceError   += _component_DeviceError;
            _owl.MoveCompleted += _component_MoveCompleted;

            _owl.DeviceInfoMessage += _owl_DeviceInfoMessage;

            _owl.Initialize();

            this.PointerPressed += ScreensaverBG_PointerPressed;
            //Return the initializer call ASAP

            Task.Factory.StartNew(() =>
            {
                ActionSchedule.Add(0, OwlCommand.Commands.RandomFull);
                ActionSchedule.Add(5, OwlCommand.Commands.Wink);
                ActionSchedule.Add(10, OwlCommand.Commands.HeadLeft);
                ActionSchedule.Add(15, OwlCommand.Commands.Wink);
                ActionSchedule.Add(20, OwlCommand.Commands.HeadRight);
                ActionSchedule.Add(25, OwlCommand.Commands.Wink);
                ActionSchedule.Add(30, OwlCommand.Commands.RandomShort);
                ActionSchedule.Add(35, OwlCommand.Commands.Wink);
                ActionSchedule.Add(40, OwlCommand.Commands.Surprise);
                ActionSchedule.Add(45, OwlCommand.Commands.Wink);
                ActionSchedule.Add(50, OwlCommand.Commands.SmallWiggle);
                ActionSchedule.Add(55, OwlCommand.Commands.Wink);

                StringBuilder sbList = new StringBuilder();
                sbList.AppendLine("SCHEDULE");
                sbList.AppendLine("=======================================");
                ActionSchedule.ToList().ForEach(v =>
                {
                    String line = String.Format(":{0} - {1}", v.Key.ToString("00"), v.Value.ToString());
                    sbList.AppendLine(line);
                });
                this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    _lastTouchDetected = DateTime.Now;
                    startupDateTime    = DateTime.Now;
                    _startupDelayTimer = ThreadPoolTimer.CreatePeriodicTimer(__startupDelayTimer_Tick, TimeSpan.FromMilliseconds(500));
                    _autoClockTimer    = ThreadPoolTimer.CreatePeriodicTimer(_clockTimer_Tick, TimeSpan.FromMilliseconds(5000));
                    _screensaverTimer  = ThreadPoolTimer.CreatePeriodicTimer(_screensaver_Tick, TimeSpan.FromMilliseconds(5000));

                    SetStatusLight(Colors.Green);
                    scheduleTextBlock.Text = sbList.ToString();
                });

                var newSession         = new ExtendedExecutionForegroundSession();
                newSession.Reason      = ExtendedExecutionForegroundReason.Unconstrained;
                newSession.Description = "Long Running Processing";
                newSession.Revoked    += OnSessionRevoked;
                //ExtendedExecutionResult result = newSession.RequestExtensionAsync().GetAwaiter().GetResult();

                newSession.RequestExtensionAsync().GetAwaiter().GetResult();

                //switch (result)
                //{
                //    case ExtendedExecutionResult.Allowed:
                //        DoLongRunningWork();
                //        break;

                //    default:
                //    case ExtendedExecutionResult.Denied:
                //        DoShortRunningWork();
                //        break;
                //}
            });
        }
Ejemplo n.º 37
0
 /// <summary>
 /// This method release the display to allow screen saver.
 /// </summary>
 public void ReleaseDisplay()
 {
     // Insert your own code here to stop the video.
     if (dispRequest != null)
     {
         // Deactivate the display request and set the var to null.
         dispRequest.RequestRelease();
         dispRequest = null;
     }
 }
Ejemplo n.º 38
0
        /// <summary>
        /// This method request the display to prevent screen saver while the MediaElement is playing a video.
        /// </summary>
        public void RequestDisplay()
        {
            if (dispRequest == null)
            {

                // Activate a display-required request. If successful, the screen is 
                // guaranteed not to turn off automatically due to user inactivity.
                dispRequest = new Windows.System.Display.DisplayRequest();
                dispRequest.RequestActive();
            }
        }
Ejemplo n.º 39
0
 public static void PrevenScreenLook()
 {
     // disable automatic screen lock
     var displayRequest = new Windows.System.Display.DisplayRequest();
     displayRequest.RequestActive();
 }
Ejemplo n.º 40
0
 /// <summary>
 /// This method release the display to allow screen saver.
 /// </summary>
 public async void ReleaseDisplay()
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
          () =>
          {
              // Insert your own code here to stop the video.
              if (dispRequest != null)
              {
                  // Deactivate the display request and set the var to null.
                  dispRequest.RequestRelease();
                  dispRequest = null;
              }
          });
 }
Ejemplo n.º 41
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            SendLocation = !SendLocation;

            var displayRequest = new Windows.System.Display.DisplayRequest();
            displayRequest.RequestActive();

            thisIdentifier = Guid.NewGuid();

            while (SendLocation)
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("https://whenwilldaddybehome.azurewebsites.net/");
                    var location = await new Windows.Devices.Geolocation.Geolocator().GetGeopositionAsync();
                    var content = new
                    {
                        Id = thisIdentifier.ToString(),
                        Lat = location.Coordinate.Point.Position.Latitude,
                        Long = location.Coordinate.Point.Position.Longitude
                    };
                    await client.PostAsync("a/updatemylocation", new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json"));

                    await Task.Delay(TimeSpan.FromSeconds(60));
                }

            }
        }
Ejemplo n.º 42
0
 private void PreventLock()
 {
     _keepScreenOnRequest = new Windows.System.Display.DisplayRequest();
     _keepScreenOnRequest.RequestActive();
 }
Ejemplo n.º 43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisplayRequest"/> class.
 /// </summary>
 public DisplayRequest()
 {
     this.request = new Windows.System.Display.DisplayRequest();
 }