Example #1
0
        /// <summary>
        /// Updates the sidebar with attributes about the file
        /// Uses the global sidebarPath variable to determine which file to display properties for
        /// </summary>
        private void updateSidebar()
        {
            //Get fileattributes
            FileAttributes fa = File.GetAttributes(sidebarPath);
            FileSystemInfo data;

            if (fa.HasFlag(FileAttributes.Directory))
            {
                data            = new DirectoryInfo(sidebarPath);
                FtypeL.Content  = "Folder";
                FsizeL.Content  = FolderDisplay.formatSize(sidebarFolder.total_size);
                FitemsL.Content = sidebarFolder.num_items;
            }
            else
            {
                data           = new FileInfo(sidebarPath);
                FtypeL.Content = data.Extension + " file";
                FileInfo fi = (FileInfo)data;
                FsizeL.Content  = FolderDisplay.formatSize(fi.Length);
                FitemsL.Content = "";
            }

            FnameL.Content     = data.Name;
            FmodifiedL.Content = data.LastWriteTime;
            FsystemL.Content   = fa.HasFlag(FileAttributes.System);
            FhiddenL.Content   = fa.HasFlag(FileAttributes.Hidden);
            FcreatedL.Content  = data.CreationTime;
            FreadonlyL.Content = fa.HasFlag(FileAttributes.ReadOnly);
            FtempL.Content     = fa.HasFlag(FileAttributes.Temporary);
            FpathT.Text        = data.FullName;
        }
Example #2
0
        /// <summary>
        /// Called when a grid row is double clicked (event handler for event raised in FolderDisplay class)
        /// </summary>
        /// <param name="sender">FolderDisplay object that raised the event</param>
        /// <param name="e">Event arguments for the event</param>
        protected void OnGridClicked(object sender, EventArgs e)
        {
            FolderDisplayEvent fde = (FolderDisplayEvent)e;

            //check the fde.fileInfo and fde.folderData to see which to do
            if (fde.fileInfo != null)
            {
                updateSidebar();
            }
            else
            {
                //open another panel
                FolderDisplay fds = (FolderDisplay)sender;

                //clear the list as needed
                clearTableToLevel(fds.level);

                //display the new folder display and register click handler
                FolderDisplay sub = new FolderDisplay(fde.folderData, fds.level + 1);
                addToTable(sub);
                sub.GridClicked     += OnGridClicked;
                sub.GridSingleClick += onSingleClick;
                sub.GridKeys        += onGridKey;
            }
        }
Example #3
0
        /// <summary>
        /// Adds a FolderDisplay object to the UI's column view
        /// </summary>
        /// <param name="fd">FolderDisplay object to add</param>
        /// <param name="readd">Whether this FolderDisplay should be re-added to the displayList</param>
        private void addToTable(FolderDisplay fd, bool readd = true)
        {
            //create the grid separator

            /*ContentGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(5) });
             * GridSplitter gs = new GridSplitter() { Width = 5 };
             * ContentGrid.Children.Add(gs);
             * Grid.SetColumn(gs, ContentGrid.ColumnDefinitions.Count - 1);
             * Grid.SetRow(gs, 1);*/

            //add the datagrid
            ContentGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ContentGrid.Children.Add(fd.dg);
            Grid.SetRow(fd.dg, 1);
            Grid.SetColumn(fd.dg, ContentGrid.ColumnDefinitions.Count - 1);

            Label l = new Label()
            {
                Content = fd.folderData.path.Name + " - " + fd.totalSizeFormatted()
            };

            ContentGrid.Children.Add(l);
            Grid.SetRow(l, 0);
            Grid.SetColumn(l, ContentGrid.ColumnDefinitions.Count - 1);

            if (readd)
            {
                displayList.Add(fd);
            }

            //scroll to end
            MainScrollView.ScrollToHorizontalOffset(System.Int32.MaxValue);
            MainScrollView.UpdateLayout();
        }
Example #4
0
        /// <summary>
        /// Updates the UI on progress updates from the background thread
        /// </summary>
        /// <param name="fd">The FolderData object passed on the callback</param>
        /// <param name="prog">Double from 0-1 representing the current progress</param>
        /// <returns>true</returns>
        private bool UpdateUIOnCallback(FolderData fd, double prog)
        {   //if first update show UI
            if (fd.subFolders.Count() == 1)
            {
                System.Windows.Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    FolderDisplay fd1 = new FolderDisplay(fd, 0);
                    addToTable(fd1);
                    //sign up the object's click event
                    fd1.GridClicked     += OnGridClicked;
                    fd1.GridSingleClick += onSingleClick;
                    fd1.GridKeys        += onGridKey;
                });
            }
            //update progress bar
            System.Windows.Application.Current.Dispatcher.Invoke((Action) delegate
            {
                MainProg.Value  = prog;
                StatusL.Content = "Sizing " + fd.ToString() + " (" + Math.Round(prog * 100) + "%)";
                //loop through displaylist to get the correct folderdisplays
                FolderData root = fd;
                //if displaylist is empty (e.g. no subfolders), create one
                if (displayList.Count == 0)
                {
                    FolderDisplay fdisp    = new FolderDisplay(root, 0);
                    fdisp.GridClicked     += OnGridClicked;
                    fdisp.GridSingleClick += onSingleClick;
                    fdisp.GridKeys        += onGridKey;
                    displayList.Add(fdisp);
                }
                displayList[0].folderData = root;
                displayList[0].updateTableListing();
                for (int i = 1; i < displayList.Count(); i++)
                {
                    //get the current one
                    FolderData fdt = displayList[i].folderData;

                    //find the correspondant in root
                    FolderData updated = root.sfDict[fdt.path.Name];

                    //update the list
                    displayList[i].folderData = updated;
                    displayList[i].updateTableListing();
                    //update root
                    root = updated;
                }
                //update the UI
                ContentGrid.Children.Clear();
                ContentGrid.ColumnDefinitions.Clear();
                foreach (FolderDisplay fdisp in displayList)
                {
                    addToTable(fdisp, false);
                }

                if (prog == 1)
                {
                    ChooseFolderBtn.IsEnabled = true;
                    ResizeFolder.IsEnabled    = true;
                    StopBtn.IsEnabled         = false;
                    sidebarFolder             = fd;
                    updateSidebar();
                }
            });

            return(true);
        }