Esempio n. 1
0
        private void connectBtn_Click(object sender, RoutedEventArgs e)
        {
            bool result = false;

            if (Ninty != null)
            {
                result = Ninty.Connect();

                var prefs = AppPrefs.Instance.GetDevicePreferences(Info.DevicePath);
                if (prefs != null && !string.IsNullOrEmpty(prefs.defaultProfile))
                {
                    Ninty.LoadProfile(prefs.defaultProfile);
                }
            }
            else if (Joy != null)
            {
                result = Joy.Connect();

                var prefs = AppPrefs.Instance.GetDevicePreferences(Info.DeviceID);
                if (prefs != null && !string.IsNullOrEmpty(prefs.defaultProfile))
                {
                    Joy.LoadProfile(prefs.defaultProfile);
                }
            }

            if (result)
            {
                connectBtn.IsEnabled = false;
                status.Content       = "Connected";
            }

            ConnectClick?.Invoke(this, result);
        }
Esempio n. 2
0
        /***********
         * The strategy here is once the program launches, it will gather all controller paths
         * and all saved information on each device and use what was saved about the device
         * to help populate details on each tab. The users can click on each tab and then
         * attempt to connect that controller then they are good to go.
         */

        private void AddController(object sender, MouseButtonEventArgs e)
        {
            // More testing
            TabItem test  = new TabItem();
            var     stack = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            stack.Children.Add(new Image()
            {
                Source              = new BitmapImage(new Uri("../Images/Icons/ProController_white_24.png", UriKind.Relative)),
                Height              = 12,
                Margin              = new Thickness(0, 0, 4, 0),
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            });
            stack.Children.Add(new TextBlock()
            {
                Text = "DUMMY " + tabControl.Items.Count.ToString()
            });
            test.Header = stack;
            NintyControl nin = new NintyControl(new Shared.DeviceInfo()
            {
                DevicePath = "Dummy", Type = NintrollerLib.ControllerType.ProController
            });

            nin.OnTypeChange += (NintrollerLib.ControllerType type) =>
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    ((Image)stack.Children[0]).Source = new BitmapImage(new Uri("../Images/Icons/ProController_black_24.png", UriKind.Relative));
                }));
            };
            test.Content = nin;
            tabControl.Items.Insert(tabControl.Items.Count - 1, test);
            tabControl.SelectedIndex = tabControl.Items.Count - 2;
            nin.Connect();
        }