コード例 #1
0
ファイル: GUIConversion.cs プロジェクト: olesar/Altaxo
        /// <summary>
        /// For a given enum value, this gives the list of possible choices for that enumeration (must not be a flag enumeration).
        /// </summary>
        /// <param name="value">The enum value that is currently selected.</param>
        /// <returns>List of all enumeration values. The current value is marked as (Selected is true for this list node).</returns>
        public static Altaxo.Collections.SelectableListNodeList GetListOfChoices(Enum value)
        {
            var  list     = new Altaxo.Collections.SelectableListNodeList();
            Type enumtype = value.GetType();

            foreach (Enum v in Enum.GetValues(enumtype))
            {
                string name = Current.Gui.GetUserFriendlyName(v);
                list.Add(new Altaxo.Collections.SelectableListNode(name, v, Enum.Equals(v, value)));
            }
            return(list);
        }
コード例 #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();
            }
        }
コード例 #3
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();
				}
			}
		}
コード例 #4
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();
      }
    }
コード例 #5
0
ファイル: GUIConversion.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// For a given enum value, this gives the list of possible choices for that enumeration (must not be a flag enumeration).
		/// </summary>
		/// <param name="value">The enum value that is currently selected.</param>
		/// <returns>List of all enumeration values. The current value is marked as (Selected is true for this list node).</returns>
		public static Altaxo.Collections.SelectableListNodeList GetListOfChoices(Enum value)
		{
			Altaxo.Collections.SelectableListNodeList list = new Altaxo.Collections.SelectableListNodeList();
			Type enumtype = value.GetType();
			foreach (Enum v in Enum.GetValues(enumtype))
			{
				string name = Current.Gui.GetUserFriendlyName(v);
				list.Add(new Altaxo.Collections.SelectableListNode(name, v, Enum.Equals(v, value)));
			}
			return list;
		}