This commit is contained in:
GG Z
2026-01-02 09:37:33 +08:00
parent 3bf2c78fbd
commit b717bc5ba1
11 changed files with 47 additions and 90 deletions

6
.idea/.idea.AddInManager/.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -84,10 +84,7 @@ namespace AddInManager
{ {
lock (typeof(AIM)) lock (typeof(AIM))
{ {
if (m_inst == null) m_inst ??= new AIM();
{
m_inst = new AIM();
}
} }
} }
return m_inst; return m_inst;

View File

@@ -26,11 +26,6 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page>--> </Page>-->
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<!-- <Compile Update="Wpf\MainWindow.xaml.cs"> <!-- <Compile Update="Wpf\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>--> </Compile>-->
@@ -74,9 +69,5 @@
<None Update="PackageContents.xml"> <None Update="PackageContents.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -34,13 +34,13 @@ namespace AddInManager
private void GetIniFilePaths() private void GetIniFilePaths()
{ {
var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var text = Path.Combine(folderPath, Settings.Default.AppFolder); var appFolder = Path.Combine(folderPath, Resources.AppFolder);
var text2 = Path.Combine(text, "AimInternal.ini"); var iniFilePath = Path.Combine(appFolder, "AimInternal.ini");
AimIniFile = new IniFile(text2); AimIniFile = new IniFile(iniFilePath);
var currentProcess = Process.GetCurrentProcess(); var currentProcess = Process.GetCurrentProcess();
var fileName = currentProcess.MainModule.FileName; var fileName = currentProcess.MainModule.FileName;
var text3 = fileName.Replace(".exe", ".ini"); var revitIniFilePath = fileName.Replace(".exe", ".ini");
RevitIniFile = new IniFile(text3); RevitIniFile = new IniFile(revitIniFilePath);
} }
public void ReadAddinsFromAimIni() public void ReadAddinsFromAimIni()
@@ -66,8 +66,8 @@ namespace AddInManager
} }
Path.GetFileName(filePath); Path.GetFileName(filePath);
var assemLoader = new AssemLoader(); var assemLoader = new AssemLoader();
List<AddinItem> list = null; List<AddinItem> cmdItems = null;
List<AddinItem> list2 = null; List<AddinItem> appItems = null;
try try
{ {
assemLoader.HookAssemblyResolve(); assemLoader.HookAssemblyResolve();
@@ -76,8 +76,8 @@ namespace AddInManager
{ {
return addinType; return addinType;
} }
list = Commands.LoadItems(assembly, StaticUtil.m_ecFullName, filePath, AddinType.Command); cmdItems = Commands.LoadItems(assembly, StaticUtil.m_ecFullName, filePath, AddinType.Command);
list2 = Applications.LoadItems(assembly, StaticUtil.m_eaFullName, filePath, AddinType.Application); appItems = Applications.LoadItems(assembly, StaticUtil.m_eaFullName, filePath, AddinType.Application);
} }
catch (Exception) catch (Exception)
{ {
@@ -86,16 +86,16 @@ namespace AddInManager
{ {
assemLoader.UnhookAssemblyResolve(); assemLoader.UnhookAssemblyResolve();
} }
if (list != null && list.Count > 0) if (cmdItems != null && cmdItems.Count > 0)
{ {
var addin = new Addin(filePath, list); var cmdAddin = new Addin(filePath, cmdItems);
Commands.AddAddIn(addin); Commands.AddAddIn(cmdAddin);
addinType |= AddinType.Command; addinType |= AddinType.Command;
} }
if (list2 != null && list2.Count > 0) if (appItems != null && appItems.Count > 0)
{ {
var addin2 = new Addin(filePath, list2); var appAddin = new Addin(filePath, appItems);
Applications.AddAddIn(addin2); Applications.AddAddIn(appAddin);
addinType |= AddinType.Application; addinType |= AddinType.Application;
} }
return addinType; return addinType;
@@ -105,8 +105,7 @@ namespace AddInManager
{ {
if (!File.Exists(RevitIniFile.FilePath)) if (!File.Exists(RevitIniFile.FilePath))
{ {
throw new System.IO.FileNotFoundException( throw new System.IO.FileNotFoundException($"路径{RevitIniFile.FilePath}中未找到revit.ini: ",
$"can't find the revit.ini file from: {RevitIniFile.FilePath}",
RevitIniFile.FilePath RevitIniFile.FilePath
); );
} }

View File

@@ -14,9 +14,9 @@ namespace AddInManager
stringBuilder.AppendLine($"文件夹[{folderPath}]"); stringBuilder.AppendLine($"文件夹[{folderPath}]");
stringBuilder.AppendLine($"有{sizeInMB}MB大小"); stringBuilder.AppendLine($"有{sizeInMB}MB大小");
stringBuilder.AppendLine("AddinManager尝试复制所有文件到临时文件夹"); stringBuilder.AppendLine("AddinManager尝试复制所有文件到临时文件夹");
stringBuilder.AppendLine("选择[Yes]复制所有文件到临时文件夹"); stringBuilder.AppendLine("选择[是(Y)]复制所有文件到临时文件夹");
stringBuilder.AppendLine("选择[No]仅复制测试DLL文件到临时文件夹"); stringBuilder.AppendLine("选择[否(N)]仅复制测试DLL文件到临时文件夹");
stringBuilder.AppendLine("选择[Cancel]取消操作"); stringBuilder.AppendLine("选择[取消]取消操作");
var text = stringBuilder.ToString(); var text = stringBuilder.ToString();
return MessageBox.Show(text, Resources.AppName, MessageBoxButton.YesNoCancel, MessageBoxImage.Information, MessageBoxResult.Yes); return MessageBox.Show(text, Resources.AppName, MessageBoxButton.YesNoCancel, MessageBoxImage.Information, MessageBoxResult.Yes);
} }

View File

@@ -19,7 +19,7 @@ namespace AddInManager.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。 // (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
@@ -61,7 +61,16 @@ namespace AddInManager.Properties {
} }
/// <summary> /// <summary>
/// 查找类似 AddinManager 的本地化字符串。 /// 查找类似 RevitAddInManager 的本地化字符串。
/// </summary>
internal static string AppFolder {
get {
return ResourceManager.GetString("AppFolder", resourceCulture);
}
}
/// <summary>
/// 查找类似 插件管理 的本地化字符串。
/// </summary> /// </summary>
internal static string AppName { internal static string AppName {
get { get {
@@ -108,7 +117,7 @@ namespace AddInManager.Properties {
} }
/// <summary> /// <summary>
/// 查找类似 Revit Addin Files(*.dll)|*.dll 的本地化字符串。 /// 查找类似 外部程序集(*.dll)|*.dll 的本地化字符串。
/// </summary> /// </summary>
internal static string LoadFileFilter { internal static string LoadFileFilter {
get { get {

View File

@@ -117,8 +117,11 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="AppFolder" xml:space="preserve">
<value>RevitAddInManager</value>
</data>
<data name="AppName" xml:space="preserve"> <data name="AppName" xml:space="preserve">
<value>AddinManager</value> <value>插件管理</value>
</data> </data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Develop_16" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Develop_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
@@ -134,7 +137,7 @@
<value>加载失败</value> <value>加载失败</value>
</data> </data>
<data name="LoadFileFilter" xml:space="preserve"> <data name="LoadFileFilter" xml:space="preserve">
<value>Revit Addin Files(*.dll)|*.dll</value> <value>外部程序集(*.dll)|*.dll</value>
</data> </data>
<data name="LoadSucceed" xml:space="preserve"> <data name="LoadSucceed" xml:space="preserve">
<value>加载成功</value> <value>加载成功</value>

View File

@@ -1,38 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AddInManager.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("RevitAddInManager")]
public string AppFolder {
get {
return ((string)(this["AppFolder"]));
}
set {
this["AppFolder"] = value;
}
}
}
}

View File

@@ -1,9 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="AddInManager.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="AppFolder" Type="System.String" Scope="User">
<Value Profile="(Default)">RevitAddInManager</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -69,7 +69,7 @@
Margin="2" Margin="2"
Click="SelectAllButton_Click" Click="SelectAllButton_Click"
Style="{StaticResource ToolbarButton}" Style="{StaticResource ToolbarButton}"
ToolTip="选所有命令"> ToolTip="选所有命令">
<TextBlock <TextBlock
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
@@ -81,7 +81,7 @@
x:Name="selectNoneButton" x:Name="selectNoneButton"
Click="SelectNoneButton_Click" Click="SelectNoneButton_Click"
Style="{StaticResource ToolbarButton}" Style="{StaticResource ToolbarButton}"
ToolTip="取消所有选择"> ToolTip="取消选中应用">
<TextBlock <TextBlock
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
@@ -133,7 +133,6 @@
MouseDoubleClick="CommandsTreeView_MouseDoubleClick" MouseDoubleClick="CommandsTreeView_MouseDoubleClick"
PreviewMouseRightButtonDown="CommandsTreeView_PreviewMouseRightButtonDown" PreviewMouseRightButtonDown="CommandsTreeView_PreviewMouseRightButtonDown"
SelectedItemChanged="CommandsTreeView_SelectedItemChanged"> SelectedItemChanged="CommandsTreeView_SelectedItemChanged">
<!-- 为 TreeViewItem 定义右键菜单 (已更新图标) -->
<TreeView.ContextMenu> <TreeView.ContextMenu>
<ContextMenu x:Name="commandsTreeViewContextMenu"> <ContextMenu x:Name="commandsTreeViewContextMenu">
<MenuItem <MenuItem
@@ -238,7 +237,7 @@
Margin="2" Margin="2"
Click="AppSelectAllButton_Click" Click="AppSelectAllButton_Click"
Style="{StaticResource ToolbarButton}" Style="{StaticResource ToolbarButton}"
ToolTip="选所有命令项"> ToolTip="选所有应用">
<TextBlock <TextBlock
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
@@ -250,7 +249,7 @@
x:Name="appSelectNoneButton" x:Name="appSelectNoneButton"
Click="AppSelectNoneButton_Click" Click="AppSelectNoneButton_Click"
Style="{StaticResource ToolbarButton}" Style="{StaticResource ToolbarButton}"
ToolTip="取消所有选择"> ToolTip="取消选中应用">
<TextBlock <TextBlock
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"

Binary file not shown.