Пример #1
0
 public static void NodeChange(TreeFile tree, MemoryTreeNode node)
 {
     if (node == null)
     {
         return;
     }
     if (node.TreeNode.TypeIndicator == EnumValues.TypeIndicator.root)
     {
         var treenode     = tree.ReadNode(node.TreeNode.DiskPosition);
         var newrootcache = new MemoryTreeNode(treenode);
         tree.RootCache = newrootcache;
     }
     else
     {
         var parent = node.Parent;
         if (parent != null)
         {
             if (node.IsParentPreviousPointer)
             {
                 parent.PreviousPointer = null;
             }
             else
             {
                 parent.Children.Remove(node.TreeNode.DiskPosition);
             }
         }
     }
     node = null;
 }
Пример #2
0
        public static void TreeToBinary(String TreePath, String BinaryPath, String MainType)
        {
            var TypeName = ObjectSchemaExtensions.GetDotNetFullNameFromVersionedName(MainType);
            var a        = SchemaAssembly();
            var t        = a.GetType(TypeName);

            if (t == null)
            {
                throw new InvalidOperationException("TypeNotExist: " + TypeName);
            }
            var tbc = TreeBinaryConverter();

            var Data = TreeFile.ReadFile(TreePath);
            var b    = tbc.TreeToBinary(t, Data);
            var Dir  = FileNameHandling.GetFileDirectory(BinaryPath);

            if (Dir != "" && !Directory.Exists(Dir))
            {
                Directory.CreateDirectory(Dir);
            }
            using (var s = Streams.CreateWritable(BinaryPath))
            {
                s.Write(b);
            }
        }
Пример #3
0
        public static void BinaryToTree(String BinaryPath, String TreePath, String MainType)
        {
            var TypeName = ObjectSchemaExtensions.GetDotNetFullNameFromVersionedName(MainType);
            var a        = SchemaAssembly();
            var t        = a.GetType(TypeName);

            if (t == null)
            {
                throw new InvalidOperationException("TypeNotExist: " + TypeName);
            }
            var tbc = TreeBinaryConverter();

            Byte[] Data;
            using (var s = Streams.OpenReadable(BinaryPath))
            {
                Data = s.Read((int)(s.Length));
            }
            var x   = tbc.BinaryToTree(t, Data);
            var Dir = FileNameHandling.GetFileDirectory(TreePath);

            if (Dir != "" && !Directory.Exists(Dir))
            {
                Directory.CreateDirectory(Dir);
            }
            TreeFile.WriteFile(TreePath, x);
        }
Пример #4
0
        public static Configuration LoadConfiguration()
        {
            var x = TreeFile.ReadFile("Configuration.tree");
            var c = (new XmlSerializer()).Read <Configuration>(x);

            return(c);
        }
Пример #5
0
        void AddFileFromTreeItem(TreeFile item, bool showHidden)
        {
            if (!showHidden && item.IsHidden)
                return;

            int level = item.Level;

            string nodePrefix = new string(' ', level * 2);

            if (item.IsNode)
            {
                if (item._State == 1)
                    nodePrefix += "- ";
                else
                    nodePrefix += "+ ";
            }
            else
            {
                nodePrefix += "  ";
            }

            if (string.IsNullOrEmpty(item.Name)) //???
                item.Name = string.Empty;

            item.Owner = nodePrefix + item.Name;

            _Files.Add(item);

            if (item._State == 1)
            {
                foreach (TreeFile ti in item.ChildFiles)
                    AddFileFromTreeItem(ti, showHidden);
            }
        }
Пример #6
0
        public static MemoryTreeNode FindNextLeaf(TreeFile TreeFile, MemoryTreeNode CurrentLeaf)
        {
            if (CurrentLeaf.TreeNode.TypeIndicator != EnumValues.TypeIndicator.leaf)
            {
                throw new Exception("this method only accept leaf");
            }
            byte[] key = KeyFinder.FindSmallestBiggerKey(CurrentLeaf.ParentNodeKey, CurrentLeaf.Parent.TreeNode.KeyArray, TreeFile.comparer);

            while (key != null)
            {
                var pointer = CurrentLeaf.Parent.TreeNode.FindPointer(key);
                if (pointer != null && pointer.PositionPointer > 0)
                {
                    var nextleaf = GetOrLoadNode(TreeFile, CurrentLeaf.Parent, pointer);
                    if (nextleaf != null && nextleaf.TreeNode.TypeIndicator == EnumValues.TypeIndicator.leaf)
                    {
                        return(nextleaf);
                    }
                }

                key = KeyFinder.FindSmallestBiggerKey(key, CurrentLeaf.Parent.TreeNode.KeyArray, TreeFile.comparer);
            }

            return(GetUpLinkFirstLeaf(TreeFile, CurrentLeaf.Parent));
        }
Пример #7
0
        static void Fill(TreeFile node)
        {
            // get
            Collection<PSObject> items = A.GetChildItems(node.Path);

            foreach (PSObject item in items)
            {
                if (!(bool)item.Properties["PSIsContainer"].Value)
                    continue;

                TreeFile t = node.ChildFiles.Add();

                // name
                t.Data = item;
                t.Name = (string)item.Properties["PSChildName"].Value;
                t.Fill = TheFill;

                // description
                PSPropertyInfo pi = item.Properties["FarDescription"];
                if (pi != null && pi.Value != null)
                    t.Description = pi.Value.ToString();

                // attributes _090810_180151
                FileSystemInfo fsi = item.BaseObject as FileSystemInfo;
                if (fsi != null)
                    t.Attributes = fsi.Attributes;
                else
                    t.Attributes = FileAttributes.Directory;
            }
        }
Пример #8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ConfigurationFilePath = Path.Combine(Environment.CurrentDirectory, Assembly.GetEntryAssembly().GetName().Name + ".exe.ini");
            if (!File.Exists(ConfigurationFilePath))
            {
                ConfigurationFilePath = Assembly.GetEntryAssembly().Location + ".ini";
            }
            if (File.Exists(ConfigurationFilePath))
            {
                var x = TreeFile.ReadFile(ConfigurationFilePath);
                c = (new XmlSerializer()).Read <Configuration>(x);
            }
            else
            {
                c             = new Configuration();
                c.IP          = "127.0.0.1";
                c.Port        = 8001;
                c.Mode        = Mode.Binary;
                c.SchemaPaths = new List <String>
                {
                    "../Examples/Communication/Schema/Common",
                    "../Examples/Communication/Schema/Communication",
                    "../Examples/Communication/Schema/Compatibility"
                };
            }

            TextBox_IP.Text             = c.IP;
            TextBox_Port.Text           = c.Port.ToInvariantString();
            ComboBox_Mode.SelectedIndex = (int)c.Mode;
        }
Пример #9
0
        private static MemoryTreeNode GetUpLinkFirstLeaf(TreeFile TreeFile, MemoryTreeNode ParentNode)
        {
            if (ParentNode.TreeNode.TypeIndicator == EnumValues.TypeIndicator.root)
            {
                return(null);
            }

            MemoryTreeNode siblingNode;

            byte[] siblingkey = KeyFinder.FindSmallestBiggerKey(ParentNode.ParentNodeKey, ParentNode.Parent.TreeNode.KeyArray, TreeFile.comparer);

            while (siblingkey != null)
            {
                var pointer = ParentNode.Parent.TreeNode.FindPointer(siblingkey);
                if (pointer != null && pointer.PositionPointer > 0)
                {
                    siblingNode = GetOrLoadNode(TreeFile, ParentNode.Parent, pointer);

                    var result = FindContainerFirstLeaf(TreeFile, siblingNode);
                    if (result != null)
                    {
                        return(result);
                    }
                }
                siblingkey = KeyFinder.FindSmallestBiggerKey(siblingkey, ParentNode.Parent.TreeNode.KeyArray, TreeFile.comparer);
            }

            return(GetUpLinkFirstLeaf(TreeFile, ParentNode.Parent));
        }
