예제 #1
0
        public override int OffsetOfNode(FileDataNode node)
        {
            if (node == this)
            {
                return(0);
            }

            int offset = GetHeaderSize();

            foreach (FileDataNode child in Nodes.OfType <FileDataNode>())
            {
                offset += 0x100;

                if (child == node)
                {
                    return(offset);
                }

                int childOffset = child.OffsetOfNode(node);
                if (childOffset != -1)
                {
                    return(offset + childOffset);
                }

                offset += (child.GetSizeInMemory() + 0x3F) & ~0x3F;
            }

            return(-1);
        }
예제 #2
0
        public void Move(int index)
        {
            FileDataNode dataParent = FileDataParent;
            TreeNode     nodeParent = Parent;
            TreeView     treeParent = (TreeView.Nodes.Contains(this) ? TreeView : null);

            index = Math.Max(index, 0);

            Remove();

            if (dataParent != null)
            {
                index = Math.Min(index, dataParent.Nodes.Count);
                dataParent.Insert(index, this);
            }
            else if (nodeParent != null)
            {
                index = Math.Min(index, nodeParent.Nodes.Count);
                nodeParent.Nodes.Insert(index, this);
            }
            else if (treeParent != null)
            {
                index = Math.Min(index, treeParent.Nodes.Count);
                treeParent.Nodes.Insert(index, this);
            }
        }
예제 #3
0
        public virtual int OffsetOfNode(FileDataNode node)
        {
            if (node == this)
            {
                return(0);
            }

            int offset = GetHeaderSize();

            foreach (FileDataNode child in Nodes.OfType <FileDataNode>())
            {
                if (child == node)
                {
                    return(offset);
                }

                int childOffset = child.OffsetOfNode(node);
                if (childOffset != -1)
                {
                    return(offset + childOffset);
                }

                offset += child.GetSizeInMemory();
            }

            return(-1);
        }
예제 #4
0
        public FileDataNode InsertAbove(string path)
        {
            FileDataNode node = FromFile(path);

            InsertAbove(node);

            return(node);
        }
예제 #5
0
        public FileDataNode Insert(int index, string path)
        {
            FileDataNode node = FromFile(path);

            Insert(index, node);

            return(node);
        }
예제 #6
0
        public FileDataNode Import(string path)
        {
            FileDataNode node = FromFile(path);

            Import(node);

            return(node);
        }
예제 #7
0
        public FileDataNode Replace(string path)
        {
            FileDataNode node = FromFile(path);

            Replace(node);

            return(node);
        }
예제 #8
0
        public override void Remove(FileDataNode node)
        {
            RmdNode rmdNode = node as RmdNode;

            if (rmdNode != null)
            {
                _Element.Elements.Remove(rmdNode.Element);
            }

            base.Remove(node);
        }
예제 #9
0
        public override void Insert(int index, FileDataNode node)
        {
            RmdNode rmdNode = node as RmdNode;

            if (rmdNode == null)
            {
                throw new Exception("Rmd container nodes can only contain other Rmd nodes.");
            }

            _ContainerElement.Elements.Insert(index, rmdNode.Element);
            base.Insert(index, node);
        }
예제 #10
0
        private void InsertAbove_Click(object sender, EventArgs e)
        {
            OpenFileDialog openDlg = new OpenFileDialog();

            if (openDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            FileDataNode node = InsertAbove(openDlg.FileName);

            if (node != null)
            {
                node.TreeView.SelectedNode = node;
            }
        }
예제 #11
0
 public void InsertAbove(FileDataNode node)
 {
     if (FileDataParent != null)
     {
         int index = FileDataParent.Nodes.IndexOf(this);
         FileDataParent.Insert(index, node);
     }
     else if (Parent != null)
     {
         int index = Parent.Nodes.IndexOf(this);
         Parent.Nodes.Insert(index, node);
     }
     else if (TreeView != null && TreeView.Nodes.Contains(this))
     {
         int index = TreeView.Nodes.IndexOf(this);
         TreeView.Nodes.Insert(index, node);
     }
 }
예제 #12
0
        private void Replace_Click(object sender, EventArgs e)
        {
            OpenFileDialog openDlg = new OpenFileDialog();

            if (openDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            FileDataNode node = Replace(openDlg.FileName);

            if (node != null)
            {
                node.TreeView.SelectedNode = node;

                if (IsExpanded)
                {
                    node.Expand();
                }
            }
        }
예제 #13
0
        public static FileDataNode FromFile(string path, bool simplifyNode)
        {
            FileDataNode result = null;

            if (path.EndsWith(".Rmd", true, CultureInfo.CurrentCulture))
            {
                result = TryFromRmdFile(path, simplifyNode);
            }
            else if (path.EndsWith(".Pac", true, CultureInfo.CurrentCulture))
            {
                result = TryFromPacFile(path);
            }
            else if (path.EndsWith(".bf", true, CultureInfo.CurrentCulture))
            {
                result = TryFromFlowFile(path);
            }

            if (result == null)
            {
                result = TryFromRmdFile(path, simplifyNode);
            }
            if (result == null)
            {
                result = TryFromPacFile(path);
            }
            if (result == null)
            {
                result = TryFromFlowFile(path);
            }

            if (result == null)
            {
                result = TryFromRawFileData(path);
            }

            return(result);
        }
예제 #14
0
 public override void Insert(int index, FileDataNode node)
 {
     throw new NotImplementedException();
 }
예제 #15
0
 public void Import(FileDataNode node)
 {
     Insert(Nodes.Count, node);
 }
예제 #16
0
 public SurrogateDataObject(FileDataNode owner)
 {
     _FileDataNode = owner;
 }
예제 #17
0
 public virtual void Insert(int index, FileDataNode node)
 {
     Nodes.Insert(index, node);
 }
예제 #18
0
 public virtual void Remove(FileDataNode node)
 {
     Nodes.Remove(node);
 }
예제 #19
0
 public void Replace(FileDataNode node)
 {
     InsertAbove(node);
     Remove();
 }