public MainWindow() { InitializeComponent(); FillBoxCaptureDevice(); if (BoxCaptureDevice.Items.Contains(Properties.Settings.Default.VideoDevice)) { var idx = BoxCaptureDevice.Items.IndexOf(Properties.Settings.Default.VideoDevice); BoxCaptureDevice.SelectedIndex = idx; } var savedProfile = Properties.Settings.Default.GameProfile; if (File.Exists(savedProfile)) { try { Scanner.GameProfile = GameProfile.FromZip(savedProfile); txtGameProfile.Text = savedProfile; } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Game Profile failed to load."); System.Diagnostics.Debug.WriteLine(e.ToString()); } finally { if (Scanner.GameProfile == null) { txtGameProfile.Text = null; } } } TryStart(); Scanner.CropGeometry = new Geometry( Properties.Settings.Default.CropX, Properties.Settings.Default.CropY, Properties.Settings.Default.CropWidth, Properties.Settings.Default.CropHeight); }
private void BtnGameProfile_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialog() { Filter = "Zip Files|*.zip", Title = "Load a Game Profile" }) { if (ofd.ShowDialog() == DialogResult.OK && ofd.CheckFileExists == true) { retry: var gp = GameProfile.FromZip(ofd.FileName); if (gp == null) { DialogResult dr = MessageBox.Show( "Failed to load Game Profile.", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error ); if (dr == DialogResult.Retry) { goto retry; } } else { Scanner.GameProfile = gp; txtGameProfile.Text = ofd.FileName; TryStart(); Properties.Settings.Default.GameProfile = ofd.FileName; Properties.Settings.Default.Save(); } } } }