Inheritance: ICoreDispatcher, ICoreAcceleratorKeys
Esempio n. 1
0
        private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
        {
            if (args.EventType.ToString().Contains("Down") && !args.Handled)
            {
                var alt = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
                var shift = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
                var control = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
                var windows = ((Window.Current.CoreWindow.GetKeyState(VirtualKey.LeftWindows) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down) || ((Window.Current.CoreWindow.GetKeyState(VirtualKey.RightWindows) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down);
                var character = ToChar(args.VirtualKey, shift);

                var keyDown = new KeyboardEventArgs
                {
                    AltKey = alt,
                    Character = character,
                    ControlKey = control,
                    EventArgs = args,
                    ShiftKey = shift,
                    VirtualKey = args.VirtualKey
                };

                try { KeyDown?.Invoke(keyDown); }
                finally
                {
                    args.Handled = keyDown.Handled;
                }
            }
        }
        /// <summary>
        /// Query the app list on the server to get the Steam App ID
        /// </summary>
        /// <returns>True if the operation succeeded, false otherwise</returns>
        private static async Task<int> LookupAppIdForApp(CoreDispatcher dispatcher, NvHttp nv, String app)
        {
            XmlQuery appList;
            string appIdStr;

            appList = new XmlQuery(nv.BaseUrl + "/applist?uniqueid=" + nv.GetUniqueId());

            // App list query went well - try to get the app ID
            try
            {
                appIdStr = await appList.SearchElement("App", "AppTitle", app, "ID");
                Debug.WriteLine(appIdStr);
                if (appIdStr == null)
                {
                    // Not found
                    DialogUtils.DisplayDialog(dispatcher, "App Not Found", "App ID Lookup Failed");
                    return 0;
                }
            }
            // Exception connecting to the resource
            catch (Exception e)
            {
                // Steam ID lookup failed
                DialogUtils.DisplayDialog(dispatcher, "Failed to get app ID: " + e.Message, "App ID Lookup Failed");
                return 0;
            }

            // We're in the clear - save the app ID
            return Convert.ToInt32(appIdStr);
        }
Esempio n. 3
0
 public ScenarioInput5()
 {
     InitializeComponent();
     dispatcher = Window.Current.Dispatcher;
     Scenario5DisplayToastWithCallbacks.Click += Scenario5DisplayToastWithCallbacks_Click;
     Scenario5HideToast.Click += Scenario5HideToast_Click;
 }
        /// <summary>
        /// When the user presses "Start Streaming Steam", first check that they are paired
        /// </summary>
        public static async Task<StreamContext> StartStreaming(CoreDispatcher uiDispatcher, Computer computer, MoonlightStreamConfiguration streamConfig)
        {
            PairingManager p = new PairingManager(computer); 

            // If we can't get the pair state, return   
            bool? pairState = await p.QueryPairState();
            if (!pairState.HasValue)
            {
                DialogUtils.DisplayDialog(uiDispatcher, "Pair state query failed", "Failed to start streaming");
                return null;
            }

            // If we're not paired, return
            if (pairState == false)
            {
                DialogUtils.DisplayDialog(uiDispatcher, "Device not paired", "Failed to start streaming");
                return null;
            }

            // Lookup the desired app in the app list
            // NOTE: This will go away when we have a proper app list
            int appId = await LookupAppIdForApp(uiDispatcher, new NvHttp(computer.IpAddress), "Steam");
            if (appId == 0)
            {
                // LookupAppIdForApp() handles displaying a failure dialog
                return null;
            }

            return new StreamContext(computer, appId, streamConfig);
        }
Esempio n. 5
0
    async void RenderSocialGroupList(List <XboxSocialUserGroup> socialUserGroups)
    {
        Windows.UI.Core.CoreDispatcher UIDispatcher = Windows.UI.Xaml.Window.Current.CoreWindow.Dispatcher;
        await UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                    () =>
        {
            m_ui.ClearSocialGroup();

            foreach (XboxSocialUserGroup socialUserGroup in socialUserGroups)
            {
                m_ui.AppendToSocialGroup("--------------------");
                if (socialUserGroup.SocialUserGroupType == SocialUserGroupType.FilterType)
                {
                    m_ui.AppendToSocialGroup(
                        string.Format("Group from filter: {0} {1}", socialUserGroup.PresenceFilterOfGroup.ToString(), socialUserGroup.RelationshipFilterOfGroup.ToString())
                        );
                }
                else
                {
                    m_ui.AppendToSocialGroup("Group from custom list");
                }

                IReadOnlyList <XboxSocialUser> userList = socialUserGroup.Users;
                foreach (XboxSocialUser socialUser in userList)
                {
                    m_ui.AppendToSocialGroup("Gamertag: " + socialUser.Gamertag + ". Status: " + socialUser.PresenceRecord.UserState.ToString());
                }

                if (userList.Count == 0)
                {
                    m_ui.AppendToSocialGroup("No friends found");
                }
            }
        });
    }
Esempio n. 6
0
        public void Run()
        {
            dispatcher = wuc.CoreWindow.GetForCurrentThread().Dispatcher;
            Callback.OnInitialized(Widget, EventArgs.Empty);
            if (!attached)
            {
                //if (shutdown) return;
                if (Widget.MainForm != null)
                {
#if TODO_XAML
                    Control.Run((Windows.UI.Xaml.Window)Widget.MainForm.ControlObject);
#else
                    throw new NotImplementedException();
#endif
                }
                else
                {
#if TODO_XAML
                    Control.ShutdownMode = sw.ShutdownMode.OnExplicitShutdown;
                    Control.Run();
#else
                    throw new NotImplementedException();
#endif
                }
            }
        }
Esempio n. 7
0
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            SetupPersonGroup();

            dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
            bool permissionGained = await RequestMicrophonePermission();

            if (!permissionGained)
                return; // No permission granted

            Language speechLanguage = SpeechRecognizer.SystemSpeechLanguage;
            string langTag = speechLanguage.LanguageTag;
            speechContext = ResourceContext.GetForCurrentView();
            speechContext.Languages = new string[] { langTag };

            speechResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("LocalizationSpeechResources");

            await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);

            try
            {
                await speechRecognizer.ContinuousRecognitionSession.StartAsync();
            }
            catch (Exception ex)
            {
                var messageDialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Exception");
                await messageDialog.ShowAsync();
            }

        }
        public MainPage()
        {
            InitializeComponent();
            DataContext = this;
            _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

            // Create the Bluetooth LE watcher from the Windows 10 UWP
            _watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };

            // Construct the Universal Bluetooth Beacon manager
            _beaconManager = new BeaconManager();
            BeaconListView.ItemsSource = _beaconManager.BluetoothBeacons;

            // Simulate beacon info
