文件命名格式中,时间格式可设置;机器码去掉硬盘信息;修复多线程操作sqlite的异常问题;修复视频标题和分P标题相同时找不到下载文件的问题;150%缩放下的窗口不超出屏幕;

pull/278/head
leiurayer 3 years ago
parent 4fd747d382
commit 0e2058548f

@ -42,8 +42,8 @@ namespace DownKyi.Core.Aria2cNet.Client.Entity
//[JsonProperty("use-head")]
//public string UseHead { get; set; }
//[JsonProperty("user-agent")]
//public string UserAgent { get; set; }
[JsonProperty("user-agent")]
public string UserAgent { get; set; }
public override string ToString()
{

@ -16,5 +16,6 @@ namespace DownKyi.Core.Settings.Models
public List<string> HistoryVideoRootPaths { get; set; } // 历史视频保存路径
public AllowStatus IsUseSaveVideoRootPath { get; set; } // 是否使用默认视频保存路径
public List<FileNamePart> FileNameParts { get; set; } // 文件命名格式
public string FileNamePartTimeFormat { get; set; } // 文件命名中的时间格式
}
}

@ -44,6 +44,9 @@ namespace DownKyi.Core.Settings
FileNamePart.VIDEO_CODEC,
};
// 文件命名中的时间格式
private readonly string fileNamePartTimeFormat = "yyyy-MM-dd";
/// <summary>
/// 获取优先下载的视频编码
/// </summary>
@ -260,5 +263,32 @@ namespace DownKyi.Core.Settings
return SetSettings();
}
/// <summary>
/// 获取文件命名中的时间格式
/// </summary>
/// <returns></returns>
public string GetFileNamePartTimeFormat()
{
appSettings = GetSettings();
if (appSettings.Video.FileNamePartTimeFormat == null || appSettings.Video.FileNamePartTimeFormat == string.Empty)
{
// 第一次获取,先设置默认值
SetFileNamePartTimeFormat(fileNamePartTimeFormat);
return fileNamePartTimeFormat;
}
return appSettings.Video.FileNamePartTimeFormat;
}
/// <summary>
/// 设置文件命名中的时间格式
/// </summary>
/// <param name="fileNamePartTimeFormat"></param>
/// <returns></returns>
public bool SetFileNamePartTimeFormat(string fileNamePartTimeFormat)
{
appSettings.Video.FileNamePartTimeFormat = fileNamePartTimeFormat;
return SetSettings();
}
}
}

@ -1,20 +1,37 @@
using System;
using DownKyi.Core.Logging;
using System;
using System.Collections.Generic;
using System.Data.SQLite;
namespace DownKyi.Core.Storage.Database
{
public class DbHelper
{
private readonly string connStr;
private readonly SQLiteConnection conn;
private static readonly Dictionary<string, SQLiteConnection> database = new Dictionary<string, SQLiteConnection>();
/// <summary>
/// 创建一个数据库
/// </summary>
/// <param name="dbPath"></param>
public DbHelper(string dbPath)
{
string connStr = $"Data Source={dbPath};Version=3;";
connStr = $"Data Source={dbPath};Version=3;";
if (database.ContainsKey(connStr))
{
conn = database[connStr];
if (conn != null)
{
return;
}
}
conn = new SQLiteConnection(connStr);
database.Add(connStr, conn);
}
/// <summary>
@ -25,8 +42,20 @@ namespace DownKyi.Core.Storage.Database
public DbHelper(string dbPath, string secretKey)
{
string connStr = $"Data Source={dbPath};Version=3;";
if (database.ContainsKey(connStr))
{
conn = database[connStr];
if (conn != null)
{
return;
}
}
conn = new SQLiteConnection(connStr);
conn.SetPassword(secretKey);
database.Add(connStr, conn);
}
/// <summary>
@ -57,6 +86,8 @@ namespace DownKyi.Core.Storage.Database
if (IsOpen())
{
conn.Close();
database.Remove(connStr);
}
}
@ -66,21 +97,29 @@ namespace DownKyi.Core.Storage.Database
/// <param name="sql"></param>
public void ExecuteNonQuery(string sql, Action<SQLiteParameterCollection> action = null)
{
lock (conn)
try
{
Open();
using (var tr = conn.BeginTransaction())
lock (conn)
{
using (var command = conn.CreateCommand())
Open();
using (var tr = conn.BeginTransaction())
{
command.CommandText = sql;
// 添加参数
action?.Invoke(command.Parameters);
command.ExecuteNonQuery();
using (var command = conn.CreateCommand())
{
command.CommandText = sql;
// 添加参数
action?.Invoke(command.Parameters);
command.ExecuteNonQuery();
}
tr.Commit();
}
tr.Commit();
}
}
catch (SQLiteException e)
{
Utils.Debugging.Console.PrintLine("DbHelper ExecuteNonQuery()发生异常: {0}", e);
LogManager.Error("DbHelper ExecuteNonQuery()", e);
}
}
/// <summary>
@ -90,16 +129,24 @@ namespace DownKyi.Core.Storage.Database
/// <param name="action"></param>
public void ExecuteQuery(string sql, Action<SQLiteDataReader> action)
{
lock (conn)
try
{
Open();
using (var command = conn.CreateCommand())
lock (conn)
{
command.CommandText = sql;
var reader = command.ExecuteReader();
action(reader);
Open();
using (var command = conn.CreateCommand())
{
command.CommandText = sql;
var reader = command.ExecuteReader();
action(reader);
}
}
}
catch (SQLiteException e)
{
Utils.Debugging.Console.PrintLine("DbHelper ExecuteQuery()发生异常: {0}", e);
LogManager.Error("DbHelper ExecuteQuery()", e);
}
}
}

