修复 保存图片时图片不存在报错的问题

This commit is contained in:
Hakoyu 2023-10-13 22:51:24 +08:00
parent e5e572fde8
commit 171c49012c
4 changed files with 60 additions and 59 deletions

View File

@ -80,6 +80,8 @@ public static class Extensions
/// <param name="path">路径</param>
public static void SaveToPng(this BitmapSource image, string path)
{
if (image is null)
return;
if (path.EndsWith(".png") is false)
path += ".png";
var encoder = new PngBitmapEncoder();

View File

@ -249,8 +249,8 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
if (I18nHelper.Current.CultureNames.Contains(lang) is false)
I18nHelper.Current.CultureNames.Add(lang);
}
if (I18nHelper.Current.CultureNames.Count > 0)
{
if (I18nHelper.Current.CultureNames.Count == 0)
return;
I18nHelper.Current.CultureName.Value = I18nHelper.Current.CultureNames.First();
foreach (var i18nData in OtherI18nDatas)
{
@ -298,7 +298,6 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
}
}
}
#endregion
#region Save
/// <summary>

View File

@ -200,21 +200,21 @@ public class ModEditWindowVM
if (saveFileDialog.ShowDialog() is true)
{
var pending = PendingBox.Show("保存中".Translate());
try
{
//try
//{
var path = Path.GetDirectoryName(saveFileDialog.FileName);
ModInfo.Value.SaveTo(path);
if (string.IsNullOrWhiteSpace(ModInfo.Value.SourcePath.Value))
ModInfo.Value.SourcePath.Value = path;
pending.Close();
MessageBox.Show(ModEditWindow, "保存成功".Translate());
}
catch (Exception ex)
{
pending.Close();
MessageBox.Show($"保存失败 错误信息:\n{0}".Translate(ex));
return;
}
//}
//catch (Exception ex)
//{
// pending.Close();
// MessageBox.Show("保存失败 错误信息:\n{0}".Translate(ex));
// return;
//}
}
}

View File

@ -36,7 +36,7 @@
<Button
Grid.Column="1"
Command="{Binding ClearHistoriesCommand}"
Content="清空历史" />
Content="{ll:Str 清空历史}" />
</Grid>
<ListBox
Grid.Row="2"