Exemplo n.º 1
0
        private void LoadNonCachedDependencies(DirectoryTreeNode directoryNode, string url, Dictionary <string, string> urls)
        {
            foreach (string name in urls.Keys)
            {
                string curUrl = string.Format("{0}/{1}", url, name);

                if (!Application.ReferencesCache.ContainsKey(urls[name]))
                {
                    Application.ReferencesCache.Append(urls[name], false, false);
                }

                Info      info      = SVNManager.Instance.Info(curUrl);
                CacheInfo cacheInfo = Application.ReferencesCache[curUrl];

                string lastRevision = SVNManager.Instance.LastRevision(curUrl);

                if (!lastRevision.Equals(cacheInfo.LastRevision))
                {
                    Application.ReferencesCache[curUrl].LastRevision = info.Entry.Revision;
                    Application.ReferencesCache.Save();
                }

                this.LoadNonCachedDependency(directoryNode, info, name, curUrl);
            }
        }
Exemplo n.º 2
0
        private void InitGGPK()
        {
            if (content != null)
            {
                return;
            }

            string ggpkPath = textBoxContentGGPK.Text;

            if (!File.Exists(ggpkPath))
            {
                OutputLine(string.Format("GGPK {0} not exists.", ggpkPath));
                return;
            }
            OutputLine(string.Format("Parsing {0}", ggpkPath));

            content = new GGPK();
            content.Read(ggpkPath, Output);

            RecordsByPath = new Dictionary <string, FileRecord>(content.RecordOffsets.Count);
            DirectoryTreeNode.TraverseTreePostorder(content.DirectoryRoot, null, n => RecordsByPath.Add(n.GetDirectoryPath() + n.Name, n as FileRecord));

            textBoxContentGGPK.Enabled = false;
            buttonSelectPOE.Enabled    = false;

            CreateExampleRegistryFile(ggpkPath);
        }
Exemplo n.º 3
0
        private void treeView1_BeforeExpand(object sender, RoutedEventArgs e)
        {
            if (_suppressEventHandling)
            {
                return;
            }

            DirectoryTreeNode node = sender as DirectoryTreeNode;

            if (node == null)
            {
                return;
            }

            _suppressEventHandling = true;
            try
            {
                UpdateNodeChildren(node);
                node.IsSelected = true;
            }
            finally
            {
                _suppressEventHandling = false;
            }

            e.Handled = true;
        }
Exemplo n.º 4
0
        private TreeViewItem FindNode(TreeViewItem parentNode, ItemCollection nodes, string directory, int attemptNumber = 1)
        {
            if (attemptNumber < 1)
            {
                throw new ArgumentOutOfRangeException("attemptNumber", attemptNumber, "attemptNumber must be >= 1");
            }

            if (attemptNumber > 2)
            {
                return(parentNode);
            }

            List <TreeViewItem> childNodes = new List <TreeViewItem>();

            foreach (TreeViewItem childNode in nodes)
            {
                childNodes.Add(childNode);
                DirectoryTreeNode dirNode = childNode as DirectoryTreeNode;
                if (dirNode == null)
                {
                    continue;
                }

                if (string.Compare(dirNode.Directory, directory, true) == 0)
                {
                    return(dirNode);
                }
            }

            UpdateNodeChildren((DirectoryTreeNode)parentNode);

            TreeViewItem node = FindNode(parentNode, parentNode.Items, directory, attemptNumber + 1);

            return(node);
        }
Exemplo n.º 5
0
        private void treeView1_BeforeCollapse(object sender, RoutedEventArgs e)
        {
            if (_suppressEventHandling)
            {
                return;
            }

            DirectoryTreeNode node = sender as DirectoryTreeNode;

            if (node == null)
            {
                return;
            }

            _suppressEventHandling = true;
            try
            {
                _viewModel.CurrentDirectory = node.Directory;
                node.IsSelected             = true;
                node.IsExpanded             = false;
            }
            finally
            {
                _suppressEventHandling = false;
            }
        }
Exemplo n.º 6
0
        private void LoadDirectories()
        {
            this.Cursor = Cursors.WaitCursor;

            string url = string.Format("{0}/References", SVNManager.DEV_URL);

            Dictionary <string, string> directories = SVNManager.Instance.List(url, false);

            foreach (string name in directories.Keys)
            {
                Directory directory = new Directory(name);
                directory.Url = string.Format("{0}/{1}/Current", url, name);

                if (!Application.ReferencesCache.ContainsKey(directory.Url))
                {
                    Info info = SVNManager.Instance.Info(directory.Url);

                    if (info != null)
                    {
                        Application.ReferencesCache.Append(directory.Url, false, false);
                    }
                    else
                    {
                        continue;
                    }
                }

                DirectoryTreeNode node = new DirectoryTreeNode(directory);
                node.ImageIndex         = 0;
                node.SelectedImageIndex = 0;
                this.tvDependencies.Nodes.Add(node);
            }

            this.Cursor = Cursors.Default;
        }
