コード例 #1
0
        /// <summary>
        /// Paste clipboard data as an Asn1Node. It try to get data from
        /// Asn1NodeDataFormat first, then try Text data format.
        /// </summary>
        /// <returns>Asn1Node</returns>
        public static Asn1Node Paste()
        {
            DataFormats.Format asn1Format   = DataFormats.GetFormat(asn1FormatName);
            Asn1Node           retval       = new Asn1Node();
            IDataObject        aRetrieveObj = Clipboard.GetDataObject();

            byte[] aData = (byte[])aRetrieveObj.GetData(asn1FormatName);
            if (aData != null)
            {
                MemoryStream ms = new MemoryStream(aData);
                ms.Position = 0;
                retval.LoadData(ms);
            }
            else
            {
                string   dataStr = (string)aRetrieveObj.GetData(DataFormats.Text);
                Asn1Node tmpNode = new Asn1Node();
                if (Asn1Util.IsAsn1EncodedHexStr(dataStr))
                {
                    byte[] data = Asn1Util.HexStrToBytes(dataStr);
                    retval.LoadData(data);
                }
            }
            return(retval);
        }
コード例 #2
0
        public static Asn1Node Paste()
        {
            DataFormats.GetFormat(Asn1ClipboardData.asn1FormatName);
            Asn1Node    asn1Node1  = new Asn1Node();
            IDataObject dataObject = Clipboard.GetDataObject();

            byte[] data1 = (byte[])dataObject.GetData(Asn1ClipboardData.asn1FormatName);
            if (data1 != null)
            {
                MemoryStream memoryStream = new MemoryStream(data1);
                memoryStream.Position = 0L;
                asn1Node1.LoadData((Stream)memoryStream);
            }
            else
            {
                string   data2     = (string)dataObject.GetData(DataFormats.Text);
                Asn1Node asn1Node2 = new Asn1Node();
                if (Asn1Util.IsAsn1EncodedHexStr(data2))
                {
                    byte[] bytes = Asn1Util.HexStrToBytes(data2);
                    asn1Node1.LoadData(bytes);
                }
            }
            return(asn1Node1);
        }
コード例 #3
0
        /// <summary>
        /// Check if there is ASN.1 DER encoded data in the clipboard.
        /// </summary>
        /// <returns>true:Yes; false:No</returns>
        public static bool IsDataReady()
        {
            bool retval = false;

            try
            {
                IDataObject aRetrieveObj = Clipboard.GetDataObject();
                byte[]      aData        = (byte[])aRetrieveObj.GetData(asn1FormatName);
                if (aData != null)
                {
                    retval = true;
                }
                else
                {
                    string dataStr = (string)aRetrieveObj.GetData(DataFormats.Text);
                    if (Asn1Util.IsAsn1EncodedHexStr(dataStr))
                    {
                        retval = true;
                    }
                }
            }
            catch
            {
                retval = false;
            }
            return(retval);
        }
コード例 #4
0
        public static bool IsDataReady()
        {
            bool flag = false;

            try
            {
                IDataObject dataObject = Clipboard.GetDataObject();
                if ((byte[])dataObject.GetData(Asn1ClipboardData.asn1FormatName) != null)
                {
                    flag = true;
                }
                else if (Asn1Util.IsAsn1EncodedHexStr((string)dataObject.GetData(DataFormats.Text)))
                {
                    flag = true;
                }
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }