Exemple #1
0
        public void Add(ITreeDat tree)
        {
            CD dat = Activator.CreateInstance(typeof(CD)) as CD;

            dat.ID        = -tree.ID;
            dat.Parent_FP = tree.FP.Parent;
            dat.Code      = tree.FP.Code;
            dat.Name      = tree.Name;
            Add(dat);
        }
Exemple #2
0
        void TreeChanged(object sender, DatEventArgs e)
        {
            ITreeDat tree = (ITreeDat)e.DatEntity;

            SetList.FilterReset();
            SetList.LoadFilter = new SQLFilter();
            SetList.LoadFilter.AddWhere(new FilterString("Parent_FP", tree.FP.ToString()));
            Refresh();
            gridMain.captList.Caption = Caption + " [ветка '" + tree.Name + "']";
        }
Exemple #3
0
        private void Fill(TreeNodeCollection nodes, List <BaseDat> lst, List <int> included, BaseDat dat)
        {
            foreach (BaseDat dt in GetChildren(lst, dat))
            {
                string path = "";
                string name = "";
                int    code = 0;
                if (dt is ITreeDat)
                {
                    ITreeDat tr = (ITreeDat)dt;
                    path = tr.FP.ToString();
                    name = tr.Name;
                    code = tr.FP.Code;
                }
                else if (dt is ICardDat)
                {
                    ICardDat cr = (ICardDat)dt;
                    if (included != null && included.IndexOf(cr.ID) < 0)
                    {
                        continue;
                    }
                    path = cr.FP.ToString();
                    name = cr.Name;
                    code = cr.Code;
                }

                bool     is_empty = false;
                TreeNode node     = nodes.Add(path, string.Format("{0}: {1}", code, name));
                node.Tag = dt;
                if (dt is ITreeDat)
                {
                    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 ICardDat)
                {
                    node.ImageIndex = node.SelectedImageIndex = 1;
                }
                if (is_empty && included != null)
                {
                    nodes.Remove(node);
                }
            }
        }
Exemple #4
0
        public virtual void chkRoot_CheckedChanged(object sender, EventArgs e)
        {
            ITreeDat dat = NewValue as ITreeDat;

            if (dat != null)
            {
                dat.Parent_FP = (chkRoot.Checked) ? null : old_parent;
                dat.FP        = new PathTree(dat.Parent_FP, dat.FP.Code);
                Text          = (((BaseDat)dat).IsNew)
                    ? "Новый" + ((dat.Parent_FP == null) ? " корневой узел" : " подузел в ветке " + dat.Parent_FP.ToString())
                    : string.Format("Изменение узла {0}", dat);
            }
        }
Exemple #5
0
        private void CardTreeForm_Load(object sender, EventArgs e)
        {
            ITreeDat dat = NewValue as ITreeDat;

            if (dat != null)
            {
                old_parent      = dat.Parent_FP;
                chkRoot.Enabled = ((BaseDat)dat).IsNew && old_parent != null;
                chkRoot.Checked = (dat.Parent_FP == null);
                BindControls(this);
            }
            chkRoot_CheckedChanged(this, EventArgs.Empty);
        }
Exemple #6
0
        private TreeNode NewNode(string key, ITreeDat 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.FP.Code, 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)
                    {
                        ITreeDat dat = (ITreeDat)_TreeV.Value;
                        ndat.FP = new PathTree(dat.FP, 10);
                    }
                    else
                    {
                        ndat.FP = new PathTree("1");
                    }
                    _EntityForm.OldValue = ndat;

                    if (_EntityForm.ShowDialog() == DialogResult.OK)
                    {
                        Reload(ndat.FP.ToString());
                    }
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #8
0
        //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, ITreeDat dat)
        {
            List <TreeNode> lastNode   = new List <TreeNode>();
            int             startDepth = (lst.Count > 0) ? ((ITreeDat)lst[0]).FP.Count : 0;

            foreach (ITreeDat dt in lst)
            {
                bool is_empty = false;


                TreeNode node = NewNode(dt.FP.ToString(), dt);

                if (lastNode.Count < dt.FP.Count)
                {
                    lastNode.Add(null);
                }

                lastNode[dt.FP.Count - startDepth] = node;

                if (dt.FP.Count == startDepth)
                {
                    nodes.Add(node);
                }
                else if (dt.FP.Count > startDepth)
                {
                    lastNode[dt.FP.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);
                }
            }
        }