private void CustomSaveButton_Click(object sender, RoutedEventArgs e)
 {
     if (Globals.CheckFileNameIsValid(CustomNameTextBox.Text) == false)
     {
         MessageBox.Show(LanguageSelector.Get("FileNameIsInvalidError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     var path = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + CustomNameTextBox.Text + ".json";
     var pointsPath = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + CustomNameTextBox.Text + "_KeyPoints.json";
     if (File.Exists(path) || File.Exists(pointsPath))
     {
         if (MessageBox.Show(LanguageSelector.Get("Overwritten"), LanguageSelector.Get("Confirm"), MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
         {
             return;
         }
     }
     File.WriteAllText(path, Json.Serializer.ToReadable(Json.Serializer.Serialize(Globals.KeyActions)));
     if (Globals.LeftControllerPoints == null) Globals.LeftControllerPoints = new List<UPoint>();
     if (Globals.RightControllerPoints == null) Globals.RightControllerPoints = new List<UPoint>();
     if (Globals.LeftControllerStickPoints == null) Globals.LeftControllerStickPoints = new List<UPoint>();
     if (Globals.RightControllerStickPoints == null) Globals.RightControllerStickPoints = new List<UPoint>();
     var points = new KeyPointsModel()
     {
         LeftCenterKeyEnable = Globals.LeftControllerCenterEnable,
         RightCenterKeyEnable = Globals.RightControllerCenterEnable,
         LeftTouchPadPoints = new List<UPoint>(Globals.LeftControllerPoints),
         RightTouchPadPoints = new List<UPoint>(Globals.RightControllerPoints),
         LeftStickPoints = new List<UPoint>(Globals.LeftControllerStickPoints),
         RightStickPoints = new List<UPoint>(Globals.RightControllerStickPoints),
         EnableSkeletal = Globals.EnableSkeletal,
     };
     File.WriteAllText(pointsPath, Json.Serializer.ToReadable(Json.Serializer.Serialize(points)));
     PresetComboBox.ItemsSource = Directory.EnumerateFiles(Globals.GetCurrentAppDir() + PresetDirectory, "*.json").Where(d => d.Contains("_KeyPoints.json") == false).Select(d => System.IO.Path.GetFileNameWithoutExtension(d));
 }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            while (Globals.Client.IsConnected != true)
            {
                await Task.Delay(100);
            }
#if BETA && FANBOX
            await Globals.Client.SendCommandAsync(new PipeCommands.SetIsBeta {
                IsBeta = true, IsPreRelease = true
            });
#elif FANBOX
            await Globals.Client.SendCommandAsync(new PipeCommands.SetIsBeta {
                IsBeta = false, IsPreRelease = true
            });

            //thanks 1000 supporters
            var imgpath = System.IO.Path.Combine(Globals.GetCurrentAppDir(), "startup.png");
            if (System.IO.File.Exists(imgpath))
            {
                var win = new Window();
                win.SizeToContent = SizeToContent.WidthAndHeight;
                win.ResizeMode    = ResizeMode.NoResize;
                var image       = new Image();
                var bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.CacheOption   = BitmapCacheOption.OnLoad;
                bitmapImage.CreateOptions = BitmapCreateOptions.None;
                bitmapImage.UriSource     = new Uri(imgpath);
                bitmapImage.EndInit();
                bitmapImage.Freeze();
                image.Source = bitmapImage;
                image.Width  = bitmapImage.PixelWidth;
                image.Height = bitmapImage.PixelHeight;
                var grid = new Grid();
                grid.Children.Add(image);
                var button = new Button();
                button.Content             = "閉じる/Close";
                button.FontSize            = 24;
                button.Height              = double.NaN;
                button.Padding             = new Thickness(10);
                button.Margin              = new Thickness(10);
                button.Click              += (csender, ce) => win.Close();
                button.HorizontalAlignment = HorizontalAlignment.Right;
                button.VerticalAlignment   = VerticalAlignment.Bottom;
                grid.Children.Add(button);
                win.Content = grid;
                win.Closed += (wsender, we) => System.IO.File.Delete(imgpath);
                win.Show();
            }
#endif
            await GetLipSyncDevice();

            await Globals.Client.SendCommandAsync(new PipeCommands.LoadCurrentSettings());
        }
Beispiel #3
0
        private async void PresetComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (PresetComboBox.SelectedItem == null)
            {
                return;
            }

            var path       = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + PresetComboBox.SelectedItem.ToString() + ".json";
            var pointsPath = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + PresetComboBox.SelectedItem.ToString() + "_KeyPoints.json";

            Globals.KeyActions = Json.Serializer.Deserialize <List <KeyAction> >(File.ReadAllText(path));
            KeyAction.KeyActionsUpgrade(Globals.KeyActions);
            UpdateKeyList();
            if (File.Exists(pointsPath))
            {
                var points = Json.Serializer.Deserialize <KeyPointsModel>(File.ReadAllText(pointsPath));
                Globals.LeftControllerPoints        = new List <UPoint>(points.LeftTouchPadPoints);
                Globals.RightControllerPoints       = new List <UPoint>(points.RightTouchPadPoints);
                Globals.LeftControllerStickPoints   = new List <UPoint>(points.LeftStickPoints);
                Globals.RightControllerStickPoints  = new List <UPoint>(points.RightStickPoints);
                Globals.LeftControllerCenterEnable  = points.LeftCenterKeyEnable;
                Globals.RightControllerCenterEnable = points.RightCenterKeyEnable;
                Globals.EnableSkeletal = points.EnableSkeletal;
                UpdateTouchPadPoints();
                UpdateStickPoints();
                await Globals.Client.SendCommandAsync(new PipeCommands.SetControllerTouchPadPoints
                {
                    isStick           = false,
                    LeftPoints        = Globals.LeftControllerPoints,
                    LeftCenterEnable  = LeftCenterKeyCheckBox.IsChecked.Value,
                    RightPoints       = Globals.RightControllerPoints,
                    RightCenterEnable = RightCenterKeyCheckBox.IsChecked.Value
                });

                await Globals.Client.SendCommandAsync(new PipeCommands.SetControllerTouchPadPoints
                {
                    isStick     = true,
                    LeftPoints  = Globals.LeftControllerStickPoints,
                    RightPoints = Globals.RightControllerStickPoints,
                });

                TouchPadApplyButton.IsEnabled = false;
            }
            await Globals.Client.SendCommandAsync(new PipeCommands.SetKeyActions {
                KeyActions = Globals.KeyActions
            });

            CustomNameTextBox.Text = PresetComboBox.SelectedItem.ToString();
            EnableSkeletalInputCheckBox.IsChecked = Globals.EnableSkeletal;
        }
Beispiel #4
0
        private async void PresetComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (PresetComboBox.SelectedItem == null)
            {
                return;
            }

            var path = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + PresetComboBox.SelectedItem.ToString() + ".json";

            Globals.KeyActions = Json.Serializer.Deserialize <List <KeyAction> >(File.ReadAllText(path));
            UpdateKeyList();
            await Globals.Client.SendCommandAsync(new PipeCommands.SetKeyActions {
                KeyActions = Globals.KeyActions
            });
        }
Beispiel #5
0
 public ShortcutKeyWindow()
 {
     InitializeComponent();
     CenterColor              = FromHsv(0, S, V);
     LeftImage.Source         = LeftWB;
     RightImage.Source        = RightWB;
     KeysDataGrid.ItemsSource = KeysListItems;
     UpdateKeyList();
     UpdateTouchPadPoints();
     if (Directory.Exists(Globals.GetCurrentAppDir() + PresetDirectory) == false)
     {
         Directory.CreateDirectory(Globals.GetCurrentAppDir() + PresetDirectory);
     }
     PresetComboBox.ItemsSource = Directory.EnumerateFiles(Globals.GetCurrentAppDir() + PresetDirectory, "*.json").Select(d => System.IO.Path.GetFileNameWithoutExtension(d));
 }
Beispiel #6
0
        private async Task SetupVirtualMotionTracker(bool install)
        {
            var messageBoxResult = MessageBox.Show(LanguageSelector.Get("SettingWindow_VMTContinue"), LanguageSelector.Get("Confirm"), MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (messageBoxResult != MessageBoxResult.OK)
            {
                return;
            }

            if (install)
            {
                try
                {
                    var targetDirectory = @"C:\VirtualMotionTracker";
                    if (Directory.Exists(targetDirectory) == false)
                    {
                        Directory.CreateDirectory(targetDirectory);
                        DirectoryCopy(Globals.GetCurrentAppDir() + "vmt", targetDirectory, true);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(LanguageSelector.Get("SettingWindow_VMTFailedFolderCreate"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
            await Globals.Client?.SendCommandWaitAsync(new PipeCommands.SetupVirtualMotionTracker {
                install = install
            }, d =>
            {
                var data = (PipeCommands.ResultSetupVirtualMotionTracker)d;
                Dispatcher.Invoke(() =>
                {
                    if (string.IsNullOrEmpty(data.result))
                    {
                        MessageBox.Show(LanguageSelector.Get("SettingWindow_VirtualMotionTrackerInstallSuccess"), "VMT Setup", MessageBoxButton.OK, MessageBoxImage.Information);
                        RestartSteamVRandVirtualMotionCapture();
                    }
                    else
                    {
                        MessageBox.Show(data.result, LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                });
            });
        }
 public ShortcutKeyWindow()
 {
     InitializeComponent();
     CenterColor = FromHsv(0, S, V);
     LeftImage.Source = LeftWB;
     RightImage.Source = RightWB;
     LeftStickImage.Source = LeftStickWB;
     RightStickImage.Source = RightStickWB;
     KeysDataGrid.ItemsSource = KeysListItems;
     UpdateKeyList();
     UpdateTouchPadPoints();
     UpdateStickPoints();
     EnableSkeletalInputCheckBox.IsChecked = Globals.EnableSkeletal;
     if (Directory.Exists(Globals.GetCurrentAppDir() + PresetDirectory) == false)
     {
         Directory.CreateDirectory(Globals.GetCurrentAppDir() + PresetDirectory);
     }
     PresetComboBox.ItemsSource = Directory.EnumerateFiles(Globals.GetCurrentAppDir() + PresetDirectory, "*.json").Where(d => d.Contains("_KeyPoints.json") == false).Select(d => System.IO.Path.GetFileNameWithoutExtension(d));
 }
Beispiel #8
0
        private void VirtualWebCamInstallButton_Click(object sender, RoutedEventArgs e)
        {
            var directory = @"C:\VMC_Camera\";

            if (Directory.Exists(directory) == false)
            {
                try
                {
                    Directory.CreateDirectory(directory);
                }
                catch (Exception)
                {
                    MessageBox.Show(LanguageSelector.Get("SettingWindow_FailedFolderCreate"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
            try
            {
                File.Copy(Globals.GetCurrentAppDir() + @"VMC_Camera\VMC_CameraFilter32bit.dll", directory + "VMC_CameraFilter32bit.dll", true);
                File.Copy(Globals.GetCurrentAppDir() + @"VMC_Camera\VMC_CameraFilter64bit.dll", directory + "VMC_CameraFilter64bit.dll", true);
            }
            catch (Exception)
            {
                MessageBox.Show(LanguageSelector.Get("SettingWindow_FailedFileCopy"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var process32 = System.Diagnostics.Process.Start(Globals.GetCurrentAppDir() + "DLLInstaller32.exe", "/i /s " + directory + "VMC_CameraFilter32bit.dll");
            var process64 = System.Diagnostics.Process.Start(Globals.GetCurrentAppDir() + "DLLInstaller64.exe", "/i /s " + directory + "VMC_CameraFilter64bit.dll");

            process32.WaitForExit();
            process64.WaitForExit();
            if (process32.ExitCode == 0 && process64.ExitCode == 0)
            {
                MessageBox.Show(LanguageSelector.Get("SettingWindow_SuccessDriverInstall"));
                WebCamEnableCheckBox.IsChecked = true; //インストールと同時にチェックを入れる
                UpdateWebCamConfig();
            }
            else
            {
                MessageBox.Show(LanguageSelector.Get("SettingWindow_FailedDriverInstall"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #9
0
        private void CustomSaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (Globals.CheckFileNameIsValid(CustomNameTextBox.Text) == false)
            {
                MessageBox.Show(LanguageSelector.Get("FileNameIsInvalidError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            var path = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + CustomNameTextBox.Text + ".json";

            if (File.Exists(path))
            {
                if (MessageBox.Show(LanguageSelector.Get("Overwritten"), LanguageSelector.Get("Confirm"), MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }
            File.WriteAllText(path, Json.Serializer.ToReadable(Json.Serializer.Serialize(Globals.KeyActions)));
            PresetComboBox.ItemsSource = Directory.EnumerateFiles(Globals.GetCurrentAppDir() + PresetDirectory, "*.json").Select(d => System.IO.Path.GetFileNameWithoutExtension(d));
        }
Beispiel #10
0
        public HandGestureControlKeyAddWindow()
        {
            InitializeComponent();

            for (int i = 1; i <= 20; i++)
            {
                var slider    = this.FindName("ValueSlider" + i.ToString("00")) as Slider;
                var textblock = this.FindName("ValueTextBlock" + i.ToString("00")) as TextBlock;
                slider.ValueChanged += Slider_ValueChanged;
                slider.Tag           = i;
                Sliders.Add(slider);
                TextBlocks.Add(textblock);
                handAngles.Add((int)slider.Value);
            }
            AngleLimitCheckBox_Checked(null, null);
            if (Directory.Exists(Globals.GetCurrentAppDir() + PresetDirectory) == false)
            {
                Directory.CreateDirectory(Globals.GetCurrentAppDir() + PresetDirectory);
            }
            PresetComboBox.ItemsSource = Directory.EnumerateFiles(Globals.GetCurrentAppDir() + PresetDirectory, "*.json").Select(d => System.IO.Path.GetFileNameWithoutExtension(d));
        }
Beispiel #11
0
        private async void PresetComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (PresetComboBox.SelectedItem == null)
            {
                return;
            }
            var path = Globals.GetCurrentAppDir() + PresetDirectory + "\\" + PresetComboBox.SelectedItem.ToString() + ".json";

            handAngles = Json.Serializer.Deserialize <List <int> >(File.ReadAllText(path));
            isLoading  = true;
            if (handAngles.Where(d => d < -90 || d > 10).Any())
            {
                AngleLimitCheckBox.IsChecked = false;
            }
            for (int i = 0; i < handAngles.Count; i++)
            {
                Sliders[i].Value   = handAngles[i];
                TextBlocks[i].Text = handAngles[i].ToString();
            }
            isLoading = false;
            var command = new PipeCommands.SetHandAngle {
                HandAngles = handAngles
            };

            if (LeftHandRadioButton.IsChecked == true)
            {
                command.LeftEnable = true;
            }
            if (RightHandRadioButton.IsChecked == true)
            {
                command.RightEnable = true;
            }
            if (BothHandRadioButton.IsChecked == true)
            {
                command.LeftEnable = command.RightEnable = true;
            }
            await Globals.Client.SendCommandAsync(command);

            CustomNameTextBox.Text = "";
        }
        private void VirtualWebCamUninstallButton_Click(object sender, RoutedEventArgs e)
        {
            var directory = @"C:\VMC_Camera\";
            var process32 = System.Diagnostics.Process.Start(Globals.GetCurrentAppDir() + "DLLInstaller32.exe", "/u /s " + directory + "VMC_CameraFilter32bit.dll");
            var process64 = System.Diagnostics.Process.Start(Globals.GetCurrentAppDir() + "DLLInstaller64.exe", "/u /s " + directory + "VMC_CameraFilter64bit.dll");

            process32.WaitForExit();
            process64.WaitForExit();
            if (process32.ExitCode == 0 && process64.ExitCode == 0)
            {
                try
                {
                    File.Delete(directory + "VMC_CameraFilter32bit.dll");
                    File.Delete(directory + "VMC_CameraFilter64bit.dll");
                }
                catch (Exception)
                {
                    MessageBox.Show(LanguageSelector.Get("SettingWindow_FailedFileDelete"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                try
                {
                    Directory.Delete(directory);
                }
                catch (Exception)
                {
                    MessageBox.Show(LanguageSelector.Get("SettingWindow_FailedFolderDelete"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                MessageBox.Show(LanguageSelector.Get("SettingWindow_SuccessDriverUninstall"));
            }
            else
            {
                MessageBox.Show(LanguageSelector.Get("SettingWindow_FailedDriverUninstall"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #13
0
        private async void RestartSteamVRandVirtualMotionCapture()
        {
            System.Diagnostics.Process.Start("vrmonitor://restartsystem");

            while (VMCisAlive)
            {
                await Globals.Client?.SendCommandAsync(new PipeCommands.Alive {
                });

                VMCisAlive = false;
                await Task.Delay(1000);
            }

            await Task.Delay(10000);

            var vmcPath_rel = Globals.GetCurrentAppDir() + @"..\VirtualMotionCapture.exe";
            var vmcPath     = System.IO.Path.GetFullPath(vmcPath_rel);

            System.Diagnostics.Process.Start(vmcPath);

            await Task.Delay(1000);

            Application.Current.Shutdown();
        }