protected override void btnNext_Click(object sender, EventArgs e) { // Choose next form and do the job if (radioCreate.Checked) { nextForm = new OptimizationParametersForm(this); } else if (radioLoad.Checked) { // TODO: Should we check input and provide detailed localized info on the error // or just let corresponding exception be thrown and show its message to the user? try { ModelStorage.Instance.Model = XmlIdentificationModelProvider.Open(textModelFile.Text); nextForm = new OptimizationParametersForm(this); } catch (Exception ex) { MessageBoxHelper.ShowError(ex.Message); return; } } else { return; } // Let's have this for now - later will decide based on the type and contents of the model file //nextForm = new OptimizationParametersForm(this); // Now call base implementation - it is responsible for forms rotation base.btnNext_Click(sender, e); }
public ModelCalculator(string modelFilePath) { if (string.IsNullOrEmpty(modelFilePath)) { throw new ArgumentNullException("modelFilePath"); } model = XmlIdentificationModelProvider.Open(modelFilePath); modelFile = modelFilePath; }
public void ProcessModel(object data) { CancellationToken cancellationToken; if (data == null) { cancellationToken = new CancellationToken(false); } else { cancellationToken = (CancellationToken)data; } if (cancellationToken.IsCancellationRequested) { OnProcessingComplete(new EventArgs()); return; } model = XmlIdentificationModelProvider.Open(optFile); if (cancellationToken.IsCancellationRequested) { OnProcessingComplete(new EventArgs()); return; } int maxProgress = model.IdentificationExperiments.Count; OnProgressChanged(new ProgressChangedEventArgs(0, maxProgress, 0, "Initialized")); int exp = 0; foreach (IdentificationExperiment experiment in model.IdentificationExperiments.Values) { if (cancellationToken.IsCancellationRequested) { break; } ProcessExperiment(experiment); OnProgressChanged(new ProgressChangedEventArgs(0, maxProgress, ++exp, "Processed experiment #" + experiment.Number.ToString())); } if (cancellationToken.IsCancellationRequested) { OnProcessingComplete(new EventArgs()); return; } XmlIdentificationModelProvider.Save(model, optFile); OnProcessingComplete(new EventArgs()); }
private void ExternalApp_Exited(object sender, EventArgs e) { try { string exchangeFilePath = textExchangeFilePath.Text.Trim(); // Update model if (File.Exists(exchangeFilePath)) { ModelStorage.Instance.Model = XmlIdentificationModelProvider.Open(exchangeFilePath); ResidualFinder.CalculateAdequacyCriteriaValues(ModelStorage.Instance.Model); } // Invoke form's method to handle external app exit // This is needed because ExternalApp_Exited is invoked in another // thread (not in UI thread) Invoke(new Action(ExternalAppFinished)); } catch (Exception ex) { MessageBoxHelper.ShowError(ex.Message); } }