Пример #10
0
        public static MemoryTreeNode FindLastLeaf(TreeFile TreeFile, MemoryTreeNode currentNode = null)
        {
            if (currentNode == null)
            {
                currentNode = TreeFile.RootCache;
            }

            NodePointer pointer = new NodePointer();
            var         key     = KeyFinder.FindLastKey(currentNode.TreeNode.KeyArray, TreeFile.comparer);

            if (key == null)
            {
                pointer.PointerBytes = currentNode.TreeNode.PreviousPointer;
            }
            else
            {
                pointer = currentNode.TreeNode.FindPointer(key);
            }


            if (pointer.PositionPointer > 0 && pointer.Indicator != EnumValues.TypeIndicator.leaf)
            {
                MemoryTreeNode newcachenode = GetOrLoadNode(TreeFile, currentNode, pointer);
                return(FindLastLeaf(TreeFile, newcachenode));
            }

            ///find the leaf that contains the key.
            if (pointer.PointerBytes != null && pointer.PositionPointer > 0 && pointer.Indicator == EnumValues.TypeIndicator.leaf)
            {
                MemoryTreeNode newcacheleaf = GetOrLoadNode(TreeFile, currentNode, pointer);
                return(newcacheleaf);
            }
            return(null);
        }
Пример #11
0
 public void Dispose()
 {
     //release the reference.
     this.treefile    = null;
     this.startnode   = null;
     this.endnode     = null;
     this.currentnode = null;
 }
Пример #12
0
            public FileItem(TreeFile file)
            {
                Verify.Argument.IsNotNull(file, "file");

                _file    = file;
                _text    = file.RelativePath;
                _icon    = GraphicsUtility.QueryIcon(file.RelativePath);
                _overlay = CachedResources.Bitmaps["ImgOverlayAdd"];
            }
Пример #13
0
        public static MemoryTreeNode GetOrLoadNode(TreeFile TreeFile, MemoryTreeNode ParentNode, NodePointer Pointer)
        {
            if (Pointer.IsFirstPreviousPointer)
            {
                if (ParentNode.PreviousPointer != null)
                {
                    return(ParentNode.PreviousPointer);
                }
                else
                {
                    TreeNode node = TreeFile.ReadNode(Pointer.PositionPointer);
                    if (node == null)
                    {
                        return(null);
                    }

                    MemoryTreeNode newcachenode = new MemoryTreeNode(node);
                    newcachenode.Parent = ParentNode;
                    newcachenode.IsParentPreviousPointer = Pointer.IsFirstPreviousPointer;
                    newcachenode.ParentNodeKey           = Pointer.KeyToPosition;
                    newcachenode.Level = ParentNode.Level + 1;

                    if (newcachenode.Level < TreeFile.MaxCacheLevel)
                    {
                        ParentNode.PreviousPointer = newcachenode;
                    }
                    return(newcachenode);
                }
            }
            else
            {
                if (ParentNode.Children.ContainsKey(Pointer.PositionPointer))
                {
                    return(ParentNode.Children[Pointer.PositionPointer]);
                }
                else
                {
                    TreeNode node = TreeFile.ReadNode(Pointer.PositionPointer);
                    if (node == null)
                    {
                        return(null);
                    }
                    MemoryTreeNode newcachenode = new MemoryTreeNode(node);
                    newcachenode.Parent = ParentNode;
                    newcachenode.IsParentPreviousPointer = Pointer.IsFirstPreviousPointer;
                    newcachenode.ParentNodeKey           = Pointer.KeyToPosition;
                    newcachenode.Level = ParentNode.Level + 1;

                    if (newcachenode.Level < TreeFile.MaxCacheLevel)
                    {
                        ParentNode.Children[Pointer.PositionPointer] = newcachenode;
                    }
                    return(newcachenode);
                }
            }
        }
