mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
修复重复加载导致的GDI报错
This commit is contained in:
parent
a39f5fae4e
commit
2fe0b0e089
@ -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;
|
||||
|
@ -102,8 +102,7 @@ namespace VPet_Simulator.Core
|
||||
var newmod = Core.Save.CalMode();
|
||||
if (Core.Save.Mode != newmod)
|
||||
{
|
||||
//TODO:切换逻辑
|
||||
|
||||
//TODO:切换显示动画
|
||||
Core.Save.Mode = newmod;
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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,7 +189,8 @@ namespace VPet_Simulator.Core
|
||||
graph.DrawImage(imgs[i], w * i, 0, w, h);
|
||||
Animations.Add(new Animation(this, time, -500 * i));
|
||||
}
|
||||
joinedBitmap.Save(Path);
|
||||
if (!File.Exists(Path))
|
||||
joinedBitmap.Save(Path);
|
||||
graph.Dispose();
|
||||
joinedBitmap.Dispose();
|
||||
imgs.ForEach(x => x.Dispose());
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
@ -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" />
|
||||
|
@ -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>
|
@ -246,18 +246,25 @@ 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(); });
|
||||
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "设置面板", () =>
|
||||
{
|
||||
Topmost = false;
|
||||
winSetting.Show();
|
||||
});
|
||||
{
|
||||
Topmost = false;
|
||||
winSetting.Show();
|
||||
});
|
||||
|
||||
Main.SetMoveMode(Set.AllowMove, Set.SmartMove, Set.SmartMoveInterval * 1000);
|
||||
Main.SetLogicInterval((int)(Set.LogicInterval * 1000));
|
||||
LoadingText.Visibility = Visibility.Collapsed;
|
||||
//加载图标
|
||||
notifyIcon = new NotifyIcon();
|
||||
notifyIcon.Text = "虚拟桌宠模拟器";
|
||||
@ -266,20 +273,20 @@ namespace VPet_Simulator.Windows
|
||||
m_menu = new ContextMenu();
|
||||
m_menu.MenuItems.Add(new MenuItem("操作教程", (x, y) => { Process.Start(AppDomain.CurrentDomain.BaseDirectory + @"\Tutorial.html"); }));
|
||||
m_menu.MenuItems.Add(new MenuItem("重置状态", (x, y) =>
|
||||
{
|
||||
Main.CleanState();
|
||||
Main.DisplayNomal();
|
||||
Left = (SystemParameters.PrimaryScreenWidth - Width) / 2;
|
||||
Top = (SystemParameters.PrimaryScreenHeight - Height) / 2;
|
||||
}));
|
||||
{
|
||||
Main.CleanState();
|
||||
Main.DisplayNomal();
|
||||
Left = (SystemParameters.PrimaryScreenWidth - Width) / 2;
|
||||
Top = (SystemParameters.PrimaryScreenHeight - Height) / 2;
|
||||
}));
|
||||
m_menu.MenuItems.Add(new MenuItem("反馈中心", (x, y) => { new winReport(this).Show(); }));
|
||||
m_menu.MenuItems.Add(new MenuItem("开发控制台", (x, y) => { new winConsole(this).Show(); }));
|
||||
|
||||
m_menu.MenuItems.Add(new MenuItem("设置面板", (x, y) =>
|
||||
{
|
||||
Topmost = false;
|
||||
winSetting.Show();
|
||||
}));
|
||||
{
|
||||
Topmost = false;
|
||||
winSetting.Show();
|
||||
}));
|
||||
m_menu.MenuItems.Add(new MenuItem("退出桌宠", (x, y) => Close()));
|
||||
|
||||
LoadDIY();
|
||||
@ -290,12 +297,12 @@ namespace VPet_Simulator.Windows
|
||||
|
||||
notifyIcon.Visible = true;
|
||||
notifyIcon.BalloonTipClicked += (a, b) =>
|
||||
{
|
||||
Topmost = false;
|
||||
winSetting.Show();
|
||||
};
|
||||
{
|
||||
Topmost = false;
|
||||
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");
|
||||
@ -303,14 +310,14 @@ namespace VPet_Simulator.Windows
|
||||
if (!Set["SingleTips"].GetBool("helloworld"))
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
Set["SingleTips"].SetBool("helloworld", true);
|
||||
notifyIcon.ShowBalloonTip(10, "你好" + (IsSteamUser ? Steamworks.SteamClient.Name : Environment.UserName),
|
||||
"欢迎使用虚拟桌宠模拟器!\n如果遇到桌宠爬不见了,可以在我这里设置居中或退出桌宠", ToolTipIcon.Info);
|
||||
Thread.Sleep(2000);
|
||||
Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议", GraphCore.Helper.SayType.Shining);
|
||||
});
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
Set["SingleTips"].SetBool("helloworld", true);
|
||||
notifyIcon.ShowBalloonTip(10, "你好" + (IsSteamUser ? Steamworks.SteamClient.Name : Environment.UserName),
|
||||
"欢迎使用虚拟桌宠模拟器!\n如果遇到桌宠爬不见了,可以在我这里设置居中或退出桌宠", ToolTipIcon.Info);
|
||||
Thread.Sleep(2000);
|
||||
Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议", GraphCore.Helper.SayType.Shining);
|
||||
});
|
||||
}
|
||||
else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 27))
|
||||
{
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
Loading…
Reference in New Issue
Block a user