Compare commits
4 Commits
15ad822e00
...
ed9561f654
| Author | SHA1 | Date |
|---|---|---|
|
|
ed9561f654 | |
|
|
2d5443783e | |
|
|
f70fa47eb8 | |
|
|
0240d8995e |
2
App.xaml
2
App.xaml
|
|
@ -7,7 +7,7 @@
|
|||
<h:ApplicationBase.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries />
|
||||
<provider:DataSourceLocator x:Key="S.DataSource.Locator" />
|
||||
<provider:ViewModelLocator x:Key="S.ViewModelLocator.Locator" />
|
||||
</ResourceDictionary>
|
||||
</h:ApplicationBase.Resources>
|
||||
</h:ApplicationBase>
|
||||
|
|
|
|||
186
App.xaml.cs
186
App.xaml.cs
|
|
@ -90,7 +90,7 @@ namespace HeBianGu.App.Disk
|
|||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region - WindowCaption -
|
||||
|
||||
//以下各种功能按钮
|
||||
|
|
@ -118,102 +118,140 @@ namespace HeBianGu.App.Disk
|
|||
//var find = dll.GetTypes().Where(x => typeof(IExplorerService).IsAssignableFrom(x))?.FirstOrDefault();
|
||||
//ServiceRegistry.Instance.Register(typeof(IExplorerService), find);
|
||||
//services.AddSingleton<IExplorerService, WindowExplorerServiceDemo>();
|
||||
|
||||
|
||||
|
||||
var minioService = services.GetService<MinioService>();
|
||||
|
||||
var bucketName = minioService._bucketName;
|
||||
var xmlSerializerService = services.GetService<ISerializerService>();
|
||||
if (File.Exists("./settings.xml"))
|
||||
if (!File.Exists("./settings.xml"))
|
||||
{
|
||||
var setting = xmlSerializerService.Load<SystemSetting>("./settings.xml");
|
||||
if (!string.IsNullOrEmpty(setting.SyncDir))
|
||||
var tempSetting = new SystemSetting();
|
||||
tempSetting.TaskCount = 3;
|
||||
tempSetting.SyncDir = Path.Combine(SelectDrive(),"HopetryBoxData");
|
||||
if (!Directory.Exists(tempSetting.SyncDir))
|
||||
{
|
||||
if (setting.TaskCount == 0)
|
||||
{
|
||||
setting.TaskCount = 3;
|
||||
}
|
||||
Directory.CreateDirectory(tempSetting.SyncDir);
|
||||
}
|
||||
xmlSerializerService.Save("./settings.xml", tempSetting);
|
||||
}
|
||||
|
||||
// 创建统一的取消令牌源
|
||||
var cancelToken = new CancellationTokenSource();
|
||||
var temp = SyncSetting.Instance;
|
||||
var notRun = true;
|
||||
// 注册设置变更监听
|
||||
temp.PropertyChanged += (s, e) =>
|
||||
var setting = xmlSerializerService.Load<SystemSetting>("./settings.xml");
|
||||
if (string.IsNullOrEmpty(setting.SyncDir))
|
||||
{
|
||||
var selectDrive = SelectDrive();
|
||||
|
||||
setting.SyncDir = Path.Combine(selectDrive, "HopetryBoxData");
|
||||
if (!Directory.Exists(setting.SyncDir))
|
||||
{
|
||||
Directory.CreateDirectory(setting.SyncDir);
|
||||
}
|
||||
|
||||
// 保存配置
|
||||
xmlSerializerService.Save("./settings.xml", setting);
|
||||
}
|
||||
|
||||
if (setting.TaskCount == 0)
|
||||
{
|
||||
setting.TaskCount = 3;
|
||||
}
|
||||
|
||||
// 创建统一的取消令牌源
|
||||
var cancelToken = new CancellationTokenSource();
|
||||
var temp = SyncSetting.Instance;
|
||||
var notRun = true;
|
||||
// 注册设置变更监听
|
||||
temp.PropertyChanged += (s, e) =>
|
||||
{
|
||||
if (temp.IsOn && notRun)
|
||||
{
|
||||
// 异步启动服务
|
||||
Console.WriteLine("启动同步:");
|
||||
try
|
||||
{
|
||||
if (temp.IsOn && notRun)
|
||||
minioService.MirrorAsync(bucketName, setting.SyncDir, setting.TaskCount);
|
||||
minioService.RealTimeListen(bucketName, setting.SyncDir,
|
||||
cancellationToken: cancelToken.Token);
|
||||
notRun = false;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Console.WriteLine("同步监听已取消");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"同步失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
// 运行中 且 temp.IsOn 变成 false
|
||||
else if (!notRun && !temp.IsOn)
|
||||
{
|
||||
notRun = true;
|
||||
// 当设置关闭时取消所有任务
|
||||
cancelToken.Cancel(); // 取消任务
|
||||
cancelToken.Dispose();
|
||||
cancelToken = new CancellationTokenSource();
|
||||
}
|
||||
};
|
||||
/*var delayTimer = new DispatcherTimer();
|
||||
delayTimer.Interval = TimeSpan.FromSeconds(5);
|
||||
delayTimer.Tick += async (s, e) =>
|
||||
{
|
||||
delayTimer.Stop(); // 确保只执行一次
|
||||
// 异步操作不会阻塞UI
|
||||
await Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
// 注册设置变更监听
|
||||
SyncSetting.Instance.PropertyChanged += (s1, e1) =>
|
||||
{
|
||||
if (SyncSetting.Instance.IsOn)
|
||||
{
|
||||
// 异步启动服务
|
||||
Console.WriteLine("启动同步:");
|
||||
try
|
||||
{
|
||||
minioService.MirrorAsync(bucketName, setting.SyncDir, setting.TaskCount);
|
||||
minioService.RealTimeListen(bucketName, setting.SyncDir,
|
||||
cancellationToken: cancelToken.Token);
|
||||
notRun = false;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Console.WriteLine("同步监听已取消");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"同步失败: {ex.Message}");
|
||||
}
|
||||
_ = StartSyncServicesAsync();
|
||||
}
|
||||
// 运行中 且 temp.IsOn 变成 false
|
||||
else if (!notRun && !temp.IsOn)
|
||||
else
|
||||
{
|
||||
notRun = true;
|
||||
// 当设置关闭时取消所有任务
|
||||
cancelToken.Cancel(); // 取消任务
|
||||
cancelToken.Cancel();
|
||||
cancelToken.Dispose();
|
||||
cancelToken = new CancellationTokenSource();
|
||||
}
|
||||
};
|
||||
/*var delayTimer = new DispatcherTimer();
|
||||
delayTimer.Interval = TimeSpan.FromSeconds(5);
|
||||
delayTimer.Tick += async (s, e) =>
|
||||
{
|
||||
delayTimer.Stop(); // 确保只执行一次
|
||||
// 异步操作不会阻塞UI
|
||||
await Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
// 注册设置变更监听
|
||||
SyncSetting.Instance.PropertyChanged += (s1, e1) =>
|
||||
{
|
||||
if (SyncSetting.Instance.IsOn)
|
||||
{
|
||||
// 异步启动服务
|
||||
_ = StartSyncServicesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 当设置关闭时取消所有任务
|
||||
cancelToken.Cancel();
|
||||
cancelToken.Dispose();
|
||||
cancelToken = new CancellationTokenSource();
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
delayTimer.Start();*/
|
||||
delayTimer.Start();*/
|
||||
|
||||
|
||||
/*var syncSettingPath = SyncSetting.Instance.GetPath();
|
||||
var syncSetting = xmlSerializerService.Load<SyncSetting>(syncSettingPath);
|
||||
SyncSetting.Instance.IsOn = syncSetting.IsOn;
|
||||
if (syncSetting.IsOn)
|
||||
{
|
||||
// 是否启监听
|
||||
minioService.MirrorAsync1(bucketName, setting.SyncDir, setting.TaskCount);
|
||||
}*/
|
||||
/*var syncSettingPath = SyncSetting.Instance.GetPath();
|
||||
var syncSetting = xmlSerializerService.Load<SyncSetting>(syncSettingPath);
|
||||
SyncSetting.Instance.IsOn = syncSetting.IsOn;
|
||||
if (syncSetting.IsOn)
|
||||
{
|
||||
// 是否启监听
|
||||
minioService.MirrorAsync1(bucketName, setting.SyncDir, setting.TaskCount);
|
||||
}*/
|
||||
|
||||
/*minioService.RealTimeListen(bucketName, setting.SyncDir,
|
||||
cancellationToken: cancelToken.Token);*/
|
||||
/*minioService.RealTimeListen(bucketName, setting.SyncDir,
|
||||
cancellationToken: cancelToken.Token);*/
|
||||
}
|
||||
|
||||
private static string SelectDrive()
|
||||
{
|
||||
var maxFreeSpace = 0L;
|
||||
var selectDrive = "";
|
||||
// 如果同步目录为空,则选择一个本地空闲空间比较大的分区
|
||||
foreach (DriveInfo drive in DriveInfo.GetDrives())
|
||||
{
|
||||
if (drive.DriveType != DriveType.Fixed) continue; // 只获取固定硬盘
|
||||
|
||||
if (drive.AvailableFreeSpace > maxFreeSpace)
|
||||
{
|
||||
maxFreeSpace = drive.AvailableFreeSpace;
|
||||
selectDrive = drive.Name;
|
||||
}
|
||||
}
|
||||
|
||||
return selectDrive;
|
||||
}
|
||||
|
||||
protected override void Configure(IApplicationBuilder app)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using HeBianGu.App.Disk.ViewModel.Sync;
|
||||
using HeBianGu.Base.WpfBase;
|
||||
using HeBianGu.Base.WpfBase;
|
||||
using HeBianGu.Service.Mvc;
|
||||
using Hopetry.ViewModel.Sync;
|
||||
|
||||
namespace HeBianGu.App.Disk;
|
||||
|
||||
|
|
@ -10,6 +10,7 @@ public class SyncController : Controller<SyncViewModel>
|
|||
{
|
||||
public async Task<IActionResult> Sync()
|
||||
{
|
||||
// 这里可以操作 viewModel
|
||||
return await ViewAsync();
|
||||
}
|
||||
}
|
||||
|
|
@ -57,6 +57,7 @@
|
|||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.4.0" />
|
||||
<PackageReference Include="Polly" Version="8.5.2" />
|
||||
<PackageReference Include="SqlSugar" Version="5.1.4.187" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.187" />
|
||||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.119" />
|
||||
<PackageReference Include="WindowsAPICodePack" Version="8.0.6" />
|
||||
|
|
@ -86,6 +87,9 @@
|
|||
<None Remove="Assets\file-detail.png" />
|
||||
<None Remove="Assets\logo.png" />
|
||||
<Resource Include="Assets\logo.png" />
|
||||
<None Update="minio.db">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
using HeBianGu.App.Disk.ViewModel.Sync;
|
||||
using HeBianGu.Base.WpfBase;
|
||||
|
||||
namespace Hopetry.Provider
|
||||
{
|
||||
internal class DataSourceLocator
|
||||
{
|
||||
public DataSourceLocator()
|
||||
{
|
||||
ServiceRegistry.Instance.Register<SyncViewModel>();
|
||||
}
|
||||
|
||||
public SyncViewModel SyncViewModel => ServiceRegistry.Instance.GetInstance<SyncViewModel>();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using HeBianGu.Base.WpfBase;
|
||||
using Hopetry.ViewModel.Send;
|
||||
using Hopetry.ViewModel.Sync;
|
||||
|
||||
namespace Hopetry.Provider
|
||||
{
|
||||
internal class ViewModelLocator
|
||||
{
|
||||
public ViewModelLocator()
|
||||
{
|
||||
ServiceRegistry.Instance.Register<SyncViewModel>();
|
||||
ServiceRegistry.Instance.Register<DownViewModel>();
|
||||
}
|
||||
|
||||
public static SyncViewModel SyncViewModel => ServiceRegistry.Instance.GetInstance<SyncViewModel>();
|
||||
public static DownViewModel DownViewModel => ServiceRegistry.Instance.GetInstance<DownViewModel>();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,187 +1,117 @@
|
|||
<UserControl x:Class="HeBianGu.App.Disk.DownControl"
|
||||
<UserControl x:Class="Hopetry.View.Send.DownControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:h="https://github.com/HeBianGu"
|
||||
xmlns:local="clr-namespace:HeBianGu.App.Disk"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
|
||||
<Grid DataContext="{StaticResource S.ViewModelLocator.Locator}">
|
||||
<DockPanel Margin="0,0,10,0">
|
||||
<h:Row DockPanel.Dock="Top" Style="{DynamicResource {x:Static h:Row.Column10Key}}">
|
||||
<TextBlock Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}" Text="下载总进度" />
|
||||
<h:FProgressBar Grid.Column="1"
|
||||
Grid.ColumnSpan="6"
|
||||
Height="15"
|
||||
CornerRadius="2"
|
||||
Maximum="100"
|
||||
Value="40">
|
||||
<h:FProgressBar.Triggers>
|
||||
<EventTrigger RoutedEvent="Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard Timeline.DesiredFrameRate="{x:Static h:StoryboardSetting.DesiredFrameRate}">
|
||||
<DoubleAnimation Storyboard.TargetProperty="Value"
|
||||
From="0"
|
||||
To="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Value}"
|
||||
Duration="00:00:30" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</h:FProgressBar.Triggers>
|
||||
</h:FProgressBar>
|
||||
<TextBlock Grid.Column="7" Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}" Text="184 KB/s" />
|
||||
<Button Grid.Column="8"
|
||||
<Button Grid.Column="0"
|
||||
Margin="10,0"
|
||||
Content="全部暂停"
|
||||
Style="{DynamicResource {x:Static h:ButtonKeys.BorderBrushTransparent}}" />
|
||||
<Button Grid.Column="9" Content="全部取消" Style="{DynamicResource {x:Static h:ButtonKeys.BorderBrushTransparent}}" />
|
||||
<Button Grid.Column="1" Content="全部取消"
|
||||
Style="{DynamicResource {x:Static h:ButtonKeys.BorderBrushTransparent}}" />
|
||||
</h:Row>
|
||||
<TabControl Padding="1 " HorizontalContentAlignment="Left">
|
||||
<TabItem Header="全部" Style="{DynamicResource {x:Static h:TabItemKeys.Accent}}" />
|
||||
<TabItem Header="下载中" />
|
||||
<TabItem Header="已完成">
|
||||
<ListBox h:Cattach.ItemHeight="Auto" ItemsSource="{Binding DownViewModel.DownItems}"
|
||||
Style="{DynamicResource {x:Static h:ListBoxKeys.Single}}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Height="50" Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid Height="60" DockPanel.Dock="Top" TextBlock.Foreground="{DynamicResource {x:Static h:BrushKeys.Orange}}">
|
||||
<TextBlock Grid.RowSpan="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Icon}}"
|
||||
Text="" />
|
||||
|
||||
<Border Background="{DynamicResource {x:Static h:BrushKeys.Orange}}" Opacity="0.2" />
|
||||
<TextBlock Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="{Binding FileName}" />
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="10:10:10" />
|
||||
|
||||
<TextBlock Margin="10,0"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="20"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Icon}}"
|
||||
Text="" />
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="3"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="{Binding FileName}" />
|
||||
|
||||
<TextBlock Margin="40,0,10,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontStyle="Oblique"
|
||||
Text="开通超级会员,立即尊享急速下载特权!" />
|
||||
<h:FProgressBar Grid.Column="3"
|
||||
Height="15"
|
||||
CornerRadius="2"
|
||||
Maximum="100"
|
||||
Value="{Binding ProgressInt}">
|
||||
<h:FProgressBar.Triggers>
|
||||
<EventTrigger RoutedEvent="Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard
|
||||
Timeline.DesiredFrameRate="{x:Static h:StoryboardSetting.DesiredFrameRate}">
|
||||
<DoubleAnimation Storyboard.TargetProperty="Value"
|
||||
From="0"
|
||||
To="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Value}"
|
||||
Duration="00:00:30" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</h:FProgressBar.Triggers>
|
||||
</h:FProgressBar>
|
||||
|
||||
<Button Height="30"
|
||||
Margin="300,0,10,0"
|
||||
Padding="15,0"
|
||||
HorizontalAlignment="Left"
|
||||
h:Cattach.CornerRadius="15"
|
||||
Background="{DynamicResource {x:Static h:BrushKeys.Orange}}"
|
||||
Content="免费试用"
|
||||
Foreground="{DynamicResource {x:Static h:BrushKeys.ForegroundWhite}}"
|
||||
Style="{DynamicResource {x:Static h:ButtonKeys.Transparent}}" />
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="3"
|
||||
Margin="-3,0"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="{Binding FileName}" />
|
||||
|
||||
<ListBox h:Cattach.ItemHeight="Auto" Style="{DynamicResource {x:Static h:ListBoxKeys.Single}}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type h:TestViewModel}">
|
||||
<Grid Height="50" Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--操作-->
|
||||
<StackPanel Grid.RowSpan="2"
|
||||
Grid.Column="4"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<Button h:Cattach.Icon="" />
|
||||
<Button h:Cattach.Icon="" h:Cattach.IconSize="13" />
|
||||
<Button h:Cattach.Icon="" h:Cattach.IconSize="15" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.RowSpan="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Icon}}"
|
||||
Text="" />
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="{Binding Value}" />
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="{Binding Value1}" />
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="{Binding Value2}" />
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="3"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="{Binding Value3}" />
|
||||
|
||||
<h:FProgressBar Grid.Column="3"
|
||||
Height="15"
|
||||
CornerRadius="2"
|
||||
Maximum="100"
|
||||
Value="{Binding Int1}">
|
||||
<h:FProgressBar.Triggers>
|
||||
<EventTrigger RoutedEvent="Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard Timeline.DesiredFrameRate="{x:Static h:StoryboardSetting.DesiredFrameRate}">
|
||||
<DoubleAnimation Storyboard.TargetProperty="Value"
|
||||
From="0"
|
||||
To="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Value}"
|
||||
Duration="00:00:30" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</h:FProgressBar.Triggers>
|
||||
</h:FProgressBar>
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="3"
|
||||
Margin="-3,0"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{DynamicResource {x:Static h:TextBlockKeys.Default}}"
|
||||
Text="{Binding Value3}" />
|
||||
|
||||
<StackPanel Grid.RowSpan="2"
|
||||
Grid.Column="4"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<Button h:Cattach.Icon="" />
|
||||
<Button h:Cattach.Icon="" h:Cattach.IconSize="13" />
|
||||
<Button h:Cattach.Icon="" h:Cattach.IconSize="15" />
|
||||
</StackPanel>
|
||||
|
||||
<Border Grid.RowSpan="11"
|
||||
Grid.ColumnSpan="11"
|
||||
Margin="0,0,0,-8"
|
||||
BorderBrush="{DynamicResource {x:Static h:BrushKeys.BorderBrushDefault}}"
|
||||
BorderThickness="0,0,0,1" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
<h:TestViewModel Int1="22"
|
||||
Value1="701KB/21.52MB"
|
||||
Value2="10:20:57"
|
||||
Value3="184KB/s"
|
||||
Value="FFmpeg直播推流拉流.rar" />
|
||||
<h:TestViewModel Int1="45"
|
||||
Value1="701KB/11.52MB"
|
||||
Value2="00:20:57"
|
||||
Value3="184KB/s"
|
||||
Value="WPF-ControlBase-master (1).zip" />
|
||||
<h:TestViewModel Int1="78"
|
||||
Value1="101KB/1.53MB"
|
||||
Value2="20:20:57"
|
||||
Value3="284KB/s"
|
||||
Value="Git-2.12.2.2-64-bit.exe" />
|
||||
<h:TestViewModel Int1="11"
|
||||
Value1="101KB/1.72MB"
|
||||
Value2="00:40:57"
|
||||
Value3="124KB/s"
|
||||
Value="代码段201911271359.rar" />
|
||||
<h:TestViewModel Int1="100"
|
||||
Value1="2.34MB/2.34MB"
|
||||
Value2=""
|
||||
Value3="已完成"
|
||||
Value="WPF-Chart-master.zip" />
|
||||
</ListBox>
|
||||
<Border Grid.RowSpan="11"
|
||||
Grid.ColumnSpan="11"
|
||||
Margin="0,0,0,-8"
|
||||
BorderBrush="{DynamicResource {x:Static h:BrushKeys.BorderBrushDefault}}"
|
||||
BorderThickness="0,0,0,1" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Windows.Controls;
|
||||
using Hopetry.Provider;
|
||||
|
||||
namespace HeBianGu.App.Disk
|
||||
namespace Hopetry.View.Send
|
||||
{
|
||||
/// <summary>
|
||||
/// DownControl.xaml 的交互逻辑
|
||||
|
|
@ -10,6 +11,9 @@ namespace HeBianGu.App.Disk
|
|||
public DownControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
Console.WriteLine("初始化DownView");
|
||||
/*DataContext = ViewModelLocator.DownViewModel;
|
||||
Console.WriteLine("DataContext 赋值后");*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
mc:Ignorable="d"
|
||||
xmlns:h="QQ:908293466"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
DataContext="{Binding Source={StaticResource S.DataSource.Locator}, Path=SyncViewModel}"
|
||||
DataContext="{Binding Source={StaticResource S.ViewModelLocator.Locator}, Path=SyncViewModel}"
|
||||
d:DesignHeight="500" d:DesignWidth="700">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using System.Windows.Controls;
|
||||
using HeBianGu.App.Disk;
|
||||
|
||||
namespace Hopetry.View.Sync;
|
||||
|
||||
|
|
@ -12,7 +9,4 @@ public partial class SyncControl : UserControl
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using HeBianGu.Base.WpfBase;
|
||||
using HeBianGu.Service.Mvc;
|
||||
using Hopetry.Models;
|
||||
using Hopetry.Provider;
|
||||
using Hopetry.Services;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Hopetry.ViewModel.Send;
|
||||
|
||||
[ViewModel("Down")]
|
||||
public class DownViewModel : MvcViewModelBase
|
||||
{
|
||||
private readonly MinioService _minioService;
|
||||
|
||||
|
||||
private ObservableCollection<DownItem> _downItems;
|
||||
|
||||
public ObservableCollection<DownItem> DownItems
|
||||
{
|
||||
get => _downItems;
|
||||
set
|
||||
{
|
||||
_downItems = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public DownViewModel(MinioService minioService)
|
||||
{
|
||||
_minioService = minioService;
|
||||
Console.WriteLine("初始化DownViewModel");
|
||||
var client = SqlSugarConfig.GetSqlSugarScope();
|
||||
var data = client.Ado.SqlQuery<DownItem>($"select * from f_down_item");
|
||||
DownItems = new ObservableCollection<DownItem>(data);
|
||||
Console.WriteLine(JsonConvert.SerializeObject(data));
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Loaded(string args)
|
||||
{
|
||||
}
|
||||
|
||||
[SugarTable("f_down_item")]
|
||||
public class DownItem
|
||||
{
|
||||
public DownItem()
|
||||
{
|
||||
}
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true,ColumnName = "id")]
|
||||
public long Id { get; set; }
|
||||
// 进度 已下载 多久下载完成 下载速度
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int ProgressInt { get; set; }
|
||||
/// <summary>
|
||||
/// object key
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "object_key")]
|
||||
public string ObjectKey { get; set; }
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "file_name")]
|
||||
public string FileName { get; set; }
|
||||
/// <summary>
|
||||
/// 文件类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "file_type")]
|
||||
public string FileType { get; set; }
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "file_size")]
|
||||
public long FileSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 速度 100kb/s
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public long Speed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 本地保存路径
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "file_path")]
|
||||
public string FilePath { get; set; }
|
||||
/// <summary>
|
||||
/// 文件的ETag
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "file_etag")]
|
||||
public string FileETag { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ using Hopetry.Services;
|
|||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using SystemSetting = FileUploader.Models.SystemSetting;
|
||||
|
||||
namespace HeBianGu.App.Disk.ViewModel.Sync;
|
||||
namespace Hopetry.ViewModel.Sync;
|
||||
|
||||
[ViewModel("Sync")]
|
||||
public class SyncViewModel : MvcViewModelBase
|
||||
|
|
|
|||
Loading…
Reference in New Issue