//#if DEBUG
//            var eddystoneBeacon = new Beacon(Beacon.BeaconTypeEnum.Eddystone);
//            eddystoneBeacon.BeaconFrames.Add(new TlmEddystoneFrame(0, 3100, (float)25.5, 2000, 1000));
//            // Ranging Data 0xEE = -18dbM: needs unchecked syntax to cast constants, works without unchecked for runtime variables
//            // (sbyte)0x12 = +18dbM
//            // Sample values from: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.tx_power_level.xml
//            eddystoneBeacon.BeaconFrames.Add(new UidEddystoneFrame(unchecked((sbyte)0xEE),         
//                new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A },
//                new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }));
//            eddystoneBeacon.BeaconFrames.Add(new UrlEddystoneFrame(220, "http://www.tieto.at"));
//            eddystoneBeacon.Rssi = -49;
//            eddystoneBeacon.BluetoothAddress = 0x0000e27ef189f6c4; // 3
//            eddystoneBeacon.Timestamp = DateTimeOffset.Now;
//            _beaconManager.BluetoothBeacons.Add(eddystoneBeacon);
//#endif
        }
        /// <summary>
        /// When activating the scenario, ensure we have permission from the user to access their microphone, and
        /// provide an appropriate path for the user to enable access to the microphone if they haven't
        /// given explicit permission for it. 
        /// </summary>
        /// <param name="e">The navigation event details</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Save the UI thread dispatcher to allow speech status messages to be shown on the UI.
            dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

            bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission();
            if (permissionGained)
            {
                // Enable the recognition buttons.
                btnRecognizeWithUI.IsEnabled = true;
                btnRecognizeWithoutUI.IsEnabled = true;

                Language speechLanguage = SpeechRecognizer.SystemSpeechLanguage;
                string langTag = speechLanguage.LanguageTag;
                speechContext = ResourceContext.GetForCurrentView();
                speechContext.Languages = new string[] { langTag };

                speechResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("LocalizationSpeechResources");

                PopulateLanguageDropdown();
                await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);
            }
            else
            {
                resultTextBlock.Visibility = Visibility.Visible;
                resultTextBlock.Text = "Permission to access capture resources was not given by the user; please set the application setting in Settings->Privacy->Microphone.";
                btnRecognizeWithUI.IsEnabled = false;
                btnRecognizeWithoutUI.IsEnabled = false;
                cbLanguageSelection.IsEnabled = false;
            }
        }
