Esempio n. 1
0
        /// <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(IWorksheetController 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.TableAreaInvalidate();
        }
Esempio n. 2
0
        /// <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(IWorksheetController 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;

            var ivictrl = new IntegerValueInputController(0, "Please enter the new position (>=0):")
            {
                Validator = new IntegerValueInputController.ZeroOrPositiveIntegerValidator()
            };

            if (Current.Gui.ShowDialog(ivictrl, "New column position", false))
            {
                newposition = ivictrl.EnteredContents;
            }
            else
            {
                return(null);
            }

            SetSelectedColumnPosition(ctrl, newposition);

            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Plots the currently selected data columns of a worksheet as horzizontal bar diagram.
        /// </summary>
        /// <param name="dg">The worksheet controller where the columns are selected in.</param>
        public static void PlotColumnChartRelativeStack(IWorksheetController dg)
        {
            var graph   = TemplateWithXYZPlotLayerWithG3DCartesicCoordinateSystem.CreateGraph(dg.DataTable.GetPropertyContext(), null, dg.DataTable.Name, true);
            var context = graph.GetPropertyContext();

            Plot(dg.DataTable, dg.SelectedDataColumns, graph, PlotStyle_Bar(context, true), GroupStyle_RelativeStack_Bar);
        }
Esempio n. 4
0
        /// <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(IWorksheetController ctrl)
        {
            if (ctrl.SelectedDataRows.Count == 0)
            {
                return(null); // nothing to do
            }
            int newposition = int.MinValue;

            var ivictrl = new IntegerValueInputController(0, "Please enter the new position (>=0):")
            {
                Validator = new IntegerValueInputController.ZeroOrPositiveIntegerValidator()
            };

            if (Current.Gui.ShowDialog(ivictrl, "New row position", false))
            {
                newposition = ivictrl.EnteredContents;
            }
            else
            {
                return(null);
            }

            SetSelectedRowPosition(ctrl, newposition);

            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// Pastes data from a table (usually deserialized table from the clipboard) into a worksheet, which has
        /// currently selected rows. The number of selected rows has to match the number of rows of the source table.
        /// </summary>
        /// <param name="dg">The worksheet to paste into.</param>
        /// <param name="sourcetable">The table which contains the data to paste into the worksheet.</param>
        /// <remarks>The operation is defined as follows: if the is no column selection, the data are inserted beginning at the first column of the destination table.
        /// If there is a column selection, the data are inserted in the selected columns, and then in the columns after the last selected columns.
        /// No exception is thrown if a column type does not match the corresponding source column type.
        /// The columns to paste into do not change their name, kind or group number. Property columns in the source table
        /// are pasted into the destination table.</remarks>
        protected static void PasteFromTableRowsToSelectedRows(IWorksheetController dg, Altaxo.Data.DataTable sourcetable)
        {
            Altaxo.Data.DataTable desttable = dg.DataTable;

            Altaxo.Data.DataColumn[] propertycolumnmap = MapOrCreatePropertyColumns(desttable, sourcetable);
            Altaxo.Data.DataColumn[] destdatacolumnmap = MapOrCreateDataColumns(desttable, dg.SelectedDataColumns, sourcetable);

            for (int nCol = 0; nCol < sourcetable.DataColumns.ColumnCount; nCol++)
            {
                // now fill the data into that column

                try
                {
                    int nDestRow = -1;
                    for (int nSrcRow = 0; nSrcRow < sourcetable.DataColumns.RowCount; nSrcRow++)
                    {
                        nDestRow = nSrcRow < dg.SelectedDataRows.Count ? dg.SelectedDataRows[nSrcRow] : nDestRow + 1;
                        destdatacolumnmap[nCol][nDestRow] = sourcetable.DataColumns[nCol][nSrcRow];
                    }
                }
                catch (Exception)
                {
                }

                // also fill in the property values
                int nDestColumnIndex = desttable.DataColumns.GetColumnNumber(destdatacolumnmap[nCol]);
                FillRow(propertycolumnmap, nDestColumnIndex, sourcetable.PropCols, nCol);
            } // for all data columns
        }
Esempio n. 6
0
        /// <summary>
        /// Plots the currently selected data columns of a worksheet as horzizontal bar diagram.
        /// </summary>
        /// <param name="dg">The worksheet controller where the columns are selected in.</param>
        public static void PlotColumnChartNormal(IWorksheetController dg)
        {
            var graph   = Altaxo.Graph.Gdi.GraphTemplates.TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.CreateGraph(dg.DataTable.GetPropertyContext(), null, dg.DataTable.Name, true);
            var context = graph.GetPropertyContext();

            Plot(dg.DataTable, dg.SelectedDataColumns, graph, PlotStyle_Bar(context), GroupStyle_Bar);
        }
Esempio n. 7
0
        public static void Interpolation(IWorksheetController ctrl, InterpolationParameters parameters)
        {
            var _columnToGroupNumber = new Dictionary <DataColumn, int>();

            for (int nSel = 0; nSel < ctrl.SelectedDataColumns.Count; nSel++)
            {
                Altaxo.Data.DataColumn yCol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[nSel]];
                Altaxo.Data.DataColumn xCol = ctrl.DataTable.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;
                }

                var xRes = new DoubleColumn();
                var yRes = new DoubleColumn();
                if (!_columnToGroupNumber.TryGetValue(xCol, out var newgroup))
                {
                    newgroup = ctrl.DataTable.DataColumns.GetUnusedColumnGroupNumber();
                    ctrl.DataTable.DataColumns.Add(xRes, xCol.Name + ".I", ColumnKind.X, newgroup);
                    _columnToGroupNumber.Add(xCol, newgroup);
                }
                ctrl.DataTable.DataColumns.Add(yRes, yCol.Name + ".I", ColumnKind.V, newgroup);

                Interpolation(xCol, yCol, parameters, xRes, yRes);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Sets the column kind of the first selected column to the specified column kind
        /// </summary>
        public static void SetSelectedColumnAsKind(IWorksheetController 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.TableAreaInvalidate(); // draw new because
            }
        }
