Esempio n. 1
0
        public MainPage()
        {
            this.InitializeComponent();

            //Create a reference to the RadialController.
            myController = RadialController.CreateForCurrentView();
            myController.RotationResolutionInDegrees = 5;
            myController.UseAutomaticHapticFeedback  = false;

            //Create menu items for the custom tool.
            volumeItem   = RadialControllerMenuItem.CreateFromFontGlyph("Volume", "\xE767", "Segoe MDL2 Assets");
            playbackItem = RadialControllerMenuItem.CreateFromFontGlyph("Playback", "\xE714", "Segoe MDL2 Assets");

            volumeItem.Invoked   += VolumeItem_Invoked;
            playbackItem.Invoked += PlaybackItem_Invoked;

            //Add the custom tool's menu item to the menu
            myController.Menu.Items.Add(volumeItem);
            myController.Menu.Items.Add(playbackItem);

            //Create handlers for button and rotational input
            myController.RotationChanged += MyController_RotationChanged;
            myController.ButtonClicked   += MyController_ButtonClicked;

            //Remove system's built-in tools
            config = RadialControllerConfiguration.GetForCurrentView();
            config.SetDefaultMenuItems(new RadialControllerSystemMenuItemKind[] { });

            //Set up menu suppression targets
            config.ActiveControllerWhenMenuIsSuppressed = myController;
            myController.ButtonHolding += MyController_ButtonHolding;

            myPlayer.CurrentStateChanged += MyPlayer_CurrentStateChanged;

            //Select the first tool
            myPlayer.Loaded += MyPlayer_Loaded;
        }
Esempio n. 2
0
        // Configure RadialController menu and custom tool.
        private void InitializeController(object sender, RoutedEventArgs args)
        {
            // Create a reference to the RadialController.
            radialController = RadialController.CreateForCurrentView();
            // Set rotation resolution to 1 degree of sensitivity.
            radialController.RotationResolutionInDegrees = 1;

            // Create the custom menu items.
            // Here, we use a font glyph for our custom tool.
            radialControllerMenuItem =
                RadialControllerMenuItem.CreateFromFontGlyph("SampleTool", "\xE1E3", "Segoe MDL2 Assets");

            // Add the item to the RadialController menu.
            radialController.Menu.Items.Add(radialControllerMenuItem);

            // Remove built-in tools to declutter the menu.
            // NOTE: The Surface Dial menu must have at least one menu item.
            // If all built-in tools are removed before you add a custom
            // tool, the default tools are restored and your tool is appended
            // to the default collection.
            radialControllerConfig =
                RadialControllerConfiguration.GetForCurrentView();
            radialControllerConfig.SetDefaultMenuItems(
                new RadialControllerSystemMenuItemKind[] { });

            // Declare input handlers for the RadialController.
            // NOTE: These events are only fired when a custom tool is active.
            radialController.ButtonClicked += (clicksender, clickargs) =>
            { RadialController_ButtonClicked(clicksender, clickargs); };
            radialController.RotationChanged += (rotationsender, rotationargs) =>
            { RadialController_RotationChanged(rotationsender, rotationargs); };

            // Begin "Step 6: Customize the device haptics"
            //radialController.ControlAcquired += (hapticssender, hapticsargs) =>
            //{ RadialController_ControlAcquired(hapticssender, hapticsargs); };
            // End "Step 6: Customize the device haptics"
        }
Esempio n. 3
0
        public MainPage()
        {
            this.InitializeComponent();

            cnc_controller = new Controller();

            radial_controller = RadialController.CreateForCurrentView();

            RadialControllerConfiguration myConfiguration = RadialControllerConfiguration.GetForCurrentView();

            myConfiguration.SetDefaultMenuItems(new[] {
                RadialControllerSystemMenuItemKind.Volume,
                RadialControllerSystemMenuItemKind.NextPreviousTrack
            });

            RandomAccessStreamReference xicon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/XAxis.64.png"));
            RandomAccessStreamReference yicon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/YAxis.64.png"));
            RandomAccessStreamReference zicon = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/ZAxis.64.png"));

            RadialControllerMenuItem xAxisItem = RadialControllerMenuItem.CreateFromIcon("X-Axis", xicon);
            RadialControllerMenuItem yAxisItem = RadialControllerMenuItem.CreateFromIcon("Y-Axis", yicon);
            RadialControllerMenuItem zAxisItem = RadialControllerMenuItem.CreateFromIcon("Z-Axis", zicon);

            xAxisItem.Tag = Axes.X;
            yAxisItem.Tag = Axes.Y;
            zAxisItem.Tag = Axes.Z;

            radial_controller.Menu.Items.Add(xAxisItem);
            radial_controller.Menu.Items.Add(yAxisItem);
            radial_controller.Menu.Items.Add(zAxisItem);

            radial_controller.UseAutomaticHapticFeedback  = true;
            radial_controller.RotationResolutionInDegrees = 5;

            radial_controller.RotationChanged += Controller_RotationChanged;
            radial_controller.ButtonClicked   += Controller_ButtonClicked;

            // foreach (var name in SerialPort.GetPortNames())
            // {
            //    port_select.Items.Add(name);
            // }

            port_select.SelectedIndex = 0;

            connect_button.Click += Connect_button_Click;
            stop_button.Click    += Stop_button_Click;
            //send_button.Click += Send_button_Click;
            unlock_button.Click += Unlock_button_Click;

            left_button.Click  += Left_button_Click;
            right_button.Click += Right_button_Click;

            x_set_text.LostFocus += X_set_text_LostFocus;
            y_set_text.LostFocus += Y_set_text_LostFocus;
            z_set_text.LostFocus += Z_set_text_LostFocus;

            live_checkBox.Checked       += Live_checkBox_Checked;
            live_checkBox.Unchecked     += Live_checkBox_Unchecked;
            go_button.Click             += Go_button_Click;
            to_origin_button.Click      += To_origin_button_Click;
            to_work_origin_button.Click += To_work_origin_button_Click;
            zero_work_button.Click      += Zero_work_button_Click;

            cnc_controller.StatusChanged   += Cnc_controller_StatusChanged;
            cnc_controller.PositionChanged += Cnc_controller_PositionChanged;
        }
 private void ModifySystemDefaults(object sender, RoutedEventArgs e)
 {
     config = RadialControllerConfiguration.GetForCurrentView();
     config.SetDefaultMenuItems(new[] { RadialControllerSystemMenuItemKind.Volume, RadialControllerSystemMenuItemKind.Scroll });
 }
 private void Remove_Defaults(object sender, RoutedEventArgs e)
 {
     config = RadialControllerConfiguration.GetForCurrentView();
     config.SetDefaultMenuItems(new RadialControllerSystemMenuItemKind[] { });
 }
 private void ModifySystemDefaults(object sender, RoutedEventArgs e)
 {
     config = RadialControllerConfiguration.GetForCurrentView();
     config.SetDefaultMenuItems(new[] { RadialControllerSystemMenuItemKind.Volume, RadialControllerSystemMenuItemKind.Scroll });
 }
 private void Remove_Defaults(object sender, RoutedEventArgs e)
 {
     config = RadialControllerConfiguration.GetForCurrentView();
     config.SetDefaultMenuItems(new RadialControllerSystemMenuItemKind[] { });
 }