修复重复加载导致的GDI报错

This commit is contained in:
ZouJin 2023-05-15 20:44:30 +10:00
parent a39f5fae4e
commit 2fe0b0e089
12 changed files with 62 additions and 44 deletions

View File

@ -43,6 +43,10 @@ namespace VPet_Simulator.Core
/// 刷新时间时会调用该方法,在所有任务处理完之后
/// </summary>
public event Action<Main> TimeUIHandle;
/// <summary>
/// 是否开始运行
/// </summary>
public bool IsWorking { get; private set; } = false;
public Main(GameCore core, bool loadtouchevent = true)
{
Console.WriteLine(DateTime.Now.ToString("T:fff"));
@ -67,6 +71,7 @@ namespace VPet_Simulator.Core
ig.WaitForReadyRun(PetGrid, () =>
{
IsWorking = true;
Dispatcher.Invoke(() =>
{
PetGrid.Tag = ig;

View File

@ -102,8 +102,7 @@ namespace VPet_Simulator.Core
var newmod = Core.Save.CalMode();
if (Core.Save.Mode != newmod)
{
//TODO:切换逻辑
//TODO:切换显示动画
Core.Save.Mode = newmod;
}
}

View File

@ -18,6 +18,7 @@ namespace VPet_Simulator.Core
{
if (!Directory.Exists(CachePath))
Directory.CreateDirectory(CachePath);
CommConfig["Cache"] = new List<string>();
}
public static string CachePath = AppDomain.CurrentDomain.BaseDirectory + @"\cache";

View File

@ -88,7 +88,6 @@ namespace VPet_Simulator.Core
GraphCore.CommUIElements["Image1.PNGAnimation"] = new System.Windows.Controls.Image() { Height = 500 };
GraphCore.CommUIElements["Image2.PNGAnimation"] = new System.Windows.Controls.Image() { Height = 500 };
GraphCore.CommUIElements["Image3.PNGAnimation"] = new System.Windows.Controls.Image() { Height = 500 };
}
Task.Run(() => startup(path, paths));
//if (storemem)
@ -164,7 +163,7 @@ namespace VPet_Simulator.Core
//生成大文件加载非常慢,先看看有没有缓存能用
Path = GraphCore.CachePath + $"\\{Sub.GetHashCode(path)}_{paths.Length}.png";
Width = 500 * (paths.Length + 1);
if (File.Exists(Path))
if (File.Exists(Path) || ((List<string>)GraphCore.CommConfig["Cache"]).Contains(path))
{
for (int i = 0; i < paths.Length; i++)
{
@ -175,6 +174,7 @@ namespace VPet_Simulator.Core
}
else
{
((List<string>)GraphCore.CommConfig["Cache"]).Add(path);
List<System.Drawing.Image> imgs = new List<System.Drawing.Image>();
foreach (var file in paths)
imgs.Add(System.Drawing.Image.FromFile(file.FullName));
@ -189,6 +189,7 @@ namespace VPet_Simulator.Core
graph.DrawImage(imgs[i], w * i, 0, w, h);
Animations.Add(new Animation(this, time, -500 * i));
}
if (!File.Exists(Path))
joinedBitmap.Save(Path);
graph.Dispose();
joinedBitmap.Dispose();

View File

@ -58,23 +58,28 @@ namespace VPet_Simulator.Core
{
if (path_name.StartsWith(GraphTypeValue[i]))
{
bool isused = false;
if (path_name.Contains("happy"))
{
graph.AddGraph(di.FullName, GameSave.ModeType.Happy, (GraphType)i);
isused = true;
}
if (path_name.Contains("nomal"))
{
graph.AddGraph(di.FullName, GameSave.ModeType.Nomal, (GraphType)i);
isused = true;
}
if (path_name.Contains("poorcondition"))
{
graph.AddGraph(di.FullName, GameSave.ModeType.PoorCondition, (GraphType)i);
isused = true;
}
if (path_name.Contains("ill"))
{
graph.AddGraph(di.FullName, GameSave.ModeType.Ill, (GraphType)i);
isused = true;
}
else
if (!isused)
{
graph.AddGraph(di.FullName, GameSave.ModeType.Nomal, (GraphType)i);
}

View File

@ -74,13 +74,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="LinePutScript, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\VUP-Simulator\packages\LinePutScript.1.8.0\lib\net462\LinePutScript.dll</HintPath>
<HintPath>..\packages\LinePutScript.1.8.0\lib\net462\LinePutScript.dll</HintPath>
</Reference>
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll</HintPath>
</Reference>
<Reference Include="Panuon.WPF.UI, Version=1.1.10.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.10\lib\net462\Panuon.WPF.UI.dll</HintPath>
<Reference Include="Panuon.WPF.UI, Version=1.1.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net462\Panuon.WPF.UI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />

View File

@ -2,5 +2,5 @@
<packages>
<package id="LinePutScript" version="1.8.0" targetFramework="net462" />
<package id="Panuon.WPF" version="1.0.1" targetFramework="net462" />
<package id="Panuon.WPF.UI" version="1.1.10" targetFramework="net462" />
<package id="Panuon.WPF.UI" version="1.1.11-beta" targetFramework="net462" />
</packages>

View File

@ -94,8 +94,8 @@
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll</HintPath>
</Reference>
<Reference Include="Panuon.WPF.UI, Version=1.1.10.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.10\lib\net462\Panuon.WPF.UI.dll</HintPath>
<Reference Include="Panuon.WPF.UI, Version=1.1.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net462\Panuon.WPF.UI.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />

View File

@ -2,5 +2,5 @@
<packages>
<package id="LinePutScript" version="1.8.0" targetFramework="net462" />
<package id="Panuon.WPF" version="1.0.1" targetFramework="net462" />
<package id="Panuon.WPF.UI" version="1.1.10" targetFramework="net462" />
<package id="Panuon.WPF.UI" version="1.1.11-beta" targetFramework="net462" />
</packages>

View File

@ -246,6 +246,14 @@ namespace VPet_Simulator.Windows
}
};
DisplayGrid.Child = Main;
Task.Run(() =>
{
while (Main.IsWorking)
{
Thread.Sleep(100);
}
Dispatcher.Invoke(() => LoadingText.Visibility = Visibility.Collapsed);
});
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "退出桌宠", () => { Close(); });
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "开发控制台", () => { new winConsole(this).Show(); });
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "反馈中心", () => { new winReport(this).Show(); });
@ -257,7 +265,6 @@ namespace VPet_Simulator.Windows
Main.SetMoveMode(Set.AllowMove, Set.SmartMove, Set.SmartMoveInterval * 1000);
Main.SetLogicInterval((int)(Set.LogicInterval * 1000));
LoadingText.Visibility = Visibility.Collapsed;
//加载图标
notifyIcon = new NotifyIcon();
notifyIcon.Text = "虚拟桌宠模拟器";
@ -295,7 +302,7 @@ namespace VPet_Simulator.Windows
winSetting.Show();
};
if (Set["SingleTips"].GetDateTime("tutorial") <= new DateTime(2023, 2, 23))
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Tutorial.html") && Set["SingleTips"].GetDateTime("tutorial") <= new DateTime(2023, 2, 23))
{
Set["SingleTips"].SetDateTime("tutorial", DateTime.Now);
Process.Start(AppDomain.CurrentDomain.BaseDirectory + @"\Tutorial.html");

View File

@ -90,8 +90,8 @@
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net48\Panuon.WPF.dll</HintPath>
</Reference>
<Reference Include="Panuon.WPF.UI, Version=1.1.10.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.10\lib\net48\Panuon.WPF.UI.dll</HintPath>
<Reference Include="Panuon.WPF.UI, Version=1.1.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net48\Panuon.WPF.UI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />

View File

@ -6,5 +6,5 @@
<package id="LinePutScript" version="1.8.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="Panuon.WPF" version="1.0.1" targetFramework="net48" />
<package id="Panuon.WPF.UI" version="1.1.10" targetFramework="net48" />
<package id="Panuon.WPF.UI" version="1.1.11-beta" targetFramework="net48" />
</packages>