将录像保存目录同步为导入视频默认目录
This commit is contained in:
parent
76cbea774c
commit
29a00fc349
@ -67,11 +67,7 @@ public sealed class CameraViewModel : BindableBase
|
||||
_settingsPath = Path.Combine(root, "workspace", "camera-settings.json");
|
||||
try
|
||||
{
|
||||
if (File.Exists(_settingsPath))
|
||||
{
|
||||
using var json = JsonDocument.Parse(File.ReadAllText(_settingsPath));
|
||||
SaveDirectory = json.RootElement.GetProperty("directory").GetString() ?? _directory;
|
||||
}
|
||||
SaveDirectory = ReadSaveDirectory(root);
|
||||
}
|
||||
catch (Exception e) { Status = "录像目录配置读取失败:" + e.Message; }
|
||||
RefreshCommand = Command(RefreshAsync, () => CanChooseCamera);
|
||||
@ -261,6 +257,17 @@ public sealed class CameraViewModel : BindableBase
|
||||
lock (_frames) { _latest?.Dispose(); _latest = null; }
|
||||
Preview = null;
|
||||
}
|
||||
internal static string ReadSaveDirectory(string root)
|
||||
{
|
||||
var path = Path.Combine(root, "workspace", "camera-settings.json");
|
||||
if (File.Exists(path))
|
||||
{
|
||||
using var json = JsonDocument.Parse(File.ReadAllText(path));
|
||||
var directory = json.RootElement.GetProperty("directory").GetString();
|
||||
if (!string.IsNullOrWhiteSpace(directory)) return directory;
|
||||
}
|
||||
return Path.Combine(root, "workspace", "recordings");
|
||||
}
|
||||
private void SaveSettings()
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_settingsPath)!);
|
||||
|
||||
@ -35,6 +35,7 @@ public sealed class MainViewModel : BindableBase
|
||||
public string LatestWeights { get => _latestWeights; private set => SetProperty(ref _latestWeights, value); }
|
||||
public string TrainingRunDirectory { get => _trainingRunDirectory; private set => SetProperty(ref _trainingRunDirectory, value); }
|
||||
public string TrainingOutputDirectory { get; set; } = "";
|
||||
public string? VideoImportDirectory { get; set; }
|
||||
public string Root { get; }
|
||||
public TrainingProject? Project => _project;
|
||||
public ObservableCollection<FrameAnnotation> Frames { get; } = [];
|
||||
@ -186,6 +187,8 @@ public sealed class MainViewModel : BindableBase
|
||||
try
|
||||
{
|
||||
var video = new OpenFileDialog { Filter = "视频|*.mp4;*.avi;*.mov;*.mkv;*.wmv|所有文件|*.*" };
|
||||
try { video.InitialDirectory = VideoImportDirectory ?? CameraViewModel.ReadSaveDirectory(Root); }
|
||||
catch (Exception e) { Append("录像目录配置读取失败:" + e.Message); }
|
||||
if (await video.ShowDialogAsync() != true) return;
|
||||
var folder = new OpenFolderDialog { Title = "选择项目保存的父文件夹(会自动新建子文件夹)" };
|
||||
if (await folder.ShowDialogAsync() != true) return;
|
||||
|
||||
@ -42,7 +42,7 @@ public partial class TrainingPage : UserControl
|
||||
if(TopLevel.GetTopLevel(this) is not Window owner)return;
|
||||
_cameraWindow=new CameraWindow(new CameraViewModel(new CameraService(),_model.Root));
|
||||
try { await _cameraWindow.ShowDialog(owner); }
|
||||
finally { _cameraWindow=null; }
|
||||
finally { _model.VideoImportDirectory=_cameraWindow.Model.SaveDirectory;_cameraWindow=null; }
|
||||
}
|
||||
public async Task ShutdownAsync()
|
||||
{await _model.StopAsync();if(_cameraWindow!=null)await _cameraWindow.Model.ShutdownAsync();}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user