更新整理
This commit is contained in:
27
.idea/.idea.Sai.RvKits/.idea/workspace.xml
generated
27
.idea/.idea.Sai.RvKits/.idea/workspace.xml
generated
@@ -21,7 +21,12 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="69ccb014-6bd6-4972-a3ac-c8cdfb213274" name="更改" comment="优化更新代码,添加界面功能并整合" />
|
||||
<list default="true" id="69ccb014-6bd6-4972-a3ac-c8cdfb213274" name="更改" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Sai.RvKits/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Sai.RvKits/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/WPFluent.Gallery/NavigateWindow.xaml" beforeDir="false" afterPath="$PROJECT_DIR$/WPFluent.Gallery/NavigateWindow.xaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/WPFluent.Gallery/Pages/Buttons.xaml" beforeDir="false" afterPath="$PROJECT_DIR$/WPFluent.Gallery/Pages/ButtonPage.xaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/WPFluent.Gallery/Pages/Buttons.xaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/WPFluent.Gallery/Pages/ButtonPage.xaml.cs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
@@ -69,7 +74,7 @@
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
".NET 项目.ShrlAlgo.WPFluent.Gallery.executor": "Debug",
|
||||
".NET 项目.ShrlAlgo.WPFluent.Gallery.executor": "Run",
|
||||
".NET 项目.WpfApp.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
@@ -81,7 +86,7 @@
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.keymap",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true",
|
||||
"附加到进程.24860:Revit.executor": "Debug"
|
||||
}
|
||||
@@ -348,7 +353,7 @@
|
||||
<workItem from="1743318964435" duration="1257000" />
|
||||
<workItem from="1743324167237" duration="2017000" />
|
||||
<workItem from="1743327442321" duration="179000" />
|
||||
<workItem from="1743331555114" duration="1688000" />
|
||||
<workItem from="1743331555114" duration="3257000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="优化更新代码,添加界面功能并整合">
|
||||
<option name="closed" value="true" />
|
||||
@@ -430,7 +435,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1743333169763</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="11" />
|
||||
<task id="LOCAL-00011" summary="清理项目">
|
||||
<option name="closed" value="true" />
|
||||
<created>1743333528168</created>
|
||||
<option name="number" value="00011" />
|
||||
<option name="presentableId" value="LOCAL-00011" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1743333528168</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="12" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -454,7 +467,9 @@
|
||||
<MESSAGE value="整理" />
|
||||
<MESSAGE value="优化更新" />
|
||||
<MESSAGE value="优化更新代码,添加界面功能并整合" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="优化更新代码,添加界面功能并整合" />
|
||||
<MESSAGE value="Merge remote-tracking branch 'origin/master' # Conflicts: #	ConsoleApp/ConsoleApp.csproj #	ConsoleApp/Program.cs #	RvAddinTest/FluentAddin.cs #	RvAddinTest/InstancesCreator.cs #	RvAddinTest/ReplaceCode.cs #	Sai.RvKits.sln #	Sai.RvKits/RvView/ElementControlDock.xaml.cs #	ShrlAlgo.Addin.Test/AddWallTypeParam.cs #	ShrlAlgo.Addin.Test/CreateWindow.xaml.cs #	ShrlAlgo.Addin.Test/GASInstancesCreator.cs #	ShrlAlgo.Addin.Test/ModifySystemTypeCmd.cs #	ShrlAlgo.Addin.Test/ShrlAlgo.Addin.Test.csproj #	ShrlAlgo.Addin.Test/TempCmd.cs #	ShrlAlgo.RvKits/ModelManager/SeparateModelCmd.cs #	ShrlAlgo.RvKits/ModelManager/SeparateModelViewModel.cs #	ShrlAlgo.RvKits/ModelManager/SeparateModelWin.xaml #	ShrlAlgo.RvKits/ModelManager/SeparateModelWin.xaml.cs #	ShrlAlgo.RvKits/Resources/adaptive_MEP_tag_16px.png #	ShrlAlgo.RvKits/Resources/adaptive_MEP_tag_32px.png #	ShrlAlgo.RvKits/RvView/AdaptiveMEPTagCmd.cs #	ShrlAlgo.RvKits/UIRibbon/DrawingViewApp.cs #	ShrlAlgo.Toolkit.Mvvm/Converters/InvertBooleanConverter.cs #	ShrlAlgo.Toolkit.Revit/Assist/CollectorAssist.cs #	ShrlAlgo.Toolkit.Revit/Helpers/KeyboardShortcutService.cs #	ShrlAlgo.Toolkit.Revit/Helpers/ParameterAssist.cs #	Wpf.Ui.Extend/Wpf.Ui.Extend.csproj #	WpfApp/MainViewModel.cs #	WpfApp/MainWindow.xaml #	WpfApp/WpfApp.csproj" />
|
||||
<MESSAGE value="清理项目" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="清理项目" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
||||
13
.idea/.idea.ShrlAlgoToolkit/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.ShrlAlgoToolkit/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider 忽略的文件
|
||||
/.idea.ShrlAlgoToolkit.iml
|
||||
/projectSettingsUpdater.xml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
1
.idea/.idea.ShrlAlgoToolkit/.idea/.name
generated
Normal file
1
.idea/.idea.ShrlAlgoToolkit/.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
||||
ShrlAlgoToolkit
|
||||
4
.idea/.idea.ShrlAlgoToolkit/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.ShrlAlgoToolkit/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
.idea/.idea.ShrlAlgoToolkit/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.ShrlAlgoToolkit/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/.idea.ShrlAlgoToolkit/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.ShrlAlgoToolkit/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -19,7 +19,7 @@ using Microsoft.Win32;
|
||||
using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
using OfficeOpenXml;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
namespace ShrlAlgo.Addin.Test;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
|
||||
namespace ShrlAlgo.Addin.Test;
|
||||
|
||||
@@ -4,6 +4,7 @@ using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
namespace ShrlAlgo.Addin.Test;
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
|
||||
@@ -9,6 +9,9 @@ using Autodesk.Revit.DB;
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
using Nice3point.Revit.Toolkit.Utils;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
namespace ShrlAlgo.Addin.Test;
|
||||
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
@@ -110,6 +113,10 @@ internal class FluentAddin : ExternalCommand
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
var ids = Document.ActiveView.OfCollector().WhereElementIsNotElementType().Where(e => e.GetLevelId() == ElementId.InvalidElementId).Select(e => e.Id).ToList();
|
||||
UiDocument.Selection.SetElementIds(ids);
|
||||
return;
|
||||
var textTypes = Document.OfClass<TextNoteType>().ToList();
|
||||
var accessoryTypes = Document.OfClass<FamilySymbol>().OfCategory(BuiltInCategory.OST_PipeAccessory).WhereElementIsElementType().ToList();
|
||||
var filledRegionTypes = Document.OfClass<FilledRegionType>().ToList();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
using WPFluent.Appearance;
|
||||
|
||||
|
||||
@@ -7,29 +8,29 @@ namespace ShrlAlgo.Addin.Test;
|
||||
/// <summary>
|
||||
/// FluentWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FluentWindow
|
||||
public partial class FluentWindow
|
||||
{
|
||||
public FluentWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
ApplicationThemeManager.Apply(this);
|
||||
ApplicationThemeManager.Changed -= ApplicationThemeManager_Changed;
|
||||
ApplicationThemeManager.Changed += ApplicationThemeManager_Changed;
|
||||
//ApplicationThemeManager.Apply(this);
|
||||
//ApplicationThemeManager.Changed -= ApplicationThemeManager_Changed;
|
||||
//ApplicationThemeManager.Changed += ApplicationThemeManager_Changed;
|
||||
}
|
||||
private void ApplicationThemeManager_Changed(ApplicationTheme currentApplicationTheme, Color systemAccent)
|
||||
{
|
||||
ApplicationThemeManager.Apply(this);
|
||||
//ApplicationThemeManager.Apply(this);
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Light)
|
||||
{
|
||||
ApplicationThemeManager.Apply(ApplicationTheme.Dark);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicationThemeManager.Apply(ApplicationTheme.Light);
|
||||
}
|
||||
//if (ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Light)
|
||||
//{
|
||||
// ApplicationThemeManager.Apply(ApplicationTheme.Dark);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// ApplicationThemeManager.Apply(ApplicationTheme.Light);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
global using ShrlAlgo.Toolkit.Revit.Assist;
|
||||
global using ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
|
||||
namespace ShrlAlgo.Addin.Test;
|
||||
/// <summary>
|
||||
@@ -17,7 +24,29 @@ public class RemoveParamCmd : ExternalCommand
|
||||
{
|
||||
public override void Execute()
|
||||
{
|
||||
var list = new List<string>();
|
||||
var filter = "族文件|*.rfa";
|
||||
var openFile = new OpenFileDialog
|
||||
{
|
||||
Multiselect = true,
|
||||
Filter = filter
|
||||
};
|
||||
openFile.ShowDialog();
|
||||
if (openFile.FileNames.Length != 0)
|
||||
{
|
||||
var strFiles = openFile.FileNames;
|
||||
|
||||
foreach (var file in strFiles)
|
||||
{
|
||||
list.Add(file);
|
||||
}
|
||||
}
|
||||
foreach (var fileName in list)
|
||||
{
|
||||
var doc = Application.OpenDocumentFile(fileName);
|
||||
doc.Save();
|
||||
doc.Close(false);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 移除任意参数
|
||||
|
||||
@@ -7,7 +7,9 @@ using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
using ShrlAlgo.Toolkit.Core.Heplers;
|
||||
using ShrlAlgoToolkit.Core.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
using Math = System.Math;
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Windows;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using Exception = System.Exception;
|
||||
|
||||
using UIFrameworkServices;
|
||||
|
||||
@@ -42,16 +42,8 @@
|
||||
<PackageReference Include="Nice3point.Revit.Toolkit" Version="2019.*" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ShrlAlgoToolkit.Core\ShrlAlgoToolkit.Core.csproj" />
|
||||
<ProjectReference Include="..\WPFluent\WPFluent.csproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\ShrlAlgo.Toolkit.Revit\ShrlAlgo.Toolkit.Revit.projitems" Label="Shared" />
|
||||
<Import Project="..\ShrlAlgo.Toolkit.Mvvm\ShrlAlgo.Toolkit.Mvvm.projitems" Label="Shared" />
|
||||
<Import Project="..\ShrlAlgo.Toolkit.Core\ShrlAlgo.Toolkit.Core.projitems" Label="Shared" />
|
||||
|
||||
<!--<Target Name="PreventRevitSDKCopyLocal" AfterTargets="ResolveReferences">
|
||||
<ItemGroup>
|
||||
--><!-- 暂时解决Revit SDK文件被复制到输出文件夹的问题 --><!--
|
||||
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' == 'Autodesk.Revit.SDK'" />
|
||||
</ItemGroup>
|
||||
</Target>-->
|
||||
<Import Project="..\ShrlAlgoToolkit.Revit\ShrlAlgoToolkit.Revit.projitems" Label="Shared" />
|
||||
</Project>
|
||||
@@ -4,6 +4,8 @@ using Autodesk.Revit.DB.Plumbing;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
using ShrlAlgoToolkit.Revit.Assists;
|
||||
using ShrlAlgoToolkit.Revit.Extensions;
|
||||
|
||||
|
||||
namespace ShrlAlgo.Addin.Test;
|
||||
|
||||
@@ -6,7 +6,7 @@ using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
using ShrlAlgo.Toolkit.Core.Heplers;
|
||||
using ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
namespace ShrlAlgo.Addin.Test;
|
||||
|
||||
@@ -58,6 +58,6 @@ public class TestGDI : ExternalCommand
|
||||
var graphics = Graphics.FromHwnd(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
|
||||
var p = new System.Drawing.Point(rectangle.Left + 1920, rectangle.Top);
|
||||
var p1 = new System.Drawing.Point(rectangle.Right + 1920, rectangle.Bottom);
|
||||
GdiHelper.DrawLine(graphics, p, p1);
|
||||
GdiAssist.DrawLine(graphics, p, p1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.1.32421.90
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShrlAlgo.RvKits", "ShrlAlgo.RvKits\ShrlAlgo.RvKits.csproj", "{AA64ED67-E47E-46B1-A6F6-999A26193E57}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShrlAlgo.Addin.Test", "ShrlAlgo.Addin.Test\ShrlAlgo.Addin.Test.csproj", "{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C47CB11C-7E87-446B-9DB5-E41290A18A4F}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{323E8FFA-E349-4084-B6B8-60BFA7469F30}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ShrlAlgo.Toolkit.Core", "ShrlAlgo.Toolkit.Core\ShrlAlgo.Toolkit.Core.shproj", "{B8AC2442-3CC7-4ECE-BD67-D78B8D19E394}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ShrlAlgo.Toolkit.Mvvm", "ShrlAlgo.Toolkit.Mvvm\ShrlAlgo.Toolkit.Mvvm.shproj", "{536597BD-5E53-4BB1-83DD-5637D3BBFFA3}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ShrlAlgo.Toolkit.Revit", "ShrlAlgo.Toolkit.Revit\ShrlAlgo.Toolkit.Revit.shproj", "{38C42BA0-E9CA-4DBD-A912-A1BBC61A2E5A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfApp", "WpfApp\WpfApp.csproj", "{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFluent.Gallery", "WPFluent.Gallery\WPFluent.Gallery.csproj", "{122DE09F-5137-4909-8ECD-F2C3A76548AF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFluent", "WPFluent\WPFluent.csproj", "{3FFC4137-48A3-4BD2-8156-3A0F7278307F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
All|Any CPU = All|Any CPU
|
||||
All|x64 = All|x64
|
||||
Debug One|Any CPU = Debug One|Any CPU
|
||||
Debug One|x64 = Debug One|x64
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
DefaultBuild|Any CPU = DefaultBuild|Any CPU
|
||||
DefaultBuild|x64 = DefaultBuild|x64
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.All|Any CPU.ActiveCfg = Debug|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.All|Any CPU.Build.0 = Debug|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.All|x64.ActiveCfg = Release|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.All|x64.Build.0 = Release|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Debug One|Any CPU.ActiveCfg = Debug One|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Debug One|Any CPU.Build.0 = Debug One|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Debug One|x64.ActiveCfg = Debug One|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Debug One|x64.Build.0 = Debug One|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Debug|x64.Build.0 = Debug|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.DefaultBuild|Any CPU.ActiveCfg = Debug One|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.DefaultBuild|Any CPU.Build.0 = Debug One|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.DefaultBuild|x64.ActiveCfg = Debug One|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.DefaultBuild|x64.Build.0 = Debug One|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Release|Any CPU.Build.0 = Release|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Release|x64.ActiveCfg = Release|x64
|
||||
{AA64ED67-E47E-46B1-A6F6-999A26193E57}.Release|x64.Build.0 = Release|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.All|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.All|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.All|x64.ActiveCfg = Debug|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.All|x64.Build.0 = Debug|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Debug One|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Debug One|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Debug One|x64.ActiveCfg = Debug|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Debug One|x64.Build.0 = Debug|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Debug|x64.Build.0 = Debug|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.DefaultBuild|x64.ActiveCfg = Debug|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.DefaultBuild|x64.Build.0 = Debug|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Release|x64.ActiveCfg = Release|x64
|
||||
{BA8EBF4A-1AAC-42A5-9BC6-E3130158C8DD}.Release|x64.Build.0 = Release|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|x64.ActiveCfg = Debug|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.All|x64.Build.0 = Debug|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Debug One|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Debug One|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Debug One|x64.ActiveCfg = Debug|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Debug One|x64.Build.0 = Debug|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Debug|x64.Build.0 = Debug|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.DefaultBuild|x64.ActiveCfg = Debug|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.DefaultBuild|x64.Build.0 = Debug|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Release|x64.ActiveCfg = Release|x64
|
||||
{F8C48DA5-7E26-4FA5-A9EE-4D80BA2E49F9}.Release|x64.Build.0 = Release|x64
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.All|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.All|Any CPU.Build.0 = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.All|x64.ActiveCfg = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.All|x64.Build.0 = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Debug One|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Debug One|Any CPU.Build.0 = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Debug One|x64.ActiveCfg = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Debug One|x64.Build.0 = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.DefaultBuild|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.DefaultBuild|Any CPU.Build.0 = Release|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.DefaultBuild|x64.ActiveCfg = Release|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.DefaultBuild|x64.Build.0 = Release|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{122DE09F-5137-4909-8ECD-F2C3A76548AF}.Release|x64.Build.0 = Release|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.All|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.All|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.All|x64.ActiveCfg = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.All|x64.Build.0 = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Debug One|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Debug One|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Debug One|x64.ActiveCfg = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Debug One|x64.Build.0 = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.DefaultBuild|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.DefaultBuild|Any CPU.Build.0 = Release|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.DefaultBuild|x64.ActiveCfg = Release|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.DefaultBuild|x64.Build.0 = Release|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{3FFC4137-48A3-4BD2-8156-3A0F7278307F}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{B8AC2442-3CC7-4ECE-BD67-D78B8D19E394} = {323E8FFA-E349-4084-B6B8-60BFA7469F30}
|
||||
{536597BD-5E53-4BB1-83DD-5637D3BBFFA3} = {323E8FFA-E349-4084-B6B8-60BFA7469F30}
|
||||
{38C42BA0-E9CA-4DBD-A912-A1BBC61A2E5A} = {323E8FFA-E349-4084-B6B8-60BFA7469F30}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CADC66CE-1F2B-4344-834E-E1EDF5C61ACC}
|
||||
EndGlobalSection
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
ShrlAlgo.Toolkit.Revit\ShrlAlgo.Toolkit.Revit.projitems*{38c42ba0-e9ca-4dbd-a912-a1bbc61a2e5a}*SharedItemsImports = 13
|
||||
ShrlAlgo.Toolkit.Mvvm\ShrlAlgo.Toolkit.Mvvm.projitems*{536597bd-5e53-4bb1-83dd-5637d3bbffa3}*SharedItemsImports = 13
|
||||
ShrlAlgo.Toolkit.Core\ShrlAlgo.Toolkit.Core.projitems*{aa64ed67-e47e-46b1-a6f6-999a26193e57}*SharedItemsImports = 5
|
||||
ShrlAlgo.Toolkit.Mvvm\ShrlAlgo.Toolkit.Mvvm.projitems*{aa64ed67-e47e-46b1-a6f6-999a26193e57}*SharedItemsImports = 5
|
||||
ShrlAlgo.Toolkit.Revit\ShrlAlgo.Toolkit.Revit.projitems*{aa64ed67-e47e-46b1-a6f6-999a26193e57}*SharedItemsImports = 5
|
||||
ShrlAlgo.Toolkit.Core\ShrlAlgo.Toolkit.Core.projitems*{b8ac2442-3cc7-4ece-bd67-d78b8d19e394}*SharedItemsImports = 13
|
||||
Sai.Toolkit.Core\Sai.Toolkit.Core.projitems*{ba8ebf4a-1aac-42a5-9bc6-e3130158c8dd}*SharedItemsImports = 5
|
||||
Sai.Toolkit.Mvvm\Sai.Toolkit.Mvvm.projitems*{ba8ebf4a-1aac-42a5-9bc6-e3130158c8dd}*SharedItemsImports = 5
|
||||
Sai.Toolkit.Revit\Sai.Toolkit.Revit.projitems*{ba8ebf4a-1aac-42a5-9bc6-e3130158c8dd}*SharedItemsImports = 5
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using ShrlAlgo.Toolkit.Mvvm;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
using System.Text;
|
||||
|
||||
using System.Windows.Data;
|
||||
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters
|
||||
{
|
||||
public class IdToNameConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (parameter is BindingProxy proxy && proxy.Data is Document document && value is ElementId id && (id != ElementId.InvalidElementId))
|
||||
{
|
||||
return document.GetElement(id).Name;
|
||||
}
|
||||
return System.Windows.Data.Binding.DoNothing;
|
||||
}
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
|
||||
public static class RvConverters
|
||||
{
|
||||
public static Element ToElement(this ElementId elementId, Document doc)
|
||||
{
|
||||
return doc.GetElement(elementId);
|
||||
}
|
||||
|
||||
public static Category ToCategory(this BuiltInCategory builtInCategory, Document doc)
|
||||
{
|
||||
return Category.GetCategory(doc, builtInCategory);
|
||||
}
|
||||
|
||||
public static BuiltInCategory ToBuiltInCategory(this Category category)
|
||||
{
|
||||
#if REVIT2018 || REVIT2020
|
||||
var builtInCategory = (BuiltInCategory)category.Id.IntegerValue;
|
||||
#elif REVIT2025
|
||||
var builtInCategory = (BuiltInCategory)category.Id.Value;
|
||||
#endif
|
||||
|
||||
return Enum.IsDefined(typeof(BuiltInCategory), builtInCategory)
|
||||
? builtInCategory
|
||||
: throw new ArgumentNullException(nameof(category), "不存在该内建类别");
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters
|
||||
{
|
||||
public class RvEnumConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{ return RvEnumConverter.GetChineseName(value); }
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{ throw new NotImplementedException(); }
|
||||
|
||||
private static string GetChineseName(object obj)
|
||||
{
|
||||
#if REVIT2018
|
||||
if (obj is BuiltInParameter parameter)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(parameter);
|
||||
}
|
||||
else if (obj is BuiltInParameterGroup group)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(group);
|
||||
}
|
||||
else if (obj is UnitType uType)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(uType);
|
||||
}
|
||||
else if (obj is ParameterType pType)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(pType);
|
||||
}
|
||||
#elif REVIT2020
|
||||
if (obj is BuiltInParameter parameter)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(parameter, Autodesk.Revit.ApplicationServices.LanguageType.Chinese_Simplified);
|
||||
}
|
||||
else if (obj is BuiltInCategory category)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(category);
|
||||
}
|
||||
else if (obj is BuiltInParameterGroup group)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(group);
|
||||
}
|
||||
else if (obj is UnitType uType)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(uType);
|
||||
}
|
||||
else if (obj is ParameterType pType)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(pType);
|
||||
}
|
||||
#elif REVIT2025
|
||||
if (obj is BuiltInParameter parameter)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(
|
||||
parameter,
|
||||
Autodesk.Revit.ApplicationServices.LanguageType.Chinese_Simplified);
|
||||
}
|
||||
else if (obj is BuiltInCategory category)
|
||||
{
|
||||
return LabelUtils.GetLabelFor(category);
|
||||
}
|
||||
else if (obj is ForgeTypeId forgeTypeId)
|
||||
{
|
||||
|
||||
if (UnitUtils.IsSymbol(forgeTypeId))
|
||||
{
|
||||
return LabelUtils.GetLabelForSymbol(forgeTypeId);
|
||||
}
|
||||
else if (SpecUtils.IsSpec(forgeTypeId))
|
||||
{
|
||||
return LabelUtils.GetLabelForSpec(forgeTypeId);
|
||||
}
|
||||
else if (UnitUtils.IsUnit(forgeTypeId))
|
||||
{
|
||||
return LabelUtils.GetLabelForUnit(forgeTypeId);
|
||||
}
|
||||
else if (ParameterUtils.IsBuiltInGroup(forgeTypeId))
|
||||
{
|
||||
return LabelUtils.GetLabelForGroup(forgeTypeId);
|
||||
}
|
||||
else if (UnitUtils.GetDiscipline(forgeTypeId).IsValidObject)
|
||||
{
|
||||
return LabelUtils.GetLabelForDiscipline(forgeTypeId);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,319 +0,0 @@
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Style;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
|
||||
public class EPPlusHelper //公式计算最后需要调用Calculate()
|
||||
{
|
||||
/// <summary>
|
||||
/// DataTable导出为Excel
|
||||
/// </summary>
|
||||
/// <param name="destFileName"></param>
|
||||
/// <param name="dt"></param>
|
||||
public static void DataTableToExcel(DataTable dt, string destFileName)
|
||||
{
|
||||
FileInfo fi = new(destFileName);
|
||||
using ExcelPackage package = new(fi);
|
||||
try
|
||||
{
|
||||
var workSheet = package.Workbook.Worksheets.Add(dt.TableName);
|
||||
workSheet.Cells["A1"].LoadFromDataTable(dt, true);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
finally
|
||||
{
|
||||
package.Save();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给第一个表中的单元格赋值
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="rowNum"></param>
|
||||
/// <param name="columnNum"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void EditCellValue(string fileName, int rowNum, int columnNum, string value)
|
||||
{
|
||||
FileInfo fi = new(fileName);
|
||||
using ExcelPackage package = new(fi);
|
||||
//ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
var sheet = package.Workbook.Worksheets[0];
|
||||
//string filename = System.IO.Path.GetFileNameWithoutExtension(fileName);
|
||||
sheet.Cells[rowNum, columnNum].Value = value;
|
||||
package.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工作表转换为DataTable,首行为表头
|
||||
/// </summary>
|
||||
/// <param name="worksheet">行列索引从1开始</param>
|
||||
/// <returns></returns>
|
||||
public static DataTable ExcelSheetToDataTable(ExcelWorksheet worksheet)
|
||||
{
|
||||
if (worksheet == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
//获取worksheet的行数
|
||||
var rows = worksheet.Dimension.End.Row;
|
||||
//获取worksheet的列数
|
||||
var cols = worksheet.Dimension.End.Column;
|
||||
|
||||
DataTable dt = new(worksheet.Name);
|
||||
DataRow dr = null;
|
||||
for (var i = 1; i <= rows; i++)
|
||||
{
|
||||
if (i > 1)
|
||||
{
|
||||
dr = dt.Rows.Add();
|
||||
}
|
||||
|
||||
for (var j = 1; j <= cols; j++)
|
||||
{
|
||||
//默认将第一行设置为datatable的标题
|
||||
var value = worksheet.Cells[i, j].Value;
|
||||
if (i == 1)
|
||||
{
|
||||
dt.Columns.Add(value == null ? $"标题{i}" : value.ToString());
|
||||
}
|
||||
//剩下的写入datatable
|
||||
else
|
||||
{
|
||||
dr[j - 1] = value == null ? string.Empty : value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工作表转换为DataTable
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="sheetName"></param>
|
||||
/// <returns></returns>
|
||||
public static DataTable ExcelSheetToDataTable(string fileName, string sheetName)
|
||||
{
|
||||
FileInfo fi = new(fileName);
|
||||
ExcelPackage p = new(fi);
|
||||
var workbook = p.Workbook;
|
||||
var worksheet = workbook.Worksheets[sheetName];
|
||||
return ExcelSheetToDataTable(worksheet);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取工作表
|
||||
/// </summary>
|
||||
/// <param name="excelFilePath"></param>
|
||||
/// <param name="sheetName"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public static ExcelWorksheet GetExcelWorksheet(string excelFilePath, string sheetName)
|
||||
{
|
||||
var excelworkbook = new FileInfo(excelFilePath);
|
||||
using var p = new ExcelPackage(excelworkbook);
|
||||
var ws = p.Workbook.Worksheets[sheetName];
|
||||
return ws ?? throw new Exception("工作表不存在。");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取Excel所有表
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
public void ReadExcel(string filePath)
|
||||
{
|
||||
using ExcelPackage package = new(new FileStream(filePath, FileMode.Open));
|
||||
for (var i = 1; i <= package.Workbook.Worksheets.Count; ++i)
|
||||
{
|
||||
var sheet = package.Workbook.Worksheets[i];
|
||||
for (int j = sheet.Dimension.Start.Column, k = sheet.Dimension.End.Column; j <= k; j++)
|
||||
{
|
||||
for (int m = sheet.Dimension.Start.Row, n = sheet.Dimension.End.Row; m <= n; m++)
|
||||
{
|
||||
//string str = GetValue(sheet, m, j);
|
||||
//if (str != null)
|
||||
//{
|
||||
// // do something
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置单元格的值
|
||||
/// </summary>
|
||||
/// <param name="sheet"></param>
|
||||
/// <param name="rowNum">1开始</param>
|
||||
/// <param name="columnNum">1开始</param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetCellValue(ExcelWorksheet sheet, int rowNum, int columnNum, string value)
|
||||
{
|
||||
//sheet.Cells[rowNum, ColumnNum].Value = value;
|
||||
sheet.SetValue(rowNum, columnNum, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过单元格名设置值
|
||||
/// </summary>
|
||||
/// <param name="sheet"></param>
|
||||
/// <param name="cellName"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetCellValue(ExcelWorksheet sheet, string cellName, string value)
|
||||
{
|
||||
sheet.Cells[cellName].Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给工作表中的单元格赋值
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="sheetname"></param>
|
||||
/// <param name="rowNum"></param>
|
||||
/// <param name="columnNum"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetCellValue(string fileName, string sheetname, int rowNum, int columnNum, string value)
|
||||
{
|
||||
FileInfo fi = new(fileName);
|
||||
using ExcelPackage package = new(fi);
|
||||
//ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
var sheet = package.Workbook.Worksheets[sheetname];
|
||||
//string filename = System.IO.Path.GetFileNameWithoutExtension(fileName);
|
||||
sheet.SetValue(rowNum, columnNum, value);
|
||||
package.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给工作表中的单元格赋值
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="sheetname"></param>
|
||||
/// <param name="cellName">单元格名称,比如A1</param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetCellValue(string fileName, string sheetname, string cellName, string value)
|
||||
{
|
||||
FileInfo fi = new(fileName);
|
||||
using ExcelPackage package = new(fi);
|
||||
//ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
var sheet = package.Workbook.Worksheets[sheetname];
|
||||
//string filename = System.IO.Path.GetFileNameWithoutExtension(fileName);
|
||||
sheet.Cells[cellName].Value = value;
|
||||
package.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给工作表中的单元格赋值
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="index">表索引,0开始</param>
|
||||
/// <param name="cellName">单元格名称,如A1</param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetCellValue(string fileName, int index, string cellName, string value)
|
||||
{
|
||||
FileInfo fi = new(fileName);
|
||||
using ExcelPackage package = new(fi);
|
||||
//ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
var sheet = package.Workbook.Worksheets[index];
|
||||
//string filename = System.IO.Path.GetFileNameWithoutExtension(fileName);
|
||||
sheet.Cells[cellName].Value = value;
|
||||
package.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置样式
|
||||
/// </summary>
|
||||
/// <param name="sheet"></param>
|
||||
/// <param name="fromRow"></param>
|
||||
/// <param name="fromCol"></param>
|
||||
/// <param name="toRow"></param>
|
||||
/// <param name="toCol"></param>
|
||||
public static void SetStyle(ExcelWorksheet sheet, int fromRow, int fromCol, int toRow, int toCol)
|
||||
{
|
||||
using var range = sheet.Cells[fromRow, fromCol, toRow, toCol];
|
||||
//range.Style.Font.Name = "微软雅黑";
|
||||
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
range.Style.Font.Size = 12;
|
||||
range.Style.Border.Top.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Left.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Right.Style = ExcelBorderStyle.Thin;
|
||||
//range.Style.SetBackgroundColor(System.Drawing.SelectedColor.FromArgb(142, 169, 219));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置表头样式
|
||||
/// </summary>
|
||||
/// <param name="sheet"></param>
|
||||
/// <param name="fromRow"></param>
|
||||
/// <param name="fromCol"></param>
|
||||
/// <param name="toRow"></param>
|
||||
/// <param name="toCol"></param>
|
||||
public static void SetTitle(ExcelWorksheet sheet, int fromRow, int fromCol, int toRow, int toCol)
|
||||
{
|
||||
using var range = sheet.Cells[fromRow, fromCol, toRow, toCol];
|
||||
range.Style.Font.Name = "微软雅黑";
|
||||
range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
range.Style.Font.Size = 14;
|
||||
range.Style.Font.Bold = true;
|
||||
range.Style.Border.Top.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Left.Style = ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Right.Style = ExcelBorderStyle.Thin;
|
||||
//range.SetBackgroundColor(System.Drawing.SelectedColor.FromArgb(142, 169, 219));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建Excel文件添加Excel表格
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="sheetName"></param>
|
||||
/// <param name="action"></param>
|
||||
public static void WriteExcel(string filePath, string sheetName, Action<ExcelPackage> action)
|
||||
{
|
||||
using ExcelPackage package = new();
|
||||
var sheet = package.Workbook.Worksheets.Add(sheetName);
|
||||
|
||||
using Stream stream = new FileStream(filePath, FileMode.Create);
|
||||
action(package);
|
||||
package.SaveAs(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入Excel
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="action"></param>
|
||||
public static void WriteExcel(string filePath, Action<ExcelPackage> action)
|
||||
{
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
try
|
||||
{
|
||||
fileInfo.Delete();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
throw new IOException("文件正在使用");
|
||||
}
|
||||
using ExcelPackage package = new(fileInfo);
|
||||
action(package);
|
||||
package.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
using ExcelPackage package = new(fileInfo);
|
||||
action(package);
|
||||
package.Save();
|
||||
//throw new ArgumentNullException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>b8ac2442-3cc7-4ece-bd67-d78b8d19e394</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>Sai.Toolkit.Core</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\DistinctExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ThumbnailOptions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\SingletonChildWindowManager.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\EnumHelpers.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\DataTableExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\GdiHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\ConfigHelpers.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\IOHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\EPPlusHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\IniHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\LogHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\ValidatorHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\WinDialogHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\XmlHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ImageExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\WindowsThumbnailProvider.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\FileEncryptHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\StringHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Heplers\SingletonViewHelper.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,22 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
||||
public sealed class GreaterThanAttribute : ValidationAttribute
|
||||
{
|
||||
public GreaterThanAttribute(string propertyName)
|
||||
{
|
||||
PropertyName = propertyName;
|
||||
}
|
||||
|
||||
public string PropertyName { get; }
|
||||
|
||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
object instance = validationContext.ObjectInstance,
|
||||
otherValue = instance.GetType().GetProperty(PropertyName).GetValue(instance);
|
||||
|
||||
return ((IComparable)value).CompareTo(otherValue) > 0 ? ValidationResult.Success : new($"当前值小于{value}");
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
|
||||
public class ComparisonConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// 模型属性到控件属性
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="targetType"></param>
|
||||
/// <param name="parameter"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <returns></returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
//value:ViewModel属性,枚举/数字/字符串
|
||||
//parameter:ConverterParameter,枚举/数字/字符串
|
||||
//return (string)parameter == (string)value;
|
||||
//绑定的枚举属性与控件转换参数一致则选中
|
||||
return value.Equals(parameter);
|
||||
//return (string)parameter == (string)value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控件选中,将Converter参数传给模型属性
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="targetType"></param>
|
||||
/// <param name="parameter"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <returns></returns>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
//value:bool 比如RadioButton的check属性
|
||||
//parameter:ConverterParameter枚举
|
||||
//一样才传递给ViewModel
|
||||
//选中则返回枚举类
|
||||
return value is true ? parameter : Binding.DoNothing;
|
||||
//return (bool)value ? parameter : Binding.DoNothing;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
|
||||
public class HasSelectedItemConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value == null ? false : (object)true;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// 未选择或选择为空时,不可用
|
||||
/// </summary>
|
||||
public class Null2EnableConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (int)value != -1;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
|
||||
public class RenameConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var modifyFamilyName = values[0].ToString();
|
||||
var familyName = values[1].ToString();
|
||||
var symbolName = values[2].ToString();
|
||||
string searchText = values[3] as string;
|
||||
string mapString = string.Empty;
|
||||
if (string.IsNullOrEmpty(searchText))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (modifyFamilyName)
|
||||
{
|
||||
case "0":
|
||||
if (string.IsNullOrEmpty(familyName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mapString = familyName;
|
||||
break;
|
||||
case "1":
|
||||
if (string.IsNullOrEmpty(symbolName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mapString = symbolName;
|
||||
break;
|
||||
}
|
||||
|
||||
return mapString.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
|
||||
public class StringsIsNotNullOrEmptyCheck : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
foreach (var item in values)
|
||||
{
|
||||
string s = item.ToString();
|
||||
if (string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
|
||||
public class TaskResultConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value is Task<string> val && val.IsCompleted ? val.Result : (object)null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>536597bd-5e53-4bb1-83dd-5637d3bbffa3</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>Sai.Toolkit.Mvvm</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)AttachedProps\TextSearch.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Attributes\GreaterThanAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Attributes\IsNumericAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Attributes\MaximumAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Attributes\MinimumAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Attributes\NotNullOrEmptyAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Attributes\UndefinedCharAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Behaviors\CloseOnClickBehaviour.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Behaviors\DropFileBehavior.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Behaviors\IValidationExceptionHandler.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Behaviors\ValidationRuleBehavior.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Behaviors\CloseByButtonBehavior.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Behaviors\CloseByPropertyBehavior.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BindingHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BindingProxy.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\InvertBooleanConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\ComparisonConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\EnumDescriptionConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\EnumSourceAndConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\HasSelectedItemConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\Null2EnableConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\RenameConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\SearchValueConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\StringsIsNotNullOrEmptyCheck.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\TaskResultConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Markup\EnumSourceExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ValidationRules\DoubleValidationRule.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ValidationRules\RangeVaildationRule.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ValidationRules\RequiredValidationRule.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ValidationRules\UndefinedCharRules.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>536597bd-5e53-4bb1-83dd-5637d3bbffa3</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<PropertyGroup />
|
||||
<Import Project="ShrlAlgo.Toolkit.Mvvm.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,520 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.ExtensibleStorage;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Assist;
|
||||
|
||||
/// <summary>
|
||||
/// 可扩展存储工具Schema框架->由字段Field组成,由Schema可以生成、构建Entity实体
|
||||
/// 层级关系:Entity->(Schema/Field定义)/Field属性-值
|
||||
/// 元素阵列不会复制扩展数据
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// <c>
|
||||
/// IList<string> list = new List<string> { "我的v1", "我的v2", "我的v3", "我的v4" };
|
||||
/// IDictionary<string, string> dict = new Dictionary<string, string>
|
||||
/// {
|
||||
/// { "p1", "v1" },
|
||||
/// { "p2", "v2" },
|
||||
/// { "p3", "v3" },
|
||||
/// { "p4", "v4" }
|
||||
/// };
|
||||
/// var builder = CreateSchemaBuilder(schemaName);
|
||||
/// //添加字段定义
|
||||
/// builder.AddSimpleField("simple", typeof(string));
|
||||
/// builder.AddArrayField("errorModels", typeof(string));
|
||||
/// builder.AddMapField("dict", typeof(string), typeof(string));
|
||||
/// builder.AddSingleField<string>("simple");
|
||||
/// builder.AddListField<string>("errorModels");
|
||||
/// builder.AddDictField<string, string>("dict");
|
||||
/// //创建Schema
|
||||
/// var schema = builder.CreateSchema();
|
||||
/// var entity = e.CreateEntity(schema);
|
||||
/// e.SetFieldValue("simple", "简单");
|
||||
/// e.SetFieldValue("errorModels", list);
|
||||
/// e.SetFieldValue("dict", dict);</c>
|
||||
/// </example>
|
||||
public static class ExtensibleStorageAssist
|
||||
{
|
||||
private static Entity GetEntity(this Schema schema, Element element)
|
||||
{
|
||||
if (element is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var entity = element.GetEntity(schema);
|
||||
if (entity.Schema is not null)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
entity = new Entity(schema);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建字典类型的字段
|
||||
/// </summary>
|
||||
/// <typeparam name="TK">key:Boolean, Byte, Int16, Int32, Float, Double, ElementId,GUID, String, XYZ, UV and Entity</typeparam>
|
||||
/// <typeparam name="TV">value:Boolean, Byte, Int16, Int32, Float, Double, ElementId,GUID, String, XYZ, UV and Entity</typeparam>
|
||||
/// <param name="schemaBuilder"></param>
|
||||
/// <param name="fieldName"></param>
|
||||
/// <param name="description">描述</param>
|
||||
/// <returns></returns>
|
||||
public static FieldBuilder AddDictField<TK, TV>(this SchemaBuilder schemaBuilder, string fieldName, string description = "")
|
||||
{
|
||||
if (schemaBuilder is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(schemaBuilder));
|
||||
}
|
||||
|
||||
if (fieldName is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fieldName));
|
||||
}
|
||||
|
||||
//if (!typeof(TK).IsPrimitive)
|
||||
// throw new NotSupportedException(nameof(TK));
|
||||
|
||||
//if (!typeof(TV).IsPrimitive)
|
||||
// throw new NotSupportedException(nameof(TV));
|
||||
if (description == string.Empty)
|
||||
{
|
||||
description = fieldName;
|
||||
}
|
||||
|
||||
var result = schemaBuilder.AddMapField(fieldName, typeof(TK), typeof(TV));
|
||||
|
||||
result.SetDocumentation(description);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建集合类型的字段
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Boolean, Byte, Int16, Int32, Float, Double, ElementId,GUID, String, XYZ, UV and Entity</typeparam>
|
||||
/// <param name="schemaBuilder"></param>
|
||||
/// <param name="fieldName"></param>
|
||||
/// <param name="description">描述</param>
|
||||
public static FieldBuilder AddListField<T>(this SchemaBuilder schemaBuilder, string fieldName, string description = "")
|
||||
{
|
||||
if (schemaBuilder is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(schemaBuilder));
|
||||
}
|
||||
|
||||
if (fieldName is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fieldName));
|
||||
}
|
||||
|
||||
//if (!typeof(Command).IsPrimitive)
|
||||
// throw new NotSupportedException(nameof(Command));
|
||||
|
||||
var result = schemaBuilder.AddArrayField(fieldName, typeof(T));
|
||||
if (description == string.Empty)
|
||||
{
|
||||
description = fieldName;
|
||||
}
|
||||
|
||||
result.SetDocumentation(description);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建简单类型的字段
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Boolean, Byte, Int16, Int32, Float, Double, ElementId,GUID, String, XYZ, UV and Entity</typeparam>
|
||||
/// <param name="schemaBuilder"></param>
|
||||
/// <param name="fieldName"></param>
|
||||
/// <param name="description">描述</param>
|
||||
/// <returns></returns>
|
||||
public static FieldBuilder AddSingleField<T>(this SchemaBuilder schemaBuilder, string fieldName, string description = "")
|
||||
{
|
||||
if (schemaBuilder is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(schemaBuilder));
|
||||
}
|
||||
|
||||
if (fieldName is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fieldName));
|
||||
}
|
||||
|
||||
//if (!typeof(Command).IsPrimitive)
|
||||
// throw new NotSupportedException(nameof(Command));
|
||||
|
||||
var result = schemaBuilder.AddSimpleField(fieldName, typeof(T));
|
||||
//result.SetUnitType(unitType);
|
||||
|
||||
if (description == string.Empty)
|
||||
{
|
||||
description = fieldName;
|
||||
}
|
||||
|
||||
result.SetDocumentation(description);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建元素扩展数据实体
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <param name="schema"></param>
|
||||
/// <returns></returns>
|
||||
public static Entity CreateEntity(this Element element, Schema schema)
|
||||
{
|
||||
Entity entity = new(schema);
|
||||
element.SetEntity(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建Schema
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
/// <returns></returns>
|
||||
public static Schema CreateSchema(this SchemaBuilder builder)
|
||||
{
|
||||
return builder?.Finish();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建参数的表
|
||||
/// </summary>
|
||||
/// <param name="schemaName"></param>
|
||||
/// <param name="accessLevel"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <returns></returns>
|
||||
public static SchemaBuilder CreateSchemaBuilder(string schemaName, AccessLevel accessLevel = AccessLevel.Public, string description = null)
|
||||
{
|
||||
if (schemaName is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(schemaName));
|
||||
}
|
||||
|
||||
SchemaBuilder builder = new(Guid.NewGuid());
|
||||
builder.SetReadAccessLevel(accessLevel);
|
||||
builder.SetWriteAccessLevel(accessLevel);
|
||||
builder.SetSchemaName(schemaName);
|
||||
description ??= schemaName;
|
||||
builder.SetDocumentation(description);
|
||||
#if USE_FORGETYPEID
|
||||
//roleFieldBuilder.SetSpec(SpecTypeId.Custom);//设置字段值的单位,并不是所有类型都需要单位
|
||||
|
||||
#else
|
||||
//roleFieldBuilder.SetUnitType(UnitType.UT_Undefined);//设置字段值的单位,并不是所有类型都需要单位
|
||||
//roleFieldBuilder1.SetUnitType(UnitType.UT_Undefined);//设置字段值的单位,并不是所有类型都需要单位
|
||||
//roleFieldBuilder2.SetUnitType(UnitType.UT_Undefined);//设置字段值的单位,并不是所有类型都需要单位
|
||||
|
||||
#endif
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除实体
|
||||
/// </summary>
|
||||
/// <param name="element">元素</param>
|
||||
/// <param name="fieldName">字段名</param>
|
||||
public static void DeleteEntityByFieldName(this Element element, string fieldName)
|
||||
{
|
||||
var schema = element.GetSchemaByFieldName(fieldName);
|
||||
if (schema != null)
|
||||
{
|
||||
element.DeleteEntity(schema);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除实体
|
||||
/// </summary>
|
||||
/// <param name="element">元素</param>
|
||||
/// <param name="schemaName">表名</param>
|
||||
public static void DeleteEntityBySchemaName(this Element element, string schemaName)
|
||||
{
|
||||
var schema = element.GetSchemaBySchemaName(schemaName);
|
||||
if (schema != null)
|
||||
{
|
||||
element.DeleteEntity(schema);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件级数据存储
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
/// <param name="schemaName"></param>
|
||||
/// <param name="fieldName"></param>
|
||||
/// <param name="fileName"></param>
|
||||
public static void GetDateStorage(Document doc, string schemaName, string fieldName, string fileName)
|
||||
{
|
||||
DataStorage storage = new FilteredElementCollector(doc).OfClass(typeof(DataStorage)).Cast<DataStorage>().First();
|
||||
Schema sch = Schema.ListSchemas().First(o => o.SchemaName == schemaName);
|
||||
Entity ent = storage.GetEntity(sch);
|
||||
byte[] bytes = ent.Get<byte[]>(sch.GetField(fieldName)).ToArray();
|
||||
using (FileStream fs = new(fileName, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
fs.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
MessageBox.Show("文件提取完毕!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取字段参数值
|
||||
/// </summary>
|
||||
/// <param name="element">元素</param>
|
||||
/// <param name="fieldName">字段名</param>
|
||||
public static T GetFieldValue<T>(this Element element, string fieldName)
|
||||
where T : new()
|
||||
{
|
||||
if (!typeof(T).IsPrimitive)
|
||||
{
|
||||
throw new NotSupportedException(nameof(T));
|
||||
}
|
||||
|
||||
T t = new();
|
||||
try
|
||||
{
|
||||
Schema schema = element.GetSchemaByFieldName(fieldName);
|
||||
Entity entity = element.GetEntity(schema);
|
||||
if (!entity.IsValid())
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
Field f = schema.GetField(fieldName);
|
||||
return entity.Get<T>(f);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取元素的所有字段值
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="e"></param>
|
||||
/// <returns></returns>
|
||||
public static List<T> GetFiledValues<T>(this Element e)
|
||||
{
|
||||
if (!typeof(T).IsPrimitive)
|
||||
{
|
||||
throw new NotSupportedException(nameof(T));
|
||||
}
|
||||
|
||||
List<T> storages = new();
|
||||
//方法一
|
||||
var schemaGuids = e.GetEntitySchemaGuids();
|
||||
foreach (var schemaGuid in schemaGuids)
|
||||
{
|
||||
Schema schema = Schema.Lookup(schemaGuid);
|
||||
Entity ent = e.GetEntity(schema);
|
||||
if (!ent.IsValid())
|
||||
{
|
||||
return storages;
|
||||
}
|
||||
|
||||
IList<Field> fields = schema.ListFields();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var f = ent.Get<T>(field);
|
||||
storages.Add(f);
|
||||
}
|
||||
}
|
||||
|
||||
//if (storages.Count == 0)
|
||||
//{
|
||||
// //方法二
|
||||
// //从内存中获取 Schema 列表
|
||||
// IList<Schema> schemas = Schema.ListSchemas();
|
||||
// //从 Schema 中获取 Field 列表
|
||||
// foreach (var schema in schemas)
|
||||
// {
|
||||
// IList<Field> fields = schema.ListFields();
|
||||
// Entity ent = e.GetEntity(schema);
|
||||
// foreach (var field in fields)
|
||||
// {
|
||||
// var f = ent.Get<Command>(field);
|
||||
// storages.Add(f);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
return storages;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过字段名称获取Schema
|
||||
/// </summary>
|
||||
/// <param name="elm"></param>
|
||||
/// <param name="fieldName"></param>
|
||||
/// <returns></returns>
|
||||
public static Schema GetSchemaByFieldName(this Element elm, string fieldName)
|
||||
{
|
||||
if (elm is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(elm));
|
||||
}
|
||||
|
||||
if (fieldName is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fieldName));
|
||||
}
|
||||
|
||||
var schemaGuids = elm.GetEntitySchemaGuids();
|
||||
|
||||
return schemaGuids.Select(Schema.Lookup).FirstOrDefault(f => f.GetField(fieldName) != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过Schema名称获取Schema
|
||||
/// </summary>
|
||||
/// <param name="elm"></param>
|
||||
/// <param name="schemaName"></param>
|
||||
/// <returns></returns>
|
||||
public static Schema GetSchemaBySchemaName(this Element elm, string schemaName)
|
||||
{
|
||||
if (elm is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(elm));
|
||||
}
|
||||
|
||||
if (schemaName is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(schemaName));
|
||||
}
|
||||
|
||||
var schemaGuids = elm.GetEntitySchemaGuids();
|
||||
|
||||
return schemaGuids.Select(Schema.Lookup).FirstOrDefault(f => f.SchemaName == schemaName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从元素中读取schema中存储的值
|
||||
/// </summary>
|
||||
/// <param name="element">存储数据的元素</param>
|
||||
/// <param name="schema">Existing schema</param>
|
||||
/// <param name="fieldName">The Field name</param>
|
||||
/// <typeparam name="T">schema中要存储的数据类型。该类型必须与schemabuilder中指定的数据类型相匹配。</typeparam>
|
||||
/// <returns>存储在元素中的数据。如果字段不存在或数据尚未保存,则返回空值</returns>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// document.ProjectInformation.LoadEntity<string<(schema, "schemaField")
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static T LoadEntity<T>(this Element element, Schema schema, string fieldName)
|
||||
{
|
||||
var field = schema.GetField(fieldName);
|
||||
var entity = schema.GetEntity(element);
|
||||
return entity is null || field is null ? default : entity.Get<T>(field);
|
||||
}
|
||||
/// <summary>
|
||||
/// 在元素中存储数据。现有数据将被覆盖
|
||||
/// </summary>
|
||||
/// <param name="element">存储数据的元素</param>
|
||||
/// <param name="schema">Existing schema</param>
|
||||
/// <param name="data">Type of data</param>
|
||||
/// <param name="fieldName">The Field name</param>
|
||||
/// <typeparam name="T">The type of data to be stored in the schema. The type must match the type of data specified in the SchemaBuilder</typeparam>
|
||||
/// <returns>True if entity save succeeded</returns>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// document.ProjectInformation.SaveEntity(schema, "data", "schemaField")
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// <summary>
|
||||
public static bool SaveEntity<T>(this Element element, Schema schema, T data, string fieldName)
|
||||
{
|
||||
var field = schema.GetField(fieldName);
|
||||
if (field is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var entity = schema.GetEntity(element);
|
||||
if (entity is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
entity.Set(field, data);
|
||||
element.SetEntity(entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置文件级别数据存储
|
||||
/// </summary>
|
||||
/// <param name="doc"></param>
|
||||
/// <param name="fileName"></param>
|
||||
public static void SetDateStorage(Document doc, string fileName)
|
||||
{
|
||||
Transaction tran = new(doc, "BIM");
|
||||
tran.Start();
|
||||
//项目文档中使用扩展数据,可以使用静态方法创建
|
||||
DataStorage store = DataStorage.Create(doc);
|
||||
Schema schema;
|
||||
using (SchemaBuilder schemaBuilder = new(new Guid(Guid.NewGuid().ToString("D"))))
|
||||
{
|
||||
schemaBuilder.SetReadAccessLevel(AccessLevel.Public);
|
||||
schemaBuilder.SetWriteAccessLevel(AccessLevel.Public);
|
||||
schemaBuilder.SetSchemaName("LeiFile");
|
||||
schemaBuilder.SetDocumentation("DataStorageFile");
|
||||
|
||||
FieldBuilder arrayField = schemaBuilder.AddArrayField("data", typeof(byte));
|
||||
arrayField.SetDocumentation("Store file data");
|
||||
|
||||
schema = schemaBuilder.Finish();
|
||||
}
|
||||
|
||||
byte[] data;
|
||||
using (FileStream stream = new(fileName, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
data = new byte[(int)stream.Length];
|
||||
stream.Read(data, 0, data.Length);
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
Entity entity = new(schema);
|
||||
Field field = schema.GetField("data");
|
||||
entity.Set(field, data);
|
||||
store.SetEntity(entity);
|
||||
MessageBox.Show("文件存储成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
tran.Commit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置可扩展参数的值:简单类型、集合、字典(这一步骤涉及对文档的修改,需在事务中进行)
|
||||
/// </summary>
|
||||
/// <param name="element">元素</param>
|
||||
/// <param name="fieldName">字段</param>
|
||||
/// <param name="value">字段值</param>
|
||||
public static void SetFieldValue<T>(this Element element, string fieldName, T value)
|
||||
{
|
||||
Schema schema = element.GetSchemaByFieldName(fieldName);
|
||||
var entity = element.GetEntity(schema);
|
||||
Field field = schema.GetField(fieldName);
|
||||
entity.Set(field, value);
|
||||
element.SetEntity(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置可扩展参数的值:简单类型、集合、字典(这一步骤涉及对文档的修改,需在事务中进行)
|
||||
/// </summary>
|
||||
/// <param name="element">元素</param>
|
||||
/// <param name="schema"></param>
|
||||
/// <param name="fieldName">字段</param>
|
||||
/// <param name="value">字段值</param>
|
||||
public static void SetFieldValue<T>(this Element element, Schema schema, string fieldName, T value)
|
||||
{
|
||||
var entity = element.GetEntity(schema);
|
||||
Field field = schema.GetField(fieldName);
|
||||
entity.Set(field, value);
|
||||
element.SetEntity(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Assist;
|
||||
|
||||
public static class ImageAssist
|
||||
{
|
||||
/// <summary>
|
||||
/// 解压资源
|
||||
/// </summary>
|
||||
/// <param name="resourceName"></param>
|
||||
/// <param name="path"></param>
|
||||
public static void ExtractResource(string resourceName, string path)
|
||||
{
|
||||
using var manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
|
||||
using Stream stream = File.Create(path);
|
||||
var array = new byte[8192];
|
||||
int count;
|
||||
while ((count = manifestResourceStream.Read(array, 0, array.Length)) > 0)
|
||||
{
|
||||
stream.Write(array, 0, count);
|
||||
}
|
||||
}
|
||||
|
||||
public static BitmapImage ToBitmapImage(this Bitmap bitmap)
|
||||
{
|
||||
if (bitmap is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(bitmap));
|
||||
}
|
||||
|
||||
using var ms = new MemoryStream();
|
||||
bitmap.Save(ms, ImageFormat.Png);
|
||||
|
||||
ms.Position = 0;
|
||||
|
||||
var result = new BitmapImage();
|
||||
|
||||
result.BeginInit();
|
||||
|
||||
result.StreamSource = ms;
|
||||
|
||||
result.CacheOption = BitmapCacheOption.OnLoad;
|
||||
|
||||
result.EndInit();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static BitmapSource ToBitmapSource(this Bitmap bitmap)
|
||||
{
|
||||
return bitmap == null
|
||||
? null
|
||||
: Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Icon转BitmapSource
|
||||
/// </summary>
|
||||
/// <param name="icon"></param>
|
||||
/// <returns></returns>
|
||||
public static BitmapSource ToBitmapSource(this Icon icon)
|
||||
{
|
||||
return Imaging.CreateBitmapSourceFromHIcon(
|
||||
icon.Handle,
|
||||
new Int32Rect(0, 0, icon.Width, icon.Height),
|
||||
BitmapSizeOptions.FromWidthAndHeight(icon.Width, icon.Height)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Assist
|
||||
{
|
||||
internal class JIGAssist
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,279 +0,0 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Assist;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 房间类的扩展
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>房间的边界外圈是逆时针,所有内圈是顺时针,墙体相交会导致边界线被切分</para>
|
||||
///<para>底部偏移 item.Room.BaseOffset = baseOffset;</para>
|
||||
///<para>高度偏移 item.Room.LimitOffset = baseOffset;</para>
|
||||
///<para>全部高度 item.Room.UnboundedHeight,顶部-底部;</para>
|
||||
/// </remarks>
|
||||
public static class RoomAssist
|
||||
{
|
||||
/// <summary>
|
||||
/// 墙饰面
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <param name="height"></param>
|
||||
/// <param name="newWallType"></param>
|
||||
/// <returns>墙饰面与房间边界的字典</returns>
|
||||
public static Dictionary<ElementId, ElementId> CreateWalls(this Room room, double height, WallType newWallType)
|
||||
{
|
||||
var doc = newWallType.Document;
|
||||
var dictionary = new Dictionary<ElementId, ElementId>();
|
||||
var levelId = room.LevelId;
|
||||
var boundarySegments = room.GetBoundarySegments(
|
||||
new SpatialElementBoundaryOptions { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish }
|
||||
);
|
||||
if (boundarySegments == null)
|
||||
{
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
foreach (var list in boundarySegments)
|
||||
{
|
||||
if (list.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var boundarySegment in list)
|
||||
{
|
||||
var element = doc.GetElement(boundarySegment.ElementId);
|
||||
if (element == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var category = doc.Settings.Categories.get_Item(BuiltInCategory.OST_RoomSeparationLines);
|
||||
if (element.Category.Id == category.Id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var wall = Wall.Create(doc, boundarySegment.GetCurve(), newWallType.Id, levelId, height, 0.0, false, false);
|
||||
wall.get_Parameter(BuiltInParameter.WALL_KEY_REF_PARAM).Set(2);
|
||||
dictionary.Add(wall.Id, boundarySegment.ElementId);
|
||||
}
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建房间的内建模型
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public static DirectShape CreateSolid(this Room room)
|
||||
{
|
||||
return RoomSolid(room, room.GetBoundaryCurveLoops());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到房间边界的线串
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public static List<CurveLoop> GetBoundaryCurveLoops(this Room room)
|
||||
{
|
||||
var boundary = room.GetBoundarySegments(Options());
|
||||
var list = new List<CurveLoop>();
|
||||
if (boundary.Count != 0)
|
||||
{
|
||||
foreach (var list2 in boundary)
|
||||
{
|
||||
var curveLoop = new CurveLoop();
|
||||
foreach (var boundarySegment in list2)
|
||||
{
|
||||
curveLoop.Append(boundarySegment.GetCurve());
|
||||
}
|
||||
|
||||
list.Add(curveLoop);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 房间边界组成的元素集合
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Element> GetBoundaryElementList(this SpatialElement room)
|
||||
{
|
||||
if (room is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(room));
|
||||
}
|
||||
|
||||
var results = new List<Element>();
|
||||
|
||||
var segments = room.GetBoundarySegments(Options()).SelectMany(s => s);
|
||||
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
if (segment.ElementId==ElementId.InvalidElementId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (results.FirstOrDefault(f => f.Id == segment.ElementId) != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var elm = room.Document.GetElement(segment.ElementId);
|
||||
|
||||
results.Add(elm);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 房间边界的对应字典(元素-曲线)集合
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<Element, Curve> GetElementCurveDict(this Room room)
|
||||
{
|
||||
if (room is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(room));
|
||||
}
|
||||
|
||||
var doc = room.Document;
|
||||
if (doc is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(doc));
|
||||
}
|
||||
|
||||
var segments = room.GetBoundarySegments(Options()).SelectMany(s => s);
|
||||
|
||||
return segments.ToDictionary(k => doc.GetElement(k.ElementId), v => v.GetCurve());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取房间几何体相交的元素
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public static FilteredElementCollector GetIntersectElements(this Room room)
|
||||
{
|
||||
var doc = room.Document;
|
||||
var solid = new SpatialElementGeometryCalculator(doc).CalculateSpatialElementGeometry(room).GetGeometry();
|
||||
ElementIntersectsSolidFilter filter = new(solid);
|
||||
return new FilteredElementCollector(doc).WherePasses(filter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取房间最外侧边界
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public static CurveArray GetOuterBoundary(this Room room)
|
||||
{
|
||||
var allCurves = new CurveArray();
|
||||
var boundarySegments = room.GetBoundarySegments(Options()).First();
|
||||
foreach (var bs in boundarySegments)
|
||||
{
|
||||
allCurves.Append(bs.GetCurve());
|
||||
}
|
||||
|
||||
return allCurves;
|
||||
}
|
||||
|
||||
private static SpatialElementBoundaryOptions Options()
|
||||
{
|
||||
return new SpatialElementBoundaryOptions { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取房间的几何体
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public static Solid GetSolid(this Room room)
|
||||
{
|
||||
var doc = room.Document;
|
||||
var segc = new SpatialElementGeometryCalculator(doc);
|
||||
|
||||
var segr = segc.CalculateSpatialElementGeometry(room);
|
||||
|
||||
return segr.GetGeometry();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到房间的三位实体
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <param name="curveLoops"></param>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
private static DirectShape RoomSolid(Room room, List<CurveLoop> curveLoops, Material material = null)
|
||||
{
|
||||
var doc = room.Document;
|
||||
var height = room.get_Parameter(BuiltInParameter.ROOM_HEIGHT).AsDouble();
|
||||
var options =
|
||||
material == null
|
||||
? new SolidOptions(ElementId.InvalidElementId, ElementId.InvalidElementId)
|
||||
: new SolidOptions(material.Id, ElementId.InvalidElementId);
|
||||
options = new SolidOptions(material.Id, ElementId.InvalidElementId);
|
||||
var solid = GeometryCreationUtilities.CreateExtrusionGeometry(curveLoops, XYZ.BasisZ, height);
|
||||
|
||||
var ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
|
||||
ds.SetName(room.Name);
|
||||
var option = ds.GetOptions();
|
||||
option.ReferencingOption = DirectShapeReferencingOption.NotReferenceable;
|
||||
ds.SetOptions(option);
|
||||
ds.AppendShape(new List<GeometryObject> { solid });
|
||||
room.Document.Regenerate();
|
||||
var elements = new FilteredElementCollector(doc);
|
||||
var solidFillPattern = elements.OfClass(typeof(FillPatternElement)).Cast<FillPatternElement>().First(a => a.GetFillPattern().IsSolidFill);
|
||||
|
||||
var random = new Random(DateTime.Now.Millisecond);
|
||||
var r = Convert.ToByte(random.Next(0, 255));
|
||||
var g = Convert.ToByte(random.Next(0, 255));
|
||||
var b = Convert.ToByte(random.Next(0, 255));
|
||||
var color = new Color(r, g, b);
|
||||
var ogs = new OverrideGraphicSettings();
|
||||
ogs.SetProjectionLineColor(color);
|
||||
#if REVIT2018
|
||||
ogs.SetSurfaceTransparency(50);
|
||||
ogs.SetProjectionFillColor(color);
|
||||
ogs.SetProjectionFillPatternId(solidFillPattern.Id);
|
||||
|
||||
ogs.SetCutFillColor(color);
|
||||
ogs.SetCutFillPatternId(solidFillPattern.Id);
|
||||
doc.ActiveView.SetElementOverrides(ds.Id, ogs);
|
||||
#else
|
||||
ogs.SetSurfaceBackgroundPatternColor(color);
|
||||
ogs.SetSurfaceForegroundPatternId(solidFillPattern.Id);
|
||||
ogs.SetSurfaceForegroundPatternColor(color);
|
||||
|
||||
ogs.SetCutBackgroundPatternColor(color);
|
||||
ogs.SetCutForegroundPatternColor(color);
|
||||
ogs.SetCutForegroundPatternId(solidFillPattern.Id);
|
||||
ogs.SetSurfaceTransparency(50);
|
||||
doc.ActiveView.SetElementOverrides(ds.Id, ogs);
|
||||
#endif
|
||||
//foreach (Face face in solid.Faces)
|
||||
//{
|
||||
// room.Document.Paint(ds.Id,,);
|
||||
// //PlanarFace pf = face as PlanarFace;
|
||||
// //if (pf.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ))
|
||||
// //{
|
||||
// // array.Append(face);
|
||||
// // break;
|
||||
// //}
|
||||
//}
|
||||
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态模型更新
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public static class DMUAssist
|
||||
{
|
||||
public static void AddTrigger(this IUpdater updater, Document document, ElementFilter filter, ChangeType change)
|
||||
{
|
||||
UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), document, filter, change);
|
||||
}
|
||||
}
|
||||
|
||||
public class Updater : IUpdater
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序范围的动态模型更新
|
||||
/// </summary>
|
||||
/// <param name="UiApplication"></param>
|
||||
/// <param name="guid"></param>
|
||||
/// <param name="execute"></param>
|
||||
/// <param name="isOptional">true:只在本次生效,下次需要重新注册(不会发出警告)</param>
|
||||
/// <param name="updateInfo"></param>
|
||||
public Updater(UIApplication UiApplication, Guid guid, Action<UpdaterData> execute, bool isOptional = true, string updateInfo = "DynamicModelUpdate")
|
||||
{
|
||||
updaterId = new UpdaterId(UiApplication.ActiveAddInId, guid);
|
||||
this.action = execute;
|
||||
this.updateInfo = updateInfo;
|
||||
if (!UpdaterRegistry.IsUpdaterRegistered(updaterId))
|
||||
{
|
||||
UpdaterRegistry.RegisterUpdater(this, isOptional);
|
||||
|
||||
/*
|
||||
* 对FamilyInstance元素的增加和删除监听
|
||||
*
|
||||
* 如果需要关注某些有自己程序创建出来的Element,可以把每个Element附上扩展数据
|
||||
* 然后使用ExtensibleStorageFilter过滤器注册DMU即可
|
||||
*
|
||||
* DUM对用户的Ctrl + Z 无效, 可以在DocumentChanged事件中完善该机制
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Action<UpdaterData> action;
|
||||
private readonly string updateInfo;
|
||||
private readonly UpdaterId updaterId;
|
||||
/// <summary>
|
||||
/// 当注册的元素发生ChangeType触发时,回调的函数
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void Execute(UpdaterData data)
|
||||
{
|
||||
//var rvtDoc = data.GetDocument();
|
||||
|
||||
//var idsModified = data.GetModifiedElementIds();
|
||||
//var idsDeleted = data.GetDeletedElementIds();
|
||||
//var idsAdded = data.GetAddedElementIds();
|
||||
//可以根据类型、元素Id、过滤器等等,分情况执行更新的操作
|
||||
action(data);
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
UpdaterRegistry.EnableUpdater(updaterId);
|
||||
}
|
||||
public void Disable()
|
||||
{
|
||||
if (UpdaterRegistry.IsUpdaterEnabled(updaterId))
|
||||
{
|
||||
UpdaterRegistry.DisableUpdater(updaterId);
|
||||
}
|
||||
}
|
||||
#region 接口实现
|
||||
public string GetAdditionalInformation()
|
||||
{
|
||||
return updateInfo;
|
||||
}
|
||||
|
||||
public ChangePriority GetChangePriority()
|
||||
{
|
||||
return ChangePriority.FreeStandingComponents;
|
||||
}
|
||||
|
||||
public UpdaterId GetUpdaterId()
|
||||
{
|
||||
return updaterId;
|
||||
}
|
||||
|
||||
public string GetUpdaterName()
|
||||
{
|
||||
return updateInfo;
|
||||
}
|
||||
#endregion
|
||||
public void RemoveAllTriggers()
|
||||
{
|
||||
UpdaterRegistry.RemoveAllTriggers(updaterId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加动态更新的对象和修改的类型的触发器
|
||||
/// </summary>
|
||||
/// <typeparam name="T">元素类型</typeparam>
|
||||
/// <param name="change">修改的类型</param>
|
||||
public void AddClassTrigger<T>(ChangeType change)
|
||||
{
|
||||
var filter = new ElementClassFilter(typeof(T));
|
||||
UpdaterRegistry.AddTrigger(updaterId, filter, change);
|
||||
}
|
||||
public void AddFilterTrigger<T>(ElementFilter filter, ChangeType change)
|
||||
{
|
||||
UpdaterRegistry.AddTrigger(updaterId, filter, change);
|
||||
}
|
||||
|
||||
public void UnRegister()
|
||||
{
|
||||
UpdaterRegistry.UnregisterUpdater(updaterId);
|
||||
}
|
||||
}
|
||||
|
||||
//internal class test
|
||||
//{
|
||||
// private readonly ChangeType change = null;
|
||||
// private readonly ICollection<ElementId> elements = null;
|
||||
// private readonly uiApplication uiApplication = null;
|
||||
// private Guid guid = new();
|
||||
|
||||
// public void MyMethod()
|
||||
|
||||
// {
|
||||
// var guid = new Guid();
|
||||
// Updater updater = new Updater
|
||||
// {
|
||||
// addinID = null,
|
||||
// Guid = guid
|
||||
// };
|
||||
|
||||
// DMUAssist<Updater> dynamicModel =
|
||||
// new DMUAssist<Updater>(uiApplication, elements, change);
|
||||
|
||||
// dynamicModel.UseUpdater();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
using System.Reflection;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
internal class EncryptParameters
|
||||
{
|
||||
public static bool InvokeModule(string mName, object[] parameters, bool apiModule = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
MethodInfo m;
|
||||
|
||||
if (apiModule)
|
||||
|
||||
m = NativeModule.GetApiModuleMethod(mName);
|
||||
else
|
||||
|
||||
m = NativeModule.GetUiModuleMethod(mName);
|
||||
|
||||
m.Invoke(null, parameters);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NativeModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取RevitAPI程序集Module内的方法名称.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public static MethodInfo GetApiModuleMethod(string name)
|
||||
{
|
||||
var module = GetApiModule();
|
||||
|
||||
var rs = module.GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Where(m => m.Name == name).ToList();
|
||||
|
||||
return !rs.Any() ? null : rs.First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取RevitAPIUI程序集Module内的方法名称.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public static MethodInfo GetUiModuleMethod(string name)
|
||||
{
|
||||
var module = GetUiModule();
|
||||
|
||||
var rs = module.GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Where(m => m.Name == name).ToList();
|
||||
return !rs.Any() ? null : rs.First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取RevitAPI Modules.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static Module GetApiModule()
|
||||
{
|
||||
return typeof(Document).Assembly.Modules.First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取RevitAPIUI Modules.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static Module GetUiModule()
|
||||
{
|
||||
return typeof(UIDocument).Assembly.Modules.First();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ParameterExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置参数对象对用户是否可见.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <param name="visible"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SetVisibility(this Parameter parameter, bool visible)
|
||||
{
|
||||
var parameterIntPtr = parameter.ToParamDef();
|
||||
|
||||
if (parameterIntPtr == IntPtr.Zero)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var result = EncryptParameters.InvokeModule("ParamDef.setUserVisible", new object[] { parameterIntPtr, visible });
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将参数对象转为非托管指针.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
public static IntPtr ToParamDef(this Parameter parameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var m = typeof(Parameter).GetMethod("getParamDef", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
return (m?.Invoke(parameter, null) as Pointer).ToIntPtr();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PointerExtension
|
||||
{
|
||||
/// 将指针转为句柄.
|
||||
/// <summary>
|
||||
/// 将指针转为句柄.
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
/// <returns></returns>
|
||||
public static IntPtr ToIntPtr(this Pointer p)
|
||||
{
|
||||
return (IntPtr)p.GetType().GetMethod("GetPointerValue", BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(p, null)!;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>38c42ba0-e9ca-4dbd-a912-a1bbc61a2e5a</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>Sai.Toolkit.Revit</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\CollectorAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ConnectorAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\DebugAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\DocumentAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\HostObjectAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ApplicationAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\JIGAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\KeyboardShortcutExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\DuplicateTypeNamesHandler.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ElementAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ExtensibleStorageAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\FamilyAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ImageAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ImportInstanceAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\LevelAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\MaterialAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\MEPAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\RoomAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ScheduleAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\SpatialAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\TransactionAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\UIAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\UIDocumentAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\UnitAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\ViewAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Assist\WallAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\BuiltEnumDictionary.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\DMUAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ElementOrientation.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\EnableAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\EncryptParameters.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ExtremeWallVariant.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\FailuresPreProcessor.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\FailuresPreprocessorHandler.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\Filters.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\FunctionByGuidLine.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\GeometryAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\KeyboardShortcutService.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\KeyIntPtrHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\LoadFamilyOptions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ShortcutRepAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\OptionsBarAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\RevitIniAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\StatusBarAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ParameterAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ViewFilterAssist.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\VisualAssist.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>38c42ba0-e9ca-4dbd-a912-a1bbc61a2e5a</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<PropertyGroup />
|
||||
<Import Project="ShrlAlgo.Toolkit.Revit.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers
|
||||
namespace ShrlAlgoToolkit.Core.Assists
|
||||
{
|
||||
public class ConfigHelpers
|
||||
public class ConfigAssist
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取项目文件夹下的配置文件根据Key获取Value
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public static class EnumHelpers
|
||||
public static class EnumAssist
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前枚举值的描述,没有描述则返回空字符串
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Windows;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public static class FileEncryptHelper
|
||||
public static class FileEncryptAssist
|
||||
{
|
||||
public static void DecryptFile(string strPath)
|
||||
{
|
||||
@@ -4,9 +4,9 @@ using Color = System.Drawing.Color;
|
||||
using Point = System.Drawing.Point;
|
||||
using Rectangle = System.Drawing.Rectangle;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public static class GdiHelper
|
||||
public static class GdiAssist
|
||||
{
|
||||
public static void DrawArc(Graphics graphics)
|
||||
{
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public static class IOHelper
|
||||
public static class IOAssist
|
||||
{
|
||||
public static void GetFilesHierarchy(string path)
|
||||
{
|
||||
44
ShrlAlgoToolkit.Core/Assists/ImageAssist.cs
Normal file
44
ShrlAlgoToolkit.Core/Assists/ImageAssist.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
public class ImageAssist
|
||||
{
|
||||
/// <summary>
|
||||
/// 提取资源
|
||||
/// </summary>
|
||||
/// <param name="resourceName"></param>
|
||||
/// <param name="path"></param>
|
||||
public static void ExtractResource(string resourceName, string path)
|
||||
{
|
||||
using var manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
|
||||
using var stream = File.Create(path);
|
||||
var array = new byte[8192];
|
||||
int count;
|
||||
while ((count = manifestResourceStream.Read(array, 0, array.Length)) > 0)
|
||||
{
|
||||
stream.Write(array, 0, count);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源管理器缩略图读取
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <param name="height"></param>
|
||||
/// <returns></returns>
|
||||
public static BitmapSource LoadFileImage(string filename, int width, int height)
|
||||
{
|
||||
var bm = WindowsThumbnailProvider.GetThumbnail(filename, width, height, ThumbnailOptions.None);
|
||||
return Imaging.CreateBitmapSourceFromHBitmap(bm.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public class IniHelper
|
||||
public class IniAssist
|
||||
{
|
||||
public IniHelper(string iniPath)
|
||||
public IniAssist(string iniPath)
|
||||
{
|
||||
path = iniPath;
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public static class LogHelper
|
||||
public static class LogAssist
|
||||
{
|
||||
//public static void WriteSeriLog(string path, string message)
|
||||
//{
|
||||
@@ -16,7 +16,7 @@ public static class LogHelper
|
||||
{
|
||||
if (logFolder == default)
|
||||
{
|
||||
var assemblyPath = typeof(LogHelper).Assembly.Location;
|
||||
var assemblyPath = typeof(LogAssist).Assembly.Location;
|
||||
var directory = Path.GetDirectoryName(assemblyPath);
|
||||
logFolder = Path.Combine(directory, "Logs");
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public static class LogHelper
|
||||
{
|
||||
if (logFolder == default)
|
||||
{
|
||||
var assemblyPath = typeof(LogHelper).Assembly.Location;
|
||||
var assemblyPath = typeof(LogAssist).Assembly.Location;
|
||||
var directory = Path.GetDirectoryName(assemblyPath);
|
||||
logFolder = $"{directory}\\Logs";
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public static class SingletonChildWindowManager
|
||||
{
|
||||
@@ -1,14 +1,14 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public sealed record SingletonViewHelper<T>
|
||||
public sealed record SingletonViewAssist<T>
|
||||
where T : Window, new()
|
||||
{
|
||||
private static T _instance;
|
||||
private static readonly object Padlock = new();
|
||||
|
||||
private SingletonViewHelper() { }
|
||||
private SingletonViewAssist() { }
|
||||
|
||||
public static T GetInstance(out bool isNewCreate)
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public class StringHelper
|
||||
public class StringAssist
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取大写字母列表
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace ShrlAlgo.Toolkit.Core.Extensions;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public enum ThumbnailOptions
|
||||
{
|
||||
@@ -2,12 +2,12 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// 各种验证帮助类
|
||||
/// </summary>
|
||||
internal class ValidatorHelper
|
||||
internal class ValidatorAssist
|
||||
{
|
||||
/// <summary>
|
||||
/// 验证用户名:必须以字母开头,可以包含字母、数字、“_”、“.”,至少5个字符
|
||||
@@ -3,7 +3,7 @@ using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Extensions;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// 获取Windows缩略图
|
||||
@@ -141,7 +141,7 @@ public class WindowsThumbnailProvider
|
||||
internal interface IShellItemImageFactory
|
||||
{
|
||||
[PreserveSig]
|
||||
HResult GetImage([In] [MarshalAs(UnmanagedType.Struct)] NativeSize size, [In] ThumbnailOptions flags, [Out] out IntPtr phbm);
|
||||
HResult GetImage([In] [MarshalAs(UnmanagedType.Struct)] NativeSize size, [In] ThumbnailOptions flags, [Out] out IntPtr phbm);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@@ -2,11 +2,11 @@
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Heplers;
|
||||
namespace ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
public class XmlHelper
|
||||
public class XmlAssist
|
||||
{
|
||||
public XmlHelper(string strPath)
|
||||
public XmlAssist(string strPath)
|
||||
{
|
||||
XmlPath = strPath;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Extensions;
|
||||
namespace ShrlAlgoToolkit.Core.Extensions;
|
||||
|
||||
public static class DataTableExtensions
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace ShrlAlgo.Toolkit.Core.Extensions;
|
||||
namespace ShrlAlgoToolkit.Core.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义Distinct扩展方法
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using ShrlAlgo.Toolkit.Core.Assist;
|
||||
using ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
@@ -8,95 +8,67 @@ using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Core.Extensions;
|
||||
namespace ShrlAlgoToolkit.Core.Extensions;
|
||||
|
||||
public static class ImageExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 提取资源
|
||||
/// </summary>
|
||||
/// <param name="resourceName"></param>
|
||||
/// <param name="path"></param>
|
||||
public static void ExtractResource(string resourceName, string path)
|
||||
{
|
||||
using var manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
|
||||
using var stream = File.Create(path);
|
||||
var array = new byte[8192];
|
||||
int count;
|
||||
while ((count = manifestResourceStream.Read(array, 0, array.Length)) > 0)
|
||||
{
|
||||
stream.Write(array, 0, count);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源管理器缩略图读取
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <param name="height"></param>
|
||||
/// <returns></returns>
|
||||
public static BitmapSource LoadFileImage(string filename, int width, int height)
|
||||
{
|
||||
var bm = WindowsThumbnailProvider.GetThumbnail(filename, width, height, ThumbnailOptions.None);
|
||||
return Imaging.CreateBitmapSourceFromHBitmap(bm.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 位图转图片
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static BitmapImage ToBitmapImage(this Bitmap bitmap)
|
||||
{
|
||||
if (bitmap is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(bitmap));
|
||||
}
|
||||
public static BitmapImage ToBitmapImage(this Bitmap bitmap)
|
||||
{
|
||||
if (bitmap is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(bitmap));
|
||||
}
|
||||
|
||||
using var ms = new MemoryStream();
|
||||
bitmap.Save(ms, ImageFormat.Png);
|
||||
using var ms = new MemoryStream();
|
||||
bitmap.Save(ms, ImageFormat.Png);
|
||||
|
||||
ms.Position = 0;
|
||||
ms.Position = 0;
|
||||
|
||||
var result = new BitmapImage();
|
||||
var result = new BitmapImage();
|
||||
|
||||
result.BeginInit();
|
||||
result.BeginInit();
|
||||
|
||||
result.StreamSource = ms;
|
||||
result.StreamSource = ms;
|
||||
|
||||
result.CacheOption = BitmapCacheOption.OnLoad;
|
||||
result.CacheOption = BitmapCacheOption.OnLoad;
|
||||
|
||||
result.EndInit();
|
||||
result.EndInit();
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 位图转像素集
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static BitmapSource ToBitmapSource(this Bitmap bitmap)
|
||||
{
|
||||
if (bitmap == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(bitmap));
|
||||
}
|
||||
return Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
public static BitmapSource ToBitmapSource(this Bitmap bitmap)
|
||||
{
|
||||
return bitmap == null
|
||||
? null
|
||||
: Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Icon转BitmapSource
|
||||
/// </summary>
|
||||
/// <param name="icon"></param>
|
||||
/// <returns></returns>
|
||||
public static BitmapSource ToBitmapSource(this Icon icon)
|
||||
{
|
||||
return Imaging.CreateBitmapSourceFromHIcon(
|
||||
icon.Handle,
|
||||
new Int32Rect(0, 0, icon.Width, icon.Height),
|
||||
BitmapSizeOptions.FromWidthAndHeight(icon.Width, icon.Height)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Icon转BitmapSource
|
||||
/// </summary>
|
||||
/// <param name="icon"></param>
|
||||
/// <returns></returns>
|
||||
public static BitmapSource ToBitmapSource(this Icon icon)
|
||||
{
|
||||
return Imaging.CreateBitmapSourceFromHIcon(
|
||||
icon.Handle,
|
||||
new Int32Rect(0, 0, icon.Width, icon.Height),
|
||||
BitmapSizeOptions.FromWidthAndHeight(icon.Width, icon.Height)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
33
ShrlAlgoToolkit.Core/Properties/AssemblyInfo.cs
Normal file
33
ShrlAlgoToolkit.Core/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("ShrlAlgoToolkit.Core")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ShrlAlgoToolkit.Core")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("8a9a4000-093e-498e-a620-5a035f76c520")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -9,7 +9,6 @@
|
||||
<UseWPF>True</UseWPF>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<RootNamespace>ShrlAlgo.Toolkit.Core</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm
|
||||
namespace ShrlAlgoToolkit.Mvvm.Assists
|
||||
{
|
||||
public static class BindingHelper
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm
|
||||
namespace ShrlAlgoToolkit.Mvvm.Assists
|
||||
{
|
||||
/// <summary>
|
||||
/// 绑定代理,用来传递绑定对象
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.AttachedProps;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Attach;
|
||||
|
||||
public class TextSearch
|
||||
{
|
||||
22
ShrlAlgoToolkit.Mvvm/Attributes/GreaterThanAttribute.cs
Normal file
22
ShrlAlgoToolkit.Mvvm/Attributes/GreaterThanAttribute.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ShrlAlgoToolkit.Mvvm.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
||||
public sealed class GreaterThanAttribute : ValidationAttribute
|
||||
{
|
||||
public GreaterThanAttribute(string propertyName)
|
||||
{
|
||||
PropertyName = propertyName;
|
||||
}
|
||||
|
||||
public string PropertyName { get; }
|
||||
|
||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
object instance = validationContext.ObjectInstance,
|
||||
otherValue = instance.GetType().GetProperty(PropertyName).GetValue(instance);
|
||||
|
||||
return ((IComparable)value).CompareTo(otherValue) > 0 ? ValidationResult.Success : new($"当前值小于{value}");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Attributes;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
||||
public sealed class IsNumericAttribute : ValidationAttribute
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Attributes;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
||||
public sealed class MaximumAttribute : ValidationAttribute
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Attributes;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
||||
public sealed class MinimumAttribute : ValidationAttribute
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Attributes;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
||||
public sealed class NotNullOrEmptyAttribute : ValidationAttribute
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Attributes
|
||||
namespace ShrlAlgoToolkit.Mvvm.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
||||
public class UndefinedCharAttribute : ValidationAttribute
|
||||
@@ -3,7 +3,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Behaviors;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Behaviors;
|
||||
|
||||
//<Windows x:Class="WpfApplication6.Window1"
|
||||
// xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Behaviors;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Behaviors;
|
||||
|
||||
/// <summary>
|
||||
/// 通过设置属性值,关闭窗口
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Behaviors;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Behaviors;
|
||||
|
||||
/// <summary>
|
||||
/// 关闭窗口
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Behaviors;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Behaviors;
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ק<EFBFBD>ļ<EFBFBD><C4BC>¼<EFBFBD>
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Behaviors;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Behaviors;
|
||||
|
||||
public interface IValidationExceptionHandler
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Behaviors;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Behaviors;
|
||||
|
||||
/// <summary>
|
||||
/// 在xaml的资源中声明,viewModel继承IValidationExceptionHandler,通过IsValid判断能否执行
|
||||
@@ -3,7 +3,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
|
||||
namespace Sai.Toolkit.Mvvm.Behaviors;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Behaviors;
|
||||
|
||||
//<Window x:Class="WpfApplication6.Window1"
|
||||
// xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
43
ShrlAlgoToolkit.Mvvm/Converters/ComparisonConverter.cs
Normal file
43
ShrlAlgoToolkit.Mvvm/Converters/ComparisonConverter.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgoToolkit.Mvvm.Converters;
|
||||
|
||||
public class ComparisonConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Model属性->Control属性
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="targetType"></param>
|
||||
/// <param name="parameter"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <returns></returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
//value:ViewModel属性,枚举/数字/字符串
|
||||
//parameter:ConverterParameter,枚举/数字/字符串
|
||||
//return (string)parameter == (string)value;
|
||||
//绑定的枚举属性与控件转换参数一致则选中
|
||||
return value.Equals(parameter);
|
||||
//return (string)parameter == (string)value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控件选中,将Converter参数传给模型属性
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="targetType"></param>
|
||||
/// <param name="parameter"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <returns></returns>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
//value:bool 比如RadioButton的check属性
|
||||
//parameter:ConverterParameter枚举
|
||||
//一样才传递给ViewModel
|
||||
//选中则返回枚举类
|
||||
return value is true ? parameter : Binding.DoNothing;
|
||||
//return (bool)value ? parameter : Binding.DoNothing;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,9 @@
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// 枚举描述转换
|
||||
/// </summary>
|
||||
public class EnumDescriptionConverter : IValueConverter
|
||||
{
|
||||
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var myEnum = (Enum)value;
|
||||
var description = GetEnumDescription(myEnum);
|
||||
return description;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string GetEnumDescription(Enum enumObj)
|
||||
{
|
||||
var fieldInfo = enumObj.GetType().GetField(enumObj.ToString());
|
||||
var descriptionAttr = fieldInfo.GetCustomAttributes(false).OfType<DescriptionAttribute>().SingleOrDefault();
|
||||
return descriptionAttr == null ? enumObj.ToString() : descriptionAttr.Description;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 枚举类上加特性[TypeConverter(typeof(EnumDescriptionTypeConverter))]
|
||||
/// </summary>
|
||||
@@ -4,7 +4,7 @@ using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// Description(描述特性)的枚举转换同时也是枚举源的集合
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Converters;
|
||||
|
||||
public class InvertBooleanConverter : IValueConverter
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
namespace ShrlAlgoToolkit.Mvvm.Converters;
|
||||
|
||||
public class SearchValueConverter : IMultiValueConverter
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Markup
|
||||
namespace ShrlAlgoToolkit.Mvvm.Markup
|
||||
{
|
||||
/// <summary>
|
||||
/// 枚举类作为数据源
|
||||
33
ShrlAlgoToolkit.Mvvm/Properties/AssemblyInfo.cs
Normal file
33
ShrlAlgoToolkit.Mvvm/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("ShrlAlgo.Toolkit.Mvvm")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ShrlAlgo.Toolkit.Mvvm")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("ca20d64f-16b1-4ddc-9e16-754192173f27")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
21
ShrlAlgoToolkit.Mvvm/ShrlAlgoToolkit.Mvvm.csproj
Normal file
21
ShrlAlgoToolkit.Mvvm/ShrlAlgoToolkit.Mvvm.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>True</UseWPF>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.ValidationRules;
|
||||
namespace ShrlAlgoToolkit.Mvvm.ValidationRules;
|
||||
|
||||
public class DoubleValidationRule : ValidationRule
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.ValidationRules;
|
||||
namespace ShrlAlgoToolkit.Mvvm.ValidationRules;
|
||||
|
||||
public class RangeValidationRule : ValidationRule
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.ValidationRules;
|
||||
namespace ShrlAlgoToolkit.Mvvm.ValidationRules;
|
||||
|
||||
public class RequiredValidationRule : ValidationRule
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.ValidationRules
|
||||
namespace ShrlAlgoToolkit.Mvvm.ValidationRules
|
||||
{
|
||||
public class UndefinedCharRules : ValidationRule
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers
|
||||
namespace ShrlAlgoToolkit.Revit.Assists
|
||||
{
|
||||
public static class BuiltEnumDictionary
|
||||
{
|
||||
29
ShrlAlgoToolkit.Revit/Assists/CategoryAssist.cs
Normal file
29
ShrlAlgoToolkit.Revit/Assists/CategoryAssist.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
public static class CategoryAssist
|
||||
{
|
||||
public static Element ToElement(this ElementId elementId, Document doc)
|
||||
{
|
||||
return doc.GetElement(elementId);
|
||||
}
|
||||
|
||||
public static Category ToCategory(this BuiltInCategory builtInCategory, Document doc)
|
||||
{
|
||||
return Category.GetCategory(doc, builtInCategory);
|
||||
}
|
||||
|
||||
public static BuiltInCategory ToBuiltInCategory(this Category category)
|
||||
{
|
||||
#if REVIT2018 || REVIT2020
|
||||
var builtInCategory = (BuiltInCategory)category.Id.IntegerValue;
|
||||
#elif REVIT2025
|
||||
var builtInCategory = (BuiltInCategory)category.Id.Value;
|
||||
#endif
|
||||
|
||||
return Enum.IsDefined(typeof(BuiltInCategory), builtInCategory)
|
||||
? builtInCategory
|
||||
: throw new ArgumentNullException(nameof(category), "不存在该内建类别");
|
||||
}
|
||||
}
|
||||
40
ShrlAlgoToolkit.Revit/Assists/DMUAssist.cs
Normal file
40
ShrlAlgoToolkit.Revit/Assists/DMUAssist.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态模型更新
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public static class DMUAssist
|
||||
{
|
||||
public static void AddTrigger(this IUpdater updater, Document document, ElementFilter filter, ChangeType change)
|
||||
{
|
||||
UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), document, filter, change);
|
||||
}
|
||||
}
|
||||
|
||||
//internal class test
|
||||
//{
|
||||
// private readonly ChangeType change = null;
|
||||
// private readonly ICollection<ElementId> elements = null;
|
||||
// private readonly uiApplication uiApplication = null;
|
||||
// private Guid guid = new();
|
||||
|
||||
// public void MyMethod()
|
||||
|
||||
// {
|
||||
// var guid = new Guid();
|
||||
// Updater updater = new Updater
|
||||
// {
|
||||
// addinID = null,
|
||||
// Guid = guid
|
||||
// };
|
||||
|
||||
// DMUAssist<Updater> dynamicModel =
|
||||
// new DMUAssist<Updater>(uiApplication, elements, change);
|
||||
|
||||
// dynamicModel.UseUpdater();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>Ԫ<EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// dwg块选择过滤
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前模型或链接模型的实体元素
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers
|
||||
namespace ShrlAlgoToolkit.Revit.Assists
|
||||
{
|
||||
public enum ElementOrientation
|
||||
{
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// 族文档可用
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// 三维视图可用
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// 命令在平面视图可用
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
/// <summary>
|
||||
/// 命令在剖面、立面可用
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user