Esempio n. 9
0
        public static void ImportAscii(IWorksheetController ctrl, System.IO.Stream myStream)
        {
            AsciiImporter      importer          = new AsciiImporter(myStream);
            AsciiImportOptions recognizedOptions = importer.Analyze(30, new AsciiImportOptions());

            importer.ImportAscii(recognizedOptions, ctrl.Doc);
        }
Esempio n. 10
0
 /// <summary>
 /// Sets the group number of the selected column
 /// </summary>
 /// <param name="ctrl">The worksheet controller for the table.</param>
 public static void ShowSetColumnGroupNumberDialog(IWorksheetController ctrl)
 {
     if (ctrl.DataTable.ShowSetColumnGroupNumberDialog(ctrl.SelectedDataColumns, ctrl.SelectedPropertyColumns))
     {
         ctrl.ClearAllSelections();
         ctrl.TableAreaInvalidate();
     }
 }
Esempio n. 11
0
		public static void StatisticsOnRows(IWorksheetController ctrl)
		{
			var table = ctrl.DataTable.DoStatisticsOnRows(ctrl.SelectedDataColumns, ctrl.SelectedDataRows);

			Current.Project.DataTableCollection.Add(table);
			// create a new worksheet without any columns
			Current.ProjectService.CreateNewWorksheet(table);
		}
Esempio n. 12
0
        public static void StatisticsOnRows(IWorksheetController ctrl)
        {
            var table = ctrl.DataTable.DoStatisticsOnRows(ctrl.SelectedDataColumns, ctrl.SelectedDataRows);

            Current.Project.DataTableCollection.Add(table);
            // create a new worksheet without any columns
            Current.ProjectService.CreateNewWorksheet(table);
        }
Esempio n. 13
0
		/// <summary>
		/// Sets the group number of the selected column
		/// </summary>
		/// <param name="ctrl">The worksheet controller for the table.</param>
		public static void ShowSetColumnGroupNumberDialog(IWorksheetController ctrl)
		{
			if (ctrl.DataTable.ShowSetColumnGroupNumberDialog(ctrl.SelectedDataColumns, ctrl.SelectedPropertyColumns))
			{
				ctrl.ClearAllSelections();
				ctrl.TableAreaInvalidate();
			}
		}
Esempio n. 14
0
        public static void Correlation(IWorksheetController ctrl)
        {
            string err = Correlation(Current.Project, ctrl);

            if (null != err)
            {
                Current.Gui.ErrorMessageBox(err);
            }
        }
Esempio n. 15
0
        public static void PasteFromClipboard(IWorksheetController dg)
        {
            DataTable table = GetTableFromClipboard();

            if (null != table)
            {
                PasteFromTable(dg, table);
            }
        }
Esempio n. 16
0
 /// <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(IWorksheetController 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();
 }
Esempio n. 17
0
        /// <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(IWorksheetController ctrl, int rowBeforeToInsert)
        {
            // ask for the number of rows to insert
            var ictrl = new IntegerValueInputController(1, "Enter the number of rows to insert:");

            if (Current.Gui.ShowDialog(ictrl, "Insert rows", false))
            {
                InsertDataRows(ctrl, rowBeforeToInsert, ictrl.EnteredContents);
            }
        }
Esempio n. 18
0
		public static void Duplicate(IWorksheetController 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
			string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(ctrl.DataTable.Name, "WKS");
			clonedTable.Name = Data.DataTableCollection.GetParentDataTableCollectionOf(ctrl.DataTable).FindNewTableName(newnamebase);
			Data.DataTableCollection.GetParentDataTableCollectionOf(ctrl.DataTable).Add(clonedTable);
			Current.ProjectService.CreateNewWorksheet(clonedTable);
		}
Esempio n. 19
0
        /// <summary>
        /// Plots the currently selected data columns of a worksheet as horzizontal bar diagram.
        /// </summary>
        /// <param name="dg">The worksheet controller where the columns are selected in.</param>
        public static void PlotBarChartStack(IWorksheetController dg)
        {
            var graph   = Altaxo.Graph.Gdi.GraphTemplates.TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.CreateGraph(dg.DataTable.GetPropertyContext(), null, dg.DataTable.Name, true);
            var xylayer = graph.RootLayer.Layers.OfType <XYPlotLayer>().First();

            ((G2DCartesicCoordinateSystem)xylayer.CoordinateSystem).IsXYInterchanged = true;
            var context = graph.GetPropertyContext();

            Plot(dg.DataTable, dg.SelectedDataColumns, graph, PlotStyle_Bar(context), GroupStyle_Stack_Bar);
        }