Esempio n. 10
0
 public OOBENetwork()
 {
     this.InitializeComponent();
     OOBENetworkPageDispatcher = Window.Current.Dispatcher;
     SetupNetwork();
     NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;
 }
        /// <summary>
        /// Upon entering the scenario, ensure that we have permissions to use the Microphone. This may entail popping up
        /// a dialog to the user on Desktop systems. Only enable functionality once we've gained that permission in order to 
        /// prevent errors from occurring when using the SpeechRecognizer. If speech is not a primary input mechanism, developers
        /// should consider disabling appropriate parts of the UI if the user does not have a recording device, or does not allow 
        /// audio input.
        /// </summary>
        /// <param name="e">Unused navigation parameters</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            // Keep track of the UI thread dispatcher, as speech events will come in on a separate thread.
            dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

            // Prompt the user for permission to access the microphone. This request will only happen
            // once, it will not re-prompt if the user rejects the permission.
            bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission();
            if (permissionGained)
            {
                btnContinuousRecognize.IsEnabled = true;

                PopulateLanguageDropdown();
                await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);
            }
            else
            {
                this.dictationTextBox.Text = "Permission to access capture resources was not given by the user, reset the application setting in Settings->Privacy->Microphone.";
                btnContinuousRecognize.IsEnabled = false;
                cbLanguageSelection.IsEnabled = false;
            }

        }
        public BluetoothAdvertismentViewerViewModel()
        {
            _table = new ConcurrentDictionary<string, BluetoothLEAdvertismentViewModel>();
            _devices = new ObservableCollection<BluetoothLEAdvertismentViewModel>();
            Advertisements = new CollectionViewSource();
            Advertisements.Source = _devices;
            _dispatcher = Advertisements.Dispatcher;

            _watcher = new BluetoothLEAdvertisementWatcher();

            // Finally set the data payload within the manufacturer-specific section
            // Here, use a 16-bit UUID: 0x1234 -> {0x34, 0x12} (little-endian)
            //var writer = new DataWriter();
            //writer.WriteUInt16(0x1234);
            //manufacturerData.Data = writer.DetachBuffer();
            //watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(manufacturerData);
            _watcher.SignalStrengthFilter.InRangeThresholdInDBm = -70;
            _watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -75;
            _watcher.SignalStrengthFilter.OutOfRangeTimeout = TimeSpan.FromMilliseconds(2000);
            _watcher.Received += OnAdvertisementReceived;
            _watcher.Stopped += OnAdvertisementWatcherStopped;

            RunCommand = new SimpleCommand(StartWatcher);
            StopCommand = new SimpleCommand(StopWatcher, false);
        }
Esempio n. 13
0
    public void Start()
    {
        Windows.ApplicationModel.Core.CoreApplicationView mainView = Windows.ApplicationModel.Core.CoreApplication.MainView;
        Windows.UI.Core.CoreWindow cw = mainView.CoreWindow;

        coreDispatcher = cw.Dispatcher;
    }
Esempio n. 14
0
 /// <summary>
 /// Initialization method that must be called from the UI thread
 /// </summary>
 public static void Init()
 {
     if (m_refDispatcher == null)
     {
         Dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
     }
 }
Esempio n. 15
0
        public ModuleManager()
        {
            _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
            _periodicTastQueue = new Queue<Task>();

            Initialize();
        }
Esempio n. 16
0
 public SongDownloadService(ICollectionService service, ISqlService sqlService, CoreDispatcher dispatcher)
 {
     this.service = service;
     this.sqlService = sqlService;
     this.dispatcher = dispatcher;
     ActiveDownloads = new ObservableCollection<Song>();
 }
Esempio n. 17
0
 public BlankPage8()
 {
     this.InitializeComponent();
     MainDispatcher = this.Dispatcher;
     _mainController = new MainController();
     Loaded += BlankPage8_Loaded;
 }
