Compare commits

..

2 Commits

Author SHA1 Message Date
陈伟 532beae7b6 Merge remote-tracking branch 'origin/dev' into dev 2025-03-24 10:24:42 +08:00
陈伟 431b1cee45 设置文件夹选择 2025-03-24 10:24:36 +08:00
4 changed files with 86 additions and 34 deletions

View File

@ -54,11 +54,10 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.3" />
<PackageReference Include="Minio" Version="6.0.4" />
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="MSTest.TestFramework" Version="3.8.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.4.0" />
<PackageReference Include="Polly" Version="8.5.2" />
<PackageReference Include="WindowsAPICodePack" Version="8.0.6" />
<PackageReference Include="WPF-UI" Version="4.0.2" />
</ItemGroup>

View File

@ -4,12 +4,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:local="clr-namespace:HeBianGu.App.Disk.ViewModel.Sync"
xmlns:h="QQ:908293466"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
DataContext="{Binding Source={StaticResource S.DataSource.Locator}, Path=SyncViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
d:DesignHeight="500" d:DesignWidth="700">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource {x:Static h:GroupBoxKeys.Dynamic}}" TargetType="GroupBox">
<Setter Property="BorderBrush" Value="Transparent" />
@ -20,16 +19,25 @@
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="h:Cattach.GuideParentTitle" Value="设置中心" />
<Setter Property="h:Cattach.UseGuide" Value="True" />
<Setter Property="h:Cattach.GuideData" Value="你可以通过此操作完成指定功能" />
<Setter Property="h:Cattach.GuideTitle" Value="{Binding RelativeSource={RelativeSource Mode=Self},Path=Header}" />
<Setter Property="h:Cattach.GuideTitle"
Value="{Binding RelativeSource={RelativeSource Mode=Self},Path=Header}" />
</Style>
<Style TargetType="DockPanel">
<Setter Property="LastChildFill" Value="False" />
</Style>
<Style TargetType="TextBox" BasedOn="{StaticResource {x:Static h:TextBoxKeys.Accent}}">
<Setter Property="Width" Value="700" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="h:Cattach.TitleWidth" Value="120" />
<Setter Property="h:Cattach.TitleHorizontalAlignment" Value="Left" />
<Setter Property="h:Cattach.UseBackground" Value="True" />
<Setter Property="h:Cattach.BackgroundColumn" Value="1" />
</Style>
<Style BasedOn="{StaticResource {x:Static h:ComboBoxKeys.LabelSingle}}" TargetType="ComboBox">
<Setter Property="Width" Value="500" />
@ -49,22 +57,24 @@
<Setter Property="h:Cattach.BackgroundColumn" Value="1" />
</Style>
</Grid.Resources>
<h:ScrollIntoItems Margin="0 0 10 0" Background="{DynamicResource {x:Static h:BrushKeys.Dark0_3}}" NavigationSource="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Items}">
<h:ScrollIntoItems Margin="0 0 10 0" Background="{DynamicResource {x:Static h:BrushKeys.Dark0_3}}"
NavigationSource="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Items}">
<h:ScrollIntoItems.NavigationDataTemplate>
<DataTemplate>
<TextBlock Text="{Binding Header}" />
</DataTemplate>
</h:ScrollIntoItems.NavigationDataTemplate>
</h:ScrollIntoItems.NavigationDataTemplate>
<h:ScrollIntoItems.NavigationStyle>
<Style BasedOn="{StaticResource {x:Static h:ListBoxKeys.Dynamic}}" TargetType="ListBox">
<Setter Property="Width" Value="150" />
<Setter Property="SelectedIndex" Value="0"/>
<Setter Property="SelectedIndex" Value="0" />
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style BasedOn="{StaticResource {x:Static h:ListBoxItemKeys.Default}}" TargetType="ListBoxItem">
<Style BasedOn="{StaticResource {x:Static h:ListBoxItemKeys.Default}}"
TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent" />
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="h:Cattach.GuideParentTitle" Value="设置中心" />
<Setter Property="h:Cattach.UseGuide" Value="True" />
<Setter Property="h:Cattach.GuideUseClick" Value="True" />
@ -76,13 +86,19 @@
<Setter Property="Padding" Value="10,0" />
</Style>
</h:ScrollIntoItems.NavigationStyle>
<GroupBox Margin="0" Header="同步设置">
<StackPanel Margin="10,6">
<h:Row>
<ComboBox h:Cattach.Title="下载目录" SelectedIndex="0" SelectedValue="{Binding SyncDir}">
<system:String>D:\迅雷云盘</system:String>
</ComboBox>
<StackPanel Orientation="Horizontal">
<TextBox h:Cattach.Title="下载目录:" Text="{Binding SyncDir, Mode=TwoWay}"
VerticalAlignment="Center" Width="250"
Grid.Column="0" />
<Button h:Cattach.Icon="&#xeadb;"
VerticalAlignment="Center"
Command="{Binding OpenDirCommand}" Grid.Column="1" />
</StackPanel>
</h:Row>
<h:Row>
<ComboBox Width="250" h:Cattach.Title="同时下载任务数" SelectedIndex="0">

View File

@ -1,6 +1,8 @@
using System.Windows;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using Hopetry.Provider;
using Microsoft.Win32;
using Microsoft.WindowsAPICodePack.Dialogs;
namespace Hopetry.View.Sync;
@ -11,18 +13,6 @@ public partial class SyncControl : UserControl
InitializeComponent();
}
public event RoutedEventHandler OKClicked;
public event RoutedEventHandler CancelClicked;
private void btnOK_Click(object sender, RoutedEventArgs e)
{
OKClicked?.Invoke(this, e);
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
CancelClicked?.Invoke(this, e);
}
}

View File

@ -1,13 +1,15 @@
using System.Windows;
using System.Windows.Threading;
using System.Windows.Forms;
using System.Windows.Input;
using HeBianGu.Service.Mvc;
using Hopetry.Provider;
using Microsoft.WindowsAPICodePack.Dialogs;
namespace HeBianGu.App.Disk.ViewModel.Sync;
[ViewModel("Sync")]
public class SyncViewModel : MvcViewModelBase
{
public ICommand OpenDirCommand { get; set; }
protected override void Init()
{
/*LinkActions.Add(new LinkAction() { Action = "Space", Controller = "Loyout", DisplayName = "会话", Logo = "\xe613" });
@ -18,9 +20,15 @@ public class SyncViewModel : MvcViewModelBase
}));*/
}
public SyncViewModel()
{
OpenDirCommand = new RelayCommand(async () => await ButtonBase_OnClick());
}
protected override void Loaded(string args)
{
}
public string _syncDir;
public string SyncDir
@ -32,5 +40,44 @@ public class SyncViewModel : MvcViewModelBase
RaisePropertyChanged();
}
}
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;
// 处理选中的文件夹路径
}
}
}