Exemple #1
0
        public void CreateBefore(string name)
        {
            //--create
            System.Xml.XmlElement elem = this.OwnerDocument.CreateElement("F");
            elem.SetAttribute("name", name);
            File newfile = new File(elem);
            //--search target
            File tgfile = this.Parent;

            System.Xml.XmlElement tgelem = tgfile != null?tgfile.Element:OwnerDocument.DocumentElement;
            //--insert
            tgelem.InsertBefore(newfile.Element, this.Element);
            if (tgfile == null)
            {
                OwnerDocument.RefreshFiles();
                if (this.TreeView != null)
                {
                    this.TreeView.Nodes.Insert(this.Index, newfile);
                    MemoTreeView tv = this.TreeView as MemoTreeView;
                    if (tv != null)
                    {
                        tv.RefreshFiles();
                    }
                }
            }
            else
            {
                tgfile.Nodes.Insert(this.Index, newfile);
            }
        }
Exemple #2
0
        //===========================================================
        //		IOnInsert
        //===========================================================
        /// <summary>
        /// DragDrop によって挿入される時の処理です。
        /// </summary>
        void NodeDragDrop.IOnInsert.BeforeInsert(System.Windows.Forms.TreeNode target, int index)
        {
            File tgfile = (File)target;

            System.Xml.XmlElement scelem = this.ParentElement;
            System.Xml.XmlElement tgelem = tgfile != null?tgfile.Element:OwnerDocument.DocumentElement;
            if (index >= 0)
            {
                goto insert;
            }
add:
            scelem.RemoveChild(this.Element);
            tgelem.AppendChild(this.Element);
            return;

insert:
            if (scelem == tgelem && this.ElementIndex == index)
            {
                return;
            }
            //--挿入位置参照用 File (兄弟 File)
            File sibling;

            if (tgfile != null)
            {
                if (index >= tgfile.Nodes.Count)
                {
                    goto add;
                }
                sibling = (File)tgfile.Nodes[index];
            }
            else
            {
                if (index >= OwnerDocument.files.Count)
                {
                    goto add;
                }
                sibling = (File)OwnerDocument.files[index];
            }

            //--移動元から削除
            scelem.RemoveChild(this.Element);

            //--移動先に挿入
            tgelem.InsertBefore(this.Element, sibling.Element);
            if (tgfile == null)
            {
                OwnerDocument.RefreshFiles();
            }
            return;
        }