Esempio n. 18
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            var 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();

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

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

            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
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
            Dispatcher = Window.Current.Dispatcher;
        }
        /// <summary>
        /// Upon entering the scenario, ensure that we have permissions to use the Microphone. This may entail popping up
        /// a dialog to the user on Desktop systems. Only enable functionality once we've gained that permission in order to 
        /// prevent errors from occurring when using the SpeechRecognizer. If speech is not a primary input mechanism, developers
        /// should consider disabling appropriate parts of the UI if the user does not have a recording device, or does not allow 
        /// audio input.
        /// </summary>
        /// <param name="e">Unused navigation parameters</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            // Keep track of the UI thread dispatcher, as speech events will come in on a separate thread.
            dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

            // Prompt the user for permission to access the microphone. This request will only happen
            // once, it will not re-prompt if the user rejects the permission.
            bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission();
            if (permissionGained)
            {
                btnContinuousRecognize.IsEnabled = true;
            }
            else
            {
                resultTextBlock.Text = "Permission to access capture resources was not given by the user, reset the application setting in Settings->Privacy->Microphone.";
            }


            Language speechLanguage = SpeechRecognizer.SystemSpeechLanguage;
            string langTag = speechLanguage.LanguageTag;
            speechContext = ResourceContext.GetForCurrentView();
            speechContext.Languages = new string[] { langTag };

            speechResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("LocalizationSpeechResources");

            PopulateLanguageDropdown();

            // Initialize the recognizer. Since the recognizer is disposed on scenario exit, we need to make sure we re-initialize it on scenario
            // entrance, as the xaml page may not get destroyed between openings of the scenario.
            await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);
        }
Esempio n. 20
0
 public async Task<ImageSource> InitializeAsync(CoreDispatcher dispatcher, IRandomAccessStream streamSource, CancellationTokenSource cancellationTokenSource)
 {
     byte[] bytes = new byte[streamSource.Size];
     await streamSource.ReadAsync(bytes.AsBuffer(), (uint)streamSource.Size, InputStreamOptions.None).AsTask(cancellationTokenSource.Token);
     var imageSource = WebpCodec.Decode(bytes);
     return imageSource;
 }
        /// <summary>
        /// Upon entering the scenario, ensure that we have permissions to use the Microphone. This may entail popping up
        /// a dialog to the user on Desktop systems. Only enable functionality once we've gained that permission in order to 
        /// prevent errors from occurring when using the SpeechRecognizer. If speech is not a primary input mechanism, developers
        /// should consider disabling appropriate parts of the UI if the user does not have a recording device, or does not allow 
        /// audio input.
        /// </summary>
        /// <param name="e">Unused navigation parameters</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            // Keep track of the UI thread dispatcher, as speech events will come in on a separate thread.
            dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

            // Prompt the user for permission to access the microphone. This request will only happen
            // once, it will not re-prompt if the user rejects the permission.
            bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission();
            if (permissionGained)
            {
                btnContinuousRecognize.IsEnabled = true;
                
                // Initialize resource map to retrieve localized speech strings.
                Language speechLanguage = SpeechRecognizer.SystemSpeechLanguage;
                string langTag = speechLanguage.LanguageTag;
                speechContext = ResourceContext.GetForCurrentView();
                speechContext.Languages = new string[] { langTag };

                speechResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("LocalizationSpeechResources");

                PopulateLanguageDropdown();
                await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);
            }
            else
            {
                this.resultTextBlock.Visibility = Visibility.Visible;
                this.resultTextBlock.Text = "Permission to access capture resources was not given by the user, reset the application setting in Settings->Privacy->Microphone.";
                btnContinuousRecognize.IsEnabled = false;
                cbLanguageSelection.IsEnabled = false;
            }
        }
Esempio n. 22
0
 public UtilWS()
 {
     // must be called from the UI thread
     var coreWindow = CoreWindow.GetForCurrentThread();
     if (coreWindow != null)
         Dispatcher = coreWindow.Dispatcher;
 }
Esempio n. 23
0
        private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
        {
            if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
                e.EventType == CoreAcceleratorKeyEventType.KeyDown))
            {
                var coreWindow = Windows.UI.Xaml.Window.Current.CoreWindow;
                var downState = CoreVirtualKeyStates.Down;
                var virtualKey = e.VirtualKey;
                bool winKey = ((coreWindow.GetKeyState(VirtualKey.LeftWindows) & downState) == downState || (coreWindow.GetKeyState(VirtualKey.RightWindows) & downState) == downState);
                bool altKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
                bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
                bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;

                // raise keydown actions
                var keyDown = new KeyboardEventArgs
                {
                    AltKey = altKey,
                    Character = ToChar(virtualKey, shiftKey),
                    ControlKey = controlKey,
                    EventArgs = e,
                    ShiftKey = shiftKey,
                    VirtualKey = virtualKey
                };

                try { _KeyDown?.Raise(this, keyDown); }
                catch { }

                // Handle F5 to refresh content
                if (virtualKey == VirtualKey.F5)
                {
                    bool noModifiers = !altKey && !controlKey && !shiftKey;
                    _RefreshRequest?.Raise(this, keyDown);
                }
            }
        }