@ -20,8 +20,8 @@ namespace DownKyi.Core.Utils
string machineCodeString = "PC." +
machineCode.GetMainBordId() + "." +
machineCode.GetCpuInfo() + "." +
machineCode.GetDiskID();// + "." +
machineCode.GetCpuInfo();// + "." +
//machineCode.GetDiskID();// + "." +
//machineCode.GetMoAddress();
return machineCodeString.Replace(" ", "");
}

@ -100,6 +100,7 @@
<Compile Include="Services\Download\AddToDownloadService.cs" />
<Compile Include="Services\Download\DownloadStorageService.cs" />
<Compile Include="Services\SearchService.cs" />
<Compile Include="Utils\WindowAdaptation.cs" />
<Compile Include="ViewModels\PageViewModels\BangumiFollowMedia.cs" />
<Compile Include="ViewModels\PageViewModels\Favorites.cs" />
<Compile Include="ViewModels\PageViewModels\FavoritesMedia.cs" />

@ -219,6 +219,7 @@
<system:String x:Key="DisplayUpMid">UP主ID</system:String>
<system:String x:Key="DisplayUpName">UP主昵称</system:String>
<system:String x:Key="Reset">恢复默认</system:String>
<system:String x:Key="FileNameTimeFormat">时间格式:</system:String>
<system:String x:Key="SettingDanmaku">弹幕</system:String>
<system:String x:Key="FilterType">按类型屏蔽</system:String>

@ -3,6 +3,7 @@ using DownKyi.Core.BiliApi.Bangumi.Models;
using DownKyi.Core.BiliApi.BiliUtils;
using DownKyi.Core.BiliApi.VideoStream;
using DownKyi.Core.BiliApi.VideoStream.Models;
using DownKyi.Core.Settings;
using DownKyi.Core.Storage;
using DownKyi.Core.Utils;
using DownKyi.Utils;
@ -120,10 +121,12 @@ namespace DownKyi.Services
};
}
// 文件命名中的时间格式
string timeFormat = SettingsManager.GetInstance().GetFileNamePartTimeFormat();
// 视频发布时间
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
DateTime dateTime = startTime.AddSeconds(episode.PubTime);
page.PublishTime = dateTime.ToString("yyyy-MM-dd");
page.PublishTime = dateTime.ToString(timeFormat);
pages.Add(page);
}
@ -194,10 +197,12 @@ namespace DownKyi.Services
};
}
// 文件命名中的时间格式
string timeFormat = SettingsManager.GetInstance().GetFileNamePartTimeFormat();
// 视频发布时间
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
DateTime dateTime = startTime.AddSeconds(episode.PubTime);
page.PublishTime = dateTime.ToString("yyyy-MM-dd");
page.PublishTime = dateTime.ToString(timeFormat);
pages.Add(page);
}

@ -3,6 +3,7 @@ using DownKyi.Core.BiliApi.Cheese;
using DownKyi.Core.BiliApi.Cheese.Models;
using DownKyi.Core.BiliApi.VideoStream;
using DownKyi.Core.BiliApi.VideoStream.Models;
using DownKyi.Core.Settings;
using DownKyi.Core.Storage;
using DownKyi.Core.Utils;
using DownKyi.Utils;
@ -88,10 +89,12 @@ namespace DownKyi.Services
};
}
// 文件命名中的时间格式
string timeFormat = SettingsManager.GetInstance().GetFileNamePartTimeFormat();
// 视频发布时间
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
DateTime dateTime = startTime.AddSeconds(episode.ReleaseDate);
page.PublishTime = dateTime.ToString("yyyy-MM-dd");
page.PublishTime = dateTime.ToString(timeFormat);
pages.Add(page);
}

@ -302,7 +302,7 @@ namespace DownKyi.Services.Download
.SetBvid(page.Bvid)
.SetCid(page.Cid)
.SetUpMid(page.Owner.Mid)
.SetUpName(page.Owner.Name);
.SetUpName(Format.FormatFileName(page.Owner.Name));
string filePath = Path.Combine(directory, fileName.RelativePath());
// 视频类别

@ -138,24 +138,31 @@ namespace DownKyi.Services.Download
// 路径
string[] temp = downloading.DownloadBase.FilePath.Split('/');
string path = downloading.DownloadBase.FilePath.Replace(temp[temp.Length - 1], "");
//string path = downloading.DownloadBase.FilePath.Replace(temp[temp.Length - 1], "");
string path = downloading.DownloadBase.FilePath.TrimEnd(temp[temp.Length - 1].ToCharArray());
// 下载文件名
string fileName = Guid.NewGuid().ToString("N");
string key = $"{downloadVideo.Id}_{downloadVideo.Codecs}";
// 老版本数据库没有这一项会变成null
if (downloading.Downloading.DownloadedFiles == null)
{
downloading.Downloading.DownloadedFiles = new List<string>();
}
if (downloading.Downloading.DownloadFiles.ContainsKey(key))
{
// 如果存在,表示下载过,
// 则继续使用上次下载的文件名
fileName = downloading.Downloading.DownloadFiles[key];
// 还要检查一下文件有没有被人删掉,删掉的话重新下载
// 如果下载视频之后音频文件被人删了。此时gid还是视频的会下错文件
if (downloading.Downloading.DownloadedFiles.Contains(key) && File.Exists(Path.Combine(path, fileName)))
{
return Path.Combine(path, fileName);
}
}
else
{
@ -575,7 +582,9 @@ namespace DownKyi.Services.Download
{
// 路径
string[] temp = downloading.DownloadBase.FilePath.Split('/');
string path = downloading.DownloadBase.FilePath.Replace(temp[temp.Length - 1], "");
//string path = downloading.DownloadBase.FilePath.Replace(temp[temp.Length - 1], "");
string path = downloading.DownloadBase.FilePath.TrimEnd(temp[temp.Length - 1].ToCharArray());
// 路径不存在则创建
if (!Directory.Exists(path))
{
@ -973,10 +982,10 @@ namespace DownKyi.Services.Download
{
//HttpProxy = $"http://{Settings.GetAriaHttpProxy()}:{Settings.GetAriaHttpProxyListenPort()}",
Dir = path,
Out = localFileName
//Header = $"cookie: {Login.GetLoginInfoCookiesString()}\nreferer: https://www.bilibili.com",
Out = localFileName,
//Header = $"cookie: {LoginHelper.GetLoginInfoCookiesString()}\nreferer: https://www.bilibili.com",
//UseHead = "true",
//UserAgent = Utils.GetUserAgent()
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36",
};
// 如果设置了代理则增加HttpProxy

@ -7,6 +7,16 @@ namespace DownKyi.Services.Download
{
public class DownloadStorageService
{
~DownloadStorageService()
{
DownloadingDb downloadingDb = new DownloadingDb();
downloadingDb.Close();
DownloadedDb downloadedDb = new DownloadedDb();
downloadedDb.Close();
DownloadBaseDb downloadBaseDb = new DownloadBaseDb();
downloadBaseDb.Close();
}
#region 下载中数据
/// <summary>
@ -25,7 +35,7 @@ namespace DownKyi.Services.Download
{
downloadingDb.Insert(downloadingItem.DownloadBase.Uuid, downloadingItem.Downloading);
}
downloadingDb.Close();
//downloadingDb.Close();
}
/// <summary>
@ -40,7 +50,7 @@ namespace DownKyi.Services.Download
DownloadingDb downloadingDb = new DownloadingDb();
downloadingDb.Delete(downloadingItem.DownloadBase.Uuid);
downloadingDb.Close();
//downloadingDb.Close();
}
/// <summary>
@ -52,7 +62,7 @@ namespace DownKyi.Services.Download
// 从数据库获取数据
DownloadingDb downloadingDb = new DownloadingDb();
Dictionary<string, object> dic = downloadingDb.QueryAll();
downloadingDb.Close();
//downloadingDb.Close();
// 遍历
List<DownloadingItem> list = new List<DownloadingItem>();
@ -85,7 +95,7 @@ namespace DownKyi.Services.Download
DownloadingDb downloadingDb = new DownloadingDb();
downloadingDb.Update(downloadingItem.DownloadBase.Uuid, downloadingItem.Downloading);
downloadingDb.Close();
//downloadingDb.Close();
}
#endregion
@ -108,7 +118,7 @@ namespace DownKyi.Services.Download
{
downloadedDb.Insert(downloadedItem.DownloadBase.Uuid, downloadedItem.Downloaded);
}
downloadedDb.Close();
//downloadedDb.Close();
}
/// <summary>
@ -123,7 +133,7 @@ namespace DownKyi.Services.Download
DownloadedDb downloadedDb = new DownloadedDb();
downloadedDb.Delete(downloadedItem.DownloadBase.Uuid);
downloadedDb.Close();
//downloadedDb.Close();
}
/// <summary>
@ -135,7 +145,7 @@ namespace DownKyi.Services.Download
// 从数据库获取数据
DownloadedDb downloadedDb = new DownloadedDb();
Dictionary<string, object> dic = downloadedDb.QueryAll();
downloadedDb.Close();
//downloadedDb.Close();
// 遍历
List<DownloadedItem> list = new List<DownloadedItem>();
@ -168,7 +178,7 @@ namespace DownKyi.Services.Download
DownloadedDb downloadedDb = new DownloadedDb();
downloadedDb.Update(downloadedItem.DownloadBase.Uuid, downloadedItem.Downloaded);
downloadedDb.Close();
//downloadedDb.Close();
}
#endregion
@ -189,7 +199,7 @@ namespace DownKyi.Services.Download
{
downloadBaseDb.Insert(downloadBase.Uuid, downloadBase);
}
downloadBaseDb.Close();
//downloadBaseDb.Close();
}
/// <summary>
@ -200,7 +210,7 @@ namespace DownKyi.Services.Download
{
DownloadBaseDb downloadBaseDb = new DownloadBaseDb();
downloadBaseDb.Delete(uuid);
downloadBaseDb.Close();
//downloadBaseDb.Close();
}
/// <summary>
@ -211,7 +221,7 @@ namespace DownKyi.Services.Download
{
DownloadBaseDb downloadBaseDb = new DownloadBaseDb();
object obj = downloadBaseDb.QueryById(uuid);
downloadBaseDb.Close();
//downloadBaseDb.Close();
return obj is DownloadBase downloadBase ? downloadBase : null;
}
@ -226,7 +236,7 @@ namespace DownKyi.Services.Download
DownloadBaseDb downloadBaseDb = new DownloadBaseDb();
downloadBaseDb.Update(downloadBase.Uuid, downloadBase);
downloadBaseDb.Close();
//downloadBaseDb.Close();
}
#endregion

@ -2,6 +2,7 @@
using DownKyi.Core.BiliApi.Video;
using DownKyi.Core.BiliApi.Video.Models;
using DownKyi.Core.BiliApi.VideoStream;
using DownKyi.Core.Settings;
using DownKyi.Core.Storage;
using DownKyi.Core.Utils;
using DownKyi.ViewModels.PageViewModels;
@ -96,10 +97,12 @@ namespace DownKyi.Services
};
}
// 文件命名中的时间格式
string timeFormat = SettingsManager.GetInstance().GetFileNamePartTimeFormat();
// 视频发布时间
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
DateTime dateTime = startTime.AddSeconds(videoView.Pubdate);
videoPage.PublishTime = dateTime.ToString("yyyy-MM-dd");
videoPage.PublishTime = dateTime.ToString(timeFormat);
videoPages.Add(videoPage);
}
@ -151,10 +154,12 @@ namespace DownKyi.Services
};
}
// 文件命名中的时间格式
string timeFormat = SettingsManager.GetInstance().GetFileNamePartTimeFormat();
// 视频发布时间
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
DateTime dateTime = startTime.AddSeconds(videoView.Pubdate);
page.PublishTime = dateTime.ToString("yyyy-MM-dd");
page.PublishTime = dateTime.ToString(timeFormat);
// 这里的发布时间有问题,
// 如果是合集,也会执行这里,
// 但是发布时间是入口视频的,不是所有视频的

