private void btnDelete_Click(object sender, EventArgs e) { ViewMemberInfos deletings = new ViewMemberInfos(); foreach (TreeListNode node in treeExist.Selection) { ViewMemberInfo info = treeExist.GetDataRecordByNode(node) as ViewMemberInfo; if (info != null && info.Item != null) { DBForm.DestroyInstance(info.Item); UnuseInitTable(info); //EraseExistDate(vwInfo); deletings.Add(info); } } // Удаление записей foreach (ViewMemberInfo infoInter in deletings) { MemberExists.Remove(infoInter); } }
/// <summary> /// Создание элемента коллекции. /// </summary> public DBFormItemBase CreateInstance(ViewMemberInfo info = null, TreeList treeList = null, ViewMemberInfos memberExists = null) { DBFormItemBase item = null; string name = "BaseView"; if (info != null) { name = info.ViewTypeName; if (TypeEx.IsSubclassOf(info.ViewType, typeof(DBViewInterface))) item = CreateComponent(typeof(DBFormItemView), name) as DBFormItemBase; else item = CreateComponent(typeof(DBFormItemBase), name) as DBFormItemBase; info.IsUsed = true; item.ViewType = info.ViewType; item.Caption = info.Caption; if (item.Caption == "") item.Caption = name; item.ImageName = info.ImageName; } else item = CreateComponent(typeof(DBFormItemBase), name) as DBFormItemBase; Items.Add(item); CreateControl(item, name); if (info != null) CreateIcon(item, info); if (treeList != null && memberExists != null) PrintExistData(treeList, item, memberExists); return item; }
/// <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); } }
private void btnAddInit_Click(object sender, EventArgs e) { foreach (TreeListNode node in treeInit.Selection) { ViewMemberInfo info = treeInit.GetDataRecordByNode(node) as ViewMemberInfo; CreateInstance(info); } }
private void treeExist_GetStateImage(object sender, GetStateImageEventArgs e) { ViewMemberInfo info = treeExist.GetDataRecordByNode(e.Node) as ViewMemberInfo; if (info != null) { e.NodeImageIndex = info.ImageIndex; } }
/// <summary> /// Очистка записи. /// </summary> public void UnuseInitTable(ViewMemberInfo tmInfo) { ViewMemberInfo infoInit = MemberInits.FindInfo(tmInfo); if (infoInit != null) { infoInit.IsUsed = false; } }
private void treeInit_MouseDoubleClick(object sender, MouseEventArgs e) { TreeListNode node = GetTreeListNode(treeInit, e.Location); if (node != null) { ViewMemberInfo info = treeInit.GetDataRecordByNode(node) as ViewMemberInfo; CreateInstance(info); } }
/// <summary> /// Создание иконки записи. /// </summary> public void CreateIcon(DBFormItemBase item, ViewMemberInfo info) { string imageName = GetImageFullName(info.ImageName); if (!ImageEx.IsExist(Icons, info.ImageName) && File.Exists(imageName)) { Image image = Image.FromFile(imageName); Icons.Images.Add(image, info.ImageName); } item.ImageIndex = ImageEx.GetImageIndex(Icons, info.ImageName); }
private void treeExist_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e) { ViewMemberInfo info = treeExist.GetDataRecordByNode(e.Node) as ViewMemberInfo; SelectedExistInfo = info; if (info != null && info.Item != null) { proExist.SelectedObject = info.Item; UpdateExistButtons(); } }
/// <summary> /// Обновления надписей и иконок. /// </summary> public void UpdateExistCaptionAndIcon() { foreach (ViewMemberInfo info in MemberInits) { ViewMemberInfo infoExist = MemberExists.FindInfo(info); if (infoExist != null) { infoExist.Caption = info.Caption; DBForm.CreateIcon(infoExist.Item, info); } } }
/// <summary> /// Автоматическое создание элемента коллекции. /// </summary> public DBFormItemBase CreateInstance(ViewMemberInfo info = null) { DBFormItemBase item = null; if (info == null) { item = DBForm.CreateInstance(treeList: treeExist, memberExists: MemberExists); } else if (MemberExists.FindInfo(info) == null) { item = DBForm.CreateInstance(info, treeExist, MemberExists); } return(item); }
/// <summary> /// Обновление визуального представление кнопок "Выше" и "Ниже". /// </summary> public void UpdateExistButtons() { ViewMemberInfo info = SelectedExistInfo; if (info != null) { btnExistUp.Enabled = !info.Item.IsFirst(); btnExistDown.Enabled = !info.Item.IsLast(); } else { btnExistUp.Enabled = false; btnExistDown.Enabled = false; } }
/// <summary> /// Создание записи для уже созданных полей таблицы /// </summary> public static ViewMemberInfo PrintExistData(TreeList treeList, DBFormItemBase item, ViewMemberInfos infos) { ViewMemberInfo info = new ViewMemberInfo() { ViewType = item.ViewType, Caption = item.Caption, ImageIndex = item.ImageIndex, ImageName = item.ImageName, Item = item }; infos.Add(info); TreeListNode node = FindNode(treeList, info); if (node != null) { treeList.FocusedNode = node; treeList.Selection.Clear(); treeList.Selection.Add(treeList.FocusedNode); } return info; }
/// <summary> /// Изменение позиции записи в дереве. /// </summary> private void SetNodeIndex(int inc) { if (treeExist.Selection.Count > 0) { TreeListNode node = treeExist.Selection[0]; int index = treeExist.GetNodeIndex(node); treeExist.SetNodeIndex(node, index + inc); ViewMemberInfo tmInfo = treeExist.GetDataRecordByNode(node) as ViewMemberInfo; if (tmInfo != null && tmInfo.Item != null) { DBFormItemBases dbItems = DBForm.Items; if (0 <= index + inc && index + inc < dbItems.Count) { DBFormItemBases dbBuffs = new DBFormItemBases(); dbItems.CopyTo(dbBuffs); dbItems.Clear(); dbBuffs.Change(index, index + inc); dbBuffs.CopyTo(dbItems); //dbItems.CorrectVisibleIndex(); } } } }
/// <summary> /// Поиск записи в древовидном объекте. /// </summary> public static TreeListNode FindNode(TreeList tree, ViewMemberInfo info) { return tree.FindNodeByFieldValue("HashCode", info.HashCode); }