more settings window hookups

This commit is contained in:
Luigi Thirty 2015-12-06 12:51:52 -05:00
parent 7235d3a3bb
commit 131b3f0152
5 changed files with 87 additions and 15 deletions

View File

@ -28,10 +28,11 @@ namespace _6502EmulatorFrontend
{
Thread M6502WorkerThread;
MainWindowViewModel vm = new MainWindowViewModel();
byte[] videoRom = File.ReadAllBytes("C:/apple/apple1.vid");
string monitorRomPath;
string basicRomPath;
string characterRomPath;
SettingsWindow settingsWindow;
byte[] videoRom;
public MainWindow()
{
@ -58,13 +59,9 @@ namespace _6502EmulatorFrontend
vm.Processor.ExecutionStopped += new M6502.ExecutionStoppedEventHandler(onExecutionStopped);
TextCompositionManager.AddTextInputHandler(this, new TextCompositionEventHandler(OnTextComposition));
//Set up settings window
settingsWindow = new SettingsWindow();
settingsWindow.RomPathsSaved += new SettingsWindow.RomPathsSavedEventHandler(OnRomPathsSaved);
settingsWindow.swvm.BasicRomPath = @"C:\apple\apple1basic.bin";
settingsWindow.swvm.MonitorRomPath = @"C:\apple\apple1.rom";
basicRomPath = @"C:\apple\apple1basic.bin";
monitorRomPath = @"C:\apple\apple1.rom";
characterRomPath = @"C:\apple\apple1.vid";
//Set up window
InitializeComponent();
@ -76,6 +73,7 @@ namespace _6502EmulatorFrontend
{
Interop.loadBinary(monitorRomPath, 0xFF00);
Interop.loadBinary(basicRomPath, 0xE000);
videoRom = File.ReadAllBytes(characterRomPath);
decodeGraphics();
Interop.resetProcessor();
@ -195,7 +193,12 @@ namespace _6502EmulatorFrontend
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
settingsWindow.ShowDialog();
settingsWindow = new SettingsWindow();
settingsWindow.RomPathsSaved += new SettingsWindow.RomPathsSavedEventHandler(OnRomPathsSaved);
settingsWindow.swvm.BasicRomPath = basicRomPath;
settingsWindow.swvm.MonitorRomPath = monitorRomPath;
settingsWindow.swvm.CharacterRomPath = characterRomPath;
settingsWindow.Show();
}
}
}

View File

@ -16,11 +16,13 @@ namespace _6502EmulatorFrontend
{
public readonly string MonitorPath;
public readonly string BasicPath;
public readonly string CharacterPath;
public RomPathEventArgs(string monitorPath, string basicPath)
public RomPathEventArgs(string monitorPath, string basicPath, string characterPath)
{
MonitorPath = monitorPath;
BasicPath = basicPath;
CharacterPath = characterPath;
}
}
@ -28,6 +30,7 @@ namespace _6502EmulatorFrontend
{
monitorRomPath = e.MonitorPath;
basicRomPath = e.BasicPath;
characterRomPath = e.CharacterPath;
}
private void OnTextComposition(object sender, TextCompositionEventArgs e)

View File

