Browse Source

load resoures when addin is inserted and enabled

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1094 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Markus Palme 20 years ago
parent
commit
752efc9b96
  1. 34
      src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs
  2. 16
      src/Main/Core/Project/Src/AddInTree/AddInTree.cs

34
src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs

@ -17,6 +17,8 @@ namespace ICSharpCode.Core @@ -17,6 +17,8 @@ namespace ICSharpCode.Core
{
Properties properties = new Properties();
List<Runtime> runtimes = new List<Runtime>();
List<string> bitmapResources = new List<string>();
List<string> stringResources = new List<string>();
string addInFileName = null;
AddInManifest manifest = new AddInManifest();
@ -102,6 +104,24 @@ namespace ICSharpCode.Core @@ -102,6 +104,24 @@ namespace ICSharpCode.Core
}
}
public List<string> BitmapResources {
get {
return bitmapResources;
}
set {
bitmapResources = value;
}
}
public List<string> StringResources {
get {
return stringResources;
}
set {
stringResources = value;
}
}
public bool Enabled {
get {
return enabled;
@ -127,25 +147,15 @@ namespace ICSharpCode.Core @@ -127,25 +147,15 @@ namespace ICSharpCode.Core
throw new AddInLoadException("BitmapResources requires ONE attribute.");
}
if(hintPath == null) break;
string filename = StringParser.Parse(reader.GetAttribute("file"));
string path = Path.Combine(hintPath, filename);
if(! File.Exists(path))
{
throw new AddInLoadException("Resource file '" + path + "' could not be found.");
}
ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(Path.GetFileNameWithoutExtension(path), Path.GetDirectoryName(path), null);
if(reader.LocalName == "BitmapResources")
{
ResourceService.RegisterNeutralImages(resourceManager);
addIn.BitmapResources.Add(filename);
}
else
{
ResourceService.RegisterNeutralStrings(resourceManager);
addIn.StringResources.Add(filename);
}
break;
case "Runtime":

16
src/Main/Core/Project/Src/AddInTree/AddInTree.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Resources;
using System.IO;
using System.Reflection;
using System.Collections;
@ -163,6 +164,21 @@ namespace ICSharpCode.Core @@ -163,6 +164,21 @@ namespace ICSharpCode.Core
foreach (ExtensionPath path in addIn.Paths.Values) {
AddExtensionPath(path);
}
string addInRoot = Path.GetDirectoryName(addIn.FileName);
foreach(string bitmapResource in addIn.BitmapResources)
{
string path = Path.Combine(addInRoot, bitmapResource);
ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(Path.GetFileNameWithoutExtension(path), Path.GetDirectoryName(path), null);
ResourceService.RegisterNeutralImages(resourceManager);
}
foreach(string stringResource in addIn.StringResources)
{
string path = Path.Combine(addInRoot, stringResource);
ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(Path.GetFileNameWithoutExtension(path), Path.GetDirectoryName(path), null);
ResourceService.RegisterNeutralStrings(resourceManager);
}
}
addIns.Add(addIn);
}

Loading…
Cancel
Save