Ejemplo n.º 1
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(GUI.WorksheetController dg, System.Windows.Forms.DataObject 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.Doc.PropertyRowCount);
            }

            System.IO.StringWriter 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.SetData(System.Windows.Forms.DataFormats.CommaSeparatedValue, str.ToString());


            // now also as tab separated text
            System.IO.StringWriter 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(sw.ToString());
        }
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                AscendingIntegerCollection s = null != o ? (AscendingIntegerCollection)o : new AscendingIntegerCollection();

                int count = info.OpenArray();

                for (int i = 0; i < count; i++)
                {
                    info.OpenElement();
                    int rangestart = info.GetInt32("Start");
                    int rangecount = info.GetInt32("Count");
                    info.CloseElement();
                    s.AddRange(rangestart, rangecount);
                }
                info.CloseArray(count);
                return(s);
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Writes ASCII to the clipboard if data cells are selected.
        /// </summary>
        /// <param name="dt">The data table.</param>
        /// <param name="selCols">Selected data columns.</param>
        /// <param name="selRows">Selected data rows.</param>
        /// <param name="selPropCols">Selected property columns.</param>
        /// <param name="dao">The clipboard data object</param>
        public static void WriteAsciiToClipBoardIfDataCellsSelected(
            DataTable dt,
            Altaxo.Collections.AscendingIntegerCollection selCols,
            Altaxo.Collections.AscendingIntegerCollection selRows,
            Altaxo.Collections.AscendingIntegerCollection selPropCols,
            System.Windows.Forms.DataObject dao)
        {
            if (selCols.Count == 0)
            {
                selCols = new Altaxo.Collections.AscendingIntegerCollection();
                selCols.AddRange(0, dt.DataColumnCount);
            }

            if (selRows.Count == 0)
            {
                selRows = new Altaxo.Collections.AscendingIntegerCollection();
                int nRows = 0; // count the rows since they are maybe less than in the hole worksheet
                for (int i = 0; i < selCols.Count; i++)
                {
                    nRows = System.Math.Max(nRows, dt[selCols[i]].Count);
                }
                selRows.AddRange(0, nRows);
            }

            System.IO.StringWriter str = new System.IO.StringWriter();
            for (int i = 0; i < selPropCols.Count; i++)
            {
                for (int j = 0; j < selCols.Count; j++)
                {
                    str.Write(dt.PropertyColumns[selPropCols[i]][selCols[j]].ToString());
                    if (j < selCols.Count - 1)
                    {
                        str.Write(";");
                    }
                    else
                    {
                        str.WriteLine();
                    }
                }
            }

            for (int i = 0; i < selRows.Count; i++)
            {
                for (int j = 0; j < selCols.Count; j++)
                {
                    str.Write(dt.DataColumns[selCols[j]][selRows[i]].ToString());
                    if (j < selCols.Count - 1)
                    {
                        str.Write(";");
                    }
                    else
                    {
                        str.WriteLine();
                    }
                }
            }
            dao.SetData(System.Windows.Forms.DataFormats.CommaSeparatedValue, str.ToString());


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

            for (int i = 0; i < selPropCols.Count; i++)
            {
                for (int j = 0; j < selCols.Count; j++)
                {
                    str.Write(dt.PropertyColumns[selPropCols[i]][selCols[j]].ToString());
                    if (j < selCols.Count - 1)
                    {
                        str.Write("\t");
                    }
                    else
                    {
                        str.WriteLine();
                    }
                }
            }
            for (int i = 0; i < selRows.Count; i++)
            {
                for (int j = 0; j < selCols.Count; j++)
                {
                    sw.Write(dt.DataColumns[selCols[j]][selRows[i]].ToString());
                    if (j < selCols.Count - 1)
                    {
                        sw.Write("\t");
                    }
                    else
                    {
                        sw.WriteLine();
                    }
                }
            }
            dao.SetData(sw.ToString());
        }
Ejemplo n.º 4
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);
			}

			System.IO.StringWriter 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
			System.IO.StringWriter 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());
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Writes ASCII to the clipboard if data cells are selected.
		/// </summary>
		/// <param name="dt">The data table.</param>
		/// <param name="selCols">Selected data columns.</param>
		/// <param name="selRows">Selected data rows.</param>
		/// <param name="selPropCols">Selected property columns.</param>
		/// <param name="dao">The clipboard data object</param>
		public static void WriteAsciiToClipBoardIfDataCellsSelected(
			DataTable dt,
			Altaxo.Collections.AscendingIntegerCollection selCols,
			Altaxo.Collections.AscendingIntegerCollection selRows,
			Altaxo.Collections.AscendingIntegerCollection selPropCols,
			Altaxo.Gui.IClipboardSetDataObject dao)
		{
			if (selCols.Count == 0)
			{
				selCols = new Altaxo.Collections.AscendingIntegerCollection();
				selCols.AddRange(0, dt.DataColumnCount);
			}

			if (selRows.Count == 0)
			{
				selRows = new Altaxo.Collections.AscendingIntegerCollection();
				int nRows = 0; // count the rows since they are maybe less than in the hole worksheet
				for (int i = 0; i < selCols.Count; i++)
				{
					nRows = System.Math.Max(nRows, dt[selCols[i]].Count);
				}
				selRows.AddRange(0, nRows);
			}

			System.IO.StringWriter str = new System.IO.StringWriter();
			for (int i = 0; i < selPropCols.Count; i++)
			{
				for (int j = 0; j < selCols.Count; j++)
				{
					str.Write(dt.PropertyColumns[selPropCols[i]][selCols[j]].ToString());
					if (j < selCols.Count - 1)
						str.Write(";");
					else
						str.WriteLine();
				}
			}

			for (int i = 0; i < selRows.Count; i++)
			{
				for (int j = 0; j < selCols.Count; j++)
				{
					str.Write(dt.DataColumns[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
			System.IO.StringWriter sw = new System.IO.StringWriter();

			for (int i = 0; i < selPropCols.Count; i++)
			{
				for (int j = 0; j < selCols.Count; j++)
				{
					str.Write(dt.PropertyColumns[selPropCols[i]][selCols[j]].ToString());
					if (j < selCols.Count - 1)
						str.Write("\t");
					else
						str.WriteLine();
				}
			}
			for (int i = 0; i < selRows.Count; i++)
			{
				for (int j = 0; j < selCols.Count; j++)
				{
					sw.Write(dt.DataColumns[selCols[j]][selRows[i]].ToString());
					if (j < selCols.Count - 1)
						sw.Write("\t");
					else
						sw.WriteLine();
				}
			}
			dao.SetData(typeof(string), sw.ToString());
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Gets the data rows that participate in a matrix area by providing a table, the collection of selected data rows, and the collection of selected data columns.
		/// </summary>
		/// <param name="table">The table.</param>
		/// <param name="selectedRows">The selected data rows.</param>
		/// <param name="participatingColumns">The data columns that participate in the matrix area.</param>
		/// <returns>The collection of indices of data rows that participate in the matrix area.</returns>
		public static Altaxo.Collections.AscendingIntegerCollection GetParticipatingDataRows(DataTable table, IAscendingIntegerCollection selectedRows, IAscendingIntegerCollection participatingColumns)
		{
			var result = new AscendingIntegerCollection();

			if (null != selectedRows && selectedRows.Count > 0)
			{
				result.Add(selectedRows);
			}
			else
			{
				var dc = table.DataColumns;
				int rows = participatingColumns.Select(i => dc[i].Count).MinOrDefault(0);

				result.AddRange(0, rows);
			}

			return result;
		}