设置文件夹选择
parent
3167897890
commit
431b1cee45
|
|
@ -54,11 +54,10 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.3" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.3" />
|
||||||
<PackageReference Include="Minio" Version="6.0.4" />
|
<PackageReference Include="Minio" Version="6.0.4" />
|
||||||
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
|
<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="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="NLog" Version="5.4.0" />
|
<PackageReference Include="NLog" Version="5.4.0" />
|
||||||
<PackageReference Include="Polly" Version="8.5.2" />
|
<PackageReference Include="Polly" Version="8.5.2" />
|
||||||
|
<PackageReference Include="WindowsAPICodePack" Version="8.0.6" />
|
||||||
<PackageReference Include="WPF-UI" Version="4.0.2" />
|
<PackageReference Include="WPF-UI" Version="4.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,11 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
xmlns:local="clr-namespace:HeBianGu.App.Disk.ViewModel.Sync"
|
|
||||||
xmlns:h="QQ:908293466"
|
xmlns:h="QQ:908293466"
|
||||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||||
DataContext="{Binding Source={StaticResource S.DataSource.Locator}, Path=SyncViewModel}"
|
DataContext="{Binding Source={StaticResource S.DataSource.Locator}, Path=SyncViewModel}"
|
||||||
d:DesignHeight="300" d:DesignWidth="300">
|
d:DesignHeight="500" d:DesignWidth="700">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Resources>
|
<Grid.Resources>
|
||||||
<Style BasedOn="{StaticResource {x:Static h:GroupBoxKeys.Dynamic}}" TargetType="GroupBox">
|
<Style BasedOn="{StaticResource {x:Static h:GroupBoxKeys.Dynamic}}" TargetType="GroupBox">
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
|
@ -24,12 +23,21 @@
|
||||||
<Setter Property="h:Cattach.GuideParentTitle" Value="设置中心" />
|
<Setter Property="h:Cattach.GuideParentTitle" Value="设置中心" />
|
||||||
<Setter Property="h:Cattach.UseGuide" Value="True" />
|
<Setter Property="h:Cattach.UseGuide" Value="True" />
|
||||||
<Setter Property="h:Cattach.GuideData" Value="你可以通过此操作完成指定功能" />
|
<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>
|
||||||
|
|
||||||
<Style TargetType="DockPanel">
|
<Style TargetType="DockPanel">
|
||||||
<Setter Property="LastChildFill" Value="False" />
|
<Setter Property="LastChildFill" Value="False" />
|
||||||
</Style>
|
</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">
|
<Style BasedOn="{StaticResource {x:Static h:ComboBoxKeys.LabelSingle}}" TargetType="ComboBox">
|
||||||
<Setter Property="Width" Value="500" />
|
<Setter Property="Width" Value="500" />
|
||||||
|
|
@ -49,7 +57,8 @@
|
||||||
<Setter Property="h:Cattach.BackgroundColumn" Value="1" />
|
<Setter Property="h:Cattach.BackgroundColumn" Value="1" />
|
||||||
</Style>
|
</Style>
|
||||||
</Grid.Resources>
|
</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>
|
<h:ScrollIntoItems.NavigationDataTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Header}" />
|
<TextBlock Text="{Binding Header}" />
|
||||||
|
|
@ -59,12 +68,13 @@
|
||||||
<h:ScrollIntoItems.NavigationStyle>
|
<h:ScrollIntoItems.NavigationStyle>
|
||||||
<Style BasedOn="{StaticResource {x:Static h:ListBoxKeys.Dynamic}}" TargetType="ListBox">
|
<Style BasedOn="{StaticResource {x:Static h:ListBoxKeys.Dynamic}}" TargetType="ListBox">
|
||||||
<Setter Property="Width" Value="150" />
|
<Setter Property="Width" Value="150" />
|
||||||
<Setter Property="SelectedIndex" Value="0"/>
|
<Setter Property="SelectedIndex" Value="0" />
|
||||||
<Setter Property="ItemContainerStyle">
|
<Setter Property="ItemContainerStyle">
|
||||||
<Setter.Value>
|
<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="Background" Value="Transparent" />
|
||||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
<Setter Property="h:Cattach.GuideParentTitle" Value="设置中心" />
|
<Setter Property="h:Cattach.GuideParentTitle" Value="设置中心" />
|
||||||
<Setter Property="h:Cattach.UseGuide" Value="True" />
|
<Setter Property="h:Cattach.UseGuide" Value="True" />
|
||||||
<Setter Property="h:Cattach.GuideUseClick" Value="True" />
|
<Setter Property="h:Cattach.GuideUseClick" Value="True" />
|
||||||
|
|
@ -80,9 +90,15 @@
|
||||||
<GroupBox Margin="0" Header="同步设置">
|
<GroupBox Margin="0" Header="同步设置">
|
||||||
<StackPanel Margin="10,6">
|
<StackPanel Margin="10,6">
|
||||||
<h:Row>
|
<h:Row>
|
||||||
<ComboBox h:Cattach.Title="下载目录" SelectedIndex="0" SelectedValue="{Binding SyncDir}">
|
<StackPanel Orientation="Horizontal">
|
||||||
<system:String>D:\迅雷云盘</system:String>
|
<TextBox h:Cattach.Title="下载目录:" Text="{Binding SyncDir, Mode=TwoWay}"
|
||||||
</ComboBox>
|
VerticalAlignment="Center" Width="250"
|
||||||
|
Grid.Column="0" />
|
||||||
|
<Button h:Cattach.Icon=""
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Command="{Binding OpenDirCommand}" Grid.Column="1" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
</h:Row>
|
</h:Row>
|
||||||
<h:Row>
|
<h:Row>
|
||||||
<ComboBox Width="250" h:Cattach.Title="同时下载任务数" SelectedIndex="0">
|
<ComboBox Width="250" h:Cattach.Title="同时下载任务数" SelectedIndex="0">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
using System.Windows;
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Hopetry.Provider;
|
using Microsoft.Win32;
|
||||||
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||||
|
|
||||||
namespace Hopetry.View.Sync;
|
namespace Hopetry.View.Sync;
|
||||||
|
|
||||||
|
|
@ -11,18 +13,6 @@ public partial class SyncControl : UserControl
|
||||||
InitializeComponent();
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
using System.Windows;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Input;
|
||||||
using HeBianGu.Service.Mvc;
|
using HeBianGu.Service.Mvc;
|
||||||
using Hopetry.Provider;
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||||
|
|
||||||
namespace HeBianGu.App.Disk.ViewModel.Sync;
|
namespace HeBianGu.App.Disk.ViewModel.Sync;
|
||||||
|
|
||||||
[ViewModel("Sync")]
|
[ViewModel("Sync")]
|
||||||
public class SyncViewModel : MvcViewModelBase
|
public class SyncViewModel : MvcViewModelBase
|
||||||
{
|
{
|
||||||
|
public ICommand OpenDirCommand { get; set; }
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
/*LinkActions.Add(new LinkAction() { Action = "Space", Controller = "Loyout", DisplayName = "会话", Logo = "\xe613" });
|
/*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)
|
protected override void Loaded(string args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public string _syncDir;
|
public string _syncDir;
|
||||||
|
|
||||||
public string SyncDir
|
public string SyncDir
|
||||||
|
|
@ -33,4 +41,43 @@ public class SyncViewModel : MvcViewModelBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
// 处理选中的文件夹路径
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue