Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
BugLordI committed Jan 31, 2024
1 parent 83e8578 commit d319bd4
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 83 deletions.
6 changes: 3 additions & 3 deletions AutoArchive/AutoArchivePlus/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public class App : Application

private static MainForm mainForm;

private static AppSetting appSetting = new AppSetting();
private static AppConfig appSetting = new AppConfig();

public static List<SteamAppInfo> InstalledApps { get; private set; } = new List<SteamAppInfo>();

public static string ICON_PATH { get => iconPath; }

public static AppSetting AppSetting { get => appSetting;}
public static AppConfig AppSetting { get => appSetting;}


[STAThread]
Expand Down Expand Up @@ -101,7 +101,7 @@ static void loadSetting()
else
{
String content = config.Content;
appSetting = JsonConvert.DeserializeObject<AppSetting>(content);
appSetting = JsonConvert.DeserializeObject<AppConfig>(content);
}
}

Expand Down
5 changes: 2 additions & 3 deletions AutoArchive/AutoArchivePlus/AppConfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"BackupConfig": {
},
"ConnectionStrings": {
"DBConnection": "Data Source=data.db"
}
},
"GameArchivePathHelpUrl": "https://github.com/BugLordI/EldenRingAutoArchive/wiki/%E5%85%B3%E4%BA%8E%E8%80%81%E8%B4%BC%E6%B8%B8%E6%88%8F%E7%9A%84%E5%AD%98%E6%A1%A3%E7%9B%B8%E5%85%B3%E9%97%AE%E9%A2%98%E6%95%B4%E7%90%86"
}
92 changes: 47 additions & 45 deletions AutoArchive/AutoArchivePlus/Component/NavigationMenuItem.xaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,63 @@
<UserControl x:Class="AutoArchivePlus.Component.NavigationMenuItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:converter="clr-namespace:AutoArchivePlus.Converter"
xmlns:language="clr-namespace:AutoArchivePlus.Language"
mc:Ignorable="d"
d:DesignHeight="38"
d:DesignWidth="196"
x:Name="self" Loaded="self_Loaded"
>
<UserControl
x:Class="AutoArchivePlus.Component.NavigationMenuItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:AutoArchivePlus.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:language="clr-namespace:AutoArchivePlus.Language"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="self"
d:DesignHeight="38"
d:DesignWidth="196"
Loaded="self_Loaded"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<converter:NavigationMenuItemConvert x:Key="convert"/>
<converter:NavigationMenuItemConvert x:Key="convert" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Resources/Styles/NavigationBarStyle.xaml"/>
<ResourceDictionary Source="../Resources/Styles/NavigationBarStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<UserControl.Background>
<SolidColorBrush Color="{Binding ElementName=self,Path=IsSelect,Converter={StaticResource convert}}"/>
<SolidColorBrush Color="{Binding ElementName=self, Path=IsSelect, Converter={StaticResource convert}}" />
</UserControl.Background>
<Button Style="{StaticResource NavigationBtn}"
Height="38"
x:Name="defaultMenu"
Command="{Binding ItemClickedCommand,ElementName=self}"
CommandParameter="{Binding DataContext,ElementName=self}"
ContextMenuOpening="defaultMenu_ContextMenuOpening"
>
<Button
x:Name="defaultMenu"
Height="38"
Command="{Binding ItemClickedCommand, ElementName=self}"
CommandParameter="{Binding DataContext, ElementName=self}"
ContextMenuOpening="defaultMenu_ContextMenuOpening"
Style="{StaticResource NavigationBtn}">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Width="160"
Header="{Binding [CloseProjectTab],Source={x:Static language:LanguageManager.Instance}}"
x:Name="closeProgramMenu"
/>
<MenuItem
x:Name="closeProgramMenu"
Width="160"
Header="{Binding [CloseProjectTab], Source={x:Static language:LanguageManager.Instance}}" />
</ContextMenu>
</Button.ContextMenu>
<Button.Content>
<Border
BorderThickness="{Binding ElementName=self,Path=IsSelect,Converter={StaticResource convert}}"
BorderBrush="#409EFF">
<StackPanel Orientation="Horizontal"
Background="Transparent"
Width="{Binding ActualWidth,ElementName=defaultMenu}"
Height="{Binding ActualHeight,ElementName=defaultMenu}"
>
<Image Source="{Binding ItemIcon,ElementName=self}"
Style="{StaticResource NavigationIcon}"
Width="{Binding ItemIconWidth,ElementName=self}"
Height="{Binding ItemIconHeight,ElementName=self}"
x:Name="icon"
/>
<TextBlock Text="{Binding ItemName,ElementName=self}"
Style="{StaticResource NavigationText}"
FontSize="13"
Foreground="{Binding ElementName=self,Path=IsSelect,Converter={StaticResource convert}}"
/>
<Border BorderBrush="#409EFF" BorderThickness="{Binding ElementName=self, Path=IsSelect, Converter={StaticResource convert}}">
<StackPanel
Width="{Binding ActualWidth, ElementName=defaultMenu}"
Height="{Binding ActualHeight, ElementName=defaultMenu}"
Background="Transparent"
Orientation="Horizontal">
<Image
x:Name="icon"
Width="{Binding ItemIconWidth, ElementName=self}"
Height="{Binding ItemIconHeight, ElementName=self}"
Source="{Binding ItemIcon, ElementName=self}"
Style="{StaticResource NavigationIcon}" />
<TextBlock
MaxWidth="163"
FontSize="13"
Foreground="{Binding ElementName=self, Path=IsSelect, Converter={StaticResource convert}}"
Style="{StaticResource NavigationText}"
Text="{Binding ItemName, ElementName=self}"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding ItemName, ElementName=self}" />
</StackPanel>
</Border>
</Button.Content>
Expand Down
60 changes: 56 additions & 4 deletions AutoArchive/AutoArchivePlus/Forms/ProjectForm.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
xmlns:vm="clr-namespace:AutoArchivePlus.ViewModel"
x:Name="projectForm"
Title="ProjectForm"
Width="650"
Height="350"
Width="666"
Height="370"
AllowsTransparency="True"
Background="Transparent"
Loaded="projectForm_Loaded"
Expand Down Expand Up @@ -106,6 +106,14 @@
</i:EventTrigger>
</i:Interaction.Triggers>
</hc:ComboBox>
<TextBlock
Grid.Row="0"
Grid.Column="2"
Height="16"
Margin="10,48,0,0"
VerticalAlignment="Center"
Foreground="Red"
Text="{Binding GameNameErrorTip}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Expand All @@ -122,10 +130,25 @@
Margin="10,0,14,0"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
hc:InfoElement.ShowClearButton="True"
BorderBrush="LightGray"
BorderThickness="2,2,2,2"
Text="{Binding GameInstallPath, Mode=TwoWay}"
ToolTip="{Binding Text, ElementName=gameInstallPath}" />
ToolTip="{Binding Text, ElementName=gameInstallPath}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding TextChanged}" CommandParameter="{Binding ElementName=gameInstallPath}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</hc:TextBox>
<TextBlock
Grid.Row="1"
Grid.Column="2"
Height="16"
Margin="10,48,0,0"
VerticalAlignment="Center"
Foreground="Red"
Text="{Binding GameInstallPathErrorTip}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Expand All @@ -146,7 +169,21 @@
BorderThickness="2,2,2,2"
IsReadOnly="True"
Text="{Binding GameArchivePath, Mode=TwoWay}"
ToolTip="{Binding Text, ElementName=gameArchivePath}" />
ToolTip="{Binding Text, ElementName=gameArchivePath}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding TextChanged}" CommandParameter="{Binding ElementName=gameArchivePath}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBlock
Grid.Row="2"
Grid.Column="2"
Height="16"
Margin="10,48,0,0"
VerticalAlignment="Center"
Foreground="Red"
Text="{Binding GameArchivePathErrorTip}" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
Expand Down Expand Up @@ -212,6 +249,21 @@
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
<Image
Grid.Row="2"
Grid.Column="3"
Width="14"
Height="14"
Margin="74,6,0,0"
Cursor="Hand"
Source="/Resources/img/help.png"
ToolTip="{Binding [GameArchivePathHelpInfoTip], Source={x:Static language:LanguageManager.Instance}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding GameArchivePathHelp}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Image>
<TextBlock
x:Name="chooseBackupPath"
Grid.Row="3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace AutoArchivePlus.Model
{
[Serializable]
public class AppSetting: BaseEntity
public class AppConfig: BaseEntity
{
private bool autoCheckStartProgram;
private bool alwaysAskWhenExits;
Expand Down Expand Up @@ -42,7 +42,7 @@ public bool ShowEffectShadow

public override bool Equals(object obj)
{
if (obj != null && obj is AppSetting that)
if (obj != null && obj is AppConfig that)
{
if (that.AutoCheckStartProgram == this.AutoCheckStartProgram
&& that.AlwaysAskWhenExits == this.AlwaysAskWhenExits
Expand Down
6 changes: 6 additions & 0 deletions AutoArchive/AutoArchivePlus/Resources/Lang.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,10 @@
<data name="RunnableProgram" xml:space="preserve">
<value>Runnable program</value>
</data>
<data name="GameInstallPathNotExistTip" xml:space="preserve">
<value>Game path error: path does not exist</value>
</data>
<data name="GameArchivePathHelpInfoTip" xml:space="preserve">
<value>Don’t know the archive path? Click to view</value>
</data>
</root>
6 changes: 6 additions & 0 deletions AutoArchive/AutoArchivePlus/Resources/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,10 @@
<data name="RunnableProgram" xml:space="preserve">
<value>可运行程序</value>
</data>
<data name="GameInstallPathNotExistTip" xml:space="preserve">
<value>游戏路径错误:路径不存在</value>
</data>
<data name="GameArchivePathHelpInfoTip" xml:space="preserve">
<value>不知道存档路径?点击查看</value>
</data>
</root>
4 changes: 2 additions & 2 deletions AutoArchive/AutoArchivePlus/ViewModel/AppSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace AutoArchivePlus.ViewModel
public class AppSettingViewModel : BaseViewModel
{

private AppSetting appSetting;
private AppConfig appSetting;

private bool isEnable;

Expand All @@ -35,7 +35,7 @@ private void AppSetting_PropertyChanged(object sender, System.ComponentModel.Pro
IsEnable = !AppSetting.Equals(App.AppSetting);
}

public AppSetting AppSetting
public AppConfig AppSetting
{
get
{
Expand Down
13 changes: 8 additions & 5 deletions AutoArchive/AutoArchivePlus/ViewModel/MainFormViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public ObservableCollection<Object> Backups
public ICommand BackupCommand => new ControlCommand(obj =>
{
DateTime now = DateTime.Now;
String desPath = Path.Combine(CurrentProject.BackupPath, CurrentProject.Name, now.ToString("yyyyMMddHHmmss"));
String dirName = FileUtil.SanitizePath(CurrentProject.Name);
String desPath = Path.Combine(CurrentProject.BackupPath, dirName, now.ToString("yyyyMMddHHmmss"));
Backup backup = new Backup()
{
Id = Guid.NewGuid().ToString(),
Expand All @@ -100,10 +101,12 @@ public ObservableCollection<Object> Backups
ProjectId = CurrentProject.Id,
DateTimeStamp = DateUtil.toUnixTimestamp(now),
};
using DBContext<Backup> dbContext = new DBContext<Backup>();
dbContext.Entity.Add(backup);
dbContext.SaveChanges();
FileUtil.copyDirectory(CurrentProject.ArchivePath, desPath);
if (FileUtil.copyDirectory(CurrentProject.ArchivePath, desPath))
{
using DBContext<Backup> dbContext = new DBContext<Backup>();
dbContext.Entity.Add(backup);
dbContext.SaveChanges();
}
readBackups(CurrentProject.Id);
});

Expand Down
Loading

0 comments on commit d319bd4

Please sign in to comment.