Exemplo n.º 1
0
        private void GoToChild(UiNode child)
        {
            if (child == null || child.GetChilds().Length < 1)
            {
                return;
            }

            UiNode current = child.Parent;

            if (current != null)
            {
                current.IsSelected = false;
            }

            child.IsExpanded = true;
            child.IsSelected = true;

            while (child != null)
            {
                child.IsExpanded = true;
                child            = child.Parent;
            }

            _listView.SelectedIndex = 0;
            _listView.FocusSelectedItem();
        }
Exemplo n.º 2
0
        private UiNode[] ExpandTrbChilds()
        {
            ImgbArchiveAccessor imgbAccessor = new ImgbArchiveAccessor(_listing, _indices, _binary);

            SeDbArchiveListing sedbListing = SeDbArchiveListingReader.Read(imgbAccessor);

            UiNode[] result = new UiNode[sedbListing.Count];
            int      offset = sedbListing.Count * 16 + 0x40;

            using (Stream headers = imgbAccessor.ExtractHeaders())
                using (BinaryReader br = new BinaryReader(headers))
                {
                    for (int i = 0; i < result.Length; i++)
                    {
                        SeDbResEntry entry = sedbListing[i];
                        String       name  = entry.Index.ToString();

                        SectionType type;
                        if (TryReadSectionType(br, offset, entry, out type))
                        {
                            name = name + "." + type.ToString().ToLower();
                        }

                        result[i] = new UiSeDbTableLeaf(name, entry, sedbListing)
                        {
                            Parent = this
                        };
                    }
                }
            return(result);
        }
Exemplo n.º 3
0
 public static void RaiseSelectedNodeChanged(UiNode node)
 {
     try
     {
         SelectedLeafChanged.NullSafeInvoke(node as IUiLeaf);
     }
     catch (Exception ex)
     {
         UiHelper.ShowError(Application.Current.MainWindow, ex);
     }
 }
Exemplo n.º 4
0
 public static void RaiseSelectedNodeChanged(UiNode node)
 {
     try
     {
         SelectedLeafChanged.NullSafeInvoke(node as IUiLeaf);
     }
     catch (Exception ex)
     {
         UiHelper.ShowError(Application.Current.MainWindow, ex);
     }
 }
Exemplo n.º 5
0
        private UiContainerNode BuildExtensionNode(UiArchiveExtension key, ConcurrentBag <UiNode> entries)
        {
            string separator = Path.AltDirectorySeparatorChar.ToString();

            UiContainerNode extensionNode             = new UiContainerNode(key.ToString().ToUpper(), UiNodeType.Group);
            Dictionary <string, UiContainerNode> dirs = new Dictionary <string, UiContainerNode>(entries.Count);

            foreach (UiNode leaf in entries)
            {
                UiNode   parent = extensionNode;
                string[] path   = leaf.Name.ToLowerInvariant().Split(Path.AltDirectorySeparatorChar);
                for (int i = 0; i < path.Length - 1; i++)
                {
                    UiContainerNode directory;
                    string          directoryName = path[i];
                    string          directoryPath = String.Join(separator, path, 0, i + 1);
                    if (!dirs.TryGetValue(directoryPath, out directory))
                    {
                        directory = new UiContainerNode(directoryName, UiNodeType.Directory)
                        {
                            Parent = parent
                        };
                        dirs.Add(directoryPath, directory);
                    }
                    parent = directory;
                }
                leaf.Parent = parent;
                leaf.Name   = path[path.Length - 1];
            }

            //foreach (IGrouping<UiNode, UiNode> leafs in entries.GroupBy(e => e.Parent))
            //    ((UiContainerNode)leafs.Key).SetChilds(leafs.ToArray());

            UiNode[] childs = null;
            foreach (IGrouping <UiNode, UiNode> leafs in dirs.Values.Union(entries).GroupBy(e => e.Parent))
            {
                if (leafs.Key == extensionNode)
                {
                    childs = leafs.ToArray();
                    continue;
                }

                ((UiContainerNode)leafs.Key).SetChilds(leafs.ToArray());
            }

            foreach (UiContainerNode node in dirs.Values)
            {
                node.AbsorbSingleChildContainer();
            }

            extensionNode.SetChilds(childs);
            return(extensionNode);
        }
Exemplo n.º 6
0
        private void OnListViewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListViewItem item = sender as ListViewItem;

            if (item == null)
            {
                return;
            }

            UiNode nodeOld = (UiNode)item.Content;

            GoToChild(nodeOld);
        }