Esempio n. 20
0
        /// <summary>
        /// Plots the currently selected data columns of a worksheet as horzizontal bar diagram.
        /// </summary>
        /// <param name="dg">The worksheet controller where the columns are selected in.</param>
        public static void PlotBarChartRelativeStack(IWorksheetController dg)
        {
            var graph = TemplateWithXYZPlotLayerWithG3DCartesicCoordinateSystem.CreateGraph(dg.DataTable.GetPropertyContext(), null, dg.DataTable.Name, true);
            var layer = graph.RootLayer.Layers.OfType <XYZPlotLayer>().First();

            layer.CoordinateSystem = ((G3DCartesicCoordinateSystem)layer.CoordinateSystem).WithXYInterchanged(true);
            var context = graph.GetPropertyContext();

            Plot(dg.DataTable, dg.SelectedDataColumns, graph, PlotStyle_Bar(context, true), GroupStyle_RelativeStack_Bar);
        }
Esempio n. 21
0
        /// <summary>
        /// Writes ASCII to the clipboard if data cells are selected.
        /// </summary>
        /// <param name="dg">The worksheet controller</param>
        /// <param name="dao">The clipboard data object</param>
        protected static void WriteAsciiToClipBoardIfDataCellsSelected(IWorksheetController dg, Altaxo.Gui.IClipboardSetDataObject dao)
        {
            // columns are selected
            DataTable dt = dg.DataTable;

            Altaxo.Collections.AscendingIntegerCollection selCols     = dg.SelectedDataColumns;
            Altaxo.Collections.AscendingIntegerCollection selRows     = dg.SelectedDataRows;
            Altaxo.Collections.AscendingIntegerCollection selPropCols = dg.SelectedPropertyColumns;
            WriteAsciiToClipBoardIfDataCellsSelected(dt, selCols, selRows, selPropCols, dao);
        }
Esempio n. 22
0
 /// <summary>
 /// Renames the selected data column or property column.
 /// </summary>
 /// <param name="ctrl">The worksheet controller for the table.</param>
 public static void RenameSelectedColumn(IWorksheetController ctrl)
 {
     if (ctrl.SelectedDataColumns.Count == 1 && ctrl.SelectedPropertyColumns.Count == 0)
     {
         ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[0]].ShowRenameColumnDialog();
     }
     else if (ctrl.SelectedDataColumns.Count == 0 && ctrl.SelectedPropertyColumns.Count == 1)
     {
         ctrl.DataTable.PropCols[ctrl.SelectedPropertyColumns[0]].ShowRenameColumnDialog();
     }
 }
Esempio n. 23
0
        /// <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(IWorksheetController ctrl, int rowBeforeToInsert, int numberOfRows)
        {
            if (numberOfRows <= 0 || rowBeforeToInsert < 0)
            {
                return;
            }

            ctrl.DataTable.DataColumns.InsertRows(rowBeforeToInsert, numberOfRows);
            ctrl.ClearAllSelections();
            ctrl.TableAreaInvalidate();
        }
Esempio n. 24
0
        public static void Duplicate(IWorksheetController ctrl)
        {
            var clonedTable = (Altaxo.Data.DataTable)ctrl.DataTable.Clone();

            // find a new name for the cloned table and add it to the DataTableCollection
            string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(ctrl.DataTable.Name, "WKS");

            clonedTable.Name = Data.DataTableCollection.GetParentDataTableCollectionOf(ctrl.DataTable).FindNewItemName(newnamebase);
            Data.DataTableCollection.GetParentDataTableCollectionOf(ctrl.DataTable).Add(clonedTable);
            Current.ProjectService.CreateNewWorksheet(clonedTable);
        }
Esempio n. 25
0
 /// <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(IWorksheetController ctrl)
 {
     if (ctrl.SelectedDataRows.Count > 0)
     {
         InsertDataRows(ctrl, ctrl.SelectedDataRows[0]);
     }
     else
     {
         InsertDataRows(ctrl, 0);
     }
 }
Esempio n. 26
0
		/// <summary>
		/// Renames the selected data column or property column.
		/// </summary>
		/// <param name="ctrl">The worksheet controller for the table.</param>
		public static void RenameSelectedColumn(IWorksheetController ctrl)
		{
			if (ctrl.SelectedDataColumns.Count == 1 && ctrl.SelectedPropertyColumns.Count == 0)
			{
				ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[0]].ShowRenameColumnDialog();
			}
			else if (ctrl.SelectedDataColumns.Count == 0 && ctrl.SelectedPropertyColumns.Count == 1)
			{
				ctrl.DataTable.PropCols[ctrl.SelectedPropertyColumns[0]].ShowRenameColumnDialog();
			}
		}
Esempio n. 27
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(IWorksheetController ctrl, int nPosition)
        {
            if (ctrl.SelectedDataRows.Count > 0)
            {
                ctrl.DataTable.DataColumns.ChangeRowPosition(ctrl.SelectedDataRows, nPosition);
            }

            ctrl.ClearAllSelections();

            ctrl.TableAreaInvalidate();
        }
Esempio n. 28
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(IWorksheetController ctrl, int nPosition)
		{
			if (ctrl.SelectedDataRows.Count > 0)
			{
				ctrl.DataTable.DataColumns.ChangeRowPosition(ctrl.SelectedDataRows, nPosition);
			}

			ctrl.ClearAllSelections();

			ctrl.TableAreaInvalidate();
		}
Esempio n. 29
0
		/// <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(IWorksheetController ctrl)
		{
			DataColumn xcol = null, ycol = null, vcol = null;

			// for this command to work, there must be exactly 3 data columns selected
			int nCols = ctrl.SelectedDataColumns.Count;
			if (nCols >= 3)
			{
				for (int i = 0; i < nCols; i++)
				{
					if (ctrl.DataTable.DataColumns.GetColumnKind(ctrl.SelectedDataColumns[i]) == ColumnKind.Y)
					{
						ycol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[i]];
						break;
					}
				}
				for (int i = 0; i < nCols; i++)
				{
					if (ctrl.DataTable.DataColumns.GetColumnKind(ctrl.SelectedDataColumns[i]) == ColumnKind.X)
					{
						xcol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[i]];
						break;
					}
				}

				if (xcol == null || ycol == null)
					return "The selected columns must be a x-column, a y-column, and one or more value columns";
			}
			else
			{
				return "You must select exactly a x-column, a y-column, and one or more value column";
			}

			// 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 = 0; i < nCols; i++)
			{
				vcol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[i]];
				if (object.ReferenceEquals(vcol, xcol) || object.ReferenceEquals(vcol, ycol))
					continue;

				DataTable newtable;
				string msg = XYVToMatrix(xcol, ycol, vcol, ctrl.DataTable, out newtable);
				if (msg != null)
					return msg;

				string newtablename = ctrl.DataTable.Name + "-" + vcol.Name;
				newtable.Name = newtablename;
				Current.ProjectService.CreateNewWorksheet(newtable);
			}

			return null;
		}
Esempio n. 30
0
        /// <summary>
        /// Remove all but the selected columns, rows or property columns.
        /// </summary>
        public static void RemoveAllButSelected(IWorksheetController ctrl)
        {
            using (var suspendToken = ctrl.DataTable.SuspendGetToken())
            {
                // Property columns are only deleted, if selected alone or in conjunction with data row selection
                if (ctrl.SelectedPropertyColumns.Count > 0 && ctrl.SelectedPropertyRows.Count == 0 && ctrl.SelectedDataColumns.Count == 0)
                {
                    for (int i = ctrl.DataTable.PropertyColumnCount - 1; i >= 0; i--)
                    {
                        if (!ctrl.SelectedPropertyColumns.Contains(i))
                        {
                            ctrl.DataTable.PropertyColumns.RemoveColumn(i);
                        }
                    }

                    ctrl.SelectedPropertyColumns.Clear();
                    ctrl.SelectedPropertyRows.Clear();
                }
                // note here: Property rows are only removed indirect by removing data columns

                // delete the selected columns if there are _only selected columns
                if (ctrl.SelectedDataColumns.Count > 0)
                {
                    for (int i = ctrl.DataTable.DataColumnCount - 1; i >= 0; i--)
                    {
                        if (!ctrl.SelectedDataColumns.Contains(i))
                        {
                            ctrl.DataTable.RemoveColumns(i, 1);
                        }
                    }
                    ctrl.SelectedDataColumns.Clear(); // now the columns are deleted, so they cannot be selected
                }

                // if rows are selected, remove them in all selected columns or in all columns (if no column selection=
                if (ctrl.SelectedDataRows.Count > 0)
                {
                    for (int i = ctrl.DataTable.DataRowCount - 1; i >= 0; i--)
                    {
                        if (!ctrl.SelectedDataRows.Contains(i))
                        {
                            ctrl.DataTable.DataColumns.RemoveRow(i);
                        }
                    }

                    ctrl.SelectedDataColumns.Clear();
                    ctrl.SelectedDataRows.Clear();
                }

                // end code for the selected rows
                suspendToken.Dispose();
            }
            ctrl.TableAreaInvalidate(); // necessary because we changed the selections
        }
Esempio n. 31
0
        /// <summary>
        /// Writes ASCII to the clipboard if only property cells are selected.
        /// </summary>
        /// <param name="dg">The worksheet controller</param>
        /// <param name="dao">The clipboard data object</param>
        protected static void WriteAsciiToClipBoardIfOnlyPropertyCellsSelected(IWorksheetController dg, Altaxo.Gui.IClipboardSetDataObject dao)
        {
            // columns are selected
            DataTable dt = dg.DataTable;

            Altaxo.Collections.AscendingIntegerCollection selCols = dg.SelectedPropertyColumns;
            Altaxo.Collections.AscendingIntegerCollection selRows = dg.SelectedPropertyRows;
            if (selRows.Count == 0)
            {
                selRows = new Altaxo.Collections.AscendingIntegerCollection();
                selRows.AddRange(0, dg.DataTable.PropertyRowCount);
            }

            var str = new System.IO.StringWriter();

            for (int i = 0; i < selRows.Count; i++)
            {
                for (int j = 0; j < selCols.Count; j++)
                {
                    str.Write(dt.PropertyColumns[selCols[j]][selRows[i]].ToString());
                    if (j < selCols.Count - 1)
                    {
                        str.Write(";");
                    }
                    else
                    {
                        str.WriteLine();
                    }
                }
            }
            dao.SetCommaSeparatedValues(str.ToString());

            // now also as tab separated text
            var sw = new System.IO.StringWriter();

            for (int i = 0; i < selRows.Count; i++)
            {
                for (int j = 0; j < selCols.Count; j++)
                {
                    sw.Write(dt.PropertyColumns[selCols[j]][selRows[i]].ToString());
                    if (j < selCols.Count - 1)
                    {
                        sw.Write("\t");
                    }
                    else
                    {
                        sw.WriteLine();
                    }
                }
            }
            dao.SetData(typeof(string), sw.ToString());
        }
Esempio n. 32
0
		public static void FFT(IWorksheetController dg)
		{
			int len = dg.SelectedDataColumns.Count;
			if (len == 0)
				return; // nothing selected

			if (!(dg.DataTable[dg.SelectedDataColumns[0]] is Altaxo.Data.DoubleColumn))
				return;

			Altaxo.Data.DoubleColumn col = (Altaxo.Data.DoubleColumn)dg.DataTable[dg.SelectedDataColumns[0]];

			Altaxo.Data.AnalysisRealFourierTransformationCommands.ShowRealFourierTransformDialog(col);
		}
Esempio n. 33
0
		public static void Transpose(IWorksheetController ctrl)
		{
			var srcTable = ctrl.DataTable;
			var options = new Altaxo.Data.DataTableTransposeOptions(srcTable.DataColumnCount, srcTable.PropertyColumnCount);
			if (!Current.Gui.ShowDialog(ref options, "Transpose worksheet", false))
				return;

			var destTable = Current.Project.CreateNewTable(srcTable.Name + "_Transposed", false);

			Altaxo.Data.Transposing.Transpose(srcTable, options, destTable);
			Current.ProjectService.ShowDocumentView(destTable);

			destTable.DataSource = new Altaxo.Data.DataTableTransposeDataSource(new Data.DataTableProxy(srcTable), options, new Data.DataSourceImportOptions());
		}
Esempio n. 34
0
        /// <summary>
        /// Pastes data from a table (usually deserialized table from the clipboard) into a worksheet.
        /// The paste operation depends on the current selection of columns, rows, or property columns.
        /// </summary>
        /// <param name="ctrl">The worksheet to paste into.</param>
        /// <param name="sourcetable">The table which contains the data to paste into the worksheet.</param>
        /// <remarks>The paste operation is defined in the following way:
        /// If nothing is currently selected, the columns are appended to the end of the worksheet and the property data
        /// are set for that columns.
        /// If only columns are currently selected, the data is pasted in that columns (column by column). If number of
        /// selected columns not match the number of columns in the paste table, but match the number of rows in the paste table,
        /// the paste is done column by row.
        ///
        /// </remarks>
        public static void PasteFromTable(IWorksheetController ctrl, Altaxo.Data.DataTable sourcetable)
        {
            using (var suspendToken = ctrl.DataTable.SuspendGetToken())
            {
                if (!ctrl.AreColumnsOrRowsSelected)
                {
                    PasteFromTableToUnselected(ctrl, sourcetable);
                }
                else if (ctrl.SelectedDataColumns.Count > 0 && ctrl.SelectedDataColumns.Count == sourcetable.DataColumns.ColumnCount)
                {
                    PasteFromTableColumnsToSelectedColumns(ctrl, sourcetable);
                }
                else if (ctrl.SelectedDataColumns.Count > 0 && ctrl.SelectedDataColumns.Count == sourcetable.DataColumns.RowCount)
                {
                    PasteFromTableRowsToSelectedColumns(ctrl, sourcetable);
                }
                else if (ctrl.SelectedDataRows.Count > 0 && ctrl.SelectedDataRows.Count == sourcetable.DataColumns.RowCount)
                {
                    PasteFromTableRowsToSelectedRows(ctrl, sourcetable);
                }
                else if (ctrl.SelectedDataRows.Count > 0 && ctrl.SelectedDataRows.Count == sourcetable.DataColumns.ColumnCount)
                {
                    PasteFromTableColumnsToSelectedRows(ctrl, sourcetable);
                }
                else if (ctrl.SelectedPropertyColumns.Count > 0 && ctrl.SelectedPropertyColumns.Count == sourcetable.DataColumns.ColumnCount)
                {
                    PasteFromTableColumnsToSelectedPropertyColumns(ctrl, sourcetable);
                }
                // now look if the data are transposed
                else if (ctrl.SelectedPropertyColumns.Count > 0 && ctrl.SelectedPropertyColumns.Count == sourcetable.DataColumns.RowCount)
                {
                    PasteFromTableColumnsTransposedToSelectedPropertyColumns(ctrl, sourcetable);
                }

                // now the not exact matches
                else if (ctrl.SelectedDataColumns.Count > 0)
                {
                    PasteFromTableColumnsToSelectedColumns(ctrl, sourcetable);
                }
                else if (ctrl.SelectedDataRows.Count > 0)
                {
                    PasteFromTableRowsToSelectedRows(ctrl, sourcetable);
                }

                suspendToken.Dispose();
            }
        }
