Пример #1
0
        private void listView_ItemDrag(object sender, ItemDragEventArgs e)
        {
            ListViewItem item = (ListViewItem)e.Item;

            if (listView.SelectedItems.Count > 1 && listView.SelectedItems.Contains(item))
            {
                List <IExplorerObjectSerialization> exObjects = new List <IExplorerObjectSerialization>();
                foreach (ListViewItem i in listView.SelectedItems)
                {
                    if (i is ExplorerObjectListViewItem && ((ExplorerObjectListViewItem)i).ExplorerObject != null)
                    {
                        IExplorerObjectSerialization ser = ExplorerObjectManager.SerializeExplorerObject(((ExplorerObjectListViewItem)i).ExplorerObject);
                        if (ser == null)
                        {
                            continue;
                        }
                        exObjects.Add(ser);
                    }
                }
                this.DoDragDrop(exObjects, DragDropEffects.Copy);
            }
            else
            {
                if (item is ExplorerObjectListViewItem && ((ExplorerObjectListViewItem)item).ExplorerObject != null)
                {
                    List <IExplorerObjectSerialization> exObjects = new List <IExplorerObjectSerialization>();
                    IExplorerObjectSerialization        ser       = ExplorerObjectManager.SerializeExplorerObject(((ExplorerObjectListViewItem)item).ExplorerObject);
                    if (ser != null)
                    {
                        exObjects.Add(ser);
                        this.DoDragDrop(exObjects, DragDropEffects.Copy);
                    }
                }
            }
        }
Пример #2
0
        virtual protected void OnEvent()
        {
            if (_doc != null && _doc.FocusMap != null && _doc.FocusMap.Display != null)
            {
                List <ExtensionSerializer> elements = new List <ExtensionSerializer>();
                foreach (IGraphicElement element in _doc.FocusMap.Display.GraphicsContainer.SelectedElements)
                {
                    if (element is IGraphicElement2 && element is IPersistable)
                    {
                        ExtensionSerializer ser = new ExtensionSerializer(element);
                        elements.Add(ser);
                    }
                }
                if (elements.Count == 0)
                {
                    return;
                }

                Clipboard.Clear();
                Clipboard.SetDataObject(new DataObject(elements.ToArray()));
            }
            if (_context != null)
            {
                List <ExplorerObjectSerialization> exObjects = new List <ExplorerObjectSerialization>();
                foreach (IExplorerObject exObject in _context)
                {
                    ExplorerObjectSerialization ser = ExplorerObjectManager.SerializeExplorerObject(exObject);
                    if (ser == null)
                    {
                        continue;
                    }

                    exObjects.Add(ser);
                }

                _context = null;

                Clipboard.Clear();
                Clipboard.SetDataObject(new DataObject(exObjects.ToArray()));
            }
            else if (_exapp != null && _exapp.SelectedObjects != null)
            {
                List <IExplorerObjectSerialization> exObjects = new List <IExplorerObjectSerialization>();
                foreach (IExplorerObject exObject in _exapp.SelectedObjects)
                {
                    IExplorerObjectSerialization ser = ExplorerObjectManager.SerializeExplorerObject(exObject);
                    if (ser == null)
                    {
                        continue;
                    }

                    exObjects.Add(ser);
                }

                Clipboard.Clear();
                Clipboard.SetDataObject(new DataObject(exObjects.ToArray()));
            }
        }
Пример #3
0
        public IExplorerObject DeserializeExplorerObject(IExplorerObjectSerialization exObjectSerialization)
        {
            try
            {
                if (exObjectSerialization == null)
                {
                    return(null);
                }

                return(DeserializeExplorerObject(
                           exObjectSerialization.Guid,
                           exObjectSerialization.FullName));
            }
            catch { return(null); }
        }
Пример #4
0
        private void treeView_ItemDrag(object sender, ItemDragEventArgs e)
        {
            TreeNode node = (TreeNode)e.Item;

            if (node is ExplorerObjectNode && ((ExplorerObjectNode)node).ExplorerObject != null)
            {
                List <IExplorerObjectSerialization> exObjects = new List <IExplorerObjectSerialization>();
                IExplorerObjectSerialization        ser       = ExplorerObjectManager.SerializeExplorerObject(((ExplorerObjectNode)node).ExplorerObject);
                if (ser != null)
                {
                    exObjects.Add(ser);
                    this.DoDragDrop(exObjects, DragDropEffects.Copy);
                }
            }
        }
Пример #5
0
        async public Task <IExplorerObject> DeserializeExplorerObject(IExplorerObjectSerialization exObjectSerialization)
        {
            try
            {
                if (exObjectSerialization == null)
                {
                    return(null);
                }

                return(await DeserializeExplorerObject(
                           exObjectSerialization.Guid,
                           exObjectSerialization.FullName));
            }
            catch { return(null); }
        }