Exemplo n.º 7
0
        private UiNode[] ExpandMovieChilds()
        {
            DbArchiveAccessor dbAccessor = new DbArchiveAccessor(_listing, _indices);
            WdbMovieArchiveListing wpdListing = WdbMovieArchiveListingReader.Read(dbAccessor);

            UiNode[] result = new UiNode[wpdListing.Count];
            for (int i = 0; i < result.Length; i++)
            {
                WdbMovieEntry movieEntry = wpdListing[i];
                result[i] = new UiWdbMovieLeaf(movieEntry.Name, movieEntry, wpdListing) { Parent = this };
            }
            return result;
        }
Exemplo n.º 8
0
        private UiNode[] ExpandMovieChilds()
        {
            DbArchiveAccessor      dbAccessor = new DbArchiveAccessor(_listing, _indices);
            WdbMovieArchiveListing wpdListing = WdbMovieArchiveListingReader.Read(dbAccessor);

            UiNode[] result = new UiNode[wpdListing.Count];
            for (int i = 0; i < result.Length; i++)
            {
                WdbMovieEntry movieEntry = wpdListing[i];
                result[i] = new UiWdbMovieLeaf(movieEntry.Name, movieEntry, wpdListing)
                {
                    Parent = this
                };
            }
            return(result);
        }
Exemplo n.º 9
0
        private void GoToParent(UiNode current)
        {
            UiNode parent = current.Parent;

            if (parent == null)
            {
                return;
            }

            current.IsSelected = false;
            parent.IsExpanded  = true;
            parent.IsSelected  = true;

            _listView.SelectedItem = current;
            _listView.FocusSelectedItem();
        }
Exemplo n.º 10
0
        private UiNode[] ExpandWpdChilds()
        {
            ImgbArchiveAccessor imgbAccessor = new ImgbArchiveAccessor(_listing, _indices, _binary);
            WpdArchiveListing   wpdListing   = WpdArchiveListingReader.Read(imgbAccessor);

            UiNode[] result = new UiNode[wpdListing.Count];
            for (int i = 0; i < result.Length; i++)
            {
                WpdEntry xgrEntry = wpdListing[i];
                result[i] = new UiWpdTableLeaf(xgrEntry.Name, xgrEntry, wpdListing)
                {
                    Parent = this
                };
            }
            return(result);
        }
Exemplo n.º 11
0
        public UiContainerNode TryBuild()
        {
            if (_nodes.Count == 0)
                return null;

            int counter = 0;
            UiContainerNode result = new UiContainerNode(Lang.Dockable.GameFileCommander.ArchivesNode, UiNodeType.Group);
            UiNode[] extensions = new UiNode[_nodes.Count];
            foreach (KeyValuePair<UiArchiveExtension, ConcurrentBag<UiNode>> pair in _nodes)
            {
                UiContainerNode extensionNode = BuildExtensionNode(pair.Key, pair.Value);
                extensionNode.Parent = result;
                extensions[counter++] = extensionNode;
            }
            result.SetChilds(extensions);
            return result;
        }
