Ejemplo n.º 1
0
        /// <summary>
        /// Handles a drop event.
        /// </summary>
        protected override void NodesTV_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                TreeNode node = NodesTV.GetNodeAt(PointToClient(new Point(e.X, e.Y)));

                if (node == null)
                {
                    return;
                }

                ContainerInfo info = node.Tag as ContainerInfo;

                if (info == null)
                {
                    return;
                }

                if (info.Type == ContainerInfoType.Store)
                {
                    CertificateStoreIdentifier id = info.GetCertificateStore();

                    if (id == null)
                    {
                        return;
                    }

                    object[] certificates = e.Data.GetData(typeof(object[])) as object[];

                    if (certificates == null)
                    {
                        return;
                    }

                    using (ICertificateStore store = id.OpenStore())
                    {
                        for (int ii = 0; ii < certificates.Length; ii++)
                        {
                            X509Certificate2 certificate = certificates[ii] as X509Certificate2;

                            if (certificate != null)
                            {
                                store.Add(certificate);
                            }
                        }
                    }

                    NodesTV.SelectedNode = node;
                    return;
                }
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles a drag over event.
        /// </summary>
        protected override void NodesTV_DragOver(object sender, DragEventArgs e)
        {
            TreeNode node = NodesTV.GetNodeAt(PointToClient(new Point(e.X, e.Y)));

            if (node == null)
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            e.Effect = DragDropEffects.Copy;
        }