3 using System.Collections.Generic;
6 using System.Threading.Tasks;
8 using System.Windows.Controls;
10 using System.Windows.Documents;
11 using System.Windows.Input;
12 using System.Windows.Media;
13 using System.Windows.Media.Imaging;
14 using System.Windows.Navigation;
15 using System.Windows.Shapes;
29 private void Initialize() {
30 this.Source =
ipf.Properties.Settings.Default;
31 this.Mode = BindingMode.TwoWay;
42 bool _trackWindowOpen =
false;
43 bool _sectorWindowOpen =
false;
46 InitializeComponent();
47 string version =
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
48 string progName =
"IPF File Reader / Writer " + version;
55 private void btFileClick(
object sender, RoutedEventArgs e) {
56 OpenFileDialog ofd =
new OpenFileDialog();
57 ofd.Filter =
"IPF/IPX file|*.ipf;*ipx|All Files|*.*";
58 bool? ok = ofd.ShowDialog();
60 fileName.Text = ofd.FileName;
61 processFile(ofd.FileName);
67 private void processFile(
string file) {
73 private void btWriteClick(
object sender, RoutedEventArgs e) {
75 MessageBox.Show(
"Nothing to write",
"Error", MessageBoxButton.OK, MessageBoxImage.Error);
79 SaveFileDialog sfd =
new SaveFileDialog();
80 sfd.Filter =
"IPF file|*.ipf|All Files|*.*";
82 bool? ok = sfd.ShowDialog();
84 fileName.Text = sfd.FileName;
97 private void btBlocksClick(
object sender, RoutedEventArgs e) {
99 tbStatus.Text =
"Nothing to display";
105 if (Int32.TryParse(tbTrack.Text, out trackNumber) ==
false) {
106 tbStatus.Text =
"Invalid track number - please correct and try again";
109 if (Int32.TryParse(tbSide.Text, out sideNumber) ==
false) {
110 tbStatus.Text =
"Invalid side number - please correct and try again";
113 if ((trackNumber < 0) || (trackNumber > 84) || (sideNumber < 0) || (sideNumber > 1)) {
114 tbStatus.Text =
"Track or Side out of range - please correct and try again";
118 if (_sectorWindowOpen)
119 _sectorWindow.Close();
123 _sectorWindow.Closed +=
new EventHandler(sectorWindowClosed);
124 _sectorWindowOpen =
true;
125 _sectorWindow.Show();
130 void sectorWindowClosed(
object sender, EventArgs e) {
131 _sectorWindowOpen =
false;
135 private void mainWinClosing(
object sender,
System.ComponentModel.CancelEventArgs e) {
136 if (_sectorWindowOpen) _sectorWindow.Close();
137 if (_trackWindowOpen) _trackWindow.Close();
141 private void fileDropped(
object sender, DragEventArgs e) {
142 string[] droppedFiles = null;
143 if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
144 droppedFiles = e.Data.GetData(DataFormats.FileDrop,
true) as
string[];
147 if ((null == droppedFiles) || (!droppedFiles.Any())) {
return; }
148 processFile(droppedFiles[0]);
151 private void dragEnter(
object sender, DragEventArgs e) {
Interaction logic for BufferWindow.xaml
bool writeIPF(string fileName, Floppy fd)
Write an IPF file from the Floppy structure
Store information about all tracks of a FD
Interaction logic for MainWindow.xaml
void displayBlocksBuffer(Floppy floppy, int track, int side)
Draw the content of the buffer
bool readIPF(string fileName, Floppy fd)
Read an IPF file and fills the Floppy structure