@ -0,0 +1,146 @@
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interop;
namespace DownKyi.Utils
{
/// <summary>
/// 为窗口<see cref="Window"/>添加附加属性的辅助类
///
/// https://www.cnblogs.com/kybs0/p/9834023.html
/// </summary>
public class WindowAdaptation
{
#region 窗口宽度比例
/// <summary>
/// 窗口宽度比例 单位:小数(0 - 1.0]
/// <para>窗口实际宽度=使用屏幕可显示区域(屏幕高度-任务栏高度)* 窗口宽度比例</para>
/// </summary>
public static readonly DependencyProperty WidthByScreenRatioProperty = DependencyProperty.RegisterAttached(
"WidthByScreenRatio", typeof(double), typeof(WindowAdaptation), new PropertyMetadata(1.0, OnWidthByScreenRatioPropertyChanged));
private static void OnWidthByScreenRatioPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is Window window && e.NewValue is double widthByScreenRatio)
{
if (widthByScreenRatio <= 0 || widthByScreenRatio > 1)
{
throw new ArgumentException($"屏幕比例不支持{widthByScreenRatio}");
}
var screenDisplayArea = GetScreenSize(window);
var screenRatioWidth = screenDisplayArea.Width * widthByScreenRatio;
//if (!double.IsNaN(window.Width) && screenDisplayArea.Width > window.Width)
//{
// window.Width = window.Width;
//}
//else
//{
// window.Width = screenRatioWidth;
//}
if (!double.IsNaN(window.Width) && screenRatioWidth > window.Width)
{
window.Width = window.Width;
}
else if (!double.IsNaN(window.MinWidth) && screenRatioWidth < window.MinWidth)
{
window.Width = screenDisplayArea.Width;
}
else
{
window.Width = screenRatioWidth;
}
}
}
public static void SetWidthByScreenRatio(DependencyObject element, double value)
{
element.SetValue(WidthByScreenRatioProperty, value);
}
public static double GetWidthByScreenRatio(DependencyObject element)
{
return (double)element.GetValue(WidthByScreenRatioProperty);
}
#endregion
#region 窗口高度比例
/// <summary>
/// 窗口宽度比例 单位:小数(0 - 1.0]
/// <para>窗口实际宽度=使用屏幕可显示区域(屏幕高度-任务栏高度)* 窗口宽度比例</para>
/// </summary>
public static readonly DependencyProperty HeightByScreenRatioProperty = DependencyProperty.RegisterAttached(
"HeightByScreenRatio", typeof(double), typeof(WindowAdaptation), new PropertyMetadata(1.0, OnHeightByScreenRatioPropertyChanged));
private static void OnHeightByScreenRatioPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is Window window && e.NewValue is double heightByScreenRatio)
{
if (heightByScreenRatio <= 0 || heightByScreenRatio > 1)
{
throw new ArgumentException($"屏幕比例不支持{heightByScreenRatio}");
}
var screenDisplayArea = GetScreenSize(window);
var screenRatioHeight = screenDisplayArea.Height * heightByScreenRatio;
if (!double.IsNaN(window.Height) && screenDisplayArea.Height > window.Height)
{
window.Height = window.Height;
}
else
{
window.Height = screenRatioHeight;
}
//if (!double.IsNaN(window.Height) && screenRatioHeight > window.Height)
//{
// window.Height = window.Height;
//}
//else if (!double.IsNaN(window.MinHeight) && screenRatioHeight < window.MinHeight)
//{
// window.Height = screenDisplayArea.Height;
//}
//else
//{
// window.Height = screenRatioHeight;
//}
}
}
public static void SetHeightByScreenRatio(DependencyObject element, double value)
{
element.SetValue(HeightByScreenRatioProperty, value);
}
public static double GetHeightByScreenRatio(DependencyObject element)
{
return (double)element.GetValue(HeightByScreenRatioProperty);
}
#endregion
const int DpiPercent = 96;
private static dynamic GetScreenSize(Window window)
{
var intPtr = new WindowInteropHelper(window).Handle;//获取当前窗口的句柄
var screen = Screen.FromHandle(intPtr);//获取当前屏幕
using (Graphics currentGraphics = Graphics.FromHwnd(intPtr))
{
//分别获取当前屏幕X/Y方向的DPI
double dpiXRatio = currentGraphics.DpiX / DpiPercent;
double dpiYRatio = currentGraphics.DpiY / DpiPercent;
var width = screen.WorkingArea.Width / dpiXRatio;
var height = screen.WorkingArea.Height / dpiYRatio;
return new { Width = width, Height = height };
}
}
}
}

@ -105,8 +105,21 @@ namespace DownKyi.ViewModels.Settings
set => SetProperty(ref selectedOptionalField, value);
}
#endregion
private List<string> fileNamePartTimeFormatList;
public List<string> FileNamePartTimeFormatList
{
get => fileNamePartTimeFormatList;
set => SetProperty(ref fileNamePartTimeFormatList, value);
}
private string selectedFileNamePartTimeFormat;
public string SelectedFileNamePartTimeFormat
{
get => selectedFileNamePartTimeFormat;
set => SetProperty(ref selectedFileNamePartTimeFormat, value);
}
#endregion
public ViewVideoViewModel(IEventAggregator eventAggregator) : base(eventAggregator)
{
@ -138,6 +151,13 @@ namespace DownKyi.ViewModels.Settings
SelectedOptionalField = -1;
// 文件命名中的时间格式
FileNamePartTimeFormatList = new List<string>
{
"yyyy-MM-dd",
"yyyy.MM.dd",
};
#endregion
}
@ -184,6 +204,9 @@ namespace DownKyi.ViewModels.Settings
SelectedFileName.Add(new DisplayFileNamePart { Id = item, Title = display });
}
// 文件命名中的时间格式
SelectedFileNamePartTimeFormat = SettingsManager.GetInstance().GetFileNamePartTimeFormat();
isOnNavigatedTo = false;
}
@ -313,6 +336,8 @@ namespace DownKyi.ViewModels.Settings
isSucceed = SettingsManager.GetInstance().SetFileNameParts(fileName);
PublishTip(isSucceed);
SelectedOptionalField = -1;
}
// 可选文件名字段点击事件
@ -363,8 +388,25 @@ namespace DownKyi.ViewModels.Settings
string display = DisplayFileNamePart(item);
SelectedFileName.Add(new DisplayFileNamePart { Id = item, Title = display });
}
SelectedOptionalField = -1;
}
// 文件命名中的时间格式事件
private DelegateCommand<object> fileNamePartTimeFormatCommand;
public DelegateCommand<object> FileNamePartTimeFormatCommand => fileNamePartTimeFormatCommand ?? (fileNamePartTimeFormatCommand = new DelegateCommand<object>(ExecuteFileNamePartTimeFormatCommand));
/// <summary>
/// 文件命名中的时间格式事件
/// </summary>
/// <param name="parameter"></param>
private void ExecuteFileNamePartTimeFormatCommand(object parameter)
{
if (!(parameter is string timeFormat)) { return; }
bool isSucceed = SettingsManager.GetInstance().SetFileNamePartTimeFormat(timeFormat);
PublishTip(isSucceed);
}
#endregion

