コード例 #1
0
ファイル: WorksheetCommands.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// Shows a dialog to add columns to a table.
		/// </summary>
		/// <param name="table">The table where to add the columns.</param>
		/// <param name="bAddToPropertyColumns">If true, the columns are added to the property columns instead of the data columns collection.</param>
		public static void ShowAddColumnsDialog(Altaxo.Data.DataTable table, bool bAddToPropertyColumns)
		{
			var lbitems = new Altaxo.Collections.SelectableListNodeList();
			lbitems.Add(new Altaxo.Collections.SelectableListNode("Numeric", typeof(Altaxo.Data.DoubleColumn), true));
			lbitems.Add(new Altaxo.Collections.SelectableListNode("Date/Time", typeof(Altaxo.Data.DateTimeColumn), false));
			lbitems.Add(new Altaxo.Collections.SelectableListNode("Text", typeof(Altaxo.Data.TextColumn), false));

			IntegerAndComboBoxController ct = new IntegerAndComboBoxController(
				"Number of colums to add:", 1, int.MaxValue, 1,
				"Type of columns to add:", lbitems, 0);
			Current.Gui.FindAndAttachControlTo(ct);

			if (true == Current.Gui.ShowDialog(ct, "Add new column(s)", false))
			{
				System.Type columntype = (System.Type)ct.SelectedItem.Tag;

				using (var suspendToken = table.SuspendGetToken())
				{
					if (bAddToPropertyColumns)
					{
						for (int i = 0; i < ct.IntegerValue; i++)
						{
							table.PropCols.Add((Altaxo.Data.DataColumn)System.Activator.CreateInstance(columntype));
						}
					}
					else
					{
						for (int i = 0; i < ct.IntegerValue; i++)
						{
							table.DataColumns.Add((Altaxo.Data.DataColumn)System.Activator.CreateInstance(columntype));
						}
					}

					suspendToken.Dispose();
				}
			}
		}
コード例 #2
0
    /// <summary>
    /// Shows a dialog to add columns to a table.
    /// </summary>
    /// <param name="table">The table where to add the columns.</param>
    /// <param name="bAddToPropertyColumns">If true, the columns are added to the property columns instead of the data columns collection.</param>
    public static void ShowAddColumnsDialog(Altaxo.Data.DataTable table, bool bAddToPropertyColumns)
    {
      Altaxo.Collections.SelectableListNodeList lbitems = new Altaxo.Collections.SelectableListNodeList();
      lbitems.Add(new Altaxo.Collections.SelectableListNode("Numeric", typeof(Altaxo.Data.DoubleColumn), true));
      lbitems.Add(new Altaxo.Collections.SelectableListNode("Date/Time", typeof(Altaxo.Data.DateTimeColumn), false));
      lbitems.Add(new Altaxo.Collections.SelectableListNode("Text", typeof(Altaxo.Data.TextColumn), false));

      IntegerAndComboBoxController ct = new IntegerAndComboBoxController(
        "Number of colums to add:", 1, int.MaxValue, 1,
        "Type of columns to add:", lbitems, 0);

      SpinAndComboBoxControl panel = new SpinAndComboBoxControl();
      ct.View = panel;

      if (true == Current.Gui.ShowDialog(ct,"Add new column(s)",false))
      {
        System.Type columntype = (System.Type)ct.SelectedItem.Item;

        table.Suspend();

        if (bAddToPropertyColumns)
        {
          for (int i = 0; i < ct.IntegerValue; i++)
          {
            table.PropCols.Add((Altaxo.Data.DataColumn)System.Activator.CreateInstance(columntype));
          }
        }
        else
        {
          for (int i = 0; i < ct.IntegerValue; i++)
          {
            table.DataColumns.Add((Altaxo.Data.DataColumn)System.Activator.CreateInstance(columntype));
          }
        }

        table.Resume();
      }
    }