Esempio n. 24
0
        public MainViewModel(FrameworkElement container)
        {
            this._container = container;

            this.Game = new GameViewModel();
            this.AppSettings = new AppSettingsViewModel();
            this.Button1 = new ButtonViewModel() { Id = 1, Color = Color.FromArgb(255, 0, 0, 0), Left = 100, Top = 100, Size = 250 };
            this.Button2 = new ButtonViewModel() { Id = 2, Color = Color.FromArgb(0, 0, 255, 0), Left = 450, Top = 250, Size = 180 };

            this.CurrentButtonSequence = new ObservableCollection<int>();
            this._dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
            this._buttonPressTimer = new Timer(OnButtonPressedTimerElapsed, null, 500, Timeout.Infinite);
            this.ButtonsVisible = false;

            // TODO injection
            this.hubClient = new HubClient(this);

            // DEBUG
            //_ticker = new Timer(TickerElapsed, null, 2000, Timeout.Infinite);

            // DEBUG scores
            var testScores = new Dictionary<string, int>();
            testScores.Add("Sorin", 45);
            testScores.Add("David", 8);
            testScores.Add("Eric", 39);
            testScores.Add("Johny", 66);

            this.OnPlayerScoresUpdating(
                new UpdatePlayerScoresMessage()
                {
                    PlayerScores = testScores
                });
        }
		public WindowsBasePlatformServices(CoreDispatcher dispatcher)
		{
			if (dispatcher == null)
				throw new ArgumentNullException("dispatcher");

			_dispatcher = dispatcher;
		}
Esempio n. 26
0
        /// <summary>
        /// Pair with the hostname in the textbox
        /// </summary>
        public async Task Pair(CoreDispatcher uiDispatcher, Computer c)
        {
            Debug.WriteLine("Pairing...");

            // Get the pair state.
            bool? pairState = await QueryPairState(); 
            if (pairState == true)
            {
                DialogUtils.DisplayDialog(uiDispatcher, "This device is already paired to the host PC", "Already Paired");
                return;
            }
            // pairstate = null. We've encountered an error
            else if (!pairState.HasValue)
            {
                DialogUtils.DisplayDialog(uiDispatcher, "Failed to query pair state", "Pairing failed");
                return;
            }

            bool challenge = await PairingCryptoHelpers.PerformPairingHandshake(uiDispatcher, new WindowsCryptoProvider(), nv, nv.GetUniqueId());
            if (!challenge)
            {
                Debug.WriteLine("Challenges failed");
                return; 
            } 

            // Otherwise, everything was successful
            MainPage.SaveComputer(c);

            // FIXME: We can't have two dialogs open at once.
            // DialogUtils.DisplayDialog(uiDispatcher, "Pairing successful", "Success");
        }
        public MapsViewModel(MapControl mapControl)
        {
            _mapControl = mapControl;
            StopStreetViewCommand = new DelegateCommand(StopStreetView, () => IsStreetView);
            StartStreetViewCommand = new DelegateCommand(StartStreetViewAsync, () => !IsStreetView);

            if (!DesignMode.DesignModeEnabled)
            {
                _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
            }

            _locator.StatusChanged += async (s, e) =>
            {
                await _dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                                PositionStatus = e.Status
                );
            };

            // intialize defaults at startup
            CurrentPosition = new Geopoint(new BasicGeoposition { Latitude = 48.2, Longitude = 16.3 });
            // { Latitude = 47.604, Longitude = -122.329 });
            CurrentMapStyle = MapStyle.Road;
            DesiredPitch = 0;
            ZoomLevel = 12;
        }
Esempio n. 28
0
 internal AudioPlayerControl(CoreDispatcher dispatcher)
 {
     this.dispatcher = dispatcher;
     BackgroundMediaPlayer.MessageReceivedFromBackground += BackgroundMediaPlayer_MessageReceivedFromBackground;
     SendToBackground(CommunicationConstants.GetInfo);
     BackgroundMediaPlayer.Current.CurrentStateChanged += BackgroundMediaPlayer_CurrentStateChanged;
 }
