public static void ImportAsciiToMultipleWorksheets(WorksheetController ctrl, string[] filenames) { int startrest = 0; Array.Sort(filenames); // Windows seems to store the filenames reverse to the clicking order or in arbitrary order if (ctrl != null) { using (System.IO.Stream myStream = new System.IO.FileStream(filenames[0], System.IO.FileMode.Open, System.IO.FileAccess.Read)) { ImportAscii(ctrl, myStream); myStream.Close(); startrest = 1; } } // import also the other files, but this time we create new tables for (int i = startrest; i < filenames.Length; i++) { using (System.IO.Stream myStream = new System.IO.FileStream(filenames[i], System.IO.FileMode.Open, System.IO.FileAccess.Read)) { Altaxo.Worksheet.GUI.IWorksheetController newwkscontroller = Current.ProjectService.CreateNewWorksheet(); ImportAscii(newwkscontroller, myStream); myStream.Close(); } } // for all files }
public static void SavitzkyGolayFiltering(WorksheetController ctrl) { if (ctrl.SelectedDataColumns.Count == 0) { return; } object paramobject = new SavitzkyGolayParameters(); if (!Current.Gui.ShowDialog(ref paramobject, "Savitzky-Golay parameters")) { return; } SavitzkyGolayParameters parameters = (SavitzkyGolayParameters)paramobject; Altaxo.Data.DataColumn yCol = ctrl.Doc.DataColumns[ctrl.SelectedDataColumns[0]]; Altaxo.Data.DataColumn xCol = ctrl.Doc.DataColumns.FindXColumnOf(yCol); double spacing = 1; if (xCol is Data.INumericColumn) { Calc.LinearAlgebra.VectorSpacingEvaluator calcspace = new Calc.LinearAlgebra.VectorSpacingEvaluator(Calc.LinearAlgebra.DataColumnWrapper.ToROVector(xCol)); if (!calcspace.HasValidSpaces || calcspace.HasInvalidSpaces) { Current.Gui.ErrorMessageBox(string.Format("The x-column {0} contains invalid spaces (is not equally spaced)", xCol.Name)); return; } if (calcspace.RelativeSpaceDeviation > 1E-2) { System.Windows.Forms.DialogResult dlgresult = System.Windows.Forms.MessageBox.Show(Current.MainWindow, string.Format("The x-column {0} is not equally spaced, the deviation is {1}, the mean spacing is {2}. Continue anyway?", xCol.Name, calcspace.RelativeSpaceDeviation, calcspace.SpaceMeanValue), "Continue?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button1); if (dlgresult == System.Windows.Forms.DialogResult.No) { return; } } spacing = calcspace.SpaceMeanValue; } Calc.Regression.SavitzkyGolay filter = new SavitzkyGolay(parameters); yCol.Suspend(); filter.Apply(DataColumnWrapper.ToROVectorCopy(yCol), DataColumnWrapper.ToVector(yCol)); if (parameters.DerivativeOrder > 0) { double factor = Math.Pow(1 / spacing, parameters.DerivativeOrder) * Calc.GammaRelated.Fac(parameters.DerivativeOrder); yCol.Data = yCol * factor; } yCol.Resume(); }
/// <summary> /// Moves the selected columns to a new position <code>nPosition</code>. /// </summary> /// <param name="ctrl">The worksheet controller.</param> /// <param name="nPosition">The new position for the selected columns.</param> public static void SetSelectedColumnPosition(WorksheetController ctrl, int nPosition) { if (ctrl.SelectedDataColumns.Count > 0) { if (ctrl.SelectedDataColumns.Count + nPosition > ctrl.DataTable.DataColumnCount) { nPosition = Math.Max(0, ctrl.DataTable.DataColumnCount - ctrl.SelectedDataColumns.Count); } ctrl.DataTable.ChangeColumnPosition(ctrl.SelectedDataColumns, nPosition); } if (ctrl.SelectedPropertyColumns.Count > 0) { if (ctrl.SelectedPropertyColumns.Count + nPosition > ctrl.DataTable.PropertyColumnCount) { nPosition = Math.Max(0, ctrl.DataTable.PropertyColumnCount - ctrl.SelectedDataColumns.Count); } ctrl.DataTable.PropertyColumns.ChangeColumnPosition(ctrl.SelectedPropertyColumns, nPosition); } ctrl.ClearAllSelections(); ctrl.UpdateTableView(); }
/// <summary> /// Moves the selected column to a new position. The new position must be entered by the user. /// </summary> /// <param name="ctrl">The worksheet controller for the table.</param> public static string SetSelectedColumnPosition(WorksheetController ctrl) { // check condition - either DataColumns or propertycolumns can be selected - but not both if (ctrl.SelectedDataColumns.Count > 0 && ctrl.SelectedPropertyColumns.Count > 0) { return("Don't know what to do - both data and property columns are selected"); } if (ctrl.SelectedDataColumns.Count == 0 && ctrl.SelectedPropertyColumns.Count == 0) { return(null); // nothing to do } int newposition = int.MinValue; IntegerValueInputController ivictrl = new IntegerValueInputController(0, "Please enter the new position (>=0):"); ivictrl.Validator = new IntegerValueInputController.ZeroOrPositiveIntegerValidator(); if (Current.Gui.ShowDialog(ivictrl, "New column position", false)) { newposition = ivictrl.EnteredContents; } else { return(null); } SetSelectedColumnPosition(ctrl, newposition); return(null); }
public static void ExportAscii(WorksheetController ctrl) { System.IO.Stream myStream; SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Text files (*.csv;*.dat;*.txt)|*.csv;*.dat;*.txt|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 1; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { if ((myStream = saveFileDialog1.OpenFile()) != null) { try { Altaxo.Serialization.Ascii.AsciiExporter.ExportAscii(myStream, ctrl.DataTable, '\t'); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ctrl.View.TableViewWindow, "There was an error during ascii export, details follow:\n" + ex.ToString()); } finally { myStream.Close(); } } } }
/// <summary> /// Retrieves the column number clicked onto /// </summary> /// <param name="dg">The parent data grid</param> /// <param name="mouseCoord">The coordinates of the mouse click.</param> /// <param name="cellRect">The function sets the x-properties (X and Width) of the cell rectangle.</param> /// <returns>Either -1 when clicked on the row header area, column number when clicked in the column range, or int.MinValue when clicked outside of all.</returns> public static int GetColumnNumber(WorksheetController dg, Point mouseCoord, ref Rectangle cellRect) { int firstVisibleColumn = dg.FirstVisibleColumn; int actualColumnRight = dg.WorksheetLayout.RowHeaderStyle.Width; int columnCount = dg.DataTable.DataColumns.ColumnCount; if (mouseCoord.X < actualColumnRight) { cellRect.X = 0; cellRect.Width = actualColumnRight; return(-1); } for (int i = firstVisibleColumn; i < columnCount; i++) { cellRect.X = actualColumnRight; Altaxo.Worksheet.ColumnStyle cs = dg.GetDataColumnStyle(i); actualColumnRight += cs.Width; if (actualColumnRight > mouseCoord.X) { cellRect.Width = cs.Width; return(i); } } // end for return(int.MinValue); }
public static void Transpose(WorksheetController ctrl) { Worksheet.GUI.TransposeWorksheetControl transposeview = new Worksheet.GUI.TransposeWorksheetControl(); Worksheet.GUI.TransposeWorksheetController transposectrl = new Worksheet.GUI.TransposeWorksheetController(ctrl.DataTable); transposectrl.ViewObject = transposeview; Current.Gui.ShowDialog(transposectrl, "Transpose worksheet", false); }
/// <summary> /// Returns the row number of the clicked cell. /// </summary> /// <param name="dg">The parent WorksheetController.</param> /// <param name="mouseCoord">The mouse coordinates of the click.</param> /// <param name="cellRect">Returns the bounding rectangle of the clicked cell.</param> /// <param name="bPropertyCol">True if clicked on either the property column header or a property column, else false.</param> /// <returns>The row number of the clicked cell, or -1 if clicked on the column header.</returns> /// <remarks>If clicked onto a property cell, the function returns the property column number.</remarks> public static int GetRowNumber(WorksheetController dg, Point mouseCoord, ref Rectangle cellRect, out bool bPropertyCol) { int firstVisibleColumn = dg.FirstVisibleColumn; int actualColumnRight = dg.WorksheetLayout.RowHeaderStyle.Width; int columnCount = dg.DataTable.DataColumns.ColumnCount; if (mouseCoord.Y < dg.WorksheetLayout.ColumnHeaderStyle.Height) { cellRect.Y = 0; cellRect.Height = dg.WorksheetLayout.ColumnHeaderStyle.Height; bPropertyCol = false; return(-1); } if (mouseCoord.Y < dg.VerticalPositionOfFirstVisibleDataRow && dg.VisiblePropertyColumns > 0) { // calculate the raw row number int rawrow = (int)Math.Floor((mouseCoord.Y - dg.WorksheetLayout.ColumnHeaderStyle.Height) / (double)dg.WorksheetLayout.PropertyColumnHeaderStyle.Height); cellRect.Y = dg.WorksheetLayout.ColumnHeaderStyle.Height + rawrow * dg.WorksheetLayout.PropertyColumnHeaderStyle.Height; cellRect.Height = dg.WorksheetLayout.PropertyColumnHeaderStyle.Height; bPropertyCol = true; return(dg.FirstVisiblePropertyColumn + rawrow); } else { int rawrow = (int)Math.Floor((mouseCoord.Y - dg.VerticalPositionOfFirstVisibleDataRow) / (double)dg.WorksheetLayout.RowHeaderStyle.Height); cellRect.Y = dg.VerticalPositionOfFirstVisibleDataRow + rawrow * dg.WorksheetLayout.RowHeaderStyle.Height; cellRect.Height = dg.WorksheetLayout.RowHeaderStyle.Height; bPropertyCol = false; return(dg.FirstVisibleTableRow + rawrow); } }
public static void FFT(WorksheetController dg) { int len = dg.SelectedDataColumns.Count; if (len == 0) { return; // nothing selected } if (!(dg.DataTable[dg.SelectedDataColumns[0]] is Altaxo.Data.DoubleColumn)) { return; } // preliminary // we simply create a new column, copy the values Altaxo.Data.DoubleColumn col = (Altaxo.Data.DoubleColumn)dg.DataTable[dg.SelectedDataColumns[0]]; double[] arr = col.Array; FastHartleyTransform.RealFFT(arr, arr.Length); col.Array = arr; }
/// <summary> /// Sets the column kind of the first selected column to the specified column kind /// </summary> public static void SetSelectedColumnAsKind(WorksheetController ctrl, Altaxo.Data.ColumnKind kind) { bool bChanged = false; if (ctrl.SelectedDataColumns.Count > 0) { for (int i = 0; i < ctrl.SelectedDataColumns.Count; i++) { ctrl.DataTable.DataColumns.SetColumnKind(ctrl.SelectedDataColumns[i], kind); } bChanged = true; } if (ctrl.SelectedPropertyColumns.Count > 0) { for (int i = 0; i < ctrl.SelectedPropertyColumns.Count; i++) { ctrl.DataTable.PropertyColumns.SetColumnKind(ctrl.SelectedPropertyColumns[i], kind); } bChanged = true; } if (bChanged) { ctrl.UpdateTableView(); // draw new because } }
/// <summary> /// Moves the selected row(s) to a new position. The new position must be entered by the user. /// </summary> /// <param name="ctrl">The worksheet controller for the table.</param> public static string SetSelectedRowPosition(WorksheetController ctrl) { if (ctrl.SelectedDataRows.Count == 0) { return(null); // nothing to do } int newposition = int.MinValue; IntegerValueInputController ivictrl = new IntegerValueInputController(0, "Please enter the new position (>=0):"); ivictrl.Validator = new IntegerValueInputController.ZeroOrPositiveIntegerValidator(); if (Current.Gui.ShowDialog(ivictrl, "New row position", false)) { newposition = ivictrl.EnteredContents; } else { return(null); } SetSelectedRowPosition(ctrl, newposition); return(null); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { WorksheetController s = new WorksheetController(null, true); info.GetBaseValueEmbedded(s, typeof(WorksheetController), parent); return(new SDWorksheetViewContent(s)); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { WorksheetController wc = (WorksheetController)info.GetValue("Controller", parent); SDWorksheetViewContent s = null != o ? (SDWorksheetViewContent)o : new SDWorksheetViewContent(wc); s._controller = wc; return(s); }
public static void ExportGalacticSPC(WorksheetController ctrl) { Altaxo.Serialization.Galactic.ExportGalacticSpcFileDialog dlg = new Altaxo.Serialization.Galactic.ExportGalacticSpcFileDialog(); dlg.Initialize(ctrl.DataTable, ctrl.SelectedDataRows, ctrl.SelectedDataColumns); dlg.ShowDialog(ctrl.View.TableViewWindow); }
/// <summary> /// Extracts the property values of the selected property columns. /// </summary> /// <param name="ctrl">The controller that controls the table.</param> public static void ExtractPropertyValues(WorksheetController ctrl) { for (int i = 0; i < ctrl.SelectedPropertyColumns.Count; i++) { Altaxo.Data.DataColumn col = ctrl.DataTable.PropCols[ctrl.SelectedPropertyColumns[i]]; ExtractPropertiesFromColumn(col, ctrl.DataTable.PropCols); } ctrl.ClearAllSelections(); }
public static void TwoDimensionalFFT(WorksheetController ctrl) { string err = TwoDimFFT(Current.Project, ctrl); if (null != err) { System.Windows.Forms.MessageBox.Show(ctrl.View.TableViewForm, err, "An error occured"); } }
public static void MultiplyColumnsToMatrix(WorksheetController ctrl) { string err = MultiplyColumnsToMatrix(Current.Project, ctrl.Doc, ctrl.SelectedDataColumns); if (null != err) { System.Windows.Forms.MessageBox.Show(ctrl.View.TableViewForm, err, "An error occured"); } }
/// <summary> /// Ask the user for the number of data rows to insert in a data table. /// </summary> /// <param name="ctrl">The worksheet controller.</param> /// <param name="rowBeforeToInsert">Number of the row before which to insert the rows.</param> public static void InsertDataRows(WorksheetController ctrl, int rowBeforeToInsert) { // ask for the number of rows to insert Altaxo.Gui.Common.IntegerValueInputController ictrl = new IntegerValueInputController(1, "Enter the number of rows to insert:"); if (Current.Gui.ShowDialog(ictrl, "Insert rows", false)) { InsertDataRows(ctrl, rowBeforeToInsert, ictrl.EnteredContents); } }
/// <summary> /// Creates a matrix from three selected columns. This must be a x-column, a y-column, and a value column. /// </summary> /// <param name="ctrl">Controller where the columns are selected in.</param> /// <returns>Null if no error occurs, or an error message.</returns> public static string XYVToMatrix(WorksheetController ctrl) { DataColumn xcol = null, ycol = null, vcol = null; // for this command to work, there must be exactly 3 data columns selected if (ctrl.SelectedDataColumns.Count == 3) { // use the last column that is a value column as v // and use the first column that is an x column as x for (int i = 2; i >= 0; i--) { if (ctrl.DataTable.DataColumns.GetColumnKind(ctrl.SelectedDataColumns[i]) == ColumnKind.V) { vcol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[i]]; break; } } for (int i = 2; i >= 0; i--) { if (ctrl.DataTable.DataColumns.GetColumnKind(ctrl.SelectedDataColumns[i]) == ColumnKind.Y) { ycol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[i]]; break; } } for (int i = 2; i >= 0; i--) { if (ctrl.DataTable.DataColumns.GetColumnKind(ctrl.SelectedDataColumns[i]) == ColumnKind.X) { xcol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[i]]; break; } } if (xcol == null || ycol == null || vcol == null) { return("The selected columns must be a x-column, a y-column, and a value column"); } } else { return("You must select exactly a x-column, a y-column, and a value column"); } DataTable newtable; string msg = XYVToMatrix(xcol, ycol, vcol, out newtable); if (msg != null) { return(msg); } Current.ProjectService.CreateNewWorksheet(newtable); return(null); }
public static void Rename(WorksheetController ctrl) { TextValueInputController tvctrl = new TextValueInputController(ctrl.Doc.Name, "Enter a name for the worksheet:"); tvctrl.Validator = new WorksheetRenameValidator(ctrl.Doc, ctrl); if (Current.Gui.ShowDialog(tvctrl, "Rename worksheet", false)) { ctrl.Doc.Name = tvctrl.InputText.Trim(); } }
public static void Duplicate(WorksheetController ctrl) { Altaxo.Data.DataTable clonedTable = (Altaxo.Data.DataTable)ctrl.DataTable.Clone(); // find a new name for the cloned table and add it to the DataTableCollection clonedTable.Name = Data.DataTableCollection.GetParentDataTableCollectionOf(ctrl.DataTable).FindNewTableName(); Data.DataTableCollection.GetParentDataTableCollectionOf(ctrl.DataTable).Add(clonedTable); Current.ProjectService.CreateNewWorksheet(clonedTable); }
/// <summary> /// Inserts a user choosen number of rows just before the first selected row. /// If no row is selected, the row is inserted before the first row. /// </summary> /// <param name="ctrl">The worksheet controller.</param> public static void InsertDataRows(WorksheetController ctrl) { if (ctrl.SelectedDataRows.Count > 0) { InsertDataRows(ctrl, ctrl.SelectedDataRows[0]); } else { InsertDataRows(ctrl, 0); } }
/// <summary> /// Moves the selected rows to a new position <code>nPosition</code>. /// </summary> /// <param name="ctrl">The worksheet controller.</param> /// <param name="nPosition">The new position for the selected rows.</param> public static void SetSelectedRowPosition(WorksheetController ctrl, int nPosition) { if (ctrl.SelectedDataRows.Count > 0) { ctrl.DataTable.DataColumns.ChangeRowPosition(ctrl.SelectedDataRows, nPosition); } ctrl.ClearAllSelections(); ctrl.UpdateTableView(); }
/// <summary> /// Insert a number of data rows into the controlled table. /// </summary> /// <param name="ctrl">The worksheet controller.</param> /// <param name="rowBeforeToInsert">Number of the row before which to insert the additional rows.</param> /// <param name="numberOfRows">Number of rows to insert.</param> public static void InsertDataRows(WorksheetController ctrl, int rowBeforeToInsert, int numberOfRows) { if (numberOfRows <= 0 || rowBeforeToInsert < 0) { return; } ctrl.Doc.DataColumns.InsertRows(rowBeforeToInsert, numberOfRows); ctrl.ClearAllSelections(); ctrl.UpdateTableView(); }
public static void Interpolation(WorksheetController ctrl) { if (ctrl.SelectedDataColumns.Count == 0) { return; } object paramobject = new InterpolationParameters(); if (!Current.Gui.ShowDialog(ref paramobject, "Interpolation")) { return; } InterpolationParameters parameters = (InterpolationParameters)paramobject; Altaxo.Data.DataColumn yCol = ctrl.Doc.DataColumns[ctrl.SelectedDataColumns[0]]; Altaxo.Data.DataColumn xCol = ctrl.Doc.DataColumns.FindXColumnOf(yCol); if (!(yCol is INumericColumn)) { Current.Gui.ErrorMessageBox("The selected column is not numeric!"); return; } if (!(xCol is INumericColumn)) { Current.Gui.ErrorMessageBox("The x-column of the selected column is not numeric!"); return; } int rows = Math.Min(xCol.Count, yCol.Count); IROVector yVec = DataColumnWrapper.ToROVector((INumericColumn)yCol, rows); IROVector xVec = DataColumnWrapper.ToROVector((INumericColumn)xCol, rows); parameters.InterpolationInstance.Interpolate(xVec, yVec); DoubleColumn xRes = new DoubleColumn(); DoubleColumn yRes = new DoubleColumn(); for (int i = 0; i < parameters.NumberOfPoints; i++) { double r = i / (double)(parameters.NumberOfPoints - 1); double x = parameters.XOrg * (1 - r) + parameters.XEnd * (r); double y = ((IInterpolationFunction)parameters.InterpolationInstance).GetYOfX(x); xRes[i] = x; yRes[i] = y; } int newgroup = ctrl.DataTable.DataColumns.GetUnusedColumnGroupNumber(); ctrl.DataTable.DataColumns.Add(xRes, xCol.Name + ".I", ColumnKind.X, newgroup); ctrl.DataTable.DataColumns.Add(yRes, yCol.Name + ".I", ColumnKind.V, newgroup); }
protected SDWorksheetViewContent(WorksheetController ctrl) { _controller = ctrl; _controller.DataColumnHeaderRightClicked += EhDataColumnHeaderRightClicked; _controller.DataRowHeaderRightClicked += EhDataRowHeaderRightClicked; _controller.PropertyColumnHeaderRightClicked += EhPropertyColumnHeaderRightClicked; _controller.TableHeaderRightClicked += EhTableHeaderRightClicked; _controller.OutsideAllRightClicked += EhOutsideAllRightClicked; _controller.TitleNameChanged += EhTitleNameChanged; }
/// <summary> /// This predicts the selected columns/rows against a user choosen calibration model. /// The orientation of spectra is given by the parameter <c>spectrumIsRow</c>. /// </summary> /// <param name="ctrl">The worksheet controller containing the selected data.</param> /// <param name="spectrumIsRow">If true, the spectra is horizontally oriented, else it is vertically oriented.</param> public static void PredictValues(WorksheetController ctrl, bool spectrumIsRow) { string modelName, destName; if (false == QuestCalibrationModelAndDestinationTable(out modelName, out destName) || null == modelName) { return; // Cancelled by user } Altaxo.Data.DataTable modelTable = Current.Project.DataTableCollection[modelName]; Altaxo.Data.DataTable destTable = (null == destName ? new Altaxo.Data.DataTable() : Current.Project.DataTableCollection[destName]); if (modelTable == null || destTable == null) { throw new ApplicationException("Unexpected: modelTable or destTable is null"); } int numberOfFactors = 0; MultivariateContentMemento memento = modelTable.GetTableProperty("Content") as MultivariateContentMemento; if (memento != null) { numberOfFactors = memento.PreferredNumberOfFactors; } if (numberOfFactors == 0) { QuestPreferredNumberOfFactors(modelTable); memento = modelTable.GetTableProperty("Content") as MultivariateContentMemento; if (memento != null) { numberOfFactors = memento.PreferredNumberOfFactors; } } memento.Analysis.PredictValues( ctrl.DataTable, ctrl.SelectedDataColumns, ctrl.SelectedDataRows, spectrumIsRow, numberOfFactors, modelTable, destTable); // if destTable is new, show it if (destTable.ParentObject == null) { Current.Project.DataTableCollection.Add(destTable); Current.ProjectService.OpenOrCreateWorksheetForTable(destTable); } }
public static void CreateHistogram(WorksheetController ctrl) { var table = Altaxo.Analysis.Statistics.Histograms.HistogramCreation.CreateHistogramOnColumns(ctrl.DataTable, ctrl.SelectedDataColumns, ctrl.SelectedDataRows, Gui.UserInteractionLevel.InteractAlways); if (null != table && !Current.Project.DataTableCollection.Contains(table)) { Current.Project.DataTableCollection.Add(table); // create a new worksheet without any columns Current.ProjectService.CreateNewWorksheet(table); } }
/// <summary> /// Creates the ClickedCellInfo from the data grid and the mouse coordinates of the click. /// </summary> /// <param name="dg">The data grid.</param> /// <param name="mouseCoord">The mouse coordinates of the click.</param> public void MouseClick(WorksheetController dg, Point mouseCoord) { bool bIsPropertyColumn = false; m_CellRectangle = new Rectangle(0, 0, 0, 0); m_Column = GetColumnNumber(dg, mouseCoord, ref m_CellRectangle); m_Row = GetRowNumber(dg, mouseCoord, ref m_CellRectangle, out bIsPropertyColumn); if (bIsPropertyColumn) { if (m_Column == -1) { m_ClickedArea = ClickedAreaType.PropertyColumnHeader; } else if (m_Column >= 0) { m_ClickedArea = ClickedAreaType.PropertyCell; } else { m_ClickedArea = ClickedAreaType.OutsideAll; } int h = m_Column; m_Column = m_Row; m_Row = h; // Swap columns and rows since it is a property column } else // it is not a property related cell { if (m_Row == -1 && m_Column == -1) { m_ClickedArea = ClickedAreaType.TableHeader; } else if (m_Row == -1 && m_Column >= 0) { m_ClickedArea = ClickedAreaType.DataColumnHeader; } else if (m_Row >= 0 && m_Column == -1) { m_ClickedArea = ClickedAreaType.DataRowHeader; } else if (m_Row >= 0 && m_Column >= 0) { m_ClickedArea = ClickedAreaType.DataCell; } else { m_ClickedArea = ClickedAreaType.OutsideAll; } } }
public static void PCAOnRows(WorksheetController ctrl) { int maxFactors = 3; IntegerValueInputController ivictrl = new IntegerValueInputController(maxFactors, "Please enter the maximum number of factors to calculate:"); ivictrl.Validator = new IntegerValueInputController.ZeroOrPositiveIntegerValidator(); if (Current.Gui.ShowDialog(ivictrl, "Set maximum number of factors", false)) { string err = PrincipalComponentAnalysis(Current.Project, ctrl.Doc, ctrl.SelectedDataColumns, ctrl.SelectedDataRows, true, ivictrl.EnteredContents); if (null != err) { Current.Gui.ErrorMessageBox(err); } } }