private void PopulateTextEditorConfigUI(TextEditorConfig textEditorConfig) { IndentationSizeNumericUpDown.Value = textEditorConfig.Indentation; TabsRadioButton.Checked = textEditorConfig.IndentationMode == IndentationMode.Tabs; SpacesRadioButton.Checked = textEditorConfig.IndentationMode == IndentationMode.Spaces; EditorConfigCheckBox.Checked = textEditorConfig.UseEditorConfig; }
private void FontDropdownComboBox_SelectedIndexChanged(object sender, EventArgs e) { string selectedFont = FontDropdownComboBox.SelectedIndex >= 0 ? (string)FontDropdownComboBox.Items[FontDropdownComboBox.SelectedIndex] : null; TextEditorConfig = TextEditorConfig.WithMainFontName(selectedFont); }
private void DefaultsButton_Click(object sender, EventArgs e) { AppConfig = AppConfig.LoadFromRegistry(null); TextEditorConfig = TextEditorConfig.LoadFromRegistry(null); StyleConfig = StyleConfig.LoadFromRegistry(null); PopulateThemeUI(AppConfig); PopulateTextEditorConfigUI(TextEditorConfig); PopulateColorEditorUI(StyleConfig); PopulateFontUI(TextEditorConfig); }
private void EditorConfigCheckBox_CheckedChanged(object sender, EventArgs e) { TextEditorConfig = TextEditorConfig.WithUseEditorConfig(EditorConfigCheckBox.Checked); }
private void SpacesRadioButton_CheckedChanged(object sender, EventArgs e) { TextEditorConfig = TextEditorConfig.WithIndentationMode(IndentationMode.Spaces); }
private void IndentationSizeNumericUpDown_ValueChanged(object sender, EventArgs e) { TextEditorConfig = TextEditorConfig.WithIndentation((int)IndentationSizeNumericUpDown.Value); }
private void FontSizeNumericUpDown_ValueChanged(object sender, EventArgs e) { TextEditorConfig = TextEditorConfig.WithMainFontSize((int)FontSizeNumericUpDown.Value); }
private void PopulateFontUI(TextEditorConfig textEditorConfig) { PopulateFontDropdown(textEditorConfig.MainFontName); FontSizeNumericUpDown.Value = textEditorConfig.MainFontSize; }
public MainWindow() { InitializeComponent(); this.Closing += MainWindow_Closing; // Initialize ZX Spectrum simulator zxSpectrum = new WPFSpectrum(); // Display ROM program TextEditor.SyntaxHighlighting = TextEditorConfig.LoadAsmHighlightingDefinition(); TextEditor.Text = zxSpectrum.ROM.Program.ToString(); // Forward keystrokes to ZX Spectrum keyboard this.KeyDown += zxSpectrum.KeyboardAdapter.OnKeyDown; this.KeyUp += zxSpectrum.KeyboardAdapter.OnKeyUp; // Capture joystick moves zxSpectrum.JoystickAdapter.CaptureJoysticks(); // Display ZX Spectrum screen through an Image UI element this.Screen.Source = zxSpectrum.ScreenAdapter.ImageSource; // Play ZX Spectrum sound through a wave out device waveOut = new WaveOut(); waveOut.Init(zxSpectrum.SpeakerAdapter); waveOut.Play(); frameWatch.Start(); lastDisplayTime = frameWatch.ElapsedMilliseconds; tapeState.Text = zxSpectrum.TapeRecorder.GetState(); // Activate debug mode from a certain location // startDebugAddress = 0x0605; //(ushort)zxSpectrum.ROM.Program.GetAddressFromLine(1825);// 0x0552; // zxSpectrum.CPU.InstructionEnd += CPU_InstructionEnd; // zxSpectrum.TapeRecorder.InsertTape(File.OpenRead(@"C:\Users\Laurent\SkyDrive\Dev\Visual Studio 2012\Projects\Z80VisualSimulator\ZXSPectrum.Test\TapeFiles\SampleTzxFiles\BuggyBoy.tzx"), "BuggyBoy.tzx"); Task.Factory.StartNew(() => { Stopwatch watch = new Stopwatch(); watch.Start(); while (true) { if (framesCount == 500) { watch.Restart(); framesCount = 0; } long timeBefore = watch.ElapsedMilliseconds; for (int i = 0; i < 5; i++) { zxSpectrum.ExecuteFor20Milliseconds(); framesCount++; Dispatcher.Invoke(this.RefreshScreen); } zxSpectrum.JoystickAdapter.RefreshPosition(); long timeAfter = watch.ElapsedMilliseconds; fiveFramesDurationMs = timeAfter - timeBefore; long deviation = (framesCount * 20) - timeAfter; // Adjust to real speed if it runs too fast if (deviation > 0) { Thread.Sleep((int)(deviation)); } } }); }