Exemplo n.º 7
0
 /// <summary>
 ///     Creates a new content node.
 /// </summary>
 /// <param name="name">Name of the node.</param>
 /// <param name="parent">Parent of the node.</param>
 /// <param name="content">Content stored in the node.</param>
 /// <param name="mutable">If <c>true</c>, node can be modified after creation.</param>
 public ContentTreeNode(string name, DirectoryTreeNode <T> parent, T content, bool mutable = true)
     : base(mutable)
 {
     Name    = name;
     Parent  = parent;
     Content = content;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Recursivly adds the specified GGPK DirectoryTree to the TreeListView
        /// </summary>
        /// <param name="directoryTreeNode">Node to add to tree</param>
        /// <param name="parentControl">TreeViewItem to add children to</param>
        private void AddDirectoryTreeToControl(DirectoryTreeNode directoryTreeNode, ItemsControl parentControl)
        {
            TreeViewItem rootItem = new TreeViewItem {
                Header = directoryTreeNode
            };

            if ((directoryTreeNode.ToString() == "ROOT") || (directoryTreeNode.ToString() == ""))
            {
                rootItem.IsExpanded = true;
            }

            if (parentControl == null)
            {
                treeView.Items.Add(rootItem);
            }
            else
            {
                parentControl.Items.Add(rootItem);
            }
            directoryTreeNode.Children.Sort();
            foreach (var item in directoryTreeNode.Children)
            {
                AddDirectoryTreeToControl(item, rootItem);
            }
            directoryTreeNode.Files.Sort();
            foreach (var item in directoryTreeNode.Files)
            {
                rootItem.Items.Add(item);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Exports entire DirectoryTreeNode to disk, preserving directory structure
        /// </summary>
        /// <param name="selectedDirectoryNode">Node to export to disk</param>
        private void ExportAllItemsInDirectory(DirectoryTreeNode selectedDirectoryNode)
        {
            List <FileRecord>   recordsToExport = new List <FileRecord>();
            Action <FileRecord> fileAction      = recordsToExport.Add;

            DirectoryTreeNode.TraverseTreePreorder(selectedDirectoryNode, null, fileAction);
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog
                {
                    FileName = Settings.Strings["ExportAllItemsInDirectory_Default_FileName"]
                };
                if (saveFileDialog.ShowDialog() != true)
                {
                    return;
                }
                string exportDirectory = Path.GetDirectoryName(saveFileDialog.FileName) + Path.DirectorySeparatorChar;
                foreach (var item in recordsToExport)
                {
                    item.ExtractFileWithDirectoryStructure(ggpkPath, exportDirectory);
                }
                MessageBox.Show(string.Format(Settings.Strings["ExportAllItemsInDirectory_Successful"], recordsToExport.Count),
                                Settings.Strings["ExportAllItemsInDirectory_Successful_Caption"], MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(Settings.Strings["ExportAllItemsInDirectory_Failed"], ex.Message),
                                Settings.Strings["Error_Caption"], MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 10
0
        private static void ExportLanguageDataFile(string contentFilePath, DirectoryTreeNode dataDir, JsonWriter jsonWriter, string datFileName, Action <int, RecordData, JsonWriter> writeRecordData)
        {
            foreach (var language in Language.All)
            {
                // Determine the directory to search for the given datFile. English is the base/main language and isn't located in a sub-folder.
                var searchDir = language == Language.English ? dataDir : dataDir.Children.FirstOrDefault(x => x.Name == language);
                if (searchDir == null)
                {
                    Logger.WriteLine($"\t{language} Language folder not found.");
                    continue;
                }

                // Find the given datFile.
                var datContainer = GetDatContainer(searchDir, contentFilePath, datFileName);
                if (datContainer == null)
                {
                    // An error was already logged.
                    continue;
                }

                Logger.WriteLine($"\tExporting {datFileName} in {language}.");

                // Create a node and write the data of each record in this node.
                jsonWriter.WritePropertyName(language);
                jsonWriter.WriteStartObject();

                for (int j = 0, recordsLength = datContainer.Records.Count; j < recordsLength; j++)
                {
                    writeRecordData(j, datContainer.Records[j], jsonWriter);
                }

                jsonWriter.WriteEndObject();
            }
        }
Exemplo n.º 11
0
        private DirectoryTreeNode RecursiveFind(TreeNodeCollection root, string path)
        {
            DirectoryTreeNode result = null;

            foreach (TreeNode node in root)
            {
                if (node is DirectoryTreeNode)
                {
                    DirectoryTreeNode dnode = node as DirectoryTreeNode;
                    if (string.Compare(dnode.LinuxPath, path, false) == 0)
                    {
                        return(dnode);
                    }
                    if (dnode.Nodes.Count > 0)
                    {
                        result = RecursiveFind(dnode.Nodes, path);
                        if (result != null)
                        {
                            return(result);
                        }
                    }
                }
            }

            return(null);
        }
Exemplo n.º 12
0
    public DirectoryTreeNode PopulateDirectoryTreeView(FileDirectory rd)
    {
        DirectoryTreeNode directoryTreeNode = new DirectoryTreeNode(rd);
        directoryTreeNode.Name = rd.getPath();
        directoryTreeNode.Text = rd.getPath();

        foreach (FileDirectory current in rd.getChildren()){
            this.PopulateDirectoryTreeViewForChildren(current, directoryTreeNode);
        }
        return directoryTreeNode;
    }
Exemplo n.º 13
0
        /// <summary>
        /// Reloads the entire content.ggpk, rebuilds the tree
        /// </summary>
        private void ReloadGGPK()
        {
            treeView1.Items.Clear();
            ResetViewer();
            textBoxOutput.Visibility = System.Windows.Visibility.Visible;
            textBoxOutput.Text       = string.Empty;
            content = null;

            workerThread = new Thread(new ThreadStart(() =>
            {
                content = new GGPK();
                try
                {
                    content.Read(ggpkPath, Output);
                }
                catch (Exception ex)
                {
                    Output(string.Format(Settings.Strings["ReloadGGPK_Failed"], ex.Message));
                    return;
                }

                if (content.IsReadOnly)
                {
                    Output(Settings.Strings["ReloadGGPK_ReadOnly"] + Environment.NewLine);
                    UpdateTitle(Settings.Strings["MainWindow_Title_Readonly"]);
                }

                OutputLine(Settings.Strings["ReloadGGPK_Traversing_Tree"]);

                // Collect all FileRecordPath -> FileRecord pairs for easier replacing
                RecordsByPath = new Dictionary <string, FileRecord>(content.RecordOffsets.Count);
                DirectoryTreeNode.TraverseTreePostorder(content.DirectoryRoot, null, n => RecordsByPath.Add(n.GetDirectoryPath() + n.Name, n as FileRecord));

                treeView1.Dispatcher.BeginInvoke(new Action(() =>
                {
                    try
                    {
                        AddDirectoryTreeToControl(content.DirectoryRoot, null);
                    }
                    catch (Exception ex)
                    {
                        Output(string.Format(Settings.Strings["Error_Read_Directory_Tree"], ex.Message));
                        return;
                    }

                    workerThread = null;
                }), null);


                OutputLine(Settings.Strings["ReloadGGPK_Successful"]);
            }));

            workerThread.Start();
        }
Exemplo n.º 14
0
    public void PopulateDirectoryTreeViewForChildren(FileDirectory rd, TreeNode root)
    {
        DirectoryTreeNode directoryTreeNode = new DirectoryTreeNode(rd);
        directoryTreeNode.Text = rd.getPath();
        directoryTreeNode.Name = rd.getPath();
        root.Nodes.Add(directoryTreeNode);

        foreach (FileDirectory current in rd.getChildren()) {
            this.PopulateDirectoryTreeViewForChildren(current, directoryTreeNode);
        }
    }
Exemplo n.º 15
0
        public async void LoadFileTreeView()
        {
            btnSearch.Text     = "Processing...";
            btnSearch.Enabled  = false;
            pbxLoading.Visible = true;
            tvFileSystem.Nodes.Clear();
            cbxSortBy.Enabled    = false;
            lblSortArrow.Visible = false;
            ShowHideDetailLabels(false);
            if (dgvFiles.Rows.Count != 0)
            {
                dgvFiles.Rows.Clear();
            }

            string selectedDrive = cbxPartitionLetters.SelectedItem?.ToString();

            // Creating root node object and getting his child nodes
            DirectoryTreeNode rootNode = new DirectoryTreeNode(selectedDrive)
            {
                Tag              = new DirectoryInfo(selectedDrive),
                ImageKey         = "harddisk.png",
                SelectedImageKey = "harddisk.png"
            };
            var childs = await Task.Run(() => filesManipulation.GetDirectoryChildren(selectedDrive));

            // Showing results and configurating some controls
            if (childs.Error == null)
            {
                cbxSortBy.Enabled    = true;
                lblSortArrow.Visible = true;

                tvFileSystem.BeginUpdate();

                rootNode.Nodes.AddRange(childs.ChildNodes.ToArray());
                tvFileSystem.Nodes.Add(rootNode);
                tvFileSystem.Nodes[0].Expand();

                tvFileSystem.EndUpdate();

                if (!CheckIfIsCached(selectedDrive))
                {
                    CacheData(selectedDrive);
                }
            }
            else
            {
                MessageBox.Show("Error occured while trying to get files.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            pbxLoading.Visible = false;
            btnSearch.Text     = "Process";
            btnSearch.Enabled  = true;
        }
Exemplo n.º 16
0
        private void LoadDirectories()
        {
            this.Cursor = Cursors.WaitCursor;

            Dictionary <string, string> directories = SVNManager.Instance.List(SVNManager.DEV_URL, false);

            foreach (string name in directories.Keys)
            {
                if (name.Equals("Sources") ||
                    name.Equals("Version") ||
                    name.Equals("Plugins"))
                {
                    continue;
                }

                string url = string.Format("{0}/{1}/{2}/{3}", SVNManager.DEV_URL, name, this.PluginData.Parent.Product.Name, this.PluginData.Parent.VersionNumber);

                Info info = SVNManager.Instance.Info(url);

                if (info == null)
                {
                    continue;
                }

                Directory directory = this.PluginData.Content[name] as Directory;

                if (directory == null)
                {
                    directory = new Directory(name, string.Empty, url);
                }

                directory.Url = url;

                DirectoryTreeNode node = new DirectoryTreeNode(directory);
                node.SelectedImageIndex = 0;
                node.ImageIndex         = 0;
                if (name.Equals("References"))
                {
                    node.Text = "Bin";
                    node.Name = "Bin";
                }

                this.tvContent.Nodes.Add(node);
            }

            foreach (DirectoryTreeNode node in this.tvContent.Nodes)
            {
                LoadContent(node);
            }

            this.Cursor = Cursors.Default;
        }
Exemplo n.º 17
0
        private void LoadCachedDependencies(DirectoryTreeNode directoryNode, string url, Dictionary <string, string> urls)
        {
            foreach (string name in urls.Keys)
            {
                string curUrl = string.Format("{0}/{1}", url, name);

                if (!Application.ReferencesCache.ContainsKey(urls[name]))
                {
                    this.LoadNonCachedDependencies(directoryNode, url, urls);
                    return;
                }

                CacheInfo cacheInfo = Application.ReferencesCache[urls[name]];

                if (cacheInfo == null)
                {
                    Info info = SVNManager.Instance.Info(curUrl);

                    this.LoadNonCachedDependency(directoryNode, info, name, curUrl);
                }
                else if (cacheInfo.IsDirectory)
                {
                    Directory directory = new Directory(name);

                    directory.Url = curUrl;

                    DirectoryTreeNode node = new DirectoryTreeNode(directory);
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 0;
                    directoryNode.Nodes.Add(node);
                }
                else
                {
                    DependencyAssembly dependencyAssembly = this.PluginData.DependencyAssemblies[name] as DependencyAssembly;

                    bool contains = dependencyAssembly != null;

                    if (!contains)
                    {
                        dependencyAssembly = new DependencyAssembly(name, @"Program\Bin");
                    }

                    DependencyAssemblyTreeNode node = new DependencyAssemblyTreeNode(dependencyAssembly);
                    node.Checked            = contains;
                    node.ImageIndex         = 1;
                    node.SelectedImageIndex = 1;

                    directoryNode.Nodes.Add(node);
                }
            }
        }
Exemplo n.º 18
0
        private void UpdateNodeChildren(DirectoryTreeNode node)
        {
            if (!node.IsAccessDenied)
            {
                if (node.IsDrive)
                {
                    DriveInfo driveInfo = new DriveInfo(node.Directory);
                    if (!driveInfo.IsReady)
                    {
                        node.Items.Clear();
                        MessageBox.Show(string.Format(DriveNotReadyMessage, node.Directory), DriveNotReadyDialogTitle, MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                }

                DirectoryInfo   info = new DirectoryInfo(node.Directory);
                DirectoryInfo[] dirs = info.GetDirectories();

                TreeViewBeginUpdate();
                try
                {
                    node.Items.Clear();
                    foreach (DirectoryInfo dir in dirs.OrderBy(p => p.FullName))
                    {
                        if ((dir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                        {
                            DirectoryTreeNode childNode = new DirectoryTreeNode(node.Depth + 1);
                            childNode.Expanding  += treeView1_BeforeExpand;
                            childNode.Collapsing += treeView1_BeforeCollapse;
                            node.Items.Add(childNode);
                            childNode.Directory = dir.FullName;
                        }
                    }

                    _viewModel.CurrentDirectory = node.Directory;
                    if (!_suppressEventHandling)
                    {
                        node.IsSelected = true;
                    }
                }
                finally
                {
                    TreeViewEndUpdate();
                }
            }
            else
            {
                MessageBox.Show(node.AccessDeniedMessage, AccessDeniedDialogTitle, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 19
0
        private static List <FileRecord> RecursiveFindByType(DirectoryTreeNode currentNode, List <FileRecord> roller = null)
        {
            if (roller == null)
            {
                roller = new List <FileRecord>();
            }

            roller.AddRange(currentNode.Files);

            foreach (var subDir in currentNode.Children)
            {
                RecursiveFindByType(subDir, roller);
            }

            return(roller);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Updates the FileViewers to display the currently selected item in the TreeView
        /// </summary>
        private void UpdateDisplayPanel()
        {
            ResetViewer();
            if (treeView.SelectedItem == null)
            {
                return;
            }
            var item = treeView.SelectedItem as TreeViewItem;

            if (item?.Header is DirectoryTreeNode)
            {
                DirectoryTreeNode selectedDirectory = (DirectoryTreeNode)item.Header;
                if (selectedDirectory.Record == null)
                {
                    return;
                }
            }
            FileRecord selectedRecord = treeView.SelectedItem as FileRecord;

            if (selectedRecord == null)
            {
                return;
            }
            try
            {
                switch (selectedRecord.FileFormat)
                {
                case FileRecord.DataFormat.Ascii: DisplayAscii(selectedRecord); break;

                case FileRecord.DataFormat.Unicode: DisplayUnicode(selectedRecord); break;

                case FileRecord.DataFormat.RichText: DisplayRichText(selectedRecord); break;
                }
            }
            catch (Exception ex)
            {
                ResetViewer();
                textBoxOutput.Visibility = Visibility.Visible;
                StringBuilder sb = new StringBuilder();
                while (ex != null)
                {
                    sb.AppendLine(ex.Message);
                    ex = ex.InnerException;
                }
                textBoxOutput.Text = string.Format(Settings.Strings["UpdateDisplayPanel_Failed"], sb);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Returns list of TreeNode that represents children of directory.
        /// </summary>
        /// <param name="directoryPath">Directory for which children is collected.</param>
        /// <returns>List of directory children.</returns>
        public ChildNodesResult GetDirectoryChildren(string directoryPath)
        {
            var directoryInfo = new DirectoryInfo(directoryPath);
            var result        = new ChildNodesResult();

            try
            {
                var directoryChilds = directoryInfo.EnumerateDirectories();
                var filesChilds     = directoryInfo.EnumerateFiles();

                foreach (var directory in directoryChilds)
                {
                    var directoryNode = new DirectoryTreeNode(directory.Name)
                    {
                        Tag              = directory,
                        ImageKey         = "folder.png",
                        SelectedImageKey = "folder.png",
                    };
                    directoryNode.Nodes.Add("dummy");

                    result.ChildNodes.Add(directoryNode);
                }

                foreach (var file in filesChilds)
                {
                    var icon = GetFileIcon(file.Extension);
                    result.ChildNodes.Add(new TreeNode(file.Name)
                    {
                        Tag              = file,
                        ImageKey         = icon,
                        SelectedImageKey = icon,
                    });
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                ErrorLogger.LogError("Unauthorized access to file: " + ex.Message);
                result.Error = ex;
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError("Exception thrown: " + ex.Message);
                result.Error = ex;
            }

            return(result);
        }
Exemplo n.º 22
0
        private static void InitGGPK()
        {
            if (content != null)
            {
                return;
            }

            searchContentGGPK();

            if (ggpkPaths.Count == 1)
            {
                ggpkPath = ggpkPaths[0];
            }
            else if (ggpkPaths.Count > 1)
            {
                int pos = 0;
                foreach (string ggpkPath2 in ggpkPaths)
                {
                    OutputLine(string.Format("[{0}] {1}", pos++, ggpkPath2));
                }
                OutputLine(string.Format("Choose [0-{0}]: ", pos - 1));
                ConsoleKeyInfo cki = Console.ReadKey();
                OutputLine("");
                Int32 number;
                if (Int32.TryParse(cki.KeyChar.ToString(), out number))
                {
                    if (number >= 0 && number <= pos - 1)
                    {
                        ggpkPath = ggpkPaths[number];
                    }
                }
            }
            if (!File.Exists(ggpkPath))
            {
                OutputLine(string.Format("GGPK {0} not exists.", ggpkPath));
                return;
            }

            OutputLine(string.Format("Parsing {0}", ggpkPath));

            content = new GrindingGearsPackageContainer();
            content.Read(ggpkPath, Output);

            RecordsByPath = new Dictionary <string, FileRecord>(content.RecordOffsets.Count);
            DirectoryTreeNode.TraverseTreePostorder(content.DirectoryRoot, null, n => RecordsByPath.Add(n.GetDirectoryPath() + n.Name, n as FileRecord));
        }
Exemplo n.º 23
0
        private void LoadNonCachedDependency(DirectoryTreeNode directoryNode, Info info, string name, string url)
        {
            if (info == null)
            {
                return;
            }

            if (info.Entry.IsDirectory)
            {
                Directory directory = this.PluginData.Content[name] as Directory;

                bool contains = directory != null;

                if (!contains)
                {
                    directory = new Directory(name, directoryNode.FullPath, url);
                }

                directory.Url = url;

                DirectoryTreeNode node = new DirectoryTreeNode(directory);
                node.Checked            = contains;
                node.ImageIndex         = 0;
                node.SelectedImageIndex = 0;
                directoryNode.Nodes.Add(node);
            }
            else
            {
                DependencyAssembly dependencyAssembly = this.PluginData.DependencyAssemblies[name] as DependencyAssembly;

                bool contains = dependencyAssembly != null;

                if (!contains)
                {
                    dependencyAssembly = new DependencyAssembly(name, @"Program\Bin");
                }

                DependencyAssemblyTreeNode node = new DependencyAssemblyTreeNode(dependencyAssembly);
                node.Checked            = contains;
                node.ImageIndex         = 1;
                node.SelectedImageIndex = 1;

                directoryNode.Nodes.Add(node);
            }
        }
Exemplo n.º 24
0
        private void menuItemExport_Click(object sender, RoutedEventArgs e)
        {
            var item = treeView.SelectedItem as TreeViewItem;

            if (item != null)
            {
                TreeViewItem      selectedTreeViewItem  = item;
                DirectoryTreeNode selectedDirectoryNode = selectedTreeViewItem.Header as DirectoryTreeNode;
                if (selectedDirectoryNode != null)
                {
                    ExportAllItemsInDirectory(selectedDirectoryNode);
                }
            }
            else if (treeView.SelectedItem is FileRecord)
            {
                ExportFileRecord((FileRecord)treeView.SelectedItem);
            }
        }
Exemplo n.º 25
0
        private static DatContainer GetDatContainer(DirectoryTreeNode dataDir, string contentFilePath, string datFileName)
        {
            var dataFile = dataDir.Files.FirstOrDefault(x => x.Name == datFileName);

            if (dataFile == null)
            {
                Logger.WriteLine($"\t{datFileName} not found in '{dataDir.Name}'.");
                return(null);
            }

#warning TODO: Optimize ReadFileContent by using a BinaryReader instead.
            var data = dataFile.ReadFileContent(contentFilePath);
            using (var dataStream = new MemoryStream(data))
            {
                // Read the MemoryStream and create a DatContainer
                return(new DatContainer(dataStream, dataFile.Name));
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 返回这个工程子项的生成的节点
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private ExtTreeNode BuildNode(ATNET.Project.ProjectItem item)
        {
            ExtTreeNode          node          = new CustomTreeNode(null, item);
            DirectoryProjectItem directoryItem = item as DirectoryProjectItem;

            if (directoryItem != null)
            {
                node = new DirectoryTreeNode(null, item);
                if (directoryItem.Items.Count > 0)
                {
                    foreach (ATNET.Project.ProjectItem pitem in directoryItem.Items)
                    {
                        ExtTreeNode node1 = BuildNode(pitem);
                        node.Items.Add(node1);
                    }
                }
                return(node as DirectoryTreeNode);
            }
            return(node as CustomTreeNode);
        }
        private IEnumerable <Tuple <DirectoryTreeNode, string[]> > GetParentOptions(DirectoryTreeNode node, string[] path)
        {
            // A node is a valid parent option if the node is either already the parent of child, or if the node is
            // a web page that the user has change permission for.

            if (node.EntityReference.LogicalName != "adx_webpage")
            {
                yield break;
            }

            if (node.write)
            {
                yield return(new Tuple <DirectoryTreeNode, string[]>(node, path));
            }

            foreach (var option in node.dirs.SelectMany(dir => GetParentOptions(dir, path.Concat(new[] { node.name }).ToArray())))
            {
                yield return(option);
            }
        }
Exemplo n.º 28
0
        public int CompareDirectories(DirectoryTreeNode x, DirectoryTreeNode y)
        {
            int result = 0;

            switch (SortByMethod)
            {
            case SortBy.Name:
                result = String.Compare(x.Name, y.Name);
                break;

            case SortBy.Size:
                result = x.Size >= y.Size ? 1 : -1;
                break;

            case SortBy.NumberOfFiles:
                result = x.NumberOfFiles >= y.NumberOfFiles ? 1 : -1;
                break;

            case SortBy.TimeLastAccessed:
                result = DateTime.Compare((x.Tag as DirectoryInfo).LastAccessTime, (y.Tag as DirectoryInfo).LastAccessTime);
                break;

            case SortBy.TimeLastModified:
                result = DateTime.Compare((x.Tag as DirectoryInfo).LastWriteTime, (y.Tag as DirectoryInfo).LastWriteTime);
                break;

            case SortBy.TimeCreated:
                result = DateTime.Compare((x.Tag as DirectoryInfo).CreationTime, (y.Tag as DirectoryInfo).CreationTime);
                break;

            default:
                break;
            }

            if (Descending && result != 0)
            {
                result *= -1;
            }

            return(result);
        }
Exemplo n.º 29
0
        public ActionResult Index_Tree()
        {
            DirectoryTreeNode root = new DirectoryTreeNode
            {
                Id   = "root",
                Text = Environment.MachineName
            };

            // Laufwerke auslesen
            DriveInfo[] allDrives = DriveInfo.GetDrives();

            foreach (var driveInfo in allDrives)
            {
                DirectoryTreeNode childNode = new DirectoryTreeNode();
                childNode.Text    = driveInfo.Name;
                childNode.Path    = driveInfo.Name.Replace("\\", "\\\\");
                childNode.IsReady = driveInfo.IsReady;

                if (childNode.IsReady)
                {
                    childNode.Id = driveInfo.VolumeLabel;
                }
                else
                {
                    childNode.Id = driveInfo.Name;
                }

                root.ChildNodes.Add(childNode);
            }

            // 1. Verzeichnissebene auslesen
            foreach (var child in root.ChildNodes)
            {
                if (child.IsReady)
                {
                    child.ChildNodes.AddRange(this.InitDirectoryChildNodes(child.Path));
                }
            }

            return(View(root));
        }
Exemplo n.º 30
0
        private static void InitGGPK()
        {
            if (content != null)
            {
                return;
            }

            ggpkPath = searchContentGGPK();
            if (!File.Exists(ggpkPath))
            {
                OutputLine(string.Format("GGPK {0} not exists.", ggpkPath));
                return;
            }
            OutputLine(string.Format("Parsing {0}", ggpkPath));

            content = new GGPK();
            content.Read(ggpkPath, Output);

            RecordsByPath = new Dictionary <string, FileRecord>(content.RecordOffsets.Count);
            DirectoryTreeNode.TraverseTreePostorder(content.DirectoryRoot, null, n => RecordsByPath.Add(n.GetDirectoryPath() + n.Name, n as FileRecord));
        }
Exemplo n.º 31
0
        private void treeView1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (_suppressEventHandling)
            {
                return;
            }

            DirectoryTreeNode node = e.NewValue as DirectoryTreeNode;

            if (node == null)
            {
                return;
            }

            string currentDirectory = _viewModel.CurrentDirectory;

            if (currentDirectory != node.Directory)
            {
                if (!node.IsExpanded)
                {
                    _suppressEventHandling = true;
                    try
                    {
                        UpdateNodeChildren(node);
                        node.IsExpanded = true;
                    }
                    finally
                    {
                        _suppressEventHandling = false;
                    }
                }
                else
                {
                    _viewModel.CurrentDirectory = node.Directory;
                }
            }

            e.Handled = true;
        }
Exemplo n.º 32
0
        private void LoadDependencies(DirectoryTreeNode directoryNode)
        {
            string url = directoryNode.Directory.Url;

            Info info = SVNManager.Instance.Info(url);

            List <string> dependencies       = new List <string>();
            Dictionary <string, string> urls = SVNManager.Instance.List(url);

            if (urls == null)
            {
                return;
            }

            if (Application.ReferencesCache.ContainsKey(url) &&
                Application.ReferencesCache[url].LastRevision.Equals(info.Entry.Revision))
            {
                this.LoadCachedDependencies(directoryNode, url, urls);
            }
            else
            {
                if (!Application.ReferencesCache.ContainsKey(url))
                {
                    Application.ReferencesCache.Append(url, false, true);
                }

                if (Application.ReferencesCache.ContainsKey(url))
                {
                    Application.ReferencesCache[url].LastRevision = info.Entry.Revision;
                    Application.ReferencesCache.Save();
                }

                this.LoadNonCachedDependencies(directoryNode, url, urls);
            }

            directoryNode.Expand();
        }
Exemplo n.º 33
0
        /// <summary>Navigates to a specified directory.</summary>
        /// <param name="directory">The directory.</param>
        private void NavigateTo(string directory)
        {
            if (string.IsNullOrEmpty(directory))
                throw new ArgumentNullException("directory");

            FileView fileView = new FileView(directory);
            string currentDirectory = _oldDirectory;
            _oldDirectory = fileView.FullName;

            if (!_drivesAdded)
            {
                _drivesAdded = true;

                foreach (DriveInfo drive in DriveInfo.GetDrives())
                {
                    DirectoryTreeNode node = new DirectoryTreeNode(0);
                    node.Expanding += treeView1_BeforeExpand;
                    node.Collapsing += treeView1_BeforeCollapse;
                    treeView1.Items.Add(node);

                    node.Directory = drive.RootDirectory.FullName;
                }
            }

            if (!fileView.IsDirectory)
                return;

            if (string.Compare(currentDirectory, fileView.FullName, true) == 0)
                return;

            List<string> nodeNames = new List<string>();
            nodeNames.Add(fileView.FullName);
            string upLevel = Path.GetDirectoryName(fileView.FullName);
            while (!string.IsNullOrEmpty(upLevel))
            {
                nodeNames.Add(upLevel);
                upLevel = Path.GetDirectoryName(upLevel);
            }

            ItemCollection nodes = treeView1.Items;
            TreeViewItem parentNode = null;

            TreeViewBeginUpdate();
            _suppressEventHandling = true;
            try
            {
                for (int i = nodeNames.Count - 1; i >= 0; i--)
                {
                    parentNode = FindNode(parentNode, nodes, nodeNames[i]);
                    nodes = parentNode.Items;
                }

                if (parentNode != null)
                {
                    UpdateNodeChildren((DirectoryTreeNode)parentNode);
                    parentNode.IsSelected = true;
                    parentNode.IsExpanded = true;
                    parentNode.BringIntoView();
                }
            }
            finally
            {
                _suppressEventHandling = false;
                TreeViewEndUpdate();
            }
        }
Exemplo n.º 34
0
        private void UpdateNodeChildren(DirectoryTreeNode node)
        {
            if (!node.IsAccessDenied)
            {
                if (node.IsDrive)
                {
                    DriveInfo driveInfo = new DriveInfo(node.Directory);
                    if (!driveInfo.IsReady)
                    {
                        node.Items.Clear();
                        MessageBox.Show(string.Format(DriveNotReadyMessage, node.Directory), DriveNotReadyDialogTitle, MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                }

                DirectoryInfo info = new DirectoryInfo(node.Directory);
                DirectoryInfo[] dirs = info.GetDirectories();

                TreeViewBeginUpdate();
                try
                {
                    node.Items.Clear();
                    foreach (DirectoryInfo dir in dirs.OrderBy(p => p.FullName))
                    {
                        if ((dir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                        {
                            DirectoryTreeNode childNode = new DirectoryTreeNode(node.Depth + 1);
                            childNode.Expanding += treeView1_BeforeExpand;
                            childNode.Collapsing += treeView1_BeforeCollapse;
                            node.Items.Add(childNode);
                            childNode.Directory = dir.FullName;
                        }
                    }

                    _viewModel.CurrentDirectory = node.Directory;
                    if (!_suppressEventHandling)
                        node.IsSelected = true;
                }
                finally
                {
                    TreeViewEndUpdate();
                }
            }
            else
            {
                MessageBox.Show(node.AccessDeniedMessage, AccessDeniedDialogTitle, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
 public void HandleDirectoryTree()
 {
     this.root = TreeViewHandler.getInstance().PopulateDirectoryTreeView(this.fd);
 }