This commit is contained in:
Hakoyu 2023-09-26 16:47:20 +08:00
parent 19203ead6c
commit 5831b2d0f7
4 changed files with 19 additions and 4 deletions

View File

@ -31,8 +31,6 @@ public class ModMakerHistory
}
}
public string LastTimeString => LastTime.ToString("yyyy/MM/dd HH:mm:ss");
public string InfoFile => Path.Combine(SourcePath, "info.lps");
[Line(ignoreCase: true)]

View File

@ -94,7 +94,7 @@ public class FoodModel : I18nModel<I18nFoodModel>
Health = Health.Value,
Likability = Likability.Value,
Price = Price.Value,
ImageSource = Image.Value,
Exp = Exp.Value,
};
}

View File

@ -34,6 +34,7 @@ public class ModMakerWindowVM
public ObservableCommand CreateNewModCommand { get; } = new();
public ObservableCommand LoadModFromFileCommand { get; } = new();
public ObservableCommand ClearHistoriesCommand { get; } = new();
public ObservableCommand<ModMakerHistory> RemoveHistoryCommand { get; } = new();
#endregion
public ModMakerWindowVM() { }
@ -45,9 +46,16 @@ public class ModMakerWindowVM
CreateNewModCommand.ExecuteEvent += CreateNewMod;
LoadModFromFileCommand.ExecuteEvent += LoadModFromFile;
ClearHistoriesCommand.ExecuteEvent += ClearHistories;
RemoveHistoryCommand.ExecuteEvent += RemoveHistory;
HistoriesSearchText.ValueChanged += ModSearchText_ValueChanged;
}
private void RemoveHistory(ModMakerHistory value)
{
Histories.Remove(value);
SaveHistories();
}
private void LoadHistories()
{
if (File.Exists(ModMakerInfo.HistoryFile) is false)
@ -73,7 +81,7 @@ public class ModMakerWindowVM
{
new Sub("Id", history.Id),
new Sub("SourcePath", history.SourcePath),
new Sub("LastTime", history.LastTimeString)
new Sub("LastTime", history.LastTime.ToString("yyyy/MM/dd HH:mm"))
}
);
File.WriteAllText(ModMakerInfo.HistoryFile, lps.ToString());

View File

@ -55,7 +55,16 @@
<Grid
Margin="5"
Background="{DynamicResource PrimaryDark}"
Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
ToolTip="{Binding InfoFile}">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem
Command="{Binding PlacementTarget.Tag.RemoveHistoryCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
Header="{ll:Str 删除此历史}" />
</ContextMenu>
</Grid.ContextMenu>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />