private static string InternalAddClipboardDropDownList(Altaxo.Gui.IClipboardSetDataObject dao, System.Drawing.Bitmap bmp, GraphExportOptions options)
        {
            string filepath = System.IO.Path.GetTempPath();
            string filename = filepath + "AltaxoGraphCopyPage" + options.GetDefaultFileNameExtension();

            ;
            if (System.IO.File.Exists(filename))
            {
                System.IO.File.Delete(filename);
            }

            bmp.Save(filename, options.ImageFormat);

            var coll = new System.Collections.Specialized.StringCollection
            {
                filename
            };

            dao.SetFileDropList(coll);

            return(filename);
        }
Beispiel #2
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());
        }
Beispiel #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,
            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);
            }

            var 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
            var 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());
        }
Beispiel #4
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);
        }
        /// <summary>Puts an object into the provided dataObject, using one or more clipboard formats.</summary>
        /// <param name="clipBoardFormats">The clip board formats (are used later on to identify the data on the clipboard).</param>
        /// <param name="toSerialize">Data to put on the clipboard.</param>
        /// <param name="dataObject">The data object to put the data into.</param>
        public static void PutObjectToDataObject(IEnumerable <string> clipBoardFormats, object toSerialize, Altaxo.Gui.IClipboardSetDataObject dataObject)
        {
            if (null == dataObject)
            {
                throw new ArgumentNullException(nameof(dataObject));
            }

            var stb = SerializeToStringBuilder(toSerialize).ToString();

            foreach (var clipboardFormat in clipBoardFormats)
            {
                dataObject.SetData(clipboardFormat, stb);
            }
        }
        /// <summary>Puts an object into the provided dataObject.</summary>
        /// <param name="clipBoardFormat">The clip board format string (is used later on to identify the data on the clipboard).</param>
        /// <param name="toSerialize">Data to put on the clipboard.</param>
        /// <param name="dataObject">The data object to put the data into.</param>
        public static void PutObjectToDataObject(string clipBoardFormat, object toSerialize, Altaxo.Gui.IClipboardSetDataObject dataObject)
        {
            if (null == dataObject)
            {
                throw new ArgumentNullException("dataObject");
            }

            var stb = SerializeToStringBuilder(toSerialize);

            dataObject.SetData(clipBoardFormat, stb.ToString());
        }