Example #1
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();
                        }
                    }
                });
            });
        }
Example #2
0
        private async void LIVExternalCameraConigExportButton_Click(object sender, RoutedEventArgs e)
        {
            Globals.LoadCommonSettings();

            var tracker = TrackersList.First(); //なんでもいい。fovだけ返してもらう
            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=" + 0f.ToString("G", format));
                        lines.Add($"y=" + 0f.ToString("G", format));
                        lines.Add($"z=" + 0f.ToString("G", format));
                        lines.Add($"rx=" + 0f.ToString("G", format));
                        lines.Add($"ry=" + 0f.ToString("G", format));
                        lines.Add($"rz=" + 0f.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();
                        }
                    }
                });
            });
        }
        private async void SaveSettingsButton_Click(object sender, RoutedEventArgs e)
        {
            Globals.LoadCommonSettings();

            var sfd = new Microsoft.Win32.SaveFileDialog();

            sfd.Filter           = "Setting File(*.json)|*.json";
            sfd.InitialDirectory = Globals.ExistDirectoryOrNull(Globals.CurrentCommonSettingsWPF.CurrentPathOnSettingFileDialog);
            if (sfd.ShowDialog() == true)
            {
                await Globals.Client.SendCommandAsync(new PipeCommands.SaveSettings {
                    Path = sfd.FileName
                });

                if (Globals.CurrentCommonSettingsWPF.CurrentPathOnSettingFileDialog != System.IO.Path.GetDirectoryName(sfd.FileName))
                {
                    Globals.CurrentCommonSettingsWPF.CurrentPathOnSettingFileDialog = System.IO.Path.GetDirectoryName(sfd.FileName);
                    Globals.SaveCommonSettings();
                }
            }
        }
Example #4
0
        private async void CameraPlus_ExportButton_Click(object sender, RoutedEventArgs e)
        {
            await Globals.Client?.SendCommandWaitAsync(new PipeCommands.ExportCameraPlus {
            }, r =>
            {
                var d = (PipeCommands.ReturnExportCameraPlus)r;
                Dispatcher.Invoke(() =>
                {
                    Globals.LoadCommonSettings();
                    var ofd              = new OpenFileDialog();
                    ofd.Filter           = "cameraplus.cfg|cameraplus.cfg";
                    ofd.Title            = "Select cameraplus.cfg";
                    ofd.FileName         = "cameraplus.cfg";
                    ofd.InitialDirectory = Globals.ExistDirectoryOrNull(Globals.CurrentCommonSettingsWPF.CurrentPathOnCameraPlusFileDialog);

                    if (ofd.ShowDialog() == true)
                    {
                        var culture = System.Globalization.CultureInfo.InvariantCulture;
                        var format  = culture.NumberFormat;
                        var lines   = File.ReadAllLines(ofd.FileName);
                        for (int i = 0; i < lines.Length; i++)
                        {
                            if (lines[i].StartsWith("posx"))
                            {
                                lines[i] = $"posx=" + d.x.ToString("G", format);
                            }
                            if (lines[i].StartsWith("posy"))
                            {
                                lines[i] = $"posy=" + d.y.ToString("G", format);
                            }
                            if (lines[i].StartsWith("posz"))
                            {
                                lines[i] = $"posz=" + d.z.ToString("G", format);
                            }
                            if (lines[i].StartsWith("angx"))
                            {
                                lines[i] = $"angx=" + d.rx.ToString("G", format);
                            }
                            if (lines[i].StartsWith("angy"))
                            {
                                lines[i] = $"angy=" + d.ry.ToString("G", format);
                            }
                            if (lines[i].StartsWith("angz"))
                            {
                                lines[i] = $"angz=" + d.rz.ToString("G", format);
                            }
                            if (lines[i].StartsWith("fov"))
                            {
                                lines[i] = $"fov=" + d.fov.ToString("G", format);
                            }
                        }
                        File.WriteAllLines(ofd.FileName, lines);

                        if (Globals.CurrentCommonSettingsWPF.CurrentPathOnCameraPlusFileDialog != System.IO.Path.GetDirectoryName(ofd.FileName))
                        {
                            Globals.CurrentCommonSettingsWPF.CurrentPathOnCameraPlusFileDialog = System.IO.Path.GetDirectoryName(ofd.FileName);
                            Globals.SaveCommonSettings();
                        }
                    }
                });
            });
        }
        private async void CameraPlus_ImportButton_Click(object sender, RoutedEventArgs e)
        {
            Globals.LoadCommonSettings();

            var ofd = new OpenFileDialog();

            ofd.Filter           = "cameraplus (*.cfg;*.json) | *.cfg;*.json";
            ofd.InitialDirectory = Globals.ExistDirectoryOrNull(Globals.CurrentCommonSettingsWPF.CurrentPathOnCameraPlusFileDialog);
            if (ofd.ShowDialog() == true)
            {
                var configs = new Dictionary <string, string>();
                if (System.IO.Path.GetExtension(ofd.FileName) == ".json")
                {
                    var json = File.ReadAllText(ofd.FileName);
                    var c    = Json.Serializer.Deserialize <CameraPlusConfig>(json);
                    await Globals.Client?.SendCommandAsync(new PipeCommands.ImportCameraPlus {
                        x = c.ThirdPersonPos.x, y = c.ThirdPersonPos.y, z = c.ThirdPersonPos.z, rx = c.ThirdPersonRot.x, ry = c.ThirdPersonRot.y, rz = c.ThirdPersonRot.z, fov = c.FieldOfView
                    });
                }
                else
                {
                    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("posx");
                    var y   = GetFloat("posy");
                    var z   = GetFloat("posz");
                    var rx  = GetFloat("angx");
                    var ry  = GetFloat("angy");
                    var rz  = GetFloat("angz");
                    var fov = GetFloat("fov");

                    await Globals.Client?.SendCommandAsync(new PipeCommands.ImportCameraPlus {
                        x = x, y = y, z = z, rx = rx, ry = ry, rz = rz, fov = fov
                    });
                }
                if (Globals.CurrentCommonSettingsWPF.CurrentPathOnCameraPlusFileDialog != System.IO.Path.GetDirectoryName(ofd.FileName))
                {
                    Globals.CurrentCommonSettingsWPF.CurrentPathOnCameraPlusFileDialog = System.IO.Path.GetDirectoryName(ofd.FileName);
                    Globals.SaveCommonSettings();
                }
            }
        }