Exemplo n.º 1
0
 public static async Task MapFoldersAsync(this SynchronizeSchemaDto schema, FolderTree folders, bool fromId)
 {
     foreach (var field in schema.Fields ?? Enumerable.Empty <UpsertSchemaFieldDto>())
     {
         await field.MapFoldersAsync(folders, fromId);
     }
 }
Exemplo n.º 2
0
        public FolderTree GetFolders()
        {
            FolderTree node = new FolderTree();

            GetFolders(ConfigManageClass.UAVPath, node);
            return(node);
        }
Exemplo n.º 3
0
        private async void UIElement_OnTapped(object sender, TappedRoutedEventArgs e)
        {
            var item = ((FrameworkElement)sender).Tag as FileExplorerItem;

            if (item == null)
            {
                return;
            }

            if (item.IsFolder)
            {
                var folder = FolderTree.First();

                if (folder.Path == item.Path)
                {
                    return;
                }

                GetTreeForFolder(await FolderTree.First()
                                 .GetFolderAsync(item.Name));
            }
            else
            {
                if (SelectionMode == SelectionMode.FileWithOpen)
                {
                    SelectedSingleItem(item);
                }
            }
        }
Exemplo n.º 4
0
        public void SetPage(FolderTree tree, bool setHeader = true)
        {
            if (History.Count > 0 && History.Peek() == tree)
            {
                return;
            }
            History.Push(tree);
            SetBackButtonVisibility();
            TreeInfo info = tree.Info;

            SetText(info, setHeader);
            if (IsBackToMusicPage(info))
            {
                LocalNavigationView.SelectedItem = LocalSongsItem;
                LocalFrame.Navigate(typeof(LocalMusicPage), tree);
                SetLocalGridView(Settings.settings.LocalMusicGridView);
            }
            else if (info.Folders > 0)
            {
                LocalNavigationView.SelectedItem = LocalFoldersItem;
                LocalFrame.Navigate(typeof(LocalFoldersPage), tree);
                SetLocalGridView(Settings.settings.LocalFolderGridView);
            }
            else
            {
                LocalNavigationView.SelectedItem = null;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 중첩된 폴더 트리 구조를 만드는 재귀 메소드
        /// </summary>
        /// <param name="folderId">해당 폴더 아이디</param>
        /// <returns></returns>
        public List <FolderTree> GetFolderTree(string folderId)
        {
            List <FolderTree> folderTreeList = new List <FolderTree>();

            using (var db = new WebDiskDBEntities())
            {
                List <FolderManage> subFolders = db.FolderManage.Where(x => x.ParentId == folderId && x.Trashed == false).ToList();

                if (subFolders.Count > 0)
                {
                    foreach (var subFolder in subFolders)
                    {
                        FolderTree folderTree = new FolderTree()
                        {
                            FolderId     = subFolder.FolderId,
                            FolderName   = subFolder.FolderName,
                            Path         = subFolder.RealPath,
                            Subfoldercnt = db.FolderManage.Where(x => x.ParentId == subFolder.FolderId).Count(),
                            children     = GetFolderTree(subFolder.FolderId)
                        };

                        folderTreeList.Add(folderTree);
                    }
                }
            }

            return(folderTreeList);
        }
    public FolderTree TreeDFS()
    {
        Folder f = (DirectoryDFS(mainFolder));
        FolderTree tree = new FolderTree(f.Name, f.Files.ToArray(), f.ChildFolders.ToArray());

        return tree;
    }
Exemplo n.º 7
0
 private void AfterTreeUpdated(FolderTree tree)
 {
     if (CurrentTree.Equals(tree))
     {
         UpdateTree(tree);
     }
     else
     {
         CurrentTree.FindTree(tree).CopyFrom(tree);
         int index = GridItems.FindIndex(i => i.Tree.Equals(tree));
         if (index > -1)
         {
             var item = GridItems[index];
             item.Tree        = tree;
             GridItems[index] = item;
         }
         if (tree.Equals(Settings.settings.Tree))
         {
             SetupTreeView(tree);
         }
         else if (FindNode(LocalFoldersTreeView.RootNodes.FirstOrDefault(n => tree.Path.StartsWith((n.Content as FolderTree).Path)), tree) is TreeViewNode node)
         {
             node.Content = tree;
             if (!node.HasUnrealizedChildren)
             {
                 FillTreeNode(node);
             }
         }
     }
 }
Exemplo n.º 8
0
        public void ScriptureExportTest()
        {
            string inputSourceDirectory = FileInput("ExportLO");
            string outputDirectory      = FileOutput("ExportLO");

            if (Directory.Exists(outputDirectory))
            {
                Directory.Delete(outputDirectory, true);
            }
            FolderTree.Copy(inputSourceDirectory, outputDirectory);
            Param.SetLoadType = "Scripture";
            Param.LoadSettings();
            _projInfo.ProjectPath              = outputDirectory;
            _projInfo.ProjectInputType         = "Scripture";
            _projInfo.DefaultXhtmlFileWithPath = Common.PathCombine(outputDirectory, "ScriptureInput.xhtml");
            _projInfo.DefaultCssFileWithPath   = Common.PathCombine(outputDirectory, "ScriptureInput.css");
            _projInfo.OutputExtension          = "odt";
            //EnableConfigurationSettings(outputDirectory);

            var        target         = new ExportLibreOffice();
            const bool expectedResult = true;
            bool       actual         = target.Export(_projInfo);

            Assert.AreEqual(expectedResult, actual);
        }
Exemplo n.º 9
0
            public async Task List(ImportArguments arguments)
            {
                var session = configuration.StartSession();

                var assets = session.Assets;

                var folder     = new DirectoryInfo(arguments.Folder);
                var folderTree = new FolderTree(session);

                foreach (var file in folder.GetFiles("*.*", SearchOption.AllDirectories))
                {
                    var relativeFolder = Path.GetRelativePath(folder.FullName, file.Directory.FullName);
                    var relativePath   = Path.GetRelativePath(folder.FullName, file.FullName);

                    var targetFolder = arguments.TargetFolder;

                    if (!string.IsNullOrWhiteSpace(relativePath) && relativePath != ".")
                    {
                        targetFolder = Path.Combine(targetFolder, relativeFolder);
                    }

                    var parentId = await folderTree.GetIdAsync(targetFolder);

                    await log.DoSafeLineAsync($"Uploading {relativePath}", async() =>
                    {
                        await assets.PostAssetAsync(session.App, parentId, duplicate: arguments.Duplicate, file: file);
                    });
                }

                log.WriteLine("> Import completed");
            }
Exemplo n.º 10
0
        private void OpenPlaylistFlyout(object sender, object e)
        {
            var flyout = sender as MenuFlyout;

            MenuFlyoutHelper.SetPlaylistMenu(sender, this, null, new MenuFlyoutOption
            {
                MultiSelectOption = new MultiSelectCommandBarOption
                {
                    ShowRemove           = false,
                    ShowReverseSelection = false
                }
            });
            FolderTree tree = null;

            if (flyout.Target.DataContext is GridFolderView gridFolderView)
            {
                tree = gridFolderView.Tree;
            }
            else if (flyout.Target.DataContext is TreeViewNode node)
            {
                tree = node.Content as FolderTree;
            }
            flyout.Items.Add(MenuFlyoutHelper.GetShowInExplorerItem(tree.Path, Windows.Storage.StorageItemTypes.Folder));
            flyout.Items.Add(MenuFlyoutHelper.GetRefreshDirectoryItem(tree, AfterTreeUpdated));
            flyout.Items.Add(MenuFlyoutHelper.GetSearchDirectoryItem(tree));
        }
Exemplo n.º 11
0
        public MainWindow()
        {
            if (!File.Exists(UAgent.workPath + "\\filemgr-win64.exe"))
            {
                MessageBox.Show("未找到 filemgr-win64.exe \n将文件放到 " + UAgent.workPath + " 目录下");
                Application.Current.Shutdown();
            }
            cloudFileTree      = new FolderTree();
            localFileTree      = new FolderTree();
            localFileTree.root = new FolderTreeNode("addRoot");
            InitializeComponent();
            // 绑定log更新
            uilog.onGetNewLog = (newLog) => {
                //logBox.Text = newLog;
                logBtn.Header = newLog;
            };
            //读档
            bucketData = savedata.getInstance().bucketdata;
            //refreshProject();

            //退出时存档
            Application.Current.Exit += (object sender, ExitEventArgs e) => { savedata.getInstance().bucketdata.serialization(); };
            //保存实例给state
            State.mainWindow = this;
        }
Exemplo n.º 12
0
        protected void CreateDictionaryForMIDs(PublicationInformation projInfo)
        {
            var output = new DictionaryForMIDsStreamWriter(projInfo);

            Debug.Assert(output.Directory != null);

            string assemblyPath = Common.AssemblyPath;

            var DictionaryForMIDsPath = Path.Combine(assemblyPath, "Dic4Mid");

            if (!Directory.Exists(DictionaryForMIDsPath))
            {
                DictionaryForMIDsPath = Path.Combine(Path.GetDirectoryName(assemblyPath), "Dic4Mid");
            }

            var creatorPath = Common.PathCombine(DictionaryForMIDsPath, "DfM-Creator");

            FolderTree.Copy(creatorPath, output.Directory);

            const string prog = "java";

            SubProcess.RedirectOutput = LogName;
            var args1 = string.Format(@"-jar DfM-Creator.jar -DictionaryGeneration .{0}main.txt . .", Path.DirectorySeparatorChar);

            SubProcess.RunCommand(output.Directory, prog, args1, true);
            var args2 = string.Format(@"-jar DfM-Creator.jar -JarCreator .{0}dictionary{0} .{0}Empty_Jar-Jad{0} .", Path.DirectorySeparatorChar);

            SubProcess.RunCommand(output.Directory, prog, args2, true);
        }
Exemplo n.º 13
0
        public static MenuFlyoutItem GetSearchDirectoryItem(FolderTree tree)
        {
            var item = new MenuFlyoutItem()
            {
                Icon = new SymbolIcon(Symbol.Find),
                Text = Helper.Localize("Search Directory")
            };

            item.Click += async(s, args) =>
            {
                await new InputDialog()
                {
                    Title           = Helper.LocalizeMessage("Search"),
                    PlaceholderText = Helper.LocalizeMessage("SearchDirectoryHint", tree.Directory),
                    Confirm         = (inputText) =>
                    {
                        MainPage.Instance.Search(new SearchKeyword()
                        {
                            Text  = inputText,
                            Songs = tree.Flatten(),
                            Tree  = tree
                        });
                    }
                }.ShowAsync();
            };
            return(item);
        }
Exemplo n.º 14
0
        private void RefreshThisTree_Click(object sender, RoutedEventArgs e)
        {
            if (!(treeView.SelectedItem is FolderTree thisTree))
            {
                MessageBox.Show("请先选择一个需要刷新的树形结构");
                return;
            }
            while (thisTree.Parent != null)
            {
                thisTree = thisTree.Parent;
            }
            thisTree.Children.Clear();
            SelectedNode = thisTree;
            Folder_Info.Clear();

            Kernel kernel = new Kernel(Folder_Tree, Folder_Info, treeView, listView, progressBar, TipText, ItemDetail, IgnoredFolder);

            ChoosePanel(ScanInfoPanel);
            FrontNode.Clear();
            thePathNow.Text = thisTree.FullPath;

            Thread t = new Thread(new ParameterizedThreadStart(kernel.Start));

            t.Start(thisTree);
        }
Exemplo n.º 15
0
        private void DeleteFolder(FolderTreeViewModel item)
        {
            if (MessageBox.Show(Window.GetWindow(this), "Are you sure you want to delete this folder and everything it contains?",
                                "Delete folder?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            if (MessageBox.Show(Window.GetWindow(this), "Are you SURE?",
                                "Delete folder?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            _amazon.DeleteFolder(item.Prefix);
            FolderTreeViewModel parentFolder = FolderTree.GetParentItem(item);

            if (parentFolder != null)
            {
                GetBucketContents(parentFolder);
            }
            else
            {
                GetBucketContents(null);
            }
        }
Exemplo n.º 16
0
 private void Setup(FolderTree tree)
 {
     LoadingProgressBar.Visibility = Visibility.Visible;
     foreach (var music in tree.Files)
     {
         music.IsPlaying = music.Equals(MediaHelper.CurrentMusic);
     }
     try
     {
         if (GridMusicView.Visibility == Visibility.Visible)
         {
             GridMusicView.Setup(tree.Files);
             Songs.SetTo(tree.Files);
         }
         else
         {
             Songs.SetTo(tree.Files);
             GridMusicView.Setup(tree.Files);
         }
     }
     catch (InvalidOperationException)
     {
         // Loading while Set New Folder will cause this Exception
         System.Diagnostics.Debug.WriteLine("InvalidOperationException On Local Music Page");
     }
     TreePath    = tree.Path;
     CurrentTree = tree;
     LoadingProgressBar.Visibility = Visibility.Collapsed;
 }
Exemplo n.º 17
0
 public void UpdatePage(FolderTree tree)
 {
     if (tree.Equals(CurrentTree))
     {
         Setup(tree);
     }
 }
Exemplo n.º 18
0
        protected void SetUp()
        {
            Common.Testing = true;
            //_styleName = new Styles();
            //_util = new Utility();
            _projInfo    = new PublicationInformation();
            _progressBar = new ProgressBar();
            string testPath = PathPart.Bin(Environment.CurrentDirectory, "/OpenOfficeConvert/TestFiles");

            _inputPath         = Common.PathCombine(testPath, "input");
            _outputPath        = Common.PathCombine(testPath, "output");
            _expectedPath      = Common.PathCombine(testPath, "expected");
            _expectedlinuxPath = Common.PathCombine(testPath, "expectedlinux");
            Common.DeleteDirectory(_outputPath);
            Directory.CreateDirectory(_outputPath);
            FolderTree.Copy(FileInput("Pictures"), FileOutput("Pictures"));
            _projInfo.ProgressBar          = _progressBar;
            _projInfo.OutputExtension      = "odt";
            _projInfo.ProjectInputType     = "Dictionary";
            _projInfo.IsFrontMatterEnabled = false;
            _projInfo.FinalOutput          = "odt";
            Common.SupportFolder           = "";
            Common.ProgInstall             = PathPart.Bin(Environment.CurrentDirectory, "/../../DistFIles");
            Common.ProgBase = PathPart.Bin(Environment.CurrentDirectory, "/../../DistFiles");             // for masterDocument
            Common.UseAfterBeforeProcess = false;

            _styleFile   = "styles.xml";
            _contentFile = "content.xml";
            _isLinux     = Common.IsUnixOS();

            if (!_isLinux)
            {
                LoadParam("Dictionary", "false");
            }
        }
Exemplo n.º 19
0
        public void DrawUI(FolderTree root)
        {
            ImGui.PushID(_uniqueUiId);

            RenderSubnodes(root);

            ImGui.PopID();
        }
Exemplo n.º 20
0
 public async Task SearchFolders(FolderTree source, string keyword, SortBy criterion)
 {
     AllFolders.SetTo(await Task.Run(() => SearchHelper.SearchFolders(source, keyword, criterion)));
     Folders.SetTo(AllFolders.Take(FolderLimit));
     FoldersTextBlock.Text           = Settings.settings.ShowCount ? Helper.LocalizeText("FoldersWithCount", AllFolders.Count) : Helper.LocalizeText("Folders");
     FoldersViewAllButton.Visibility = AllFolders.Count > FolderLimit ? Visibility.Visible : Visibility.Collapsed;
     SortFoldersButton.Visibility    = AllFolders.Count < 2 ? Visibility.Collapsed : Visibility.Visible;
 }
Exemplo n.º 21
0
        public static async Task MapFoldersAsync(this UpsertSchemaFieldDto field, FolderTree folders, bool fromId)
        {
            await MapFoldersAsync(field.Properties, folders, fromId);

            foreach (var nested in field.Nested ?? Enumerable.Empty <UpsertSchemaNestedFieldDto>())
            {
                await MapFoldersAsync(nested.Properties, folders, fromId);
            }
        }
 public void ShowMe(Gdk.Rectangle area, String path)
 {
     Move(area.X, area.Y);
     Resize(area.Width, area.Height);
     ShowAll();
     GrabUtil.GrabWindow(this);
     FolderTree.GrabFocus();
     SetPath(path);
 }
Exemplo n.º 23
0
 private void ForwardButton_Click(object sender, RoutedEventArgs e)
 {
     if (FrontNode.Count == 0)
     {
         return;
     }
     SelectedNode = FrontNode.Pop();
     DisplayNode();
 }
        protected virtual void OnFolderTreeBeforeNodeExpand(object sender, HollyLibrary.NodeEventArgs args)
        {
            HTreeNode node = args.Node;
            String    path = getPathFromNode(node);

            buildNode(node);
            //select the expanded node
            FolderTree.selectNode(node);
            ChangeFatherPath(path);
        }
Exemplo n.º 25
0
 /// <summary>
 /// 上面的控件(3个Button和2个Popup和1个TextBox)
 /// </summary>
 private void BackwardButton_Click(object sender, RoutedEventArgs e)
 {
     if (SelectedNode == null || SelectedNode.Parent == null)
     {
         return;
     }
     FrontNode.Push(SelectedNode);
     SelectedNode = SelectedNode.Parent;
     DisplayNode();
 }
Exemplo n.º 26
0
        public FolderTreeTests()
        {
            A.CallTo(() => session.Assets)
            .Returns(assets);

            A.CallTo(() => session.App)
            .Returns("my-app");

            sut = new FolderTree(session);
        }
Exemplo n.º 27
0
        public void MoveJarFileTest()
        {
            Common.Testing = true;
            PublicationInformation projInfo = new PublicationInformation();

            projInfo.DefaultXhtmlFileWithPath = _testFiles.Copy("sena3-imba.xhtml");
            FolderTree.Copy(_testFiles.Input("DfM_enseh_SIL"), _testFiles.Output("DfM_enseh_SIL"));
            MoveJarFile(projInfo);
            Assert.True(File.Exists(_testFiles.Output("DfM_enseh_SIL.jar")));
        }
Exemplo n.º 28
0
 private void Setup(FolderTree tree)
 {
     if (TreePath == tree.Path)
     {
         return;
     }
     LocalLoadingControl.Visibility = Visibility.Visible;
     UpdateTree(tree);
     LocalLoadingControl.Visibility = Visibility.Collapsed;
 }
Exemplo n.º 29
0
        private void CopyFolderSupportToIO(string fileName)
        {
            string fromFileName = Common.PathCombine(_supportSource, fileName);
            string toFileName   = Common.PathCombine(_inputBasePath, fileName);

            FolderTree.Copy(fromFileName, toFileName);

            toFileName = Common.PathCombine(_outputBasePath, fileName);
            FolderTree.Copy(fromFileName, toFileName);
        }
Exemplo n.º 30
0
        Action?DefaultNodeDraw(FolderTree node)
        {
            ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(0f, 1f, 1f, 1f));
            bool opened = ImGui.TreeNodeEx($"{node.Name}", ImGuiTreeNodeFlags.FramePadding);

            ImGui.PopStyleColor();
            if (opened)
            {
                return () => { ImGui.TreePop(); }
            }
            ;
            return(null);
        }

        void RenderNode(FolderTree node)
        {
            var closingAction = _nodeDrawDeleg(node);

            if (closingAction != null)                  // node is unfolded
            {
                RenderSubnodes(node);

                closingAction();
            }
        }

        void RenderSubnodes(FolderTree node)
        {
            if (node.Children == null)
            {
                return;
            }

            // first render the folders
            foreach (var subn in node.Children)
            {
                if (!subn.IsFolder)
                {
                    continue;
                }
                RenderNode(subn);
            }


            // then render non-folders
            foreach (var subn in node.Children)
            {
                if (subn.IsFolder)
                {
                    continue;
                }
                RenderNode(subn);
            }
        }
    }
Exemplo n.º 31
0
        // WalkDirectoryTree
        //
        // Recursive function to walk the directory tree and build the FolderTree object.
        // This function largely lifted from Microsoft, except that we added the building of FolderTree.
        //
        // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-iterate-through-a-directory-tree
        //
        private FolderTree WalkDirectoryTree(System.IO.DirectoryInfo root)
        {
            string rootFolder = getRoot();

            string shortName = RemoveRootFolder(root.FullName);

            // FolderTree: name, list of FolderTree objects, list of filenames.
            //
            //
            FolderTree tree = new FolderTree(shortName, new List <string>());;

            System.IO.FileInfo[]      files   = null;
            System.IO.DirectoryInfo[] subDirs = null;

            try
            {
                files = root.GetFiles("*.*");
            }
            // This is thrown if even one of the files requires permissions greater
            // than the application provides.
            catch (UnauthorizedAccessException e)
            {
                // This code just writes out the message and continues to recurse.
                // You may decide to do something different here. For example, you
                // can try to elevate your privileges and access the file again.
                // log.Add(e.Message);
                throw;
            }
            catch (System.IO.DirectoryNotFoundException e)
            {
                throw;
            }

            if (files != null)
            {
                foreach (System.IO.FileInfo fi in files)
                {
                    tree.files.Add(RemoveRootFolder(fi.FullName));  // we only want the path relative to root
                }
            }
            //
            // Now find all the subdirectories under this directory.
            //
            subDirs = root.GetDirectories();
            if (subDirs != null)
            {
                foreach (System.IO.DirectoryInfo dirInfo in subDirs)
                {
                    // Resursive call for each subdirectory.
                    tree.folders.Add(WalkDirectoryTree(dirInfo));
                }
            }

            return(tree);
        }
    static void Main()
    {
        string path = @"C:\Windows";

        FolderTree windowsTree = new FolderTree(path);
        windowsTree = windowsTree.TreeDFS();

        Folder appPatch = windowsTree.FindFolder(@"C:\Windows\AppPatch");
        double sum = appPatch.CalculateFileSizeSum(appPatch) / 1048576;

        Console.WriteLine(@"sum of files in C:\Windows\AppPatch = {0:0.00}mb", sum);
    }
Exemplo n.º 33
0
 private void CreateFolderTree()
 {
     _folderTree = new FolderTree(Controller, _fileView);
     _folderTree.ID = "FolderTree";
     Controls.Add(_folderTree);
 }
Exemplo n.º 34
0
 private void CreateSelectFolderDialog()
 {
     _selectFolderTree = new FolderTree(Controller);
     _selectFolderTree.ID = "SelectFolderTree";
     _selectFolderTree.Width = 250;
     _selectFolderTree.Height = 300;
     Controls.Add(_selectFolderTree);
 }