Esempio n. 35
0
        /// <summary>
        /// Pastes data from a table (usually deserialized table from the clipboard) into a worksheet, which has
        /// currently selected columns. The number of selected columns has to match the number of columns of the source table.
        /// </summary>
        /// <param name="dg">The worksheet to paste into.</param>
        /// <param name="sourcetable">The table which contains the data to paste into the worksheet.</param>
        /// <remarks>The operation is defined as follows: if the is no ro selection, the data are inserted beginning at row[0] of the destination table.
        /// If there is a row selection, the data are inserted in the selected rows, and then in the rows after the last selected rows.
        /// No exception is thrown if a column type does not match the corresponding source column type.
        /// The columns to paste into do not change their name, kind or group number. But property columns in the source table
        /// are pasted into the destination table.</remarks>
        protected static void PasteFromTableColumnsToSelectedColumns(IWorksheetController dg, Altaxo.Data.DataTable sourcetable)
        {
            Altaxo.Data.DataTable desttable = dg.DataTable;

            Altaxo.Data.DataColumn[] propertycolumnmap = MapOrCreatePropertyColumns(desttable, sourcetable);

            // use the selected columns, then use the following columns, then add columns
            int nDestCol = -1;

            for (int nSrcCol = 0; nSrcCol < sourcetable.DataColumns.ColumnCount; nSrcCol++)
            {
                nDestCol = nSrcCol < dg.SelectedDataColumns.Count ? dg.SelectedDataColumns[nSrcCol] : nDestCol + 1;
                Altaxo.Data.DataColumn destcolumn;
                if (nDestCol < desttable.DataColumns.ColumnCount)
                {
                    destcolumn = desttable.DataColumns[nDestCol];
                }
                else
                {
                    string name  = sourcetable.DataColumns.GetColumnName(nSrcCol);
                    int    group = sourcetable.DataColumns.GetColumnGroup(nSrcCol);
                    Altaxo.Data.ColumnKind kind = sourcetable.DataColumns.GetColumnKind(nSrcCol);
                    destcolumn = (Altaxo.Data.DataColumn)Activator.CreateInstance(sourcetable.DataColumns[nSrcCol].GetType());
                    desttable.DataColumns.Add(destcolumn, name, kind, group);
                }

                // now fill the data into that column
                Altaxo.Data.DataColumn sourcecolumn = sourcetable.DataColumns[nSrcCol];

                try
                {
                    int nDestRow = -1;
                    for (int nSrcRow = 0; nSrcRow < sourcetable.DataColumns.RowCount; nSrcRow++)
                    {
                        nDestRow             = nSrcRow < dg.SelectedDataRows.Count ? dg.SelectedDataRows[nSrcRow] : nDestRow + 1;
                        destcolumn[nDestRow] = sourcecolumn[nSrcRow];
                    }
                }
                catch (Exception)
                {
                }

                // also fill in the property values
                int nDestColumnIndex = desttable.DataColumns.GetColumnNumber(destcolumn);
                FillRow(propertycolumnmap, nDestColumnIndex, sourcetable.PropCols, nSrcCol);
            } // for all data columns
        }
Esempio n. 36
0
		public static void SavitzkyGolayFiltering(IWorksheetController 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.DataTable.DataColumns[ctrl.SelectedDataColumns[0]];
			Altaxo.Data.DataColumn xCol = ctrl.DataTable.DataColumns.FindXColumnOf(yCol);

			SavitzkyGolay(parameters, yCol, xCol);
		}
Esempio n. 37
0
        public static void FFT(IWorksheetController dg)
        {
            int len = dg.SelectedDataColumns.Count;

            if (len == 0)
            {
                return; // nothing selected
            }
            if (!(dg.DataTable[dg.SelectedDataColumns[0]] is Altaxo.Data.DoubleColumn))
            {
                return;
            }

            var col = (Altaxo.Data.DoubleColumn)dg.DataTable[dg.SelectedDataColumns[0]];

            Altaxo.Data.AnalysisRealFourierTransformationCommands.ShowRealFourierTransformDialog(col);
        }
Esempio n. 38
0
        public static void Transpose(IWorksheetController ctrl)
        {
            var srcTable = ctrl.DataTable;
            var options  = new Altaxo.Data.DataTableTransposeOptions();

            if (!Current.Gui.ShowDialog(ref options, "Transpose worksheet", false))
            {
                return;
            }

            var destTable = Current.Project.CreateNewTable(srcTable.Name + "_Transposed", false);

            Altaxo.Data.Transposing.Transpose(srcTable, options, destTable);
            Current.IProjectService.ShowDocumentView(destTable);

            destTable.DataSource = new Altaxo.Data.DataTableTransposeDataSource(new Data.DataTableProxy(srcTable), options, new Data.DataSourceImportOptions());
        }
Esempio n. 39
0
        public static string Correlation(Altaxo.AltaxoDocument mainDocument, IWorksheetController dg)
        {
            int len = dg.SelectedDataColumns.Count;

            if (len == 0)
            {
                return("No column selected!"); // nothing selected
            }
            if (len > 2)
            {
                return("Too many columns selected!");
            }

            if (!(dg.DataTable[dg.SelectedDataColumns[0]] is Altaxo.Data.DoubleColumn))
            {
                return("First selected column is not numeric!");
            }

            if (dg.SelectedDataColumns.Count == 2 && !(dg.DataTable[dg.SelectedDataColumns[1]] is Altaxo.Data.DoubleColumn))
            {
                return("Second selected column is not numeric!");
            }

            double[] arr1 = ((Altaxo.Data.DoubleColumn)dg.DataTable[dg.SelectedDataColumns[0]]).Array;
            double[] arr2 = arr1;
            if (dg.SelectedDataColumns.Count == 2)
            {
                arr2 = ((Altaxo.Data.DoubleColumn)dg.DataTable[dg.SelectedDataColumns[1]]).Array;
            }

            double[] result = new double[arr1.Length + arr2.Length - 1];
            //Pfa235Convolution co = new Pfa235Convolution(arr1.Length);
            //co.Convolute(arr1, arr2, result, null, FourierDirection.Forward);

            Calc.Fourier.NativeFourierMethods.CorrelationNonCyclic(arr1, arr2, result);

            var col = new Altaxo.Data.DoubleColumn
            {
                Array = result
            };

            dg.DataTable.DataColumns.Add(col, "Correlate");

            return(null);
        }