Пример #14
0
 public ItemCollection(TreeFile treefile, IComparer <byte[]> comparer, byte[] startkeybytes, byte[] endkeybytes, bool loweropen, bool upperopen, bool ascending)
 {
     this.treefile      = treefile;
     this.startKeyBytes = startkeybytes;
     this.endKeyBytes   = endkeybytes;
     this.lowerOpen     = loweropen;
     this.upperOpen     = upperopen;
     this.comparer      = comparer;
     this.ascending     = ascending;
 }
Пример #15
0
        public static void JsonToTree(String JsonPath, String TreePath)
        {
            var xs = new XmlSerializer(true);
            var t  = Txt.ReadFile(JsonPath);
            var j  = Niveum.Json.JToken.Parse(t);
            var o  = World.Json.JsonTranslator.WorldFromJson(j);
            var x  = xs.Write <World.World>(o);

            TreeFile.WriteFile(TreePath, x);
        }
Пример #16
0
        public static void TreeToJson(String TreePath, String JsonPath)
        {
            var xs = new XmlSerializer(true);
            var x  = TreeFile.ReadFile(TreePath);
            var o  = xs.Read <World.World>(x);
            var j  = World.Json.JsonTranslator.WorldToJson(o);
            var t  = j.ToString(Niveum.Json.Formatting.Indented);

            Txt.WriteFile(JsonPath, t);
        }
Пример #17
0
        public TreeNode(TreeFile tree)
        {
            this.tree = tree;

            KeyArray = new Dictionary <byte[], byte[]>(this.tree.equalitycomparer);

            _freeRelativePos = new HashSet <int>();

            PreviousPointer = new byte[this.tree.config.PointerLen];
        }
Пример #18
0
 public void Close()
 {
     lock (_object)
     {
         if (_tree != null)
         {
             _tree.Close();
             _tree = null;
         }
     }
 }
Пример #19
0
        public static void TreeToBinaryWithFirefly(String TreePath, String BinaryPath)
        {
            var tbc  = new TreeBinaryConverter();
            var Data = TreeFile.ReadFile(TreePath);
            var b    = tbc.TreeToBinary <World.World>(Data);

            using (var s = Streams.CreateWritable(BinaryPath))
            {
                s.Write(b);
            }
        }
Пример #20
0
    void SaveTreeData(TreeFile treeData)
    {
        string          dataPath        = Path.Combine(folderPath, treeData.fileName + ConstantScript.fileExtension);
        BinaryFormatter binaryFormatter = new BinaryFormatter();

        using (FileStream fileStream = File.Open(dataPath, FileMode.OpenOrCreate))
        {
            binaryFormatter.Serialize(fileStream, treeData);
        }
        Debug.Log("Data Path:" + dataPath);
    }
