Beispiel #1
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();
    }
Beispiel #2
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(WorksheetController ctrl, int rowBeforeToInsert, int numberOfRows)
    {
      if (numberOfRows <= 0 || rowBeforeToInsert<0)
        return;

      ctrl.Doc.DataColumns.InsertRows(rowBeforeToInsert, numberOfRows);
      ctrl.ClearAllSelections();
      ctrl.UpdateTableView();
    }
    /// <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>
    /// Sets the column kind of the first selected column or property column to a X column.
    /// </summary>
    public static void SetSelectedColumnAsY(WorksheetController 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.UpdateTableView(); // draw new because 

    }
    /// <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>
    /// Sets the group number of the currently selected columns to <code>nGroup</code>.
    /// </summary>
    /// <param name="ctrl">The worksheet controller.</param>
    /// <param name="nGroup">The group number to set for the selected columns.</param>
    public static void SetSelectedColumnGroupNumber(WorksheetController ctrl, int nGroup)
    {
      for(int i=0;i<ctrl.SelectedDataColumns.Count;i++)
      {
        ctrl.DataTable.DataColumns.SetColumnGroup(ctrl.SelectedDataColumns[i], nGroup);
      }
      
      for(int i=0;i<ctrl.SelectedPropertyColumns.Count;i++)
      {
        ctrl.DataTable.PropertyColumns.SetColumnGroup(ctrl.SelectedPropertyColumns[i], nGroup);
      }

      ctrl.ClearAllSelections();

      ctrl.UpdateTableView();
    }