/
spruttechnology
/
cam-api-examples
Обзор
Документация
Войти
/
spruttechnology
/
cam-api-examples
Код
Запросы
3
Задачи
Пакеты
0
Релизы
1
Аналитика
v19/develop
Attributes/ExtensionAttributesManageNet/project/main/LibraryChecker.cs
51 строка
2 KB
cepera
Attributes example simplified. Untyped attributes usage described.
29 май 2025, 17:28
29 май 2025, 17:28
ff25e43
Код
Авторство
О чём код?
using CAMAPI.DotnetHelper; using CAMAPI.CustomAttributes; using CAMAPI.UIDialogs; using CAMAPI.UIDialogs.DotnetHelper; namespace ExtensionAttributesManageNet; /// <summary> /// Check the user created example attributes library before. /// </summary> internal static class LibraryChecker { /// <summary> /// Check the user created example attributes library before. /// </summary> private static bool IsLibrarAttached(ICamApiCustomAttributesManager manager) { if (manager==null) return false; using var appLibs = ComWrapper.Create(manager.ApplicationLibraries); if (appLibs.It.Count<1) return false; for (int i = 0; i < appLibs.It.Count; i++) { string fn = appLibs.It.LibFileName[i]; if (!String.IsNullOrEmpty(fn) && fn.Contains("ExampleAttributes.atrlib")) { if (File.Exists(fn)) return true; } } return false; } /// <summary> /// Show message if user didnt create example attributes library before. /// </summary> public static bool CheckIsExampleLibraryAttached(ICamApiObjectWithAttributes objectWithAttributes) { using var manager = ComWrapper.Create(objectWithAttributes.AttributesManager); var res = IsLibrarAttached(manager.It); if (!res) { using var dialogs = UIDialogs.CreateHelper(); dialogs.It.MessageBox("Example attributes library does not connected. Click to 'Attributes: Create library' item before.", TMessageDialogType.mdtInformation, (ushort)TUIButtonTypeFlags.btfOk, TUIButtonType.btOk, ""); } return res; } }