Пример #21
0
        private static MemoryTreeNode FindContainerLastLeaf(TreeFile TreeFile, MemoryTreeNode ContainerNode)
        {
            if (ContainerNode == null)
            {
                return(null);
            }
            if (ContainerNode.TreeNode.TypeIndicator == EnumValues.TypeIndicator.leaf)
            {
                return(ContainerNode);
            }

            NodePointer pointer = new NodePointer();

            pointer.PointerBytes = ContainerNode.TreeNode.PreviousPointer;

            if (pointer.PositionPointer > 0)
            {
                var subnode = GetOrLoadNode(TreeFile, ContainerNode, pointer);
                if (subnode != null)
                {
                    var result = FindContainerFirstLeaf(TreeFile, subnode);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            // did not get return, try one key by one key.
            byte[] key = KeyFinder.FindSmallestBiggerKey(null, ContainerNode.TreeNode.KeyArray, TreeFile.comparer);

            while (key != null)
            {
                var nodepointer = ContainerNode.TreeNode.FindPointer(key);

                if (nodepointer != null && nodepointer.PositionPointer > 0)
                {
                    var keynode = GetOrLoadNode(TreeFile, ContainerNode, nodepointer);
                    if (keynode != null)
                    {
                        var result = FindContainerFirstLeaf(TreeFile, keynode);
                        if (result != null)
                        {
                            return(result);
                        }
                    }
                }

                key = KeyFinder.FindSmallestBiggerKey(key, ContainerNode.TreeNode.KeyArray, TreeFile.comparer);
            }

            return(null);
        }
Пример #22
0
 private void OnUnstagedDeleted(object sender, EventArgs e)
 {
     _unstaged = null;
     if (_staged == null)
     {
         RemoveSafe();
     }
     else
     {
         UpdateCheckedState();
     }
 }
Пример #23
0
        public static void DumpSyntaxResult(String InputDirectory, String OutputDirectory)
        {
            var Files = new Dictionary <String, FileParserResult>();

            foreach (var FilePath in Directory.EnumerateFiles(InputDirectory, "*.tree", SearchOption.AllDirectories))
            {
                var AbsolutePath = FileNameHandling.GetAbsolutePath(FilePath, System.Environment.CurrentDirectory);
                var FileContent  = Txt.ReadFile(FilePath);
                var Text         = TokenParser.BuildText(FileContent, AbsolutePath);
                var Result       = FileParser.ParseFile(Text);
                Files.Add(AbsolutePath, Result);
            }

            //var arr = AmbiguousRemover.Reduce(Files, new List<String> { }, new TypeProvider());
            //if (arr.UnresolvableAmbiguousOrErrors.Count > 0)
            //{
            //    var l = new List<String> { };
            //    foreach (var p in arr.UnresolvableAmbiguousOrErrors)
            //    {
            //        var ErrorMessage = p.Key;
            //        var ErrorRange = p.Value;
            //        l.Add(p.Key + ": " + ErrorRange.Text.Path + (ErrorRange.Range.OnSome ? ": " + ErrorRange.Range.Value.ToString() : ""));
            //    }
            //    var OutputPath = FileNameHandling.GetPath(OutputDirectory, "Error.txt");
            //    var OutputDir = FileNameHandling.GetFileDirectory(OutputPath);
            //    if (!Directory.Exists(OutputDir)) { Directory.CreateDirectory(OutputDir); }
            //    Txt.WriteFile(OutputPath, String.Join("\r\n", l) + "\r\n");
            //    return;
            //}
            //Files = arr.Files;

            foreach (var p in Files)
            {
                var RelativePath = FileNameHandling.GetRelativePath(p.Key, FileNameHandling.GetAbsolutePath(InputDirectory, System.Environment.CurrentDirectory));
                var FileName     = FileNameHandling.GetFileName(p.Key);
                var fd           = new FileDumper();
                var Comment
                    = "==========================================================================" + "\r\n"
                      + "\r\n"
                      + "  SourceFile:  " + FileName + "\r\n"
                      + "\r\n"
                      + "==========================================================================";
                var f          = fd.Dump(p.Value, Comment);
                var OutputPath = FileNameHandling.GetPath(FileNameHandling.GetPath(OutputDirectory, FileNameHandling.GetFileDirectory(RelativePath)), FileNameHandling.GetMainFileName(FileName) + ".syn.tree");
                var OutputDir  = FileNameHandling.GetFileDirectory(OutputPath);
                if (!Directory.Exists(OutputDir))
                {
                    Directory.CreateDirectory(OutputDir);
                }
                TreeFile.WriteRaw(OutputPath, f);
            }
        }
Пример #24
0
 void LoadTreeData(TreeFile treeData)
 {
     GameObject[] allTrees = GameObject.FindGameObjectsWithTag("Tree");
     for (int i = 0; i < allTrees.Length; i++)
     {
         DeleteTree(allTrees[i]);
     }
     for (int j = 0; j < treeData.treeList.Count; j++)
     {
         PlantTree(treeData.treeList[j].treeName, treeData.treeList[j].treeType, treeData.treeList[j].treePositionX, treeData.treeList[j].treePositionZ);
     }
     treeId = treeData.treeId;
 }
Пример #25
0
        public static void BinaryToTreeWithFirefly(String BinaryPath, String TreePath)
        {
            var tbc = new TreeBinaryConverter();

            Byte[] Data;
            using (var s = Streams.OpenReadable(BinaryPath))
            {
                Data = s.Read((int)(s.Length));
            }
            var x = tbc.BinaryToTree <World.World>(Data);

            TreeFile.WriteFile(TreePath, x);
        }
Пример #26
0
        public ConflictedFileMenu(TreeFile file)
        {
            Verify.Argument.IsValidGitObject(file, "file");
            Verify.Argument.AreEqual(StagedStatus.Unstaged, file.StagedStatus & StagedStatus.Unstaged, "file",
                                     "This file is not unstaged.");
            Verify.Argument.AreNotEqual(ConflictType.None, file.ConflictType, "file",
                                        "This file is not in conflicted state.");

            _file = file;

            Items.Add(GuiItemFactory.GetMergeToolItem <ToolStripMenuItem>(_file));
            if (_file.ConflictType != ConflictType.DeletedByUs &&
                _file.ConflictType != ConflictType.DeletedByThem &&
                _file.ConflictType != ConflictType.AddedByThem &&
                _file.ConflictType != ConflictType.AddedByUs)
            {
                var mergeTools = new ToolStripMenuItem("Select Merge Tool");
                foreach (var tool in MergeTool.KnownTools)
                {
                    if (tool.SupportsWin)
                    {
                        mergeTools.DropDownItems.Add(GuiItemFactory.GetMergeToolItem <ToolStripMenuItem>(_file, tool));
                    }
                }
                Items.Add(mergeTools);
            }

            Items.Add(new ToolStripSeparator());

            switch (_file.ConflictType)
            {
            case ConflictType.DeletedByThem:
            case ConflictType.DeletedByUs:
                Items.Add(GuiItemFactory.GetResolveConflictItem <ToolStripMenuItem>(_file, ConflictResolution.KeepModifiedFile));
                Items.Add(GuiItemFactory.GetResolveConflictItem <ToolStripMenuItem>(_file, ConflictResolution.DeleteFile));
                break;

            case ConflictType.AddedByThem:
            case ConflictType.AddedByUs:
                Items.Add(GuiItemFactory.GetResolveConflictItem <ToolStripMenuItem>(_file, ConflictResolution.KeepModifiedFile));
                Items.Add(GuiItemFactory.GetResolveConflictItem <ToolStripMenuItem>(_file, ConflictResolution.DeleteFile));
                break;

            default:
                Items.Add(GuiItemFactory.GetMarkAsResolvedItem <ToolStripMenuItem>(_file));
                Items.Add(GuiItemFactory.GetResolveConflictItem <ToolStripMenuItem>(_file, ConflictResolution.UseOurs));
                Items.Add(GuiItemFactory.GetResolveConflictItem <ToolStripMenuItem>(_file, ConflictResolution.UseTheirs));
                break;
            }
        }
Пример #27
0
        internal void OnFileContextMenuRequested(TreeFile file)
        {
            var handler = (EventHandler <UntrackedFileContextMenuRequestedEventArgs>)Events[UntrackedFileContextMenuRequestedEvent];

            if (handler != null)
            {
                var args = new UntrackedFileContextMenuRequestedEventArgs(file);
                handler(this, args);
                if (args.ContextMenu != null)
                {
                    args.ContextMenu.Show(this, PointToClient(Cursor.Position));
                }
            }
        }
Пример #28
0
 private void RemoveTreeItem(TreeFile file)
 {
     foreach (WorktreeConflictedFileItem item in _lstConflicts.Items)
     {
         if (item.DataContext.RelativePath == file.RelativePath)
         {
             item.RemoveSafe();
             break;
         }
     }
     if (_lstConflicts.Items.Count == 0)
     {
         ClickOk();
     }
 }
Пример #29
0
 public void DelSelf()
 {
     lock (_object)
     {
         if (_tree != null)
         {
             _tree.Close();
             _tree = null;
         }
         if (System.IO.File.Exists(fullindexfilename))
         {
             File.Delete(fullindexfilename);
         }
     }
 }
Пример #30
0
        public ConflictedFileMenu(TreeFile file)
        {
            Verify.Argument.IsValidGitObject(file, "file");
            Verify.Argument.AreEqual(StagedStatus.Unstaged, file.StagedStatus & StagedStatus.Unstaged, "file",
                "This file is not unstaged.");
            Verify.Argument.AreNotEqual(ConflictType.None, file.ConflictType, "file",
                "This file is not in conflicted state.");

            _file = file;

            Items.Add(GuiItemFactory.GetMergeToolItem<ToolStripMenuItem>(_file));
            if( _file.ConflictType != ConflictType.DeletedByUs &&
                _file.ConflictType != ConflictType.DeletedByThem &&
                _file.ConflictType != ConflictType.AddedByThem &&
                _file.ConflictType != ConflictType.AddedByUs)
            {
                var mergeTools = new ToolStripMenuItem("Select Merge Tool");
                foreach(var tool in MergeTool.KnownTools)
                {
                    if(tool.SupportsWin)
                    {
                        mergeTools.DropDownItems.Add(GuiItemFactory.GetMergeToolItem<ToolStripMenuItem>(_file, tool));
                    }
                }
                Items.Add(mergeTools);
            }

            Items.Add(new ToolStripSeparator());

            switch(_file.ConflictType)
            {
                case ConflictType.DeletedByThem:
                case ConflictType.DeletedByUs:
                    Items.Add(GuiItemFactory.GetResolveConflictItem<ToolStripMenuItem>(_file, ConflictResolution.KeepModifiedFile));
                    Items.Add(GuiItemFactory.GetResolveConflictItem<ToolStripMenuItem>(_file, ConflictResolution.DeleteFile));
                    break;
                case ConflictType.AddedByThem:
                case ConflictType.AddedByUs:
                    Items.Add(GuiItemFactory.GetResolveConflictItem<ToolStripMenuItem>(_file, ConflictResolution.KeepModifiedFile));
                    Items.Add(GuiItemFactory.GetResolveConflictItem<ToolStripMenuItem>(_file, ConflictResolution.DeleteFile));
                    break;
                default:
                    Items.Add(GuiItemFactory.GetMarkAsResolvedItem<ToolStripMenuItem>(_file));
                    Items.Add(GuiItemFactory.GetResolveConflictItem<ToolStripMenuItem>(_file, ConflictResolution.UseOurs));
                    Items.Add(GuiItemFactory.GetResolveConflictItem<ToolStripMenuItem>(_file, ConflictResolution.UseTheirs));
                    break;
            }
        }
Пример #31
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            c.IP   = TextBox_IP.Text;
            c.Port = NumericStrings.InvariantParseInt32(TextBox_Port.Text);
            c.Mode = GetMode();

            var x = (new XmlSerializer()).Write(c);

            try
            {
                TreeFile.WriteFile(ConfigurationFilePath, x);
            }
            catch
            {
            }
        }
Пример #32
0
    public string SetFile(string filePath, [OptionalAttribute, DefaultParameterValueAttribute(BinaryPrefix.Kibibytes)] BinaryPrefix prefix)
    {
        TreeFile f = new TreeFile(filePath);
        mFiles.Add(f);

        mSizeOfFiles += f.GetSize(BinaryPrefix.Kibibytes);

        switch (prefix)
        {
            case BinaryPrefix.Mebibytes:
                return f.GetSize(BinaryPrefix.Mebibytes).ToString("N") + " MiB";
            case BinaryPrefix.Gibibytes:
                return f.GetSize(BinaryPrefix.Gibibytes).ToString("N") + " GiB";
            default:
                return f.GetSize(BinaryPrefix.Kibibytes).ToString("N") + " KiB";
        }
    }
Пример #33
0
        private static MemoryTreeNode GetUpLinkLastLeaf(TreeFile TreeFile, MemoryTreeNode ParentNode)
        {
            if (ParentNode.TreeNode.TypeIndicator == EnumValues.TypeIndicator.root)
            {
                return(null);
            }

            MemoryTreeNode siblingNode;

            byte[] siblingkey = KeyFinder.FindBiggestSmallerKey(ParentNode.ParentNodeKey, ParentNode.Parent.TreeNode.KeyArray, TreeFile.comparer);

            while (siblingkey != null)
            {
                var pointer = ParentNode.Parent.TreeNode.FindPointer(siblingkey);
                if (pointer != null && pointer.PositionPointer > 0)
                {
                    siblingNode = GetOrLoadNode(TreeFile, ParentNode.Parent, pointer);

                    var result = FindContainerLastLeaf(TreeFile, siblingNode);
                    if (result != null)
                    {
                        return(result);
                    }
                }
                siblingkey = KeyFinder.FindBiggestSmallerKey(siblingkey, ParentNode.Parent.TreeNode.KeyArray, TreeFile.comparer);
            }

            /// need to check the first previous pointer after process all key arrays.
            NodePointer previousPointer = new NodePointer();

            previousPointer.PointerBytes = ParentNode.Parent.TreeNode.PreviousPointer;

            var PreviousPointerNode = GetOrLoadNode(TreeFile, ParentNode.Parent, previousPointer);

            //parentNode.Parent.PreviousPointerNode can't be the same with ParentNode,otherwise it will cause a dead cycle.
            if (PreviousPointerNode != null && ParentNode != PreviousPointerNode)
            {
                var result = FindContainerLastLeaf(TreeFile, PreviousPointerNode);
                if (result != null)
                {
                    return(result);
                }
            }

            return(GetUpLinkLastLeaf(TreeFile, ParentNode.Parent));
        }
Пример #34
0
        public static ObjectSchemaTemplateInfo FromBinary(Byte[] Bytes)
        {
            XElement x;

            using (ByteArrayStream s = new ByteArrayStream(Bytes))
            {
                using (var sr = Txt.CreateTextReader(s.AsNewReading(), TextEncoding.Default, true))
                {
                    x = TreeFile.ReadFile(sr);
                }
            }

            XmlSerializer xs = new XmlSerializer();
            var           t  = xs.Read <ObjectSchemaTemplate>(x);
            var           ti = new ObjectSchemaTemplateInfo(t);

            return(ti);
        }
Пример #35
0
 public ComboFileStatusItem(TreeFile staged, TreeFile unstaged)
 {
     _staged = staged;
     _unstaged = unstaged;
     UpdateCheckedState();
 }
Пример #36
0
 private void OnUnstagedDeleted(object sender, EventArgs e)
 {
     _unstaged = null;
     if(_staged == null)
     {
         RemoveSafe();
     }
     else
     {
         UpdateCheckedState();
     }
 }
Пример #37
0
        void Reset(string path)
        {
            // set location
            if (!string.IsNullOrEmpty(path) && path != ".")
                A.Psf.Engine.SessionState.Path.SetLocation(path);

            // get location
            PathInfoEx location = new PathInfoEx(A.Psf.Engine.SessionState.Path.CurrentLocation);
            if (!My.ProviderInfoEx.IsNavigation(location.Provider))
                throw new RuntimeException("Provider '" + location.Provider + "' does not support navigation.");

            // get root item
            Collection<PSObject> items = A.Psf.Engine.SessionState.InvokeProvider.Item.Get(new string[] { "." }, true, true);
            PSObject data = items[0];

            // reset roots
            RootFiles.Clear();
            TreeFile ti = new TreeFile();
            ti.Name = location.Path; // special case name for the root
            ti.Fill = TheFill;
            ti.Data = data;
            RootFiles.Add(ti);
            ti.Expand();

            // panel info
            Location = ti.Path;
        }
Пример #38
0
            public FileItem(TreeFile file)
            {
                Verify.Argument.IsNotNull(file, "file");

                _file = file;
                _text = file.RelativePath;
                _icon = GraphicsUtility.QueryIcon(file.RelativePath);
                _overlay = CachedResources.Bitmaps["ImgOverlayAdd"];
            }
 public UntrackedFileContextMenuRequestedEventArgs(TreeFile file)
 {
     _file = file;
 }