public void LoadModel(string path) { var stream = File.OpenRead(path); var formatter = new BinaryFormatter(); var model = (ExportModel)formatter.Deserialize(stream); stream.Close(); if (model.InputCell != null) { Distribution = DistributionFactory.GetDistribution(model.Distribution.Name, model.Distribution.Parameters); SetInputCell(Application.ActiveSheet.Cells(model.InputCell.Row, model.InputCell.Column)); } if (model.OutputCell != null) { SetOutputCell(Application.ActiveSheet.Cells(model.OutputCell.Row, model.OutputCell.Column)); OutputCell.Formula = model.OutputCell.Formula; } if (model.DecisionVariables?.Count > 0) { foreach (var v in model.DecisionVariables.Values) { v.DecisionCell = Application.ActiveSheet.Cells(v.Row, v.Column); } } DecisionVariables = model.DecisionVariables; }
public void SetInputCell(Enums.Distribuciones dist) { if (InputCell != null) { this.InputCell.Interior.Color = Excel.XlRgbColor.rgbWhite; this.InputCell = null; } var activeCell = Application.ActiveCell; this.Distribution = DistributionFactory.GetDistribution(dist); this.InputCell = activeCell; this.InputCell.Interior.Color = Excel.XlRgbColor.rgbGreen; this.InputCell.Value = this.Distribution.GetNext(); }