コード例 #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();
        }
コード例 #2
0
ファイル: UiFileTableNode.cs プロジェクト: pinguallyj/Pulse
        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);
        }
コード例 #3
0
ファイル: InteractionService.cs プロジェクト: kidaa/Pulse
 public static void RaiseSelectedNodeChanged(UiNode node)
 {
     try
     {
         SelectedLeafChanged.NullSafeInvoke(node as IUiLeaf);
     }
     catch (Exception ex)
     {
         UiHelper.ShowError(Application.Current.MainWindow, ex);
     }
 }
コード例 #4
0
 public static void RaiseSelectedNodeChanged(UiNode node)
 {
     try
     {
         SelectedLeafChanged.NullSafeInvoke(node as IUiLeaf);
     }
     catch (Exception ex)
     {
         UiHelper.ShowError(Application.Current.MainWindow, ex);
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #7
0
ファイル: UiDataTableNode.cs プロジェクト: truongan012/Pulse
        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;
        }
コード例 #8
0
ファイル: UiDataTableNode.cs プロジェクト: pinguallyj/Pulse
        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);
        }
コード例 #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();
        }
コード例 #10
0
ファイル: UiFileTableNode.cs プロジェクト: pinguallyj/Pulse
        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);
        }
コード例 #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;
        }
コード例 #12
0
ファイル: UiArchives.cs プロジェクト: pinguallyj/Pulse
        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);
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #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);
            }
        }
コード例 #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;
        }
コード例 #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);
     }
 }
コード例 #18
0
ファイル: UiFileTableNode.cs プロジェクト: truongan012/Pulse
        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;
        }
コード例 #19
0
        private void OnListViewSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UiNode node = e.AddedItems.OfType <UiNode>().FirstOrDefault();

            InteractionService.RaiseSelectedNodeChanged(node);
        }
コード例 #20
0
ファイル: UiLazyContainerNode.cs プロジェクト: kidaa/Pulse
 protected internal override UiNode[] SetChilds(UiNode[] childs)
 {
     throw new NotSupportedException("UiLazyChildsNode.SetChilds");
 }
コード例 #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;
         }
     }
 }
コード例 #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);
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #25
0
ファイル: UiFileTableNode.cs プロジェクト: truongan012/Pulse
        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;
        }