Esempio n. 40
0
		/// <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(IWorksheetController 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;
		}
Esempio n. 41
0
		/// <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(IWorksheetController 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;
		}
Esempio n. 42
0
		/// <summary>
		/// Pastes data columns from the source table (usually deserialized table from the clipboard) into rows of the destination table, which has
		/// currently selected rows. The number of selected rows has to match the number of columns of the source table.
		/// </summary>
		/// <param name="dg">The worksheet to paste into.</param>
		/// <param name="sourcetable">The table which contains the data to paste into the worksheet.</param>
		/// <remarks>The operation is defined as follows: if there is no column selection, the data are inserted beginning at the first column of the destination table.
		/// If there is a column selection, the data are inserted in the selected columns, and then in the columns after the last selected columns.
		/// No exception is thrown if a cell type does not match the corresponding source cell type.
		/// The columns to paste into do not change their name, kind or group number. Property columns in the source table
		/// are not used for this operation.</remarks>
		protected static void PasteFromTableColumnsToSelectedRows(IWorksheetController dg, Altaxo.Data.DataTable sourcetable)
		{
			Altaxo.Data.DataTable desttable = dg.DataTable;
			Altaxo.Data.DataColumn[] destdatacolumnmap = MapOrCreateDataColumnsToRows(desttable, dg.SelectedDataColumns, sourcetable);

			int nDestRow = -1;
			for (int nSrcCol = 0; nSrcCol < sourcetable.DataColumns.ColumnCount; nSrcCol++)
			{
				nDestRow = nSrcCol < dg.SelectedDataRows.Count ? dg.SelectedDataRows[nSrcCol] : nDestRow + 1;

				for (int nSrcRow = 0; nSrcRow < sourcetable.DataColumns.RowCount; nSrcRow++)
				{
					int nDestCol = nSrcRow;
					try { destdatacolumnmap[nDestCol][nDestRow] = sourcetable.DataColumns[nSrcCol][nSrcRow]; }
					catch (Exception) { }
				}
			}
		}
Esempio n. 43
0
 public static void ImportAscii(IWorksheetController ctrl, System.IO.Stream myStream)
 {
   AsciiImporter importer = new AsciiImporter(myStream);
   AsciiImportOptions recognizedOptions = importer.Analyze(30, new AsciiImportOptions());
   importer.ImportAscii(recognizedOptions,ctrl.Doc);
 }
Esempio n. 44
0
		public static void PasteFromClipboard(IWorksheetController dg)
		{
			DataTable table = GetTableFromClipboard();

			if (null != table)
				PasteFromTable(dg, table);
		}
Esempio n. 45
0
		protected static void PasteFromTableRowsToSelectedColumns(IWorksheetController dg, Altaxo.Data.DataTable sourcetable)
		{
			PasteFromTableColumnsToSelectedRows(dg, sourcetable);
		}
Esempio n. 46
0
		public static void WorksheetClearData(IWorksheetController ctrl)
		{
			ctrl.DataTable.DataColumns.ClearData();
			ctrl.DataTable.PropCols.ClearData();
		}
Esempio n. 47
0
		/// <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(IWorksheetController 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.TableAreaInvalidate();
		}
Esempio n. 48
0
		public static void Interpolation(IWorksheetController ctrl)
		{
			if (ctrl.SelectedDataColumns.Count == 0)
				return;

			object paramobject = new InterpolationParameters();

			if (!Current.Gui.ShowDialog(ref paramobject, "Interpolation"))
				return;

			InterpolationParameters parameters = (InterpolationParameters)paramobject;

			Interpolation(ctrl, parameters);
		}
Esempio n. 49
0
		public static LinearFitBySvd MultivariateLinearFit(IWorksheetController ctrl)
		{
			return Calc.Regression.Multivariate.MultivariateLinearRegression.ShowDialogAndRegress(ctrl.DataTable.DataColumns, ctrl.SelectedDataColumns);
		}
