172 lines
5.2 KiB
C#
172 lines
5.2 KiB
C#
using HeBianGu.Service.Mvc;
|
|
using Hopetry.ViewModel.Send;
|
|
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Windows;
|
|
using System.Windows.Threading;
|
|
using Hopetry.Provider;
|
|
|
|
namespace HeBianGu.App.Disk
|
|
{
|
|
[ViewModel("Send")]
|
|
internal class SendViewModel : MvcViewModelBase
|
|
{
|
|
private LinkAction _uploadingAction; //正在上传
|
|
private LinkAction _completeAction; //上传完成
|
|
protected override void Init()
|
|
{
|
|
LinkActions.Add(new LinkAction() { Action = "Down", Controller = "Send", DisplayName = "正在下载", Logo = "\xe6f3" });
|
|
// 正在上传
|
|
_uploadingAction = new LinkAction()
|
|
{
|
|
Action = "UpLoad",
|
|
Controller = "Send",
|
|
DisplayName = "正在上传",
|
|
Logo = "\xe6f3"
|
|
};
|
|
LinkActions.Add(_uploadingAction);
|
|
|
|
_completeAction = new LinkAction()
|
|
{
|
|
Action = "CompleteUpload",
|
|
Controller = "Send",
|
|
DisplayName = "上传完成",
|
|
Logo = "\xe613"
|
|
};
|
|
LinkActions.Add(_completeAction);
|
|
//LinkActions.Add(new LinkAction() { Action = "Down", Controller = "Send", DisplayName = "文件快传", Logo = "\xe764" });
|
|
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() =>
|
|
{
|
|
SelectLink = LinkActions[0];
|
|
}));
|
|
|
|
}
|
|
|
|
protected override void Loaded(string args)
|
|
{
|
|
|
|
}
|
|
|
|
#region 文件上传
|
|
//上传文件总数
|
|
private ObservableCollection<UpLoadItems> _upLoadItems = new ObservableCollection<UpLoadItems>();
|
|
/// <summary> 说明 </summary>
|
|
public ObservableCollection<UpLoadItems> UpLoadItems
|
|
{
|
|
get { return _upLoadItems; }
|
|
set
|
|
{
|
|
_upLoadItems = value;
|
|
//UpdateUploadingItems();
|
|
RaisePropertyChanged("UpLoadItems");
|
|
}
|
|
}
|
|
|
|
//已上传完成文件
|
|
private ObservableCollection<UpLoadItems> _completeItems = new ObservableCollection<UpLoadItems>();
|
|
public ObservableCollection<UpLoadItems> CompleteItems
|
|
{
|
|
get { return _completeItems; }
|
|
private set
|
|
{
|
|
_completeItems = value;
|
|
RaisePropertyChanged("CompleteItems");
|
|
}
|
|
}
|
|
|
|
|
|
// 只读属性,返回过滤后的集合(动态计算)
|
|
private ObservableCollection<UpLoadItems> _uploadingItems = new ObservableCollection<UpLoadItems>();
|
|
public ObservableCollection<UpLoadItems> UploadingItems
|
|
{
|
|
get { return _uploadingItems; }
|
|
private set
|
|
{
|
|
_uploadingItems = value;
|
|
RaisePropertyChanged("UploadingItems");
|
|
}
|
|
}
|
|
|
|
// 在 UpLoadItems 变化时更新 UploadingItems
|
|
public void UpdateUploadingItems()
|
|
{
|
|
UploadingItems = new ObservableCollection<UpLoadItems>(
|
|
UpLoadItems?.Where(item => item.Value3 != "已完成") ?? Enumerable.Empty<UpLoadItems>()
|
|
);
|
|
}
|
|
|
|
|
|
//文件上传进度
|
|
private double _progress;
|
|
|
|
public double Progress
|
|
{
|
|
get { return _progress; }
|
|
set
|
|
{
|
|
if (_progress != value)
|
|
{
|
|
_progress = value;
|
|
RaisePropertyChanged("Progress");
|
|
}
|
|
}
|
|
}
|
|
|
|
//上传文件个数
|
|
private string _filecount;
|
|
|
|
public string FileCount
|
|
{
|
|
get { return _filecount; }
|
|
set
|
|
{
|
|
if (_filecount != value)
|
|
{
|
|
_filecount = value;
|
|
RaisePropertyChanged("FileCount");
|
|
}
|
|
}
|
|
}
|
|
//上传完成文件个数
|
|
private int _uploadingcount;
|
|
|
|
public int UploadingCount
|
|
{
|
|
get { return _uploadingcount; }
|
|
set
|
|
{
|
|
if (_uploadingcount != value)
|
|
{
|
|
_uploadingcount = value;
|
|
_uploadingAction.FullName = "(" + _uploadingcount + ")";
|
|
RaisePropertyChanged("UploadingCount");
|
|
}
|
|
}
|
|
}
|
|
//上传文件个数
|
|
private int _completecount;
|
|
|
|
public int CompleteCount
|
|
{
|
|
get { return _completecount; }
|
|
set
|
|
{
|
|
if (_completecount != value)
|
|
{
|
|
_completecount = value;
|
|
_completeAction.FullName= "(" + _completecount + ")";
|
|
RaisePropertyChanged("CompleteCount");
|
|
}
|
|
}
|
|
}
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
protected void OnPropertyChanged(string propertyName)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
#endregion
|
|
}
|
|
}
|