/
FileShow.xaml.cs
53 lines (42 loc) · 1.54 KB
/
FileShow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace FileMangement
{
public partial class FileShow : Window
{
private FAT disk = null;
private FCB currentFile = null;
public const int BLOCK_CONTENT_LENGTH = 12; //块的数据容量度量
public FileShow(FAT _disk, FCB _currentFile)
{
InitializeComponent();
disk = _disk;
currentFile = _currentFile;
FileName_Text.Text = currentFile.name;
FileSize_Text.Text = Convert.ToString(currentFile.size);
FileContent_Text.Text = disk.ExtractFileContent(currentFile);
}
private void FileEdit_Button_Click(object sender, RoutedEventArgs e)
{
FileEdit fileEditWindow = new FileEdit();
fileEditWindow.ShowDialog();
string newFileContent = fileEditWindow._newFileContent;
if (newFileContent == null) return;
currentFile.size = newFileContent.Count() / BLOCK_CONTENT_LENGTH + 1;
disk.EditFileContent(currentFile, newFileContent);
FileSize_Text.Text = Convert.ToString(currentFile.size);
FileContent_Text.Text = disk.ExtractFileContent(currentFile);
}
}
}