Esempio n. 29
0
        public MainPage()
        {
            this.InitializeComponent();
            DataContext = this;
            _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

            // Create the Bluetooth LE watcher from the Windows 10 UWP
            _watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };

            // Construct the Universal Bluetooth Beacon manager
            _beaconManager = new BeaconManager();
            BeaconListView.ItemsSource = _beaconManager.BluetoothBeacons;

            // Simulate beacon info
//#if DEBUG
//            var eddystoneBeacon = new Beacon(Beacon.BeaconTypeEnum.Eddystone);
//            eddystoneBeacon.BeaconFrames.Add(new TlmEddystoneFrame(0, 3100, (float)25.5, 2000, 1000));
//            eddystoneBeacon.BeaconFrames.Add(new UidEddystoneFrame(220,
//                new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A },
//                new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }));
//            eddystoneBeacon.BeaconFrames.Add(new UrlEddystoneFrame(220, "http://www.tieto.at"));
//            eddystoneBeacon.Rssi = -49;
//            eddystoneBeacon.BluetoothAddress = 0x0000e27ef189f6c4; // 3
//            eddystoneBeacon.Timestamp = DateTimeOffset.Now;
//            _beaconManager.BluetoothBeacons.Add(eddystoneBeacon);
//#endif
        }
        public DashboardViewModel(CoreDispatcher dispatcher)
        {
            _dispatcher = dispatcher;
            PageTitle = "Learning to use Gyrometer";

            SetupSensor();
        }
Esempio n. 31
0
        public WindowsPhoneRunner(Windows.UI.Core.CoreDispatcher dispatcher, Windows.UI.Xaml.Controls.TextBlock textBlock)
        {
            _dispatcher = dispatcher;
            _output = textBlock;


        }
 public DownloadableViewModelBase()
 {
     IsDownloading = false;
     IsIndeterminate = true;
     _cts = new CancellationTokenSource();
     _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
 }
Esempio n. 33
0
        /// <summary>
        ///     Invoked on every keystroke, including system keys such as Alt key combinations, when
        ///     this page is active and occupies the entire window.  Used to detect keyboard navigation
        ///     between pages even when the page itself doesn't have focus.
        /// </summary>
        /// <param name="sender">Instance that triggered the event.</param>
        /// <param name="args">Event data describing the conditions that led to the event.</param>
        private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
        {
            var virtualKey = args.VirtualKey;

            // Only investigate further when Left, Right, or the dedicated Previous or Next keys are pressed
            if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || args.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
                (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right || (int)virtualKey == 166 || (int)virtualKey == 167))
            {
                var coreWindow = Window.Current.CoreWindow;
                var downState = CoreVirtualKeyStates.Down;
                var menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
                var controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
                var shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
                var noModifiers = !menuKey && !controlKey && !shiftKey;
                var onlyAlt = menuKey && !controlKey && !shiftKey;

                if (((int)virtualKey == 166 && noModifiers) || (virtualKey == VirtualKey.Left && onlyAlt))
                {
                    // When the previous key or Alt+Left are pressed navigate back
                    args.Handled = true;
                    GoBack(this, new RoutedEventArgs());
                }
                else if (((int)virtualKey == 167 && noModifiers) || (virtualKey == VirtualKey.Right && onlyAlt))
                {
                    // When the next key or Alt+Right are pressed navigate forward
                    args.Handled = true;
                    GoForward(this, new RoutedEventArgs());
                }
            }
        }
Esempio n. 34
0
    // Use this for initialization
    void Start()
    {
#if ENABLE_WINMD_SUPPORT
        Windows.ApplicationModel.Core.CoreApplicationView mainView = Windows.ApplicationModel.Core.CoreApplication.MainView;
        Windows.UI.Core.CoreWindow cw = mainView.CoreWindow;
        UIDispatcher = cw.Dispatcher;
        SignIn();
#endif
    }
Esempio n. 35
0
    public void Start()
    {
        Windows.ApplicationModel.Core.CoreApplicationView mainView = Windows.ApplicationModel.Core.CoreApplication.MainView;
        Windows.UI.Core.CoreWindow cw = mainView.CoreWindow;
        XboxLiveUser.SignOutCompleted += OnUserSignOut;

        m_uiDispatcher = cw.Dispatcher;
        SignInSilent();
    }
Esempio n. 36
0
 public static void Dispatch <T>(this Action <T> action, T arg, Dispatcher dispatcher)
 {
     if (dispatcher.CheckAccess())
     {
         action(arg);
     }
     else
     {
         dispatcher.BeginInvoke(() => action(arg));
     }
 }
Esempio n. 37
0
        public ChatViewModel(Dispatcher dispatcher)
        {
            Dispatcher         = dispatcher;
            SendMessageCommand = new DelegateCommand(async() => await SendMessage(), () => CanSend);
            ClearLogCommand    = new DelegateCommand(() => LogMessages.Clear());
            Messages           = new ObservableCollection <Message>();
            LogMessages        = new ObservableCollection <string>();
            Status             = "Waiting to connect...";

            Connect().Forget();
        }
Esempio n. 38
0
 public static void Dispatch(this Action action, Dispatcher dispatcher)
 {
     if (dispatcher.CheckAccess())
     {
         action();
     }
     else
     {
         dispatcher.BeginInvoke(() => action());
     }
 }
Esempio n. 39
0
 /// <summary>
 /// This method uses parts of http://stackoverflow.com/a/39929182/1580088.
 /// This event is called whenever a key is pressed down on a computer keyboard. We use this method
 /// to trigger application-wide hotkeys, most notably the Alt+Enter combination for
 /// toggling fullscreen mode.
 /// </summary>
 private static void HandleToggleKeyboardShortcut(Windows.UI.Core.CoreDispatcher sender, Windows.UI.Core.AcceleratorKeyEventArgs args)
 {
     if (args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown)
     {
         // "menu key" is Alt, in Microsoft-speak.
         if (args.VirtualKey == Windows.System.VirtualKey.Enter && args.KeyStatus.IsMenuKeyDown)
         {
             SetFullScreenMode(!ApplicationView.GetForCurrentView().IsFullScreenMode);
             args.Handled = true;
         }
     }
 }
Esempio n. 40
0
        public async void OnStart(object sender, SimpleVideoClientStartedEventArgs VideoStart)
        {
            Windows.UI.Core.CoreDispatcher dis = CoreWindow.GetForCurrentThread().Dispatcher;
            CoreWindow wiw = CoreWindow.GetForCurrentThread();
            await wiw.Dispatcher.RunAsync(CoreDispatcherPriority.High,
                ref new DispatchedHandler(() =>
                {
                    
                    elem.SetMediaStreamSource(VideoStart.MediaStreamSource);
                    elem.CurrentStateChanged += 

                }
            ));
        }
Esempio n. 41
0
        public DispatchingHubProxy(IHubProxy hubProxy, Dispatcher dispatcher)
        {
            if (hubProxy == null)
            {
                throw new ArgumentNullException("hubProxy");
            }

            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            _hubProxy   = hubProxy;
            _dispatcher = dispatcher;
        }
Esempio n. 42
0
        public CollectionTraceWriter(ICollection <string> collection, Dispatcher dispatcher)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            _collection = collection;
            _dispatcher = dispatcher;
        }
Esempio n. 43
0
        public DispatchingHubConnection(string url, Dispatcher dispatcher)
            : base(url)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            _dispatcher          = dispatcher;
            base.StateChanged   += HubConnection_StateChanged;
            base.ConnectionSlow += HubConnection_ConnectionSlow;
            base.Reconnecting   += HubConnection_Reconnecting;
            base.Reconnected    += HubConnection_Reconnected;
            base.Closed         += HubConnection_Closed;
            base.Error          += HubConnection_Error;
        }
Esempio n. 44
0
        /// <summary>
        ///     当此页处于活动状态并占用整个窗口时,在每次
        ///     击键(包括系统键,如 Alt 组合键)时调用。    用于检测页之间的键盘
        ///     导航(即使在页本身没有焦点时)。
        /// </summary>
        /// <param name="sender">触发事件的实例。</param>
        /// <param name="e">描述导致事件的条件的事件数据。</param>
        private void CoreDispatcher_AcceleratorKeyActivated(Windows.UI.Core.CoreDispatcher sender,
                                                            AcceleratorKeyEventArgs e)
        {
            var virtualKey = e.VirtualKey;

            // 仅当按向左、向右或专用上一页或下一页键时才进一步
            // 调查
            if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
                 e.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
                (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right ||
                 (int)virtualKey == 166 || (int)virtualKey == 167))
            {
                CoreWindow coreWindow  = Window.Current.CoreWindow;
                var        downState   = CoreVirtualKeyStates.Down;
                bool       menuKey     = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
                bool       controlKey  = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
                bool       shiftKey    = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
                bool       noModifiers = !menuKey && !controlKey && !shiftKey;
                bool       onlyAlt     = menuKey && !controlKey && !shiftKey;

                if (((int)virtualKey == 166 && noModifiers) ||
                    (virtualKey == VirtualKey.Left && onlyAlt))
                {
                    // 在按上一页键或 Alt+向左键时向后导航
                    e.Handled = true;
                    GoBackCommand.Execute(null);
                }
                else if (((int)virtualKey == 167 && noModifiers) ||
                         (virtualKey == VirtualKey.Right && onlyAlt))
                {
                    // 在按下一页键或 Alt+向右键时向前导航
                    e.Handled = true;
                    GoForwardCommand.Execute(null);
                }
            }
        }
Esempio n. 45
0
        public async static Task <(Func <ImageSource> Small, Func <ImageSource> Large)> BookIcons(IFileItem file, CancellationToken cancel, Windows.UI.Core.CoreDispatcher dispatcher, Uri smallIcon, Uri largeIcon)
        {
            string id =
                (file as HistoryMRUItem)?.Id ??
                //(a as kurema.FileExplorerControl.Models.FileItems.HistoryItem)?.Content?.Id ??
                Storages.PathStorage.GetIdFromPath(file.Path);

            if (!string.IsNullOrEmpty(id))
            {
                var image = await Managers.ThumbnailManager.GetImageSourceAsync(id);

                if (image != null)
                {
                    return(() => new Windows.UI.Xaml.Media.Imaging.BitmapImage(smallIcon),
                           () => image
                           );
                }
            }
            if (file is StorageFileItem storage)
            {
                return(() => new Windows.UI.Xaml.Media.Imaging.BitmapImage(smallIcon),
                       () =>
                {
                    var bitmap = new Windows.UI.Xaml.Media.Imaging.BitmapImage(largeIcon);
                    if ((bool)Storages.SettingStorage.GetValue("FetchThumbnailsBackground"))
                    {
                        Task.Run(() => Managers.ThumbnailManager.SaveImageAndLoadAsync(storage.Content, dispatcher, bitmap, cancel));
                    }
                    return bitmap;
                }
                       );
            }

            return(() => new Windows.UI.Xaml.Media.Imaging.BitmapImage(smallIcon),
                   () => new Windows.UI.Xaml.Media.Imaging.BitmapImage(largeIcon));
        }
Esempio n. 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CoreDispatcher"/> class.
 /// </summary>
 public CoreDispatcher()
 {
     this.dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
 }
Esempio n. 47
0
 public static void Dispatch <T1, T2, T3>(this Action <T1, T2, T3> action, T1 arg1, T2 arg2, T3 arg3, Dispatcher dispatcher)
 {
     if (dispatcher.CheckAccess())
     {
         action(arg1, arg2, arg3);
     }
     else
     {
         dispatcher.BeginInvoke(() => action(arg1, arg2, arg3));
     }
 }
Esempio n. 48
0
 public static Task <(Func <ImageSource> Small, Func <ImageSource> Large)> BookIconsExplorer(IFileItem file, CancellationToken cancel, Windows.UI.Core.CoreDispatcher dispatcher)
 {
     return(BookIcons(file, cancel, dispatcher, new Uri("ms-appx:///res/Icon/icon_book_s.png"), new Uri("ms-appx:///res/Icon/icon_book_l.png")));
 }
Esempio n. 49
0
 public WindowsAppRunner(CoreDispatcher dispatcher, TextBlock textBlock)
 {
     _dispatcher = dispatcher;
     _output     = textBlock;
 }
Esempio n. 50
0
 public static Task <(Func <ImageSource> Small, Func <ImageSource> Large)> BookIconsBookshelf(IFileItem file, CancellationToken cancel, Windows.UI.Core.CoreDispatcher dispatcher)
 {
     //ToDo: Add book cover and fix this.
     return(BookIcons(file, cancel, dispatcher, new Uri("ms-appx:///res/cover/shincho.png"), new Uri("ms-appx:///res/cover/shincho.png")));
 }
 public AudioDeviceWatcher(AudioDeviceType ioType, Windows.UI.Core.CoreDispatcher dispatcher)
 {
     m_deviceType     = ioType;
     m_coreDispatcher = dispatcher;
     StartWatcher();
 }
Esempio n. 52
0
 public WindowsPhoneRunner(Windows.UI.Core.CoreDispatcher dispatcher, Windows.UI.Xaml.Controls.TextBlock textBlock)
 {
     _dispatcher = dispatcher;
     _output     = textBlock;
 }