添加项目文件。
This commit is contained in:
95
Sai.RvKits/Converters/RvEnumConverter.cs
Normal file
95
Sai.RvKits/Converters/RvEnumConverter.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Sai.RvKits.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user