public void GetNewDataConfig( ) { NewDataConfig = new ABCScreenConfig(OwnerView); AddedList.Clear(); foreach (DevExpress.XtraTreeList.Nodes.TreeListNode node in this.treeBinding.Nodes) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(node); if (obj == null || (ABCBindingConfig)obj.InnerData == null) { continue; } ABCBindingConfig bindInfo = (ABCBindingConfig)obj.InnerData; if (AddedList.Contains(bindInfo)) { continue; } ABCBindingConfig info = GetNewBindingInfo(node); if (NewDataConfig.BindingList.ContainsKey(bindInfo.Name) == false) { NewDataConfig.BindingList.Add(bindInfo.Name, bindInfo); } } }
public void UpdateFieldName(ABCCommonTreeListNode obj) { if (obj == null || obj.InnerData == null) { return; } if (obj.ParentNode != null) { ABCCommonTreeListNode objparent = obj.ParentNode; ABCBindingConfig currentBind = (ABCBindingConfig)obj.InnerData; ABCBindingConfig parentBind = (ABCBindingConfig)objparent.InnerData; if (currentBind != null && parentBind != null) { if (currentBind.ParentName != parentBind.TableName || (currentBind.ParentName == parentBind.TableName && (String.IsNullOrWhiteSpace(currentBind.ParentField) || String.IsNullOrWhiteSpace(currentBind.ChildField)))) { if (DataStructureProvider.IsExistedTable(parentBind.TableName)) { currentBind.ParentField = DataStructureProvider.GetPrimaryKeyColumn(parentBind.TableName); } if (DataStructureProvider.IsExistedTable(currentBind.TableName)) { currentBind.ChildField = DataStructureProvider.GetTable(currentBind.TableName).GetForeignKeyOfTableName(parentBind.TableName); } } currentBind.ParentName = parentBind.Name; } } //foreach ( TreeListNode nodeChild in node.Nodes ) // UpdateFieldName( nodeChild ); }
private ABCBindingConfig GetNewBindingInfo(DevExpress.XtraTreeList.Nodes.TreeListNode node) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(node); if (obj == null || (ABCScreen.ABCBindingConfig)obj.InnerData == null) { return(null); } ABCBindingConfig bindInfo = (ABCBindingConfig)obj.InnerData; bindInfo.Children.Clear(); foreach (DevExpress.XtraTreeList.Nodes.TreeListNode childNode in node.Nodes) { ABCBindingConfig childInfo = GetNewBindingInfo(childNode); childInfo.Parent = bindInfo; childInfo.ParentName = bindInfo.Name; bindInfo.Children.Add(childInfo.Name, childInfo); } if (AddedList.Contains(bindInfo) == false) { AddedList.Add(bindInfo); } return(bindInfo); }
void Menu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewRoot") { foreach (String strNewItem in new TableChooserForm().ShowChoose()) { ABCBindingConfig newInfo = new ABCBindingConfig(strNewItem); newInfo.Name = GetNewName(newInfo.Name); if (this.treeBinding.FocusedNode == null) { newInfo.IsMainObject = true; } new ABCCommonTreeListNode((ABCCommonTreeListNode)this.treeBinding.DataSource, newInfo); } this.treeBinding.RefreshDataSource(); } if (e.Item.Tag != null && e.Item.Tag.ToString() == "New") { foreach (String strNewItem in new TableChooserForm().ShowChoose()) { ABCBindingConfig newInfo = new ABCBindingConfig(strNewItem); newInfo.Name = GetNewName(newInfo.Name); if (this.treeBinding.FocusedNode == null) { new ABCCommonTreeListNode((ABCCommonTreeListNode)this.treeBinding.DataSource, newInfo); newInfo.IsMainObject = true; } else { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(this.treeBinding.FocusedNode); if (obj == null || (ABCBindingConfig)obj.InnerData == null) { return; } ABCCommonTreeListNode node = new ABCCommonTreeListNode(obj, newInfo); UpdateFieldName(node); } } this.treeBinding.RefreshDataSource(); // this.treeBinding.FocusedNode.ExpandAll(); } if (e.Item.Tag != null && e.Item.Tag.ToString() == "Delete") { if (this.treeBinding.FocusedNode != null) { DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want remove this Binding Information and all children ? ", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { this.treeBinding.DeleteSelectedNodes(); this.treeBinding.RefreshDataSource(); } } } }
void treeBinding_AfterDragNode(object sender, NodeEventArgs e) { ABCCommonTreeListNode node = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(e.Node); if (node == null || (ABCBindingConfig)node.InnerData == null) { UpdateFieldName(node); } treeBinding.RefreshDataSource(); this.treeBinding.ExpandAll(); }
void treeList1_CustomDrawNodeCell(object sender, CustomDrawNodeCellEventArgs e) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeList1.GetDataRecordByNode(e.Node); if (obj == null || (DataStructInfo)obj.InnerData == null) { return; } if (((DataStructInfo)obj.InnerData).Selected) { e.Appearance.Font = new Font(e.Appearance.Font, e.Appearance.Font.Style | FontStyle.Bold); } }
void treeBinding_CustomDrawNodeCell(object sender, CustomDrawNodeCellEventArgs e) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(e.Node); if (obj == null || (ABCScreen.ABCBindingConfig)obj.InnerData == null) { return; } if (((ABCScreen.ABCBindingConfig)obj.InnerData).IsMainObject) { e.Appearance.Font = new Font(e.Appearance.Font, FontStyle.Bold); } }
void treeBinding_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(e.Node); if (obj == null || (ABCScreen.ABCBindingConfig)obj.InnerData == null) { PropertyGrid.SelectedObject = null; FieldFilterGrid.DataSource = null; FieldFilterGrid.RefreshDataSource(); return; } PropertyGrid.SelectedObject = (ABCScreen.ABCBindingConfig)obj.InnerData; FieldFilterGrid.DataSource = ((ABCScreen.ABCBindingConfig)obj.InnerData).FieldFilterConditions; FieldFilterGrid.RefreshDataSource(); }
public ABCCommonTreeListNode(ABCCommonTreeListNode parent, object _data) { this.ParentNode = parent; if (parent != null) { this.Level = parent.Level + 1; } this.InnerData = _data; if (this.ParentNode != null) { this.ParentNode.ChildrenNodes.Add(this); } }
void Menu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (e.Item.Tag != null && e.Item.Tag.ToString() == "Explore" && treeList1.Selection.Count > 0) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeList1.GetDataRecordByNode(treeList1.FocusedNode); if (obj == null || (DataStructInfo)obj.InnerData == null) { return; } ExploreFKNode(obj); treeList1.RefreshDataSource(); treeList1.ExpandAll(); } }
void treeList1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right && ModifierKeys == Keys.None && treeList1.State == TreeListState.Regular) { Point pt = this.PointToClient(MousePosition); TreeListHitInfo info = treeList1.CalcHitInfo(pt); if (info.HitInfoType == HitInfoType.Cell || info.HitInfoType == HitInfoType.StateImage) { treeList1.FocusedNode = info.Node; ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeList1.GetDataRecordByNode(treeList1.FocusedNode); if (obj == null || (DataStructInfo)obj.InnerData == null) { return; } DataStructInfo data = (DataStructInfo)obj.InnerData; if (DataStructureProvider.IsForeignKey(data.TableName, data.FieldName)) { ContextMenu.ShowPopup(MousePosition); } } } else if (e.Button == MouseButtons.Left && ModifierKeys == Keys.None && treeList1.State == TreeListState.NodePressed) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeList1.GetDataRecordByNode(treeList1.FocusedNode); if (obj == null || (DataStructInfo)obj.InnerData == null) { return; } (obj.InnerData as DataStructInfo).Selected = !(obj.InnerData as DataStructInfo).Selected; if ((obj.InnerData as DataStructInfo).Selected) { foreach (DataStructInfo data in lstData) { if (data != (obj.InnerData as DataStructInfo) && data.TotalFieldName != (obj.InnerData as DataStructInfo).TotalFieldName) { data.Selected = false; } } } treeList1.RefreshDataSource(); } }
private void InitNodes( ) { AddedList.Clear(); ABCCommonTreeListNode rootNode = new ABCCommonTreeListNode(null, null); foreach (ABCScreen.ABCBindingConfig bindInfo in this.DataConfig.BindingList.TreeValues) { InitNodes(rootNode, bindInfo); } treeBinding.DataSource = rootNode; treeBinding.ExpandAll(); if (treeBinding.Nodes.Count > 0) { treeBinding.FocusedNode = treeBinding.Nodes[0]; } }
void treeBinding_GetStateImage(object sender, DevExpress.XtraTreeList.GetStateImageEventArgs e) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(e.Node); if (obj == null || (ABCScreen.ABCBindingConfig)obj.InnerData == null) { return; } if (((ABCScreen.ABCBindingConfig)obj.InnerData).IsList) { e.NodeImageIndex = 0; } else { e.NodeImageIndex = 1; } }
public void ExploreFKNode(ABCCommonTreeListNode obj) { DataStructInfo data = (DataStructInfo)obj.InnerData; if (DataStructureProvider.IsForeignKey(data.TableName, data.FieldName)) { String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(data.TableName, data.FieldName); if (DataStructureProvider.DataTablesList.ContainsKey(strPKTableName) == false) { return; } foreach (String strFieldName in DataStructureProvider.DataTablesList[strPKTableName].ColumnsList.Keys) { DataStructInfo dataInfo = new DataStructInfo(strPKTableName, strFieldName); dataInfo.TotalFieldName = data.TotalFieldName + ":" + strFieldName; lstData.Add(dataInfo); new ABCCommonTreeListNode(obj, dataInfo); } } }
void repoCheck_EditValueChanged(object sender, EventArgs e) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeList1.GetDataRecordByNode(treeList1.FocusedNode); if (obj == null || (DataStructInfo)obj.InnerData == null) { return; } (obj.InnerData as DataStructInfo).Selected = (sender as DevExpress.XtraEditors.CheckEdit).Checked; if ((obj.InnerData as DataStructInfo).Selected) { foreach (DataStructInfo data in lstData) { if (data != (obj.InnerData as DataStructInfo) && data.TotalFieldName != (obj.InnerData as DataStructInfo).TotalFieldName) { data.Selected = false; } } } treeList1.RefreshDataSource(); }
public void InitOldResult(ABCCommonTreeListNode root) { try { if (String.IsNullOrWhiteSpace(Result)) { return; } String[] strArr = Result.Split(':'); if (strArr.Length <= 0) { return; } ABCCommonTreeListNode currentNode = root; for (int i = 0; i < strArr.Length; i++) { String strFieldName = strArr[i]; foreach (ABCCommonTreeListNode child in currentNode.ChildrenNodes) { if ((child.InnerData as DataStructInfo).FieldName == strFieldName) { ExploreFKNode(child); currentNode = child; break; } } } (currentNode.InnerData as DataStructInfo).Selected = true; treeList1.RefreshDataSource(); treeList1.ExpandAll(); } catch (Exception ex) { } }
private ABCScreen.ABCBindingConfig InitNodes(ABCCommonTreeListNode parentNode, ABCScreen.ABCBindingConfig bindInfo) { if (AddedList.Contains(bindInfo)) { return(null); } AddedList.Add(bindInfo); ABCScreen.ABCBindingConfig newBindInfo = (ABCScreen.ABCBindingConfig)bindInfo.Clone(); ABCCommonTreeListNode node = new ABCCommonTreeListNode(parentNode, newBindInfo); foreach (ABCScreen.ABCBindingConfig childInfo in bindInfo.Children.Values) { ABCScreen.ABCBindingConfig newChildBindInfo = InitNodes(node, childInfo); if (newChildBindInfo != null) { newChildBindInfo.Parent = newBindInfo; newBindInfo.Children.Add(newChildBindInfo.Name, newChildBindInfo); } } return(newBindInfo); }
void treeBinding_DragDrop(object sender, DragEventArgs e) { object obj = e.Data.GetData(typeof(TreeListNode)); if (obj is TreeListNode == false) { e.Effect = DragDropEffects.None; return; } TreeListNode dragNode = (TreeListNode)obj; Point p = treeBinding.PointToClient(new Point(e.X, e.Y)); TreeListNode targetNode = treeBinding.CalcHitInfo(p).Node; if (dragNode != null && targetNode != null && dragNode != targetNode) { ABCCommonTreeListNode objDrag = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(dragNode); ABCCommonTreeListNode objTarget = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(targetNode); if (objDrag != null && objTarget != null) { if (objDrag.ParentNode != null) { objDrag.ParentNode.ChildrenNodes.Remove(objDrag); } objDrag.ParentNode = objTarget; objTarget.ChildrenNodes.Add(objDrag); e.Effect = DragDropEffects.Move; treeBinding.RefreshDataSource(); treeBinding.ExpandAll(); UpdateFieldName(objDrag); return; } } e.Effect = DragDropEffects.None; }
private bool IsExistedName(DevExpress.XtraTreeList.Nodes.TreeListNode node, String strName) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(node); if (obj == null || (ABCBindingConfig)obj.InnerData == null) { return(false); } if (((ABCBindingConfig)obj.InnerData).Name == strName) { return(true); } foreach (DevExpress.XtraTreeList.Nodes.TreeListNode nodeChild in node.Nodes) { if (IsExistedName(nodeChild, strName)) { return(true); } } return(false); }
public void Initialize( ) { treeList1.OptionsBehavior.ShowEditorOnMouseUp = false; treeList1.OptionsBehavior.CloseEditorOnLostFocus = true; treeList1.OptionsBehavior.ImmediateEditor = false; treeList1.OptionsSelection.UseIndicatorForSelection = false; treeList1.OptionsView.ShowColumns = true; treeList1.OptionsView.ShowVertLines = false; treeList1.OptionsView.ShowHorzLines = false; treeList1.OptionsView.ShowFocusedFrame = false; treeList1.OptionsBehavior.DragNodes = false; #region Columns DevExpress.XtraTreeList.Columns.TreeListColumn colField = new DevExpress.XtraTreeList.Columns.TreeListColumn(); colField.Caption = "Field"; colField.FieldName = "FieldName"; colField.Visible = true; colField.VisibleIndex = 0; colField.OptionsColumn.AllowEdit = false; DevExpress.XtraTreeList.Columns.TreeListColumn colCheck = new DevExpress.XtraTreeList.Columns.TreeListColumn(); colCheck.Caption = "Select"; colCheck.FieldName = "Selected"; colCheck.Visible = true; colCheck.VisibleIndex = 0; colCheck.OptionsColumn.AllowEdit = true; colCheck.Width = 20; repoCheck = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit(); colCheck.ColumnEdit = repoCheck; treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { colCheck, colField }); #endregion ABCCommonTreeListNode root = new ABCCommonTreeListNode(null, null); foreach (String strFieldName in DataStructureProvider.DataTablesList[this.TableName].ColumnsList.Keys) { DataStructInfo dataInfo = new DataStructInfo(TableName, strFieldName); new ABCCommonTreeListNode(root, dataInfo); lstData.Add(dataInfo); } treeList1.DataSource = root; treeList1.RefreshDataSource(); treeList1.Refresh(); if (treeList1.Nodes.Count > 0) { treeList1.FocusedNode = treeList1.Nodes[0]; } InitOldResult(root); treeList1.ExpandAll(); colCheck.Width = 20; treeList1.MouseClick += new MouseEventHandler(treeList1_MouseClick); treeList1.CustomDrawNodeCell += new CustomDrawNodeCellEventHandler(treeList1_CustomDrawNodeCell); repoCheck.EditValueChanged += new EventHandler(repoCheck_EditValueChanged); InitPopupMenu(); }
void PropertyGrid_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e) { ABCCommonTreeListNode node = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(treeBinding.FocusedNode); if (node == null || (ABCBindingConfig)node.InnerData == null) { return; } if (e.Row.Name == "rowTableName") { UpdateFieldName(node); } if (e.Row.Name == "rowIsList") { if (e.Value != null && Convert.ToBoolean(e.Value) && ((ABCBindingConfig)node.InnerData).IsMainObject) { ((ABCBindingConfig)node.InnerData).IsMainObject = false; } } if (e.Row.Name == "rowDisplayOnly") { if (e.Value != null && Convert.ToBoolean(e.Value) && ((ABCBindingConfig)node.InnerData).AutoSave) { ((ABCBindingConfig)node.InnerData).AutoSave = false; } } if (e.Row.Name == "rowAutoSave") { if (e.Value != null && Convert.ToBoolean(e.Value)) { ((ABCBindingConfig)node.InnerData).DisplayOnly = false; ((ABCBindingConfig)node.InnerData).IsMainObject = false; } } if (e.Row.Name == "rowIsMainObject") { if (e.Value != null && Convert.ToBoolean(e.Value)) { ((ABCBindingConfig)node.InnerData).AutoSave = false; if (((ABCBindingConfig)node.InnerData).IsList) { ((ABCBindingConfig)node.InnerData).IsList = false; } foreach (DevExpress.XtraTreeList.ViewInfo.RowInfo row in this.treeBinding.ViewInfo.RowsInfo.Rows) { ABCCommonTreeListNode nodeData = (ABCCommonTreeListNode)treeBinding.GetDataRecordByNode(row.Node); if (nodeData == node || nodeData == null || (ABCBindingConfig)nodeData.InnerData == null) { continue; } ((ABCBindingConfig)nodeData.InnerData).IsMainObject = false; } } } PropertyGrid.Refresh(); treeBinding.RefreshDataSource(); }