@ -3,12 +3,15 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:DownKyi.Utils"
xmlns:prism="http://prismlibrary.com/"
Title="{DynamicResource AppName}"
Width="1100"
Height="750"
MinWidth="1100"
MinHeight="750"
MinWidth="800"
MinHeight="550"
local:WindowAdaptation.HeightByScreenRatio="0.75"
local:WindowAdaptation.WidthByScreenRatio="0.8"
prism:ViewModelLocator.AutoWireViewModel="True"
ResizeMode="CanResize"
WindowStartupLocation="CenterScreen"
@ -200,4 +203,5 @@
</Border>
</Grid>
</Border>
</Window>

@ -403,6 +403,7 @@
TextWrapping="WrapWithOverflow" />
</StackPanel>
<StackPanel Margin="10" />
</StackPanel>
</ScrollViewer>
</UserControl>

@ -105,6 +105,7 @@
</ComboBox>
</StackPanel>
<StackPanel Margin="10" />
</StackPanel>
</ScrollViewer>
</UserControl>

@ -188,6 +188,7 @@
ToolTip="{DynamicResource LayoutAlgorithmAsyncTip}" />
</StackPanel>
<StackPanel Margin="10" />
</StackPanel>
</ScrollViewer>
</UserControl>

@ -256,6 +256,7 @@
</ComboBox>
</StackPanel>
<StackPanel Margin="10" />
</StackPanel>
</ScrollViewer>
</UserControl>

@ -178,20 +178,20 @@
Grid.Column="0"
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource FileName}" />
Text="{DynamicResource OptionalFields}" />
<ListBox
x:Name="nameSelectedFileName"
Name="nameOptionalFields"
Grid.Row="0"
Grid.Column="1"
MinHeight="30"
Margin="0,0,0,20"
ItemContainerStyle="{StaticResource TagItem2Style}"
ItemsSource="{Binding SelectedFileName, Mode=TwoWay}"
ItemsSource="{Binding OptionalFields, Mode=TwoWay}"
SelectedIndex="{Binding SelectedOptionalField}"
SelectionMode="Single"
Style="{StaticResource Tag2Style}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectedFileNameCommand}" CommandParameter="{Binding ElementName=nameSelectedFileName, Path=SelectedItem}" />
<i:InvokeCommandAction Command="{Binding OptionalFieldsCommand}" CommandParameter="{Binding ElementName=nameOptionalFields, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
@ -201,23 +201,49 @@
Grid.Column="0"
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource OptionalFields}" />
Text="{DynamicResource FileName}" />
<ListBox
Name="nameOptionalFields"
x:Name="nameSelectedFileName"
Grid.Row="1"
Grid.Column="1"
MinHeight="30"
ItemContainerStyle="{StaticResource TagItem2Style}"
ItemsSource="{Binding OptionalFields, Mode=TwoWay}"
SelectedIndex="{Binding SelectedOptionalField}"
ItemsSource="{Binding SelectedFileName, Mode=TwoWay}"
SelectionMode="Single"
Style="{StaticResource Tag2Style}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding OptionalFieldsCommand}" CommandParameter="{Binding ElementName=nameOptionalFields, Path=SelectedItem}" />
<i:InvokeCommandAction Command="{Binding SelectedFileNameCommand}" CommandParameter="{Binding ElementName=nameSelectedFileName, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
<StackPanel
Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource FileNameTimeFormat}" />
<ComboBox
Name="nameFileNamePartTimeFormat"
Width="120"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
ItemsSource="{Binding FileNamePartTimeFormatList}"
SelectedItem="{Binding SelectedFileNamePartTimeFormat}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding FileNamePartTimeFormatCommand}" CommandParameter="{Binding ElementName=nameFileNamePartTimeFormat, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<Button
Grid.Row="2"
Grid.Column="1"
@ -232,6 +258,7 @@
</Grid>
</GroupBox>
<StackPanel Margin="10" />
</StackPanel>
</ScrollViewer>
</UserControl>

Loading…
Cancel
Save