using System;
using System.Collections;
using System.Collections.Generic;
using ChemAxon.NET.IKVM.IO;
using ChemAxon.NET.IKVM.Chemistry;
using ChemAxon.NET.API;
using ChemAxon.NET.API.IO;
namespace ChemAxon.NET.UnitTest.API.Examples.IO.Clipboard
{
public class ClipboardExample
{
public void CopyMolecules_To_Clipboard_Example()
{
var molecules = new List<IJChemMolecule>();
molecules.Add(MainFactory.Chemistry.CreateMolecule("benzene"));
molecules.Add(MainFactory.Chemistry.CreateMolecule("methylpropane"));
molecules.Add(MainFactory.Chemistry.CreateMolecule("hexane"));
IClipboardHandler clipboard = MainFactory.IO.OpenClipboard();
clipboard.CopyTo(molecules);
}
public void PasteMolecules_From_Clipboard_Example()
{
IClipboardHandler clipboard = MainFactory.IO.OpenClipboard();
IEnumerable<IJChemMolecule> molecules;
bool isMoleculeOnClipboard = clipboard.PasteFrom(out molecules);
if (isMoleculeOnClipboard)
{
Console.WriteLine("Molecules from clipboard:");
foreach (IJChemMolecule molecule in molecules)
Console.WriteLine(molecule.Formula);
}
else
Console.WriteLine("There is no molecule on the clipboard!");
}
public void Copy_Mixed_Date_To_Clipboard_Example()
{
IClipboardHandler clipboard = MainFactory.IO.OpenClipboard();
IClipboardTable clipboardData = clipboard.CreateClipboardTable(3, 2);
clipboardData[0, 0].Data.SetValue(MainFactory.Chemistry.CreateMolecule("benzene"));
clipboardData[1,1].Data.SetValue("Comment 1");
clipboardData[2, 0].Data.SetValue(MainFactory.Chemistry.CreateMolecule("methylpropane"));
clipboardData[0, 1].Data.SetValue("Comment 2");
clipboardData[1,0].Data.SetValue("Comment 3");
clipboardData[2, 1].Data.SetValue(MainFactory.Chemistry.CreateMolecule("hexane"));
clipboard.CopyTo(clipboardData);
}
public void Paste_Mixed_Data_From_Clipboard_Example()
{
IClipboardHandler clipboard = MainFactory.IO.OpenClipboard();
IClipboardTable clipboardData;
bool isMixedDataOnClipboard = clipboard.PasteFrom(out clipboardData);
if (isMixedDataOnClipboard)
{
Console.WriteLine("Mixed data from clipboard:");
for (int row = 0; row < clipboardData.RowCount; row++)
{
for (int column = 0; column < clipboardData.ColumnCount; column++)
{
if (clipboardData[row, column].Data.DataType == DataType.Molecule)
{
IJChemMolecule molecule = clipboardData[row, column].Data.Value as IJChemMolecule;
Console.Write(string.Format("\t{0}", molecule.Formula));
}
else
{
object data = clipboardData[row, column].Data.Value;
Console.Write(string.Format("\t{0}", data));
}
}
Console.WriteLine();
}
}
else
Console.WriteLine("There is no molecule on the clipboard!");
}
}
}