/// <summary> /// Поиск записи из коллекции. /// </summary> public static int FindRecordPossition(System.ComponentModel.Component сollection, XPBaseObject record) { if (record == null) { return(0); } if (сollection is XPCollection) { XPCollection xpCollection = сollection as XPCollection; string propertyName = DBAttribute.GetKey(record.GetType()); int idRecord = (int)record.GetMemberValue(propertyName); for (int i = 0; i < xpCollection.Count; i++) { XPBaseObject recordInt = (XPBaseObject)xpCollection[i]; int idRecordInt = (int)recordInt.GetMemberValue(propertyName); if (idRecordInt == idRecord) { return(i); } } } return(0); }
/// <summary> /// Создание списка возможных типов таблицы. /// </summary> public void GenerateInitTables() { if (DBForm.TypeDiscoveryService != null) { ICollection types = DBForm.TypeDiscoveryService.GetTypes(typeof(DBViewBase), false); foreach (Type actionType in types) { if (actionType != typeof(DBViewBase)) { ViewMemberInfo info = new ViewMemberInfo(); info.ViewType = actionType; info.Caption = DBAttribute.GetCaption(actionType); string name = DBAttribute.GetIconFile(info.ViewType); string dir = DBForm.GetImageFullName(name); if (dir != "" && File.Exists(dir) && !ImageEx.IsExist(imgInit, name)) { imgInit.AddImage(Image.FromFile(dir), name); } info.ImageIndex = ImageEx.GetImageIndex(imgInit, name); info.ImageName = name; if (MemberExists.FindInfo(info) != null) { info.IsUsed = true; } MemberInits.Add(info); } } lblTotalCount.Caption = string.Format("Всего: {0}", types.Count); } }
/// <summary> /// Анализ PropertyInfoEx объекта и добавление полученных данных в объект TableMemberInfo. /// </summary> public TableMemberInfo AnalisProperty(PropertyInfoEx propertyInfo, TableMemberInfo tableInfo, ref int recordCount) { TableMemberInfo result = new TableMemberInfo(); result.FieldName = propertyInfo.PropertyInfo.Name; result.Caption = PropertyInfoEx.GetDisplayNameAttribute(propertyInfo.PropertyInfo); result.PropertyType = propertyInfo.PropertyInfo.PropertyType; if (propertyInfo.IsXPCollection) { result.PropertyTypeCollection = propertyInfo.PropertyInfoCollection.PropertyType; } result.IsXPBaseObject = propertyInfo.IsXPBaseObject; result.IsXPCollection = propertyInfo.IsXPCollection; if (result.IsXPBaseObject || result.IsXPCollection) { string name = ""; if (result.IsXPBaseObject) { name = DBAttribute.GetIconFile(result.PropertyType); } if (result.IsXPCollection) { name = DBAttribute.GetIconFile(result.PropertyTypeCollection); } string dir = DBInterface.GetImageFullName(name); if (dir != "" && File.Exists(dir) && !ImageEx.IsExist(imgInit, name)) { imgInit.AddImage(Image.FromFile(dir), name); } result.ImageIndex = ImageEx.GetImageIndex(imgInit, name); result.ImageName = name; } if (tableInfo != null) { tableInfo.Add(result); } if (MemberExists.FindInfo(result) != null) { result.IsUsed = true; } // Ограничение по количеству записей recordCount++; if (recordCount >= RecordCountMax) { return(null); } else { return(result); } }
/// <summary> /// Обновления надписей и иконок. /// </summary> public void UpdateExistCaptionAndIcon() { foreach (TableMemberInfo info in MemberInits) { TableMemberInfo infoExist = MemberExists.FindInfo(info); if (infoExist != null) { infoExist.Caption = info.Caption; DBInterface.CreateIcon(infoExist.Item, info); if (info.Items.Count > 0) { UpdateExistCaptionAndIcon(info.Items, 1); } } } DBInterface.TableCaption = DBAttribute.GetCaption(DBInterface.TableType); }