private void loadBtn_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.FileName = string.IsNullOrEmpty(FileName) ? "ir_Calibration" : FileName; dialog.DefaultExt = ".irc"; dialog.Filter = App.IR_CAL_FILTER; bool? doLoad = dialog.ShowDialog(); IRCalibration loadedConfig; if (doLoad == true && dialog.CheckFileExists) { if (App.LoadFromFile <IRCalibration>(dialog.FileName, out loadedConfig)) { FileName = dialog.FileName; _irCalibration = loadedConfig; boxWidth.Value = _irCalibration.boundry.width; boxHeight.Value = _irCalibration.boundry.height; boxX.Value = _irCalibration.boundry.center_x - _irCalibration.boundry.width / 2; boxY.Value = _irCalibration.boundry.center_y - _irCalibration.boundry.height / 2; } else { var c = MessageBox.Show("Could not open the file \"" + dialog.FileName + "\".", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
protected IRCalibrationWindow() { _irCalibration = new IRCalibration(); InitializeComponent(); set = true; }