修复 类库模式下的资源载入问题

This commit is contained in:
Hakoyu 2023-09-08 00:46:31 +08:00
parent c3a20d84c8
commit c4d33fb3de
8 changed files with 47 additions and 8 deletions

View File

@ -11,5 +11,7 @@ namespace VPet.ModMaker
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application { }
public partial class App : Application
{
}
}

View File

@ -23,7 +23,6 @@ public class ModMaker : MainPlugin
public ModMaker(IMainWindow mainwin)
: base(mainwin) { }
public override void LoadPlugin()
{
Set = MW.Set.FindLine("ModMaker");
@ -41,11 +40,12 @@ public class ModMaker : MainPlugin
modset.Items.Add(menuset);
}
public override void Setting()
{
if (Maker == null)
{
// 载入ModMaker资源
Application.Current.Resources.MergedDictionaries.Add(new ModMakerStyles());
Maker = new ModMakerWindow();
Maker.ModMaker = this;
Maker.Show();

View File

@ -0,0 +1,12 @@
<ResourceDictionary
x:Class="VPet.ModMaker.ModMakerStyles"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Panuon.WPF.UI;component/Control.xaml" />
<ResourceDictionary Source="/VPet-Simulator.Windows.Interface;component/ResourceStyle.xaml" />
<ResourceDictionary Source="../Converters.xaml" />
<ResourceDictionary Source="../Templates.xaml" />
<ResourceDictionary Source="../Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

16
VPet.ModMaker/Styles.cs Normal file
View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace VPet.ModMaker;
public partial class ModMakerStyles : ResourceDictionary
{
public ModMakerStyles()
{
InitializeComponent();
}
}

View File

@ -27,4 +27,5 @@
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
</Style>
<Style x:Key="Grid_Style" TargetType="Grid" />
</ResourceDictionary>

View File

@ -49,7 +49,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>VPet.ModMaker.App</StartupObject>
<StartupObject>
</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="LinePutScript, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
@ -76,10 +77,10 @@
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="VPet-Simulator.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\VPet-Simulator.Core.1.0.3\lib\net462\VPet-Simulator.Core.dll</HintPath>
<HintPath>..\packages\VPet-Simulator.Core.1.0.5.1\lib\net462\VPet-Simulator.Core.dll</HintPath>
</Reference>
<Reference Include="VPet-Simulator.Windows.Interface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\VPet-Simulator.Windows.Interface.1.0.3\lib\net462\VPet-Simulator.Windows.Interface.dll</HintPath>
<HintPath>..\packages\VPet-Simulator.Windows.Interface.1.0.5.2\lib\net462\VPet-Simulator.Windows.Interface.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
@ -105,6 +106,7 @@
<Compile Include="Models\SelectTextModel.cs" />
<Compile Include="Models\WorkModel.cs" />
<Compile Include="SimpleObservable\ObservableCommandT.cs" />
<Compile Include="Styles.cs" />
<Compile Include="ViewModels\ModEdit\ClickTextEdit\ClickTextEditWindowVM.cs" />
<Compile Include="ViewModels\ModEdit\ClickTextEdit\ClickTextPageVM.cs" />
<Compile Include="ViewModels\ModEdit\FoodEdit\FoodPageVM.cs" />
@ -197,6 +199,11 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
<Page Include="Properties\DesignTimeResources.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<ContainsDesignTimeResources>true</ContainsDesignTimeResources>
</Page>
<Page Include="Converters.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -59,6 +59,7 @@ public class ModMakerWindowVM
private void SaveHistories()
{
Directory.CreateDirectory(nameof(ModMaker));
if (File.Exists(ModMakerInfo.HistoryFile) is false)
File.Create(ModMakerInfo.HistoryFile).Close();
var lps = new LPS();

View File

@ -4,6 +4,6 @@
<package id="LinePutScript.Localization.WPF" version="1.0.6" targetFramework="net462" />
<package id="Panuon.WPF" version="1.0.2" targetFramework="net462" />
<package id="Panuon.WPF.UI" version="1.1.15.8" targetFramework="net462" />
<package id="VPet-Simulator.Core" version="1.0.3" targetFramework="net462" />
<package id="VPet-Simulator.Windows.Interface" version="1.0.3" targetFramework="net462" />
<package id="VPet-Simulator.Core" version="1.0.5.1" targetFramework="net462" />
<package id="VPet-Simulator.Windows.Interface" version="1.0.5.2" targetFramework="net462" />
</packages>