@ -9,8 +9,10 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22*"/>
<RowDefinition Height="93*"/>
<RowDefinition Height="20*"/>
<RowDefinition Height="22*"/>
<RowDefinition Height="22*"/>
<RowDefinition Height="50*"/>
<RowDefinition Height="21*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
@ -20,9 +22,12 @@
<Label Grid.Column="0" x:Name="label" Content="Monitor ROM ($FF00)" HorizontalAlignment="Left" Margin="10,8,0,0" VerticalAlignment="Top" Width="130" Height="26"/>
<Label Grid.Column="0" x:Name="label1" Content="Basic ROM ($E000)" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="130" Grid.Row="1" Height="26"/>
<TextBox Grid.Column="1" Grid.Row="0" x:Name="tbMonitorRomPath" HorizontalAlignment="Left" Height="23" Margin="10,12,0,0" TextWrapping="Wrap" Text="{Binding Path=MonitorRomPath}" VerticalAlignment="Top" Width="240"/>
<Button x:Name="btnMonitorRom" Content="Browse" Grid.Column="2" HorizontalAlignment="Left" Margin="10,12,0,0" VerticalAlignment="Top" Width="88" Height="22"/>
<Button x:Name="btnMonitorRom" Content="Browse" Grid.Column="2" HorizontalAlignment="Left" Margin="10,12,0,0" VerticalAlignment="Top" Width="88" Height="22" Click="btnMonitorRom_Click"/>
<TextBox Grid.Column="1" Grid.Row="1" x:Name="tbBasicRomPath" HorizontalAlignment="Left" Height="23" Margin="10,12,0,0" TextWrapping="Wrap" Text="{Binding Path=BasicRomPath}" VerticalAlignment="Top" Width="240"/>
<Button x:Name="btnBasicRom" Content="Browse" Grid.Column="2" HorizontalAlignment="Left" Margin="10,12,0,0" VerticalAlignment="Top" Width="88" Height="22" Grid.Row="1"/>
<Button x:Name="btnSave" Content="Save" Grid.Column="2" HorizontalAlignment="Left" Margin="10,8,0,0" Grid.Row="2" VerticalAlignment="Top" Width="88" Click="btnSave_Click"/>
<Button x:Name="btnBasicRom" Content="Browse" Grid.Column="2" HorizontalAlignment="Left" Margin="10,12,0,0" VerticalAlignment="Top" Width="88" Height="22" Grid.Row="1" Click="btnBasicRom_Click"/>
<Button x:Name="btnSave" Content="Save" Grid.Column="2" HorizontalAlignment="Left" Margin="10,0,0,10" Grid.Row="4" VerticalAlignment="Bottom" Width="88" Click="btnSave_Click" Height="22"/>
<Label Grid.Column="0" x:Name="label1_Copy" Content="Character ROM" HorizontalAlignment="Left" Margin="10,9,0,0" VerticalAlignment="Top" Width="130" Grid.Row="2" Height="26"/>
<TextBox Grid.Column="1" Grid.Row="2" x:Name="tbCharacterRomPath" HorizontalAlignment="Left" Height="23" Margin="10,11,0,0" TextWrapping="Wrap" Text="{Binding Path=CharacterRomPath}" VerticalAlignment="Top" Width="240"/>
<Button x:Name="btnCharacterRom" Content="Browse" Grid.Column="2" HorizontalAlignment="Left" Margin="10,11,0,0" VerticalAlignment="Top" Width="88" Height="22" Grid.Row="2" Click="btnCharacterRom_Click"/>
</Grid>
</Window>

View File

@ -1,4 +1,5 @@
using System;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -33,7 +34,53 @@ namespace _6502EmulatorFrontend
private void btnSave_Click(object sender, RoutedEventArgs e)
{
RomPathsSaved(this, new MainWindow.RomPathEventArgs(swvm.MonitorRomPath, swvm.BasicRomPath, swvm.CharacterRomPath));
this.Close();
}
private void btnMonitorRom_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog();
ofd.Filter = "apple1.rom|apple1.rom|All Files (*.*)|*.*";
ofd.FilterIndex = 1;
bool? userClickedOK = ofd.ShowDialog();
if (userClickedOK == true)
{
swvm.MonitorRomPath = ofd.FileName;
tbMonitorRomPath.Text = ofd.FileName;
}
}
private void btnBasicRom_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog();
ofd.Filter = "apple1basic.bin|apple1basic.bin|All Files (*.*)|*.*";
ofd.FilterIndex = 1;
bool? userClickedOK = ofd.ShowDialog();
if (userClickedOK == true)
{
swvm.BasicRomPath = ofd.FileName;
tbBasicRomPath.Text = ofd.FileName;
}
}
private void btnCharacterRom_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog();
ofd.Filter = "apple1.vid|apple1.vid|All Files (*.*)|*.*";
ofd.FilterIndex = 1;
bool? userClickedOK = ofd.ShowDialog();
if (userClickedOK == true)
{
swvm.CharacterRomPath = ofd.FileName;
tbCharacterRomPath.Text = ofd.FileName;
}
}
}
}

View File

@ -11,6 +11,7 @@ namespace _6502EmulatorFrontend
{
private string _monitorRomPath;
private string _basicRomPath;
private string _characterRomPath;
public string MonitorRomPath
{
@ -38,6 +39,19 @@ namespace _6502EmulatorFrontend
}
}
public string CharacterRomPath
{
get { return _characterRomPath; }
set
{
if (value != _characterRomPath)
{
_characterRomPath = value;
OnPropertyChanged("CharacterRomPath");
}
}
}
#region INotifyPropertyChanged Implementation
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string name)