145 lines
5.2 KiB
C#
145 lines
5.2 KiB
C#
using HeBianGu.Base.WpfBase;
|
|
using HeBianGu.Service.Mvc;
|
|
using Microsoft.Win32;
|
|
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using System.Windows.Threading;
|
|
|
|
namespace HeBianGu.App.Disk
|
|
{
|
|
[ViewModel("Loyout")]
|
|
internal class LoyoutViewModel : MvcViewModelBase
|
|
{
|
|
private string _path;
|
|
/// <summary> 说明 </summary>
|
|
public string Path
|
|
{
|
|
get { return _path; }
|
|
set
|
|
{
|
|
_path = value;
|
|
RaisePropertyChanged("Path");
|
|
}
|
|
}
|
|
|
|
|
|
private string _nearPath;
|
|
/// <summary> 说明 </summary>
|
|
public string NearPath
|
|
{
|
|
get { return _nearPath; }
|
|
set
|
|
{
|
|
_nearPath = value;
|
|
RaisePropertyChanged("NearPath");
|
|
}
|
|
}
|
|
|
|
|
|
private string _sharePath;
|
|
/// <summary> 说明 </summary>
|
|
public string SharePath
|
|
{
|
|
get { return _sharePath; }
|
|
set
|
|
{
|
|
_sharePath = value;
|
|
RaisePropertyChanged("SharePath");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected override void Init()
|
|
{
|
|
Path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
|
|
|
|
NearPath = Environment.GetFolderPath(Environment.SpecialFolder.Recent);
|
|
|
|
SharePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
|
|
|
// LinkActions.Add(new LinkAction() { Action = "Near", Controller = "Loyout", DisplayName = "最近使用", Logo = "\xe6f3" });
|
|
LinkActions.Add(new LinkAction() { Action = "Explorer", Controller = "Loyout", DisplayName = "全部文件", Logo = "" });
|
|
// LinkActions.Add(new LinkAction() { Action = "Image", Controller = "Loyout", DisplayName = " 图片", Logo = "" });
|
|
// LinkActions.Add(new LinkAction() { Action = "Video", Controller = "Loyout", DisplayName = " 视频", Logo = "" });
|
|
// LinkActions.Add(new LinkAction() { Action = "Document", Controller = "Loyout", DisplayName = " 文档", Logo = "" });
|
|
// LinkActions.Add(new LinkAction() { Action = "Music", Controller = "Loyout", DisplayName = " 音乐", Logo = "" });
|
|
// LinkActions.Add(new LinkAction() { Action = "Explorer", Controller = "Loyout", DisplayName = " 种子", Logo = "" });
|
|
//LinkActions.Add(new LinkAction() { Action = "Recent", Controller = "Loyout", DisplayName = " 其他", Logo = "" });
|
|
// LinkActions.Add(new LinkAction() { Action = "Space", Controller = "Loyout", DisplayName = "隐藏空间", Logo = "\xe613" });
|
|
//LinkActions.Add(new LinkAction() { Action = "Share", Controller = "Loyout", DisplayName = "我的分享", Logo = "\xe764" });
|
|
// LinkActions.Add(new LinkAction() { Action = "Near", Controller = "Loyout", DisplayName = "回收站", Logo = "\xe618" });
|
|
|
|
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() =>
|
|
{
|
|
SelectLink = LinkActions[0];
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
protected override void Loaded(string args)
|
|
{
|
|
|
|
}
|
|
|
|
#region 文件上传
|
|
private ICommand _uploadCommand;
|
|
public ICommand UploadCommand
|
|
{
|
|
get
|
|
{
|
|
return _uploadCommand ?? (_uploadCommand = new RelayCommand(UploadFile));
|
|
}
|
|
}
|
|
|
|
private void UploadFile(object obj)
|
|
{
|
|
//// 打开文件选择对话框
|
|
//OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
//openFileDialog.Filter = "All Files (*.*)|*.*"; // 设置文件过滤器
|
|
//openFileDialog.Multiselect = false; // 单文件上传
|
|
|
|
//if (openFileDialog.ShowDialog() == true)
|
|
//{
|
|
// string filePath = openFileDialog.FileName;
|
|
// string fileName = Path.GetFileName(filePath);
|
|
|
|
// try
|
|
// {
|
|
// // 模拟文件上传逻辑
|
|
// // 这里可以替换为实际的上传逻辑,例如调用 API 或保存到指定目录
|
|
// string destinationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), fileName);
|
|
// File.Copy(filePath, destinationPath, overwrite: true);
|
|
|
|
// // 更新上传时间
|
|
// UploadTime = DateTime.Now;
|
|
|
|
// // 提示上传成功
|
|
// MessageBox.Show($"文件 {fileName} 上传成功!", "上传完成", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// // 处理上传失败
|
|
// MessageBox.Show($"文件上传失败: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
// }
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
internal class DataFileViewModel : ObservableSourceViewModel<TestViewModel>
|
|
{
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|