private void ListFromSelection_Click(object sender, RibbonControlEventArgs e) { var uniqueValues = UniqueCellValues(_currentSelection); if (!uniqueValues.Any()) { MessageBox.Show(List_From_Selection.NothingToCreate, List_From_Selection.ListNotCreated, MessageBoxButtons.OK); return; } var testDestination = xlApplication.InputBox(List_From_Selection.ChooseListDestination, List_From_Selection.ListLocation, Type: 8); if (!(testDestination is Excel.Range destination)) { MessageBox.Show(List_From_Selection.NoDestinationChosen, List_From_Selection.ListNotCreated, MessageBoxButtons.OK); return; } destination = destination.Resize[uniqueValues.Count]; if (CheckDestination.WillOverwriteInformation(destination)) { var result = MessageBox.Show(string.Format(List_From_Selection.OverwriteMessage, Environment.NewLine), List_From_Selection.OverwriteTitle, MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } } destination.Value2 = xlApplication.WorksheetFunction.Transpose(uniqueValues.ToArray()); destination.BorderAround2(Excel.XlLineStyle.xlContinuous); }
public void SolveSystem() { if (Model.CoefficientMatrix is null || Model.AnswerVector is null || Model.InverseCoefficientMatrix is null || Model.SolutionVector is null) { MessageBox.Show(SystemOfLinearEquations.InvalidInputText, SystemOfLinearEquations.InvalidInputCaption); return; } if (Model.CoefficientMatrix.Rows.Count != Model.CoefficientMatrix.Columns.Count) { MessageBox.Show(SystemOfLinearEquations.NonSquareMatrixText, SystemOfLinearEquations.NonSquareMatrixCaption); return; } double matrixDeterminant; try { matrixDeterminant = Globals.ThisAddIn.Application.WorksheetFunction.MDeterm(Model.CoefficientMatrix); } catch (Exception) { MessageBox.Show(SystemOfLinearEquations.NonSingularMatrixText, SystemOfLinearEquations.NonSingularMatrixCaption); return; } if (Model.AnswerVector.Rows.Count != Model.CoefficientMatrix.Columns.Count) { MessageBox.Show(SystemOfLinearEquations.AnswerVectorMustMatchCoeffMatrixColumns); return; } if (Model.AnswerVector.Columns.Count != 1) { MessageBox.Show(SystemOfLinearEquations.AnswerVectorSingleColumn); return; } Model.InverseCoefficientMatrix = Model.InverseCoefficientMatrix.Resize[Model.CoefficientMatrix.Rows.Count, Model.CoefficientMatrix.Columns.Count]; Model.SolutionVector = Model.SolutionVector.Resize[Model.AnswerVector.Rows.Count, 1]; if (CheckDestination.WillOverwriteInformation(Model.InverseCoefficientMatrix) || CheckDestination.WillOverwriteInformation(Model.SolutionVector)) { DialogResult result = MessageBox.Show("Information will be erased if you continue", "Ok to proceed?", MessageBoxButtons.YesNo); if (result.Equals(DialogResult.No)) { return; } } Model.InverseCoefficientMatrix.FormulaArray = $"=minverse({Model.CoefficientMatrix.Address})"; Model.SolutionVector.FormulaArray = $"=mmult({Model.InverseCoefficientMatrix.Address},{Model.AnswerVector.Address})"; }
public frmImport() { InitializeComponent(); _checkDest = new CheckDestination(); _importDataSlAmerica = new ImportDataSLAmerica(); _importDataSlaKorea = new ImportDataSLAKorea(); _importDataLiteTek = new ImportDataLiteTek(); _importDataIIStanley = new ImportDataIIStanley(); _importDataSus = new ImportDataSUS(); _importDataTrwsaf = new ImportDataTRWSAF(); SetGridColumns(); PopulateCustomersDropDown(); btnImport.Visible = false; }