2025-03-24 10:24:36 +08:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using System.Windows.Input;
|
2025-03-22 15:29:32 +08:00
|
|
|
|
using HeBianGu.Service.Mvc;
|
2025-03-24 10:24:36 +08:00
|
|
|
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
2025-03-22 15:29:32 +08:00
|
|
|
|
|
|
|
|
|
|
namespace HeBianGu.App.Disk.ViewModel.Sync;
|
|
|
|
|
|
|
|
|
|
|
|
[ViewModel("Sync")]
|
|
|
|
|
|
public class SyncViewModel : MvcViewModelBase
|
|
|
|
|
|
{
|
2025-03-24 10:24:36 +08:00
|
|
|
|
public ICommand OpenDirCommand { get; set; }
|
|
|
|
|
|
|
2025-03-22 15:29:32 +08:00
|
|
|
|
protected override void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
/*LinkActions.Add(new LinkAction() { Action = "Space", Controller = "Loyout", DisplayName = "会话", Logo = "\xe613" });
|
|
|
|
|
|
|
|
|
|
|
|
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SelectLink = LinkActions[0];
|
|
|
|
|
|
}));*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-24 10:24:36 +08:00
|
|
|
|
public SyncViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
OpenDirCommand = new RelayCommand(async () => await ButtonBase_OnClick());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-22 15:29:32 +08:00
|
|
|
|
protected override void Loaded(string args)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2025-03-24 10:24:36 +08:00
|
|
|
|
|
2025-03-22 15:29:32 +08:00
|
|
|
|
public string _syncDir;
|
|
|
|
|
|
|
|
|
|
|
|
public string SyncDir
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _syncDir;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
_syncDir = value;
|
|
|
|
|
|
RaisePropertyChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-24 10:24:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class RelayCommand : ICommand
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly Action _execute;
|
|
|
|
|
|
|
|
|
|
|
|
public RelayCommand(Action execute)
|
|
|
|
|
|
{
|
|
|
|
|
|
_execute = execute;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool CanExecute(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public event EventHandler CanExecuteChanged;
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
_execute();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task ButtonBase_OnClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonOpenFileDialog dialog = new CommonOpenFileDialog
|
|
|
|
|
|
{
|
|
|
|
|
|
IsFolderPicker = true
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
|
|
|
|
|
{
|
|
|
|
|
|
var folderPath = dialog.FileName; // 获取选中的文件夹路径
|
|
|
|
|
|
//MessageBox.Show("folderPath " + folderPath);
|
|
|
|
|
|
SyncDir = folderPath;
|
|
|
|
|
|
// 处理选中的文件夹路径
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-22 15:29:32 +08:00
|
|
|
|
}
|