Esempio n. 50
0
		/// <summary>
		/// Pastes data from a table (usually deserialized table from the clipboard) into a worksheet, which has
		/// currently selected rows. The number of selected rows has to match the number of rows of the source table.
		/// </summary>
		/// <param name="dg">The worksheet to paste into.</param>
		/// <param name="sourcetable">The table which contains the data to paste into the worksheet.</param>
		/// <remarks>The operation is defined as follows: if the is no column selection, the data are inserted beginning at the first column of the destination table.
		/// If there is a column selection, the data are inserted in the selected columns, and then in the columns after the last selected columns.
		/// No exception is thrown if a column type does not match the corresponding source column type.
		/// The columns to paste into do not change their name, kind or group number. Property columns in the source table
		/// are pasted into the destination table.</remarks>
		protected static void PasteFromTableRowsToSelectedRows(IWorksheetController dg, Altaxo.Data.DataTable sourcetable)
		{
			Altaxo.Data.DataTable desttable = dg.DataTable;

			Altaxo.Data.DataColumn[] propertycolumnmap = MapOrCreatePropertyColumns(desttable, sourcetable);
			Altaxo.Data.DataColumn[] destdatacolumnmap = MapOrCreateDataColumns(desttable, dg.SelectedDataColumns, sourcetable);

			for (int nCol = 0; nCol < sourcetable.DataColumns.ColumnCount; nCol++)
			{
				// now fill the data into that column

				try
				{
					int nDestRow = -1;
					for (int nSrcRow = 0; nSrcRow < sourcetable.DataColumns.RowCount; nSrcRow++)
					{
						nDestRow = nSrcRow < dg.SelectedDataRows.Count ? dg.SelectedDataRows[nSrcRow] : nDestRow + 1;
						destdatacolumnmap[nCol][nDestRow] = sourcetable.DataColumns[nCol][nSrcRow];
					}
				}
				catch (Exception)
				{
				}

				// also fill in the property values
				int nDestColumnIndex = desttable.DataColumns.GetColumnNumber(destdatacolumnmap[nCol]);
				FillRow(propertycolumnmap, nDestColumnIndex, sourcetable.PropCols, nCol);
			} // for all data columns
		}
Esempio n. 51
0
		public static void AddPropertyColumns(IWorksheetController ctrl)
		{
			ShowAddColumnsDialog(ctrl.DataTable, true);
		}
Esempio n. 52
0
		public static void AddDataColumns(IWorksheetController ctrl)
		{
			ShowAddColumnsDialog(ctrl.DataTable, false);
		}
Esempio n. 53
0
		/// <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(IWorksheetController 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);
		}
Esempio n. 54
0
		/// <summary>
		/// This will create a property column as text column with the names of the data columns.
		/// </summary>
		/// <param name="ctrl">The worksheet controller.</param>
		public static void CreatePropertyColumnOfColumnNames(IWorksheetController ctrl)
		{
			CreatePropertyColumnOfColumnNames(ctrl.DataTable);
		}
Esempio n. 55
0
		/// <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(IWorksheetController ctrl, int rowBeforeToInsert, int numberOfRows)
		{
			if (numberOfRows <= 0 || rowBeforeToInsert < 0)
				return;

			ctrl.DataTable.DataColumns.InsertRows(rowBeforeToInsert, numberOfRows);
			ctrl.ClearAllSelections();
			ctrl.TableAreaInvalidate();
		}
Esempio n. 56
0
		/// <summary>
		/// Sets the column kind of the first selected column to the specified column kind
		/// </summary>
		public static void SetSelectedColumnAsKind(IWorksheetController 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.TableAreaInvalidate(); // draw new because
		}
Esempio n. 57
0
		public static void Interpolation(IWorksheetController ctrl, InterpolationParameters parameters)
		{
			Dictionary<DataColumn, int> _columnToGroupNumber = new Dictionary<DataColumn, int>();

			for (int nSel = 0; nSel < ctrl.SelectedDataColumns.Count; nSel++)
			{
				Altaxo.Data.DataColumn yCol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[nSel]];
				Altaxo.Data.DataColumn xCol = ctrl.DataTable.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;
				}

				DoubleColumn xRes = new DoubleColumn();
				DoubleColumn yRes = new DoubleColumn();
				int newgroup;
				if (!_columnToGroupNumber.TryGetValue(xCol, out newgroup))
				{
					newgroup = ctrl.DataTable.DataColumns.GetUnusedColumnGroupNumber();
					ctrl.DataTable.DataColumns.Add(xRes, xCol.Name + ".I", ColumnKind.X, newgroup);
					_columnToGroupNumber.Add(xCol, newgroup);
				}
				ctrl.DataTable.DataColumns.Add(yRes, yCol.Name + ".I", ColumnKind.V, newgroup);

				Interpolation(xCol, yCol, parameters, xRes, yRes);
			}
		}
Esempio n. 58
0
		/// <summary>
		/// Sets the column kind of the first selected column or property column to a X column.
		/// </summary>
		public static void SetSelectedColumnAsY(IWorksheetController ctrl)
		{
			bool bChanged = false;
			if (ctrl.SelectedDataColumns.Count > 0)
			{
				ctrl.DataTable.DataColumns.SetColumnKind(ctrl.SelectedDataColumns[0], Altaxo.Data.ColumnKind.Y);
				bChanged = true;
			}
			if (ctrl.SelectedPropertyColumns.Count > 0)
			{
				ctrl.DataTable.PropertyColumns.SetColumnKind(ctrl.SelectedPropertyColumns[0], Altaxo.Data.ColumnKind.Y);
				bChanged = true;
			}
			if (bChanged)
				ctrl.TableAreaInvalidate(); // draw new because
		}
Esempio n. 59
0
		/// <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(IWorksheetController 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();
		}
Esempio n. 60
0
		/// <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(IWorksheetController ctrl)
		{
			if (ctrl.SelectedDataRows.Count > 0)
				InsertDataRows(ctrl, ctrl.SelectedDataRows[0]);
			else
				InsertDataRows(ctrl, 0);
		}