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));
 }
示例#2
0
        private async void CalibrationButton_Click(object sender, RoutedEventArgs e)
        {
            if (CalibrationButton.IsEnabled == false)
            {
                return;                                       //何度も実行しないように
            }
            CalibrationButton.IsEnabled = false;
            int timercount = 5;

            do
            {
                StatusTextBlock.Text = timercount.ToString();
                await Task.Delay(1000);
            } while (timercount-- > 0);
            StatusTextBlock.Text = LanguageSelector.Get("CalibrationWindow_Status_Calibrating");
            await Globals.Client.SendCommandAsync(new PipeCommands.Calibrate {
                CalibrateType = CalibrateFixedHandRadioButton.IsChecked == true ? PipeCommands.CalibrateType.FixedHand : (CalibrateFixedHandWithGroundRadioButton.IsChecked == true ? PipeCommands.CalibrateType.FixedHandWithGround : PipeCommands.CalibrateType.Default)
            });

            await Task.Delay(1000);

            StatusTextBlock.Text = LanguageSelector.Get("CalibrationWindow_Status_Finish");
            await Task.Delay(1000);

            Close();
        }
示例#3
0
        private async void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            if (KeyConfigs.Count == 0)
            {
                MessageBox.Show(LanguageSelector.Get("KeyNotFoundError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (FunctionComboBox.SelectedItem == null)
            {
                MessageBox.Show(LanguageSelector.Get("FunctionNotFoundError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var action = new KeyAction();

            action.KeyConfigs = KeyConfigs;
            var name = FunctionComboBox.SelectedItem.ToString();

            action.Name           = name;
            action.OnlyPress      = true;
            action.FunctionAction = true;
            action.Function       = (Functions)FunctionComboBox.SelectedIndex;
            action.IsKeyUp        = KeyUpCheckBox.IsChecked.Value;

            if (Globals.KeyActions == null)
            {
                Globals.KeyActions = new List <KeyAction>();
            }
            Globals.KeyActions.Add(action);
            await Globals.Client.SendCommandAsync(new PipeCommands.SetKeyActions {
                KeyActions = Globals.KeyActions
            });

            this.DialogResult = true;
        }
示例#4
0
        private async void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            if (KeyConfigs.Count == 0)
            {
                MessageBox.Show(LanguageSelector.Get("KeyNotFoundError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var action = new KeyAction();

            action.KeyConfigs = KeyConfigs;
            var name = CustomNameTextBox.Text;

            action.Name            = name;
            action.OnlyPress       = false;
            action.FaceAction      = true;
            action.FaceNames       = faceItems.Select(d => d.Key).ToList();
            action.FaceStrength    = faceItems.Select(d => d.Value).ToList();
            action.StopBlink       = AutoBlinkCheckBox.IsChecked.Value;
            action.IsKeyUp         = KeyUpCheckBox.IsChecked.Value;
            action.LipSyncMaxLevel = (float)LipSyncMaxLevelSlider.Value;

            if (Globals.KeyActions == null)
            {
                Globals.KeyActions = new List <KeyAction>();
            }
            Globals.KeyActions.Add(action);
            await Globals.Client.SendCommandAsync(new PipeCommands.SetKeyActions {
                KeyActions = Globals.KeyActions
            });

            this.DialogResult = true;
        }
示例#5
0
        private async void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (isLoading)
            {
                return;
            }
            var slider    = sender as Slider;
            var textblock = TextBlocks[Sliders.IndexOf(slider)];

            textblock.Text = slider.Value.ToString();
            handAngles[(int)slider.Tag - 1] = (int)slider.Value;
            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 = LanguageSelector.Get("Custom");
        }
示例#6
0
        private async void ExternalCameraConigButton_Click(object sender, RoutedEventArgs e)
        {
            if (ControllerComboBox.SelectedItem == null)
            {
                MessageBox.Show(LanguageSelector.Get("SettingWindow_SelectedItemError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Globals.LoadCommonSettings();

            var tracker = ControllerComboBox.SelectedItem as TrackerConfigWindow.TrackerInfo;
            var ofd     = new OpenFileDialog();

            ofd.Filter           = "externalcamera.cfg|externalcamera.cfg";
            ofd.InitialDirectory = Globals.ExistDirectoryOrNull(Globals.CurrentCommonSettingsWPF.CurrentPathOnExternalCameraFileDialog);
            if (ofd.ShowDialog() == true)
            {
                var configs = new Dictionary <string, string>();
                var lines   = File.ReadAllLines(ofd.FileName);
                foreach (var line in lines)
                {
                    if (line.Contains("="))
                    {
                        var items = line.Split(new string[] { "=" }, 2, StringSplitOptions.None);
                        configs.Add(items[0], items[1]);
                    }
                }
                Func <string, float> GetFloat = (string key) =>
                {
                    if (configs.ContainsKey(key) == false)
                    {
                        return(0.0f);
                    }
                    if (float.TryParse(configs[key], out var ret))
                    {
                        return(ret);
                    }
                    return(0.0f);
                };
                var x   = GetFloat("x");
                var y   = GetFloat("y");
                var z   = GetFloat("z");
                var rx  = GetFloat("rx");
                var ry  = GetFloat("ry");
                var rz  = GetFloat("rz");
                var fov = GetFloat("fov");

                await Globals.Client?.SendCommandAsync(new PipeCommands.SetExternalCameraConfig {
                    x = x, y = y, z = z, rx = rx, ry = ry, rz = rz, fov = fov, ControllerName = tracker.SerialNumber
                });

                if (Globals.CurrentCommonSettingsWPF.CurrentPathOnExternalCameraFileDialog != System.IO.Path.GetDirectoryName(ofd.FileName))
                {
                    Globals.CurrentCommonSettingsWPF.CurrentPathOnExternalCameraFileDialog = System.IO.Path.GetDirectoryName(ofd.FileName);
                    Globals.SaveCommonSettings();
                }
            }
        }
示例#7
0
 private void OpenFolderButton_Click(object sender, RoutedEventArgs e)
 {
     if (Directory.Exists(PathTextBox.Text) == false)
     {
         MessageBox.Show(LanguageSelector.Get("PhotoWindow_ErrorFolderExist"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     System.Diagnostics.Process.Start(PathTextBox.Text);
 }
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     if (e.Args.Length == 0)
     {
         return;
     }
     CommandLineArgs = e.Args;
     LanguageSelector.SetAutoLanguage();
 }
        private void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var language = LanguageComboBox.SelectedItem as string;

            if (string.IsNullOrWhiteSpace(language))
            {
                language = "Japanese";
            }
            LanguageSelector.ChangeLanguage(language);
        }
        private void CalibrationButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(Globals.CurrentVRMFilePath))
            {
                MessageBox.Show(LanguageSelector.Get("MainWindow_ErrorCalibration"), LanguageSelector.Get("Error"));
                return;
            }
            var win = new CalibrationWindow();

            win.ShowDialog();
        }
示例#11
0
        private void UpdateKeyList()
        {
            KeysListItems.Clear();
            if (Globals.KeyActions == null)
            {
                return;
            }
            foreach (var key in Globals.KeyActions)
            {
                var typestr = "";
                if (key.HandAction)
                {
                    if (key.Hand == Hands.Both)
                    {
                        typestr += LanguageSelector.Get("BothHand");
                    }
                    else if (key.Hand == Hands.Right)
                    {
                        typestr += LanguageSelector.Get("RightHand");
                    }
                    else
                    {
                        typestr += LanguageSelector.Get("LeftHand");
                    }
                }
                if (key.FaceAction)
                {
                    typestr += LanguageSelector.Get("FacialExpression");
                }
                if (key.FunctionAction)
                {
                    typestr += LanguageSelector.Get("Function");
                }

                var keysstr = "";
                var keystrs = new List <string>();
                foreach (var k in key.KeyConfigs)
                {
                    keystrs.Add(k.ToString());
                }
                if (keystrs.Count > 0)
                {
                    keysstr = string.Join(" + ", keystrs);
                }
                KeysListItems.Add(new KeysListItem
                {
                    TypeStr   = typestr,
                    NameStr   = key.Name,
                    KeysStr   = keysstr,
                    KeyAction = key
                });
            }
        }
 private async void LipSyncDeviceComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (LipSyncDeviceComboBox.SelectedItem == null)
     {
         return;
     }
     if (LipSyncDeviceComboBox.SelectedItem.ToString().StartsWith(LanguageSelector.Get("Error") + ":"))
     {
         return;
     }
     await Globals.Client.SendCommandAsync(new PipeCommands.SetLipSyncDevice {
         device = LipSyncDeviceComboBox.SelectedItem.ToString()
     });
 }
示例#13
0
        private async void ExternalCameraConigExportButton_Click(object sender, RoutedEventArgs e)
        {
            if (ControllerComboBox.SelectedItem == null)
            {
                MessageBox.Show(LanguageSelector.Get("SettingWindow_SelectedItemError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Globals.LoadCommonSettings();

            var tracker = ControllerComboBox.SelectedItem as TrackerConfigWindow.TrackerInfo;
            await Globals.Client?.SendCommandWaitAsync(new PipeCommands.GetExternalCameraConfig {
                ControllerName = tracker.SerialNumber
            }, r =>
            {
                var d = (PipeCommands.SetExternalCameraConfig)r;
                Dispatcher.Invoke(() =>
                {
                    var sfd              = new SaveFileDialog();
                    sfd.Filter           = "externalcamera.cfg|externalcamera.cfg";
                    sfd.Title            = "Export externalcamera.cfg";
                    sfd.FileName         = "externalcamera.cfg";
                    sfd.InitialDirectory = Globals.ExistDirectoryOrNull(Globals.CurrentCommonSettingsWPF.CurrentPathOnExternalCameraFileDialog);

                    if (sfd.ShowDialog() == true)
                    {
                        var culture = System.Globalization.CultureInfo.InvariantCulture;
                        var format  = culture.NumberFormat;
                        var lines   = new List <string>();
                        lines.Add($"x=" + d.x.ToString("G", format));
                        lines.Add($"y=" + d.y.ToString("G", format));
                        lines.Add($"z=" + d.z.ToString("G", format));
                        lines.Add($"rx=" + d.rx.ToString("G", format));
                        lines.Add($"ry=" + d.ry.ToString("G", format));
                        lines.Add($"rz=" + d.rz.ToString("G", format));
                        lines.Add($"fov=" + d.fov.ToString("G", format));
                        lines.Add($"near=0.01");
                        lines.Add($"far=1000");
                        lines.Add($"disableStandardAssets=False");
                        lines.Add($"frameSkip=0");
                        File.WriteAllLines(sfd.FileName, lines);

                        if (Globals.CurrentCommonSettingsWPF.CurrentPathOnExternalCameraFileDialog != System.IO.Path.GetDirectoryName(sfd.FileName))
                        {
                            Globals.CurrentCommonSettingsWPF.CurrentPathOnExternalCameraFileDialog = System.IO.Path.GetDirectoryName(sfd.FileName);
                            Globals.SaveCommonSettings();
                        }
                    }
                });
            });
        }
 void LoadLipSyncDevice(string device)
 {
     if (string.IsNullOrEmpty(device))
     {
         return;
     }
     if (LipSyncDevices.Contains(device))
     {
         LipSyncDeviceComboBox.SelectedItem = device;
     }
     else
     {
         LipSyncDevices.Insert(0, device.StartsWith(LanguageSelector.Get("Error") + ":") ? device : LanguageSelector.Get("Error") + ":" + device);
     }
 }
 void LoadLipSyncDevice(string device)
 {
     if (string.IsNullOrEmpty(device))
     {
         return;
     }
     if (LipSyncDevices.Contains(device))
     {
         LipSyncDeviceComboBox.SelectedItem = device;
         LipsyncTabTextBlock.Background     = new SolidColorBrush(Colors.Transparent);
     }
     else
     {
         LipSyncDevices.Insert(0, device.StartsWith(LanguageSelector.Get("Error") + ":") ? device : LanguageSelector.Get("Error") + ":" + device);
     }
 }
 private async void LipSyncDeviceComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     LipsyncTabTextBlock.Background = new SolidColorBrush(Colors.PaleVioletRed);
     if (LipSyncDeviceComboBox.SelectedItem == null)
     {
         return;
     }
     if (LipSyncDeviceComboBox.SelectedItem.ToString().StartsWith(LanguageSelector.Get("Error") + ":"))
     {
         return;
     }
     LipsyncTabTextBlock.Background = new SolidColorBrush(Colors.Transparent);
     await Globals.Client.SendCommandAsync(new PipeCommands.SetLipSyncDevice {
         device = LipSyncDeviceComboBox.SelectedItem.ToString()
     });
 }
示例#17
0
        private void UpdateKeys()
        {
            var texts = new List <string>();

            foreach (var key in KeyConfigs)
            {
                texts.Add(key.ToString());
            }
            if (texts.Count > 0)
            {
                KeysTextBox.Text = string.Join(" + ", texts);
            }
            else
            {
                KeysTextBox.Text = LanguageSelector.Get("KeysWatermark");
            }
        }
示例#18
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);
                    }
                });
            });
        }
示例#19
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));
        }
