private void Controller_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { log.Text += "\nRotation Changed Delta = " + args.RotationDeltaInDegrees; LogContactInfo(args.Contact); sliders[activeItemIndex].Value += args.RotationDeltaInDegrees; }
/// <summary> /// When the dial is turned. /// </summary> private void RadialController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { if (!string.IsNullOrEmpty(_selectedControl) && CanvasControl.ReadyToDraw) { // Check to see if the dial is pressed during rotation. var increment = CalculateIncrements(args); switch (_selectedControl) { case "Contrast": Contrast = +increment; break; case "Saturation": Saturation = +increment; break; case "Exposure": Exposure = +increment; break; case "Blur": Blur = +increment * 10; break; } CreateEffects(); } }
private void MyController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args) { if (highlightedItem == Preview) { //Click on the Preview, update the background UpdateBackground(); } else if (selectedItem != null) { //Click on a selected slider, unselect the slider selectedItem = null; UpdateHighlight(highlightedItem); //decrease sensitivity to make it more comfortable to navigate between items myController.RotationResolutionInDegrees = 10; } else if (selectedItem == null) { //No selection, select a slider UpdateSelection(highlightedItem as Slider); //increase sensitivity to make it easier to change slider value myController.RotationResolutionInDegrees = 1; } }
// Dial rotation handler private void Controller_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { if (IsActive) { Rotate(args.RotationDeltaInDegrees); } }
private void RadialController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { if (CurrentSelection == ColoringBookRadialController.Color) { if (args.RotationDeltaInDegrees > 0) { ColorPaletteViewModel.SelectNextItem(); } else { ColorPaletteViewModel.SelectPreviousItem(); } } else if (CurrentSelection == ColoringBookRadialController.UndoRedo) { if (args.RotationDeltaInDegrees > 0) { RedoOperation?.Invoke(this, EventArgs.Empty); } else { UndoOperation?.Invoke(this, EventArgs.Empty); } } }
private void CreateController() { IRadialControllerInterop interop = (IRadialControllerInterop)System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMarshal.GetActivationFactory(typeof(RadialController)); Guid guid = typeof(RadialController).GetInterface("IRadialController").GUID; _radialController = interop.CreateForWindow(new IntPtr(_dte.ActiveWindow.HWnd), ref guid); }
// Dial screen contact ended and placed again private void Controller_ScreenContactEnded(RadialController sender, object args) { if (IsActive) { _dialGrid.Opacity = 0.0d; } }
private void OnControlLost(RadialController sender, object args) { if (_status != null) { _status.Deactivate(); } }
/// <summary> /// This function gets called every time there is a rotational change on the connected Surface Dial while a Surface Dial enabled TextBox is in focus. /// This function ensures that the TextBox stays within the set range between MinValue and MaxValue while rotating the Surface Dial. /// It defaults the content of the TextBox to 0.0 if a non-numerical value is detected. /// </summary> /// <param name="sender">The RadialController being used.</param> /// <param name="args">The arguments of the changed event.</param> private static void Controller_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { if (_textBox == null) { return; } string t = _textBox.Text; double nr; if (double.TryParse(t, out nr)) { nr += args.RotationDeltaInDegrees * GetStepValue(_textBox); if (GetEnableMinMaxValue(_textBox)) { if (nr < GetMinValue(_textBox)) { nr = GetMinValue(_textBox); } if (nr > GetMaxValue(_textBox)) { nr = GetMaxValue(_textBox); } } } else { // default to zero if content is not a number nr = 0.0d; } _textBox.Text = nr.ToString("0.00"); }
/// <summary> /// When a Surface Dial TextBox gets focus, ensure the proper events are setup, and connect the Surface Dial itself. /// </summary> /// <param name="sender">The TextBox in being affected.</param> /// <param name="e">The event arguments.</param> private static void TextBox_GotFocus(object sender, RoutedEventArgs e) { _textBox = sender as TextBox; if (_textBox == null) { return; } if (!IsSupported) { return; } _controller = _controller ?? RadialController.CreateForCurrentView(); if (GetForceMenuItem(_textBox)) { _stepTextMenuItem = RadialControllerMenuItem.CreateFromKnownIcon("Step Text Box", GetIcon(_textBox)); _controller.Menu.Items.Add(_stepTextMenuItem); _controller.Menu.SelectMenuItem(_stepTextMenuItem); } _controller.UseAutomaticHapticFeedback = GetEnableHapticFeedback(_textBox); _controller.RotationResolutionInDegrees = 1; _controller.RotationChanged += Controller_RotationChanged; if (GetEnableTapToNextControl(_textBox)) { _controller.ButtonClicked += Controller_ButtonClicked; } }
private void StarController() { var interop = (IRadialControllerInterop)System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMarshal .GetActivationFactory(typeof(RadialController)); Guid guid = typeof(RadialController).GetInterface("IRadialController").GUID; Window window = Window.GetWindow(this); var wih = new WindowInteropHelper(window); IntPtr hWnd = wih.Handle; controller = interop.CreateForWindow(hWnd, ref guid); controller.ControlAcquired += Controller_ControlAcquired; controller.ControlLost += Controller_ControlLost; controller.RotationChanged += Controller_RotationChanged; controller.ButtonClicked += Controller_ButtonClicked; controller.RotationResolutionInDegrees = 1; var button = RadialControllerMenuItem.CreateFromKnownIcon("Item 1", RadialControllerMenuKnownIcon.Ruler); var button2 = RadialControllerMenuItem.CreateFromKnownIcon("Item 2", RadialControllerMenuKnownIcon.PenType); button.Invoked += Button_Invoked; button2.Invoked += Button_Invoked; controller.Menu.Items.Add(button); controller.Menu.Items.Add(button2); mainClicks = 0; }
private void CreateController() { IRadialControllerInterop interop = (IRadialControllerInterop)System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMarshal.GetActivationFactory(typeof(RadialController)); Guid guid = typeof(RadialController).GetInterface("IRadialController").GUID; radialController = interop.CreateForWindow(this.Handle, ref guid); }
private void InitializeController() { Controller = RadialController.CreateForCurrentView(); Controller.RotationResolutionInDegrees = 1; Controller.RotationChanged += Controller_RotationChanged; Controller.ButtonClicked += Controller_ButtonClicked; }
private void InitializeSurfaceDial() { _radialController = RadialController.CreateForCurrentView(); _radialController.ButtonClicked += _radialController_ButtonClicked; _radialController.RotationChanged += _radialController_RotationChanged; var bluricon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Blur.png")); var fogicon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Fog.png")); var hueicon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Hue.png")); var saturationicon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Saturation.png")); var sepiaicon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Sepia.png")); var blurItem = RadialControllerMenuItem.CreateFromIcon(TAGS.Blur, bluricon); blurItem.Tag = blurItem.DisplayText; var fogItem = RadialControllerMenuItem.CreateFromIcon(TAGS.Fog, fogicon); fogItem.Tag = fogItem.DisplayText; var hueItem = RadialControllerMenuItem.CreateFromIcon(TAGS.Hue, hueicon); hueItem.Tag = hueItem.DisplayText; var saturationItem = RadialControllerMenuItem.CreateFromIcon(TAGS.Saturation, saturationicon); saturationItem.Tag = saturationItem.DisplayText; var sepiaItem = RadialControllerMenuItem.CreateFromIcon(TAGS.Sepia, sepiaicon); sepiaItem.Tag = sepiaItem.DisplayText; _radialController.Menu.Items.Add(blurItem); _radialController.Menu.Items.Add(fogItem); _radialController.Menu.Items.Add(hueItem); _radialController.Menu.Items.Add(saturationItem); _radialController.Menu.Items.Add(sepiaItem); }
private void RadialController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { switch (thisTool) { case CurrentTool.BrightnessItem: double tempBrightnessValue = brightnessValue; tempBrightnessValue += args.RotationDeltaInDegrees / 36 * 10; if (!(tempBrightnessValue < 0) && !(tempBrightnessValue > 100)) { brightnessValue += args.RotationDeltaInDegrees / 36 * 10; string msg = String.Format("Brightness: {0}%", brightnessValue); ShowSlideText.Text = msg; BrightnessSlide.Value = brightnessValue; brightnessChange(Math.Round(brightnessValue).ToString()); } else if (tempBrightnessValue < 0) { toggleLight(0); } break; } }
public OnScreenVisualPage() { this.InitializeComponent(); RadialControllerConfiguration myConfiguration = RadialControllerConfiguration.GetForCurrentView(); myConfiguration.SetDefaultMenuItems(new[] { RadialControllerSystemMenuItemKind.Volume, RadialControllerSystemMenuItemKind.Scroll }); // Create a reference to the RadialController. myController = RadialController.CreateForCurrentView(); // Create an icon for the custom tool. RandomAccessStreamReference icon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/dial_icon_custom_visual.png")); // Create a menu item for the custom tool. screenColorMenuItem = RadialControllerMenuItem.CreateFromIcon("Screen Color", icon); // Add the custom tool to the RadialController menu. myController.Menu.Items.Add(screenColorMenuItem); screenColorMenuItem.Invoked += ColorMenuItem_Invoked; myController.ScreenContactStarted += MyController_ScreenContactStarted; myController.ScreenContactContinued += MyController_ScreenContactContinued; myController.ScreenContactEnded += MyController_ScreenContactEnded; myController.RotationChanged += MyController_RotationChanged; }
private void _controller_ControlLost(RadialController sender, object args) { if (ControlLost != null) { ControlLost(null, args); } }
private void _controller_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args) { if (ButtonClicked != null) { ButtonClicked(null, args.ToUnity()); } }
private void _controller_RotationChanged(RadialController sender, Windows.UI.Input.RadialControllerRotationChangedEventArgs args) { if (RotationChanged != null) { RotationChanged(null, args.ToUnity()); } }
private void _controller_ScreenContactEnded(RadialController sender, object args) { if (ScreenContactEnded != null) { ScreenContactEnded(null, args); } }
private void _controller_ScreenContactStarted(RadialController sender, RadialControllerScreenContactStartedEventArgs args) { if (ScreenContactStarted != null) { ScreenContactStarted(null, args.ToUnity()); } }
private void ControllerRotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { switch (_currentTool) { case CurrentTool.Bright: Rotate.Angle += args.RotationDeltaInDegrees; var brightness = ((int)(Rotate.Angle / 10)).ToHueBrightness(); colourShower.SetBrightness(brightness); break; case CurrentTool.Color: _selBrush += (int)(args.RotationDeltaInDegrees / 10); //if (_selBrush >= _namedBrushes.Count) // _selBrush = 0; //if (_selBrush < 0) // _selBrush = _namedBrushes.Count - 1; var newColour = _selBrush.ToHueColour(); var newRGBColor = newColour.ToRGBColour(); Rectangle.Fill = new SolidColorBrush(new Color() { R = (byte)(newRGBColor.R * 255), G = (byte)(newRGBColor.G * 255), B = (byte)(newRGBColor.B * 255) }); colourShower.ShowColour(newColour); break; default: break; } }
private void _controller_ControlAcquired(RadialController sender, RadialControllerControlAcquiredEventArgs args) { if (ControlAcquired != null) { ControlAcquired(null, args.ToUnity()); } }
private void InitializeDial() { radialController = RadialController.CreateForCurrentView(); // Set rotation resolution to 1 degree of sensitivity. radialController.RotationResolutionInDegrees = 36; // create new dial menu item //ToggleMenuItem = // RadialControllerMenuItem.CreateFromFontGlyph("Toggle Light", "\xE793", "Segoe MDL2 Assets"); //radialController.Menu.Items.Add(ToggleMenuItem); BrightnessMenuItem = RadialControllerMenuItem.CreateFromFontGlyph("Brightness", "\xE706", "Segoe MDL2 Assets"); radialController.Menu.Items.Add(BrightnessMenuItem); ColorMenuItem = RadialControllerMenuItem.CreateFromFontGlyph("Color", "\xE790", "Segoe MDL2 Assets"); radialController.Menu.Items.Add(ColorMenuItem); // clear all default item RadialControllerConfiguration config = RadialControllerConfiguration.GetForCurrentView(); config.SetDefaultMenuItems(new RadialControllerSystemMenuItemKind[] { }); // bind dial menu item to CurrentTool Enum //ToggleMenuItem.Invoked += (sender, args) => thisTool = CurrentTool.ToggleItem; BrightnessMenuItem.Invoked += (sender, args) => thisTool = CurrentTool.BrightnessItem; ColorMenuItem.Invoked += (sender, args) => thisTool = CurrentTool.ColorItem; // subscribe click and rotation of the dial radialController.ButtonClicked += (sender, args) => { RadialController_ButtonClicked(sender, args); }; radialController.RotationChanged += (sender, args) => { RadialController_RotationChanged(sender, args); }; }
public MainPage() { this.InitializeComponent(); controller = RadialController.CreateForCurrentView(); controller.UseAutomaticHapticFeedback = false; controller.RotationResolutionInDegrees = 1; customItem = RadialControllerMenuItem.CreateFromKnownIcon("Rotate", RadialControllerMenuKnownIcon.Ruler); controller.Menu.Items.Add(customItem); controller.Menu.SelectMenuItem(customItem); config = RadialControllerConfiguration.GetForCurrentView(); config.ActiveControllerWhenMenuIsSuppressed = controller; config.SetDefaultMenuItems(new[] { RadialControllerSystemMenuItemKind.Volume, RadialControllerSystemMenuItemKind.Scroll }); //comment these three lines to supress menu scenario controller.ControlLost += Controller_ControlLost; controller.ControlAcquired += Controller_ControlAcquired; controller.RotationChanged += Controller_RotationChanged; //uncomment it to supress the default menu //config.IsMenuSuppressed = true; //controller.ButtonHolding += Controller_ButtonHolding; }
private void SetupController() { if (null == Controller) { Controller = RadialController.CreateForCurrentView(); } RadialControllerConfiguration _dialConfiguration = RadialControllerConfiguration.GetForCurrentView(); // Remove standard menu items _dialConfiguration.SetDefaultMenuItems(new RadialControllerSystemMenuItemKind[] { }); // Create an icon for the custom tool. RandomAccessStreamReference icon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/List/specs_creative.png")); // Create a menu item for the custom tool. _brushColorMenuItem = RadialControllerMenuItem.CreateFromIcon("Brush Color", icon); // Add the custom tool to the RadialController menu. Controller.Menu.Items.Add(_brushColorMenuItem); // Set rotation degrees Controller.RotationResolutionInDegrees = ROTATION_DEGREES; // Bind dial controls to local methods _brushColorMenuItem.Invoked += ColorMenuItem_Invoked; Controller.RotationChanged += Controller_RotationChanged; Controller.ButtonClicked += Controller_ButtonClicked; Controller.ScreenContactStarted += Controller_ScreenContactStarted; Controller.ScreenContactContinued += Controller_ScreenContactContinued; Controller.ScreenContactEnded += Controller_ScreenContactEnded; }
private void ConfigureRadialController() { if (!RadialControllerConfiguration.IsAppControllerEnabled) { return; } // Setup DialController dialController = RadialController.CreateForCurrentView(); dialController.RotationResolutionInDegrees = 1; // Wireup event handler for rotation dialController.RotationChanged += DialController_RotationChanged; dialController.ButtonClicked += DialController_ButtonClicked; // Remove the default items to make more room for our custom items var config = RadialControllerConfiguration.GetForCurrentView(); config.SetDefaultMenuItems(new[] { RadialControllerSystemMenuItemKind.Scroll }); // Add a custom menu item for each of the video effects foreach (VideoEffectItemViewModel effect in PageViewModel.VideoEffects) { // Create a menu item, using the effect's name and thumbnail var menuItem = RadialControllerMenuItem.CreateFromIcon(effect.DisplayName, RandomAccessStreamReference.CreateFromUri(new Uri(effect.IconImagePath))); // Hook up the menu item's invoked (aka clicked/selected) event handler menuItem.Invoked += MenuItem_Invoked; // Add it to the RadialDial dialController.Menu.Items.Add(menuItem); } }
// Update is called once per frame void Update() { Dictionary <ColorPalette, float> cooldownValues = itemGeneratorController.GetCooldownValues(); List <ColorPalette> colorsInGenerator = new List <ColorPalette>(cooldownValues.Keys); List <ColorPalette> colorsInRadials = new List <ColorPalette>(colorRadials.Keys); colorsInGenerator.Remove(ColorPalette.All); colorsInRadials.Remove(ColorPalette.All); foreach (ColorPalette color in colorsInGenerator) { if (!colorRadials.ContainsKey(color)) { GameObject newUIElement = Instantiate(radialControllerPrefab.gameObject, transform.position, transform.rotation, transform); RadialController newRadial = newUIElement.GetComponent <RadialController>(); colorRadials.Add(color, newRadial); newUIElement.transform.SetSiblingIndex(0); newRadial.Initialize(ColorSchema.GetColor(color)); } colorRadials[color].SetTimeRemaining(cooldownValues[color]); } foreach (ColorPalette color in colorsInRadials) { if (!cooldownValues.ContainsKey(color)) { GameObject radialWithoutCooldown = colorRadials[color].gameObject; Destroy(radialWithoutCooldown); colorRadials.Remove(color); } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { _compositor = ElementCompositionPreview.GetElementVisual(this)?.Compositor; // User the events on the ink presenter _inkPresenter = MyInkCanvas.InkPresenter; _inkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch; _inkPresenter.StrokesCollected += InkPresenter_StrokesCollected; _inkPresenter.StrokesErased += InkPresenter_StrokesErased; _inkPresenter.UnprocessedInput.PointerPressed += UnprocessedInput_PointerPressed; _inkPresenter.InputProcessingConfiguration.RightDragAction = InkInputRightDragAction.LeaveUnprocessed; // Radial controller used for recognition if (RadialController.IsSupported()) { App.RadialController.ButtonPressed += RadialController_ButtonPressed; // Supress menu of controller _radialConfiguration = RadialControllerConfiguration.GetForCurrentView(); _radialConfiguration.ActiveControllerWhenMenuIsSuppressed = App.RadialController; _radialConfiguration.IsMenuSuppressed = true; } // When using Cortana perform app protocol recognition App.ProtocolSubject.Subscribe(dataEventArgs => App_Protocol(dataEventArgs)); ImageAnimationSetup(); }
private void MyController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args) { //if the last interaction was a press-and-hold, do not do anything when the click event is fired if (doNotProcessClick) { doNotProcessClick = false; return; } //In Playback mode, toggle between play and pause if (currentMode == Mode.Playback) { if (myPlayer.CurrentState == MediaElementState.Playing) { myPlayer.Pause(); } else { myPlayer.Play(); } } //In Volume mode, toggle between muted and unmuted else if (currentMode == Mode.Volume) { myPlayer.IsMuted = !myPlayer.IsMuted; } }
public Scenario2_SystemDefaultMenu() { this.InitializeComponent(); controller = RadialController.CreateForCurrentView(); controller.RotationChanged += Controller_RotationChanged; customItem = RadialControllerMenuItem.CreateFromKnownIcon("Item1", RadialControllerMenuKnownIcon.InkColor); }
private void Controller_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { log.Text += "\nRotation Changed Delta = " + args.RotationDeltaInDegrees; if (args.Contact != null) { log.Text += "\nBounds = " + args.Contact.Bounds.ToString(); log.Text += "\nPosition = " + args.Contact.Position.ToString(); } Slider1.Value += args.RotationDeltaInDegrees; }
private void InitializeController() { Controller = RadialController.CreateForCurrentView(); Controller.RotationResolutionInDegrees = 1; // Wire events Controller.RotationChanged += Controller_RotationChanged; Controller.ButtonClicked += Controller_ButtonClicked; Controller.ScreenContactStarted += Controller_ScreenContactStarted; Controller.ScreenContactContinued += Controller_ScreenContactContinued; Controller.ScreenContactEnded += Controller_ScreenContactEnded; Controller.ControlAcquired += Controller_ControlAcquired; Controller.ControlLost += Controller_ControlLost; }
private void Controller_ScreenContactEnded(RadialController sender, object args) { log.Text += "\nContact Ended"; }
private void Controller_ControlLost(RadialController sender, object args) { log.Text += "\nControl Lost"; }
private void Controller_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args) { log.Text += "\nButton Clicked "; LogContactInfo(args.Contact); ToggleSwitch toggle = toggles[activeItemIndex]; toggle.IsOn = !toggle.IsOn; }
private void Controller_ScreenContactContinued(RadialController sender, RadialControllerScreenContactContinuedEventArgs args) { log.Text += "\nContact Continued "; LogContactInfo(args.Contact); }
private void RadialController_ControlAcquired(RadialController sender, RadialControllerControlAcquiredEventArgs args) { }
private void Controller_ControlAcquired(RadialController sender, RadialControllerControlAcquiredEventArgs args) { log.Text += "\nControl Acquired"; LogContactInfo(args.Contact); }
private void RadialController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args) { }
private void RadialController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { Rotation(args.RotationDeltaInDegrees); }