GetData() public static method

Retrieves the data from the clipboard.
public static GetData ( string format ) : object
format string
return object
        private void PasteMI_Click(object sender, EventArgs e)
        {
            try
            {
                string xml = (string)ClipboardHack.GetData(DataFormats.Text);

                if (String.IsNullOrEmpty(xml))
                {
                    return;
                }

                // deserialize the data.
                CertificateIdentifier id = null;

                using (XmlTextReader reader = new XmlTextReader(new StringReader(xml)))
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(CertificateIdentifier));
                    id = (CertificateIdentifier)serializer.ReadObject(reader, false);
                }

                if (id.Certificate != null)
                {
                    using (ICertificateStore store = m_storeId.OpenStore())
                    {
                        store.Add(id.Certificate);
                    }

                    AddItem(id.Certificate);
                }
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Exemplo n.º 2
0
        private void PasteMI_Click(object sender, EventArgs e)
        {
            try
            {
                string xml = (string)ClipboardHack.GetData(DataFormats.Text);

                if (String.IsNullOrEmpty(xml))
                {
                    return;
                }

                // check if in the favorites list.
                ContainerInfo info = NodesTV.SelectedNode.Tag as ContainerInfo;

                // check if pasting into a store.
                if (info.Type == ContainerInfoType.Store)
                {
                    CertificateIdentifier id = null;

                    using (XmlTextReader reader = new XmlTextReader(new StringReader(xml)))
                    {
                        DataContractSerializer serializer = new DataContractSerializer(typeof(CertificateIdentifier));
                        id = (CertificateIdentifier)serializer.ReadObject(reader, false);
                    }

                    if (id.Certificate != null)
                    {
                        CertificateStoreIdentifier storeId = info.GetCertificateStore();

                        using (ICertificateStore store = storeId.OpenStore())
                        {
                            store.Add(id.Certificate);
                        }
                    }

                    SelectNode();
                    return;
                }
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }