void TreeChanged(object sender, DatEventArgs e) { ITreeNDat tree = (ITreeNDat)e.DatEntity; SetList.FilterReset(); SetList.LoadFilter = new SQLFilter(); SetList.LoadFilter.AddWhere(new FilterString("Parent_FPn", tree.FPn.ToString())); Refresh(); gridMain.captList.Caption = Caption + " [ветка '" + tree.Name + "']"; }
private void Fill(TreeNodeCollection nodes, List <BaseDat> lst, List <int> included, BaseDat dat) { foreach (BaseDat dt in GetChildren(lst, dat)) { string path = ""; string name = ""; string codeN = ""; if (dt is ITreeNDat) { ITreeNDat tr = (ITreeNDat)dt; path = tr.FPn.ToString(); name = tr.Name; codeN = tr.FPn.CodeS; } else if (dt is ICardNDat) { ICardNDat cr = (ICardNDat)dt; if (included != null && included.IndexOf(cr.ID) < 0) { continue; } path = cr.FPn.ToString(); name = cr.Name; codeN = cr.CodeN; } bool is_empty = false; TreeNode node = nodes.Add(path, string.Format("{0}: {1}", codeN, name)); node.Tag = dt; if (dt is ITreeNDat) { node.ImageIndex = node.SelectedImageIndex = 0; Fill(node.Nodes, lst, included, dt); if (node.Nodes.Count == 0) { is_empty = true; } else { is_empty = CardsCount(node.Nodes) == 0; } } else if (dt is ICardNDat) { node.ImageIndex = node.SelectedImageIndex = 1; } if (is_empty && included != null) { nodes.Remove(node); } } }
public virtual void chkRoot_CheckedChanged(object sender, EventArgs e) { ITreeNDat dat = NewValue as ITreeNDat; if (dat != null) { dat.Parent_FPn = (chkRoot.Checked) ? null : old_parent; dat.FPn = new PathTreeN(dat.Parent_FPn, dat.FPn.CodeS); Text = (((BaseDat)dat).IsNew) ? "Новый" + ((dat.Parent_FPn == null) ? " корневой узел" : " подузел в ветке " + dat.Parent_FPn.ToString()) : string.Format("Изменение узла {0}", dat); } }
private void CardTreeForm_Load(object sender, EventArgs e) { ITreeNDat dat = NewValue as ITreeNDat; if (dat != null) { old_parent = dat.Parent_FPn; chkRoot.Enabled = ((BaseDat)dat).IsNew && old_parent != null; chkRoot.Checked = (dat.Parent_FPn == null); BindControls(this); } chkRoot_CheckedChanged(this, EventArgs.Empty); }
private TreeNode NewNode(string key, ITreeNDat dt) { TreeNode ret = new TreeNode(); ret.Name = key; ret.Tag = dt; if (dt is ITreeCustomDisplayName) { ret.Text = ((ITreeCustomDisplayName)dt).DisplayName; } else { ret.Text = string.Format("{0}: {1}", dt.FPn.CodeS, dt.Name); } ret.ImageIndex = ret.SelectedImageIndex = 0; return(ret); }
void ValueNew(object sender, EventArgs e) { if (_EntityForm == null) { if (TreeNew != null) { TreeNew(this, new DatEventArgs(null)); } } else { try { TD ndat = new TD(); if (_TreeV.Value != null) { ITreeNDat dat = (ITreeNDat)_TreeV.Value; ndat.FPn = new PathTreeN(dat.FPn, "10"); } else { ndat.FPn = new PathTreeN("1"); } _EntityForm.OldValue = ndat; if (_EntityForm.ShowDialog() == DialogResult.OK) { Reload(ndat.FPn.ToString()); } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//private TreeNode NewNode(string key, string text, ITreeDat dt) //{ // TreeNode ret = new TreeNode(text); // ret.Name = key; // ret.Tag = dt; // ret.ImageIndex = ret.SelectedImageIndex = 0; // return ret; //} private void FillTree(TreeNodeCollection nodes, List <BaseDat> lst, List <int> included, ITreeNDat dat) { List <TreeNode> lastNode = new List <TreeNode>(); int startDepth = (lst.Count > 0) ? ((ITreeNDat)lst[0]).FPn.Count : 0; foreach (ITreeNDat dt in lst) { bool is_empty = false; TreeNode node = NewNode(dt.FPn.ToString(), dt); if (lastNode.Count < dt.FPn.Count) { lastNode.Add(null); } lastNode[dt.FPn.Count - startDepth] = node; if (dt.FPn.Count == startDepth) { nodes.Add(node); } else if (dt.FPn.Count > startDepth) { lastNode[dt.FPn.Count - startDepth - 1].Nodes.Add(node); } if (node.Nodes.Count == 0) { is_empty = true; } else { is_empty = CardsCount(node.Nodes) == 0; } if (is_empty && included != null) { nodes.Remove(node); } } }