Exemplo n.º 12
0
        public bool IsMatch(UiNode node)
        {
            if (!IsMandatory)
            {
                return(true);
            }
            if (Types != null && !Types.Contains(node.Type))
            {
                return(false);
            }
            if (Wildcards != null && !Wildcards.Any(w => w.IsMatch(node.Name)))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 13
0
        private void OnListViewKeyDown(object sender, KeyEventArgs e)
        {
            UiNode selectedChild = (UiNode)_listView.SelectedItem;

            if (e.Key == Key.Back)
            {
                UiNode current = (UiNode)_treeView.SelectedItem;
                if (current == null)
                {
                    return;
                }

                selectedChild.IsSelected = false;
                GoToParent(current);
            }
            else if (e.Key == Key.Enter)
            {
                GoToChild(selectedChild);
            }
        }
Exemplo n.º 14
0
        public UiContainerNode TryBuild()
        {
            if (_nodes.Count == 0)
            {
                return(null);
            }

            int             counter = 0;
            UiContainerNode result  = new UiContainerNode(Lang.Dockable.GameFileCommander.ArchivesNode, UiNodeType.Group);

            UiNode[] extensions = new UiNode[_nodes.Count];
            foreach (KeyValuePair <UiArchiveExtension, ConcurrentBag <UiNode> > pair in _nodes)
            {
                UiContainerNode extensionNode = BuildExtensionNode(pair.Key, pair.Value);
                extensionNode.Parent  = result;
                extensions[counter++] = extensionNode;
            }
            result.SetChilds(extensions);
            return(result);
        }
Exemplo n.º 15
0
        private void SelectNode()
        {
            try
            {
                string selectedPath = InteractionService.Configuration.Provide().FileCommanderSelectedNodePath;
                if (selectedPath == null)
                {
                    return;
                }

                string[] names = selectedPath.Split('|');
                int      index = names.Length - 1;

                IEnumerable <UiNode> current = _treeNodes;
                while (index >= 0)
                {
                    string name = names[index--];
                    UiNode node = current.FirstOrDefault(n => n.Name == name);
                    if (node == null)
                    {
                        break;
                    }

                    node.IsExpanded = true;
                    if (index == -1)
                    {
                        node.IsSelected = true;
                    }
                    else
                    {
                        current = node.GetChilds();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Exemplo n.º 16
0
        private void SetIsChecked(bool?value)
        {
            if (value == null && _checkedChanger == CheckedChanger.Manual)
            {
                value = !_isChecked;
            }

            if (_checkedChanger != CheckedChanger.Child && (_isExpanded || _isSelected))
            {
                UiNode[] childs = GetChilds();
                for (int i = 0; i < childs.Length; i++)
                {
                    UiNode entry = childs[i];
                    entry._checkedChanger = CheckedChanger.Parent;
                    entry.IsChecked       = value;
                }
            }

            Parent?.OnChildCheckedChanged(_isChecked, value);

            _isChecked = value;
        }
Exemplo n.º 17
0
 private void SaveFileCommanderSelectedNodePath()
 {
     try
     {
         StringBuilder sb   = new StringBuilder(256);
         UiNode        node = this;
         while (node != null)
         {
             sb.Append(node.Name);
             node = node.Parent;
             if (node != null)
             {
                 sb.Append('|');
             }
         }
         ApplicationConfigInfo configuration = InteractionService.Configuration.Provide();
         configuration.FileCommanderSelectedNodePath = sb.ToString();
         configuration.ScheduleSave();
     }
     catch (Exception ex)
     {
         Log.Error(ex);
     }
 }
Exemplo n.º 18
0
        private UiNode[] ExpandTrbChilds()
        {
            ImgbArchiveAccessor imgbAccessor = new ImgbArchiveAccessor(_listing, _indices, _binary);

            SeDbArchiveListing sedbListing = SeDbArchiveListingReader.Read(imgbAccessor);
            UiNode[] result = new UiNode[sedbListing.Count];
            int offset = sedbListing.Count * 16 + 0x40;
            using (Stream headers = imgbAccessor.ExtractHeaders())
            using (BinaryReader br = new BinaryReader(headers))
            {
                for (int i = 0; i < result.Length; i++)
                {
                    SeDbResEntry entry = sedbListing[i];
                    String name = entry.Index.ToString();

                    SectionType type;
                    if (TryReadSectionType(br, offset, entry, out type))
                        name = name + "." + type.ToString().ToLower();

                    result[i] = new UiSeDbTableLeaf(name, entry, sedbListing) {Parent = this};
                }
            }
            return result;
        }
Exemplo n.º 19
0
        private void OnListViewSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UiNode node = e.AddedItems.OfType <UiNode>().FirstOrDefault();

            InteractionService.RaiseSelectedNodeChanged(node);
        }
Exemplo n.º 20
0
 protected internal override UiNode[] SetChilds(UiNode[] childs)
 {
     throw new NotSupportedException("UiLazyChildsNode.SetChilds");
 }
Exemplo n.º 21
0
 private void Check(UiNode node)
 {
     switch (node.Type)
     {
         case UiNodeType.Group:
         case UiNodeType.Directory:
         case UiNodeType.Archive:
         {
             foreach (UiNode child in node.GetChilds())
                 Check(child);
             break;
         }
         case UiNodeType.FileTable:
         {
             if (PathComparer.Instance.Value.Equals(node.Name, @"system.win32.xgr") || node.Name.StartsWith("tutorial"))
                 foreach (UiNode child in node.GetChilds())
                     Check(child);
             break;
         }
         case UiNodeType.ArchiveLeaf:
         {
             UiArchiveLeaf leaf = (UiArchiveLeaf)node;
             string extension = PathEx.GetMultiDotComparableExtension(leaf.Entry.Name);
             switch (extension)
             {
                 case ".ztr":
                     if (leaf.Entry.Name.Contains("_us"))
                         leaf.IsChecked = true;
                     break;
             }
             break;
         }
         case UiNodeType.FileTableLeaf:
         {
             UiWpdTableLeaf leaf = (UiWpdTableLeaf)node;
             switch (leaf.Entry.Extension)
             {
                 case "wfl":
                 case "txbh":
                     leaf.IsChecked = true;
                     break;
             }
             break;
         }
     }
 }
Exemplo n.º 22
0
        protected override UiNode[] ExpandChilds()
        {
            UiChildPackageBuilder childPackages = new UiChildPackageBuilder(InteractionService.GameLocation.Provide().AreasDirectory);

            switch (InteractionService.GamePart)
            {
            case FFXIIIGamePart.Part1:
                _listing = ArchiveListingReaderV1.Read(_accessor, null, null);
                break;

            case FFXIIIGamePart.Part2:
                _listing = ArchiveListingReaderV2.Read(_accessor, null, null);
                break;

            default:
                throw new NotSupportedException(InteractionService.GamePart.ToString());
            }

            _listing.Parent = _parentListing;

            HashSet <string>            set = new HashSet <string>();
            Dictionary <string, UiNode> dic = new Dictionary <string, UiNode>(_listing.Count * 2);

            foreach (ArchiveEntry entry in _listing)
            {
                UiNode parent = this;

                string name;
                string entryPath = entry.Name.ToLowerInvariant();
                int    index     = entryPath.LastIndexOf(Path.AltDirectorySeparatorChar);
                if (index > 0)
                {
                    name = entryPath.Substring(index + 1);
                    string directoryPath = entryPath.Substring(0, index);
                    set.Add(directoryPath);
                    if (!dic.TryGetValue(directoryPath, out parent))
                    {
                        string directoryName = directoryPath;
                        int    nameIndex     = directoryPath.LastIndexOf(Path.AltDirectorySeparatorChar);
                        if (nameIndex > 0)
                        {
                            directoryName = directoryPath.Substring(nameIndex + 1);
                        }

                        parent = new UiContainerNode(directoryName, UiNodeType.Directory);
                        dic.Add(directoryPath, parent);
                    }
                }
                else
                {
                    name = entryPath;
                }

                if (!dic.ContainsKey(entryPath))
                {
                    dic.Add(entryPath, new UiArchiveLeaf(name, entry, _listing)
                    {
                        Parent = parent
                    });
                }

                childPackages.TryAdd(_listing, entry, entryPath, name);
            }

            UiContainerNode packagesNode = childPackages.TryBuild();

            if (packagesNode != null)
            {
                packagesNode.Parent = this;
                dic.Add(packagesNode.Name, packagesNode);
            }

            string separator = Path.AltDirectorySeparatorChar.ToString();

            foreach (string dir in set)
            {
                UiNode parent = this;

                string[] parts = dir.Split(Path.AltDirectorySeparatorChar);
                for (int i = 0; i < parts.Length; i++)
                {
                    UiNode node;
                    string name = parts[i];
                    string path = String.Join(separator, parts, 0, i + 1);
                    if (!dic.TryGetValue(path, out node))
                    {
                        node = new UiContainerNode(name, UiNodeType.Directory);
                        dic.Add(path, node);
                    }
                    node.Parent = parent;
                    parent      = node;
                }
            }

            UiNode[] result = EmptyChilds;
            foreach (IGrouping <UiNode, UiNode> group in dic.Values.GroupBy(n => n.Parent))
            {
                if (group.Key == this)
                {
                    result = group.ToArray();
                    continue;
                }

                UiContainerNode dir = ((UiContainerNode)group.Key);
                dir.SetChilds(group.ToArray());
            }

            foreach (UiNode node in dic.Values)
            {
                if (node.Type != UiNodeType.Directory)
                {
                    continue;
                }

                UiContainerNode container = (UiContainerNode)node;
                container.AbsorbSingleChildContainer();
            }

            return(result);
        }
Exemplo n.º 23
0
        private void GoToChild(UiNode child)
        {
            if (child == null || child.GetChilds().Length < 1)
                return;

            UiNode current = child.Parent;
            if (current != null)
                current.IsSelected = false;

            child.IsExpanded = true;
            child.IsSelected = true;

            while (child != null)
            {
                child.IsExpanded = true;
                child = child.Parent;
            }

            _listView.SelectedIndex = 0;
            _listView.FocusSelectedItem();
        }
Exemplo n.º 24
0
        private void GoToParent(UiNode current)
        {
            UiNode parent = current.Parent;
            if (parent == null)
                return;

            current.IsSelected = false;
            parent.IsExpanded = true;
            parent.IsSelected = true;

            _listView.SelectedItem = current;
            _listView.FocusSelectedItem();
        }
Exemplo n.º 25
0
        private UiNode[] ExpandWpdChilds()
        {
            ImgbArchiveAccessor imgbAccessor = new ImgbArchiveAccessor(_listing, _indices, _binary);
            WpdArchiveListing wpdListing = WpdArchiveListingReader.Read(imgbAccessor);

            UiNode[] result = new UiNode[wpdListing.Count];
            for (int i = 0; i < result.Length; i++)
            {
                WpdEntry xgrEntry = wpdListing[i];
                result[i] = new UiWpdTableLeaf(xgrEntry.Name, xgrEntry, wpdListing) {Parent = this};
            }
            return result;
        }