示例#20
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);
            }
        }
示例#21
0
        private void PathSelectButton_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new System.Windows.Forms.FolderBrowserDialog();

            dlg.Description = LanguageSelector.Get("PhotoWindow_FolderSelect");
            if (string.IsNullOrWhiteSpace(PathTextBox.Text) == false && Directory.Exists(PathTextBox.Text))
            {
                dlg.SelectedPath = PathTextBox.Text;
            }
            else
            {
                dlg.SelectedPath = defaultPath;
            }

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                PathTextBox.Text = dlg.SelectedPath;
            }
        }
示例#22
0
        private async void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            if (KeyConfigs.Count == 0)
            {
                MessageBox.Show(LanguageSelector.Get("KeyNotFoundError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var action = new KeyAction();

            action.KeyConfigs = KeyConfigs;
            var name = CustomNameTextBox.Text;

            if (string.IsNullOrEmpty(name) && PresetComboBox.SelectedItem != null)
            {
                name = PresetComboBox.SelectedItem as string;
            }
            else if (string.IsNullOrEmpty(name))
            {
                name = LanguageSelector.Get("Custom");
            }
            action.Name           = name;
            action.OnlyPress      = false;
            action.HandAction     = true;
            action.HandAngles     = handAngles;
            action.Hand           = BothHandRadioButton.IsChecked == true ? Hands.Both : (RightHandRadioButton.IsChecked == true ? Hands.Right : Hands.Left);
            action.IsKeyUp        = KeyUpCheckBox.IsChecked.Value;
            action.HandChangeTime = (float)AnimationTimeSlider.Value;

            if (Globals.KeyActions == null)
            {
                Globals.KeyActions = new List <KeyAction>();
            }
            Globals.KeyActions.Add(action);
            await Globals.Client.SendCommandAsync(new PipeCommands.SetKeyActions {
                KeyActions = Globals.KeyActions
            });

            this.DialogResult = true;
        }
 private async void ExternalCameraConigExportButton_Click(object sender, RoutedEventArgs e)
 {
     if (ControllerComboBox.SelectedItem == null)
     {
         MessageBox.Show(LanguageSelector.Get("SettingWindow_SelectedItemError"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     var tracker = ControllerComboBox.SelectedItem as TrackerConfigWindow.TrackerInfo;
     await Globals.Client?.SendCommandWaitAsync(new PipeCommands.GetExternalCameraConfig {
         ControllerName = tracker.SerialNumber
     }, r =>
     {
         var d = (PipeCommands.SetExternalCameraConfig)r;
         Dispatcher.Invoke(() =>
         {
             var sfd      = new SaveFileDialog();
             sfd.Filter   = "externalcamera.cfg|externalcamera.cfg";
             sfd.Title    = "Export externalcamera.cfg";
             sfd.FileName = "externalcamera.cfg";
             if (sfd.ShowDialog() == true)
             {
                 var lines = new List <string>();
                 lines.Add($"x={d.x}");
                 lines.Add($"y={d.y}");
                 lines.Add($"z={d.z}");
                 lines.Add($"rx={d.rx}");
                 lines.Add($"ry={d.ry}");
                 lines.Add($"rz={d.rz}");
                 lines.Add($"fov={d.fov}");
                 lines.Add($"near=0.01");
                 lines.Add($"far=1000");
                 lines.Add($"disableStandardAssets=False");
                 lines.Add($"frameSkip=0");
                 File.WriteAllLines(sfd.FileName, lines);
             }
         });
     });
 }
        private async void CalibrationButton_Click(object sender, RoutedEventArgs e)
        {
            if (CalibrationButton.IsEnabled == false)
            {
                return;                                       //何度も実行しないように
            }
            CalibrationButton.IsEnabled = false;
            int timercount = 5;

            do
            {
                StatusTextBlock.Text = timercount.ToString();
                await Task.Delay(1000);
            } while (timercount-- > 0);
            StatusTextBlock.Text = LanguageSelector.Get("CalibrationWindow_Status_Calibrating");
            var calibrateType = CalibrateFixedHandRadioButton.IsChecked == true ? PipeCommands.CalibrateType.FixedHand : (CalibrateFixedHandWithGroundRadioButton.IsChecked == true ? PipeCommands.CalibrateType.FixedHandWithGround : PipeCommands.CalibrateType.Default);

            Globals.CurrentCommonSettingsWPF.LastCalibrateType = calibrateType;
            await Globals.Client.SendCommandAsync(new PipeCommands.Calibrate {
                CalibrateType = calibrateType
            });

            await Task.Delay(1000);

            StatusTextBlock.Text = LanguageSelector.Get("CalibrationWindow_Status_Finish");
            Globals.CurrentCommonSettingsWPF.EnableCalibrationEndSound = CalibrationEndSoundCheckBox.IsChecked.Value;
            if (Globals.CurrentCommonSettingsWPF.EnableCalibrationEndSound)
            {
                System.Media.SystemSounds.Beep.Play();
            }

            Globals.SaveCommonSettings();
            await Task.Delay(1000);

            Close();
        }
示例#25
0
        private async void TakePhoto()
        {
            if (TakePhotoButton.IsEnabled == false)
            {
                return;                                     //何度も実行しないように
            }
            TakePhotoButton.IsEnabled = false;
            if (int.TryParse(TimerSecondsTextBox.Text, out var timerSeconds) == false)
            {
                MessageBox.Show(LanguageSelector.Get("PhotoWindow_ErrorTimer"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (int.TryParse(ResolutionWidthTextBox.Text, out var width) == false || width <= 0)
            {
                MessageBox.Show(LanguageSelector.Get("PhotoWindow_ErrorWidth"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (Directory.Exists(PathTextBox.Text) == false)
            {
                MessageBox.Show(LanguageSelector.Get("PhotoWindow_ErrorFolderExist"), LanguageSelector.Get("Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            while (timerSeconds > 0)
            {
                TimerTextBlock.Text = timerSeconds.ToString();
                await Task.Delay(1000);

                timerSeconds--;
            }
            await Globals.Client.SendCommandAsync(new PipeCommands.TakePhoto {
                Width = width, TransparentBackground = TransparentCheckBox.IsChecked == true, Directory = PathTextBox.Text
            });

            TimerTextBlock.Text       = "";
            TakePhotoButton.IsEnabled = true;
        }
        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);
            }
        }
 private void UpdateWindowTitle()
 {
     Title = $"{LanguageSelector.Get("MainWindowTitle")} ({(CurrentWindowNum == 0 ? LanguageSelector.Get("MainWindowTitleLoading") : CurrentWindowNum.ToString())})";
 }