public MainPage() { this.InitializeComponent(); _owl = new OwlMasterController.Owl(); _owl.DeviceError += _component_DeviceError; _owl.MoveCompleted += _component_MoveCompleted; _owl.DeviceInfoMessage += _owl_DeviceInfoMessage; _owl.Initialize(); SetStatusLight(Colors.Green); }
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; //} }); }