Exemplo n.º 1
0
        public void ModifySelectedFile()
        {
            if (SelectedFile == null)
            {
                return;
            }

            var oldSize = ((FatFileMetada)SelectedFile.Metadata).FileSize;

            var fileWindow = new Windows.FileWindow(SelectedFile)
            {
                ConfirmContent = "Modify",
                Owner          = Application.Current.MainWindow
            };

            fileWindow.ShowDialog();

            if (!fileWindow.IsConfirmed)
            {
                return;
            }

            var newFile = fileWindow.File;

            ((FatFileMetada)newFile.Metadata).WriteDate  = new DateTime().Date;
            ((FatFileMetada)newFile.Metadata).WriteTime  = DateTime.Now;
            ((FatFileMetada)newFile.Metadata).AccessDate = DateTime.Now;

            //Clear selection

            var newSize = ((FatFileMetada)newFile.Metadata).FileSize;

            if (newSize > oldSize)
            {
                var numberNewCluster = (int)Math.Ceiling((decimal)newSize / Settings.ClusterSize) - newFile.NumberClusterUse;
                newFile.IncreaseFileSize(oldSize);
                FileAllocationTable.IncreaseClusterFile(numberNewCluster, newFile);
            }
            else if (newSize < oldSize) //Smaller size
            {
                FileAllocationTable.DecreaseClusterFile(oldSize, newFile);
                newFile.DecreaseSizeFile(oldSize);
            }

            //Reselect
            SelectClustersByFile(newFile, true);
        }
Exemplo n.º 2
0
        public override bool NewFile()
        {
            var fileWindow = new Windows.FileWindow
            {
                ConfirmContent = "Create",
                Owner          = Application.Current.MainWindow
            };

            fileWindow.ShowDialog();

            if (!fileWindow.IsConfirmed)
            {
                return(false);
            }

            return(NewFile(fileWindow.File));
        }