public void BindingOnMediaEnded(Windows.Foundation.TypedEventHandler <MediaPlayer, object> callback, bool to_bind) { if (to_bind) { Player.MediaEnded += callback; } else { Player.MediaEnded -= callback; } }
private static async void executeOnNotification(Sensor sensor, Windows.Foundation.TypedEventHandler <GattCharacteristic, GattValueChangedEventArgs> methodToExecute) { //Get gatt characteristic GattCharacteristic characteristic = await GetCharacteristic(sensor); //Enable notifications GattCommunicationStatus status = await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify); //WARNING!!! the "+=" tells event listener to CALL a delagate method. characteristic.ValueChanged += methodToExecute; }
private void PinChangedToggleSwitch_Toggled(object sender, RoutedEventArgs e) { if (PinChangedToggleSwitch.IsOn) { PinChangedEventHandler = new Windows.Foundation.TypedEventHandler<SerialDevice, PinChangedEventArgs>(this.PinChangedEvent); rootPage.NotifyUser("Pin Changed Event registered", NotifyType.StatusMessage); EventHandlerForDevice.Current.Device.PinChanged += PinChangedEventHandler; PinChangedValue.Text = "On"; } else { rootPage.NotifyUser("Pin Changed Event unregistered", NotifyType.StatusMessage); EventHandlerForDevice.Current.Device.PinChanged += PinChangedEventHandler; PinChangedValue.Text = "Off"; } }
private void ErrorReceivedToggleSwitch_Toggled(object sender, RoutedEventArgs e) { if (ErrorReceivedToggleSwitch.IsOn) { ErrorReceivedEventHandler = new Windows.Foundation.TypedEventHandler <SerialDevice, ErrorReceivedEventArgs>(this.ErrorReceivedEvent); rootPage.NotifyUser("Error Received Event registered", NotifyType.StatusMessage); EventHandlerForDevice.Current.Device.ErrorReceived += ErrorReceivedEventHandler; ErrorReceivedValue.Text = "On"; } else { rootPage.NotifyUser("Error Received Event unregistered", NotifyType.StatusMessage); EventHandlerForDevice.Current.Device.ErrorReceived -= ErrorReceivedEventHandler; ErrorReceivedValue.Text = "Off"; } }
// TODO: this will spawn a new window instead of navigating to an existing frame. public async Task <int> OpenAsync(Type page, string parameter = null, ViewSizePreference size = ViewSizePreference.UseHalf) { var coreView = CoreApplication.CreateNewView(); ApplicationView view = null; var create = new Action(() => { // setup content var frame = new Frame(); frame.NavigationFailed += (s, e) => { System.Diagnostics.Debugger.Break(); }; frame.Navigate(page, parameter); // create window var window = Window.Current; window.Content = frame; // setup view/collapse view = ApplicationView.GetForCurrentView(); Windows.Foundation.TypedEventHandler <ApplicationView, ApplicationViewConsolidatedEventArgs> consolidated = null; consolidated = new Windows.Foundation.TypedEventHandler <ApplicationView, ApplicationViewConsolidatedEventArgs>((s, e) => { (s as ApplicationView).Consolidated -= consolidated; if (CoreApplication.GetCurrentView().IsMain) { return; } try { window.Close(); } finally { CoreApplication.GetCurrentView().CoreWindow.Activate(); } }); view.Consolidated += consolidated; }); // execute create await WindowWrapper.Current().Dispatcher.DispatchAsync(create); // show view if (await ApplicationViewSwitcher.TryShowAsStandaloneAsync(view.Id, size)) { // change focus await ApplicationViewSwitcher.SwitchAsync(view.Id); } return(view.Id); }
public static void AddButtonListener(Windows.Foundation.TypedEventHandler <GpioPin, GpioPinValueChangedEventArgs> listener) { button.ValueChanged += listener; }
// TODO: this will spawn a new window instead of navigating to an existing frame. public async Task<int> OpenAsync(Type page, string parameter = null, ViewSizePreference size = ViewSizePreference.UseHalf) { var coreView = CoreApplication.CreateNewView(); ApplicationView view = null; var create = new Action(() => { // setup content var frame = new Frame(); frame.NavigationFailed += (s, e) => { System.Diagnostics.Debugger.Break(); }; frame.Navigate(page, parameter); // create window var window = Window.Current; window.Content = frame; // setup view/collapse view = ApplicationView.GetForCurrentView(); Windows.Foundation.TypedEventHandler<ApplicationView, ApplicationViewConsolidatedEventArgs> consolidated = null; consolidated = new Windows.Foundation.TypedEventHandler<ApplicationView, ApplicationViewConsolidatedEventArgs>((s, e) => { (s as ApplicationView).Consolidated -= consolidated; if (CoreApplication.GetCurrentView().IsMain) return; try { window.Close(); } finally { CoreApplication.GetCurrentView().CoreWindow.Activate(); } }); view.Consolidated += consolidated; }); // execute create await WindowWrapper.Current().Dispatcher.DispatchAsync(create); // show view if (await ApplicationViewSwitcher.TryShowAsStandaloneAsync(view.Id, size)) { // change focus await ApplicationViewSwitcher.SwitchAsync(view.Id); } return view.Id; }
public static async Task SetViewpointToCurrentLocation(MapView mapView, GraphicsOverlay mapGraphics, Windows.Foundation.TypedEventHandler <Windows.Devices.Geolocation.Geolocator, Windows.Devices.Geolocation.PositionChangedEventArgs> PositionChangedHandler, bool zoomToLocation = true) { var currentLoc = await SpatialHelper.GetCurrentLocation(); if (currentLoc.HasValue) { var currentLocPoint = CreateRouteStop(currentLoc.Value.Latitude, currentLoc.Value.Longitude, System.Drawing.Color.Red); currentLocPoint.Attributes.Add("id", "currentLocation"); mapGraphics.Graphics.Add(currentLocPoint); if (zoomToLocation) { await mapView.SetViewpointCenterAsync(currentLoc.Value.Latitude, currentLoc.Value.Longitude); await mapView.SetViewpointScaleAsync(2000); } if (PositionChangedHandler != null) { SpatialHelper.Geolocator.PositionChanged += PositionChangedHandler; } } }
internal void Show() { Windows.Foundation.TypedEventHandler <Windows.ApplicationModel.DataTransfer.DataTransferManager, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs> handler = null; handler = (Windows.ApplicationModel.DataTransfer.DataTransferManager s, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs arg) => { s.DataRequested -= handler; arg.Request.Data.Properties.Title = Title; arg.Request.Data.Properties.Description = Message; arg.Request.Data.SetWebLink(LinkUri); }; Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += handler; Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI(); }