Esempio n. 1
0
        public void Content_DragDrop(System.Windows.Forms.DragEventArgs e)
        {
            foreach (string format in e.Data.GetFormats())
            {
                object ob = e.Data.GetData(format);
                if (ob is List <IExplorerObjectSerialization> )
                {
                    ExplorerObjectManager exObjectManager = new ExplorerObjectManager();

                    List <IExplorerObject> exObjects = exObjectManager.DeserializeExplorerObject((List <IExplorerObjectSerialization>)ob);
                    if (exObjects == null)
                    {
                        return;
                    }

                    foreach (IExplorerObject exObject in exObjects)
                    {
                        if (exObject is IExplorerParentObject)
                        {
                            ((IExplorerParentObject)exObject).Refresh();
                        }
                        if (exObject.Object is IFeatureDataset)
                        {
                            IDataset dataset = (IDataset)exObject.Object;

                            FormDatasetProperties dlg = new FormDatasetProperties(dataset);
                            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                Map map = new Map();
                                map.AddDataset(dataset, 0);
                                map.Name = dataset.DatasetName;

                                map.Limit = map.Envelope = ((IFeatureDataset)dataset).Envelope;
                                FormAddServices services = new FormAddServices(map);
                                if (services.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    AddMap2Connection(services.ServiceNames, services.Maps);
                                }
                            }
                        }
                        else if (exObject.Object is IMap)
                        {
                            FormAddServices services = new FormAddServices((IMap)exObject.Object);
                            if (services.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                AddMap2Connection(services.ServiceNames, services.Maps);
                            }
                        }
                        else if (exObject.Object is IMapDocument)
                        {
                            FormAddServices services = new FormAddServices(((IMapDocument)exObject.Object).Maps);
                            if (services.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                AddMap2Connection(services.ServiceNames, services.Maps);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
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);
                    }
                }
            }
        }
Esempio n. 3
0
        async public void Content_DragDrop(System.Windows.Forms.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
            }
            else
            {
                foreach (string format in e.Data.GetFormats())
                {
                    object ob = e.Data.GetData(format);
                    if (ob is IEnumerable <IExplorerObjectSerialization> )
                    {
                        ExplorerObjectManager exObjectManager = new ExplorerObjectManager();

                        List <IExplorerObject> exObjects = await exObjectManager.DeserializeExplorerObject((IEnumerable <IExplorerObjectSerialization>) ob);

                        if (exObjects == null)
                        {
                            return;
                        }

                        _dataset = await((IExplorerObject)this).GetInstanceAsync() as IFeatureDataset;

                        foreach (IExplorerObject exObject in ListOperations <IExplorerObject> .Clone(exObjects))
                        {
                            IFeatureClass fc = await exObject.GetInstanceAsync() as IFeatureClass;

                            if (fc == null)
                            {
                                continue;
                            }

                            if (fc.Dataset != null && fc.Dataset.ConnectionString.ToLower() == _dataset.ConnectionString.ToLower())
                            {
                                exObjects.Remove(exObject);
                            }
                        }
                        if (exObjects.Count == 0)
                        {
                            return;
                        }

                        FormFeatureclassCopy dlg = await FormFeatureclassCopy.Create(exObjects, _dataset);

                        if (dlg.ShowDialog() != DialogResult.OK)
                        {
                            continue;
                        }

                        foreach (FeatureClassListViewItem fcItem in dlg.FeatureClassItems)
                        {
                            await ImportDatasetObject(fcItem);
                        }
                        exObjectManager.Dispose(); // alle ExplorerObjects wieder löschen...
                    }
                }
            }
            await this.Refresh();
        }
Esempio n. 4
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()));
            }
        }
Esempio n. 5
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);
                }
            }
        }
        public void Content_DragDrop(DragEventArgs e, IUserData userdata)
        {
            if (_fdb == null)
            {
                return;
            }

            bool schemaOnly = false;

            if (userdata != null &&
                userdata.GetUserData("gView.Framework.UI.BaseTools.PasteSchema") != null &&
                userdata.GetUserData("gView.Framework.UI.BaseTools.PasteSchema").Equals(true))
            {
                schemaOnly = true;
            }

            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
            }
            else
            {
                foreach (string format in e.Data.GetFormats())
                {
                    object ob = e.Data.GetData(format);
                    if (ob is IEnumerable <IExplorerObjectSerialization> )
                    {
                        ExplorerObjectManager exObjectManager = new ExplorerObjectManager();

                        List <IExplorerObject> exObjects = new List <IExplorerObject>(exObjectManager.DeserializeExplorerObject((IEnumerable <IExplorerObjectSerialization>)ob));
                        if (exObjects == null)
                        {
                            return;
                        }

                        foreach (IExplorerObject exObject in ListOperations <IExplorerObject> .Clone(exObjects))
                        {
                            IFeatureClass fc = exObject.Object as IFeatureClass;
                            if (fc == null)
                            {
                                continue;
                            }

                            if (fc.Dataset != null && fc.Dataset.DatasetName == _dsname &&
                                _fdb != null &&
                                fc.Dataset.Database is AccessFDB &&
                                ((AccessFDB)fc.Dataset.Database)._conn.ConnectionString.ToLower() ==
                                _fdb._conn.ConnectionString.ToLower())
                            {
                                exObjects.Remove(exObject);
                            }
                        }
                        if (exObjects.Count == 0)
                        {
                            return;
                        }

                        FormFeatureclassCopy dlg = new FormFeatureclassCopy(exObjects, _dataset);
                        dlg.SchemaOnly = schemaOnly;
                        if (dlg.ShowDialog() != DialogResult.OK)
                        {
                            continue;
                        }

                        foreach (FeatureClassListViewItem fcItem in dlg.FeatureClassItems)
                        {
                            ImportDatasetObject(fcItem, schemaOnly);
                        }

                        /*
                         * foreach (IExplorerObject exObject in exObjects)
                         * {
                         *  ImportDatasetObject(exObject.Object);
                         * }
                         * */
                        exObjectManager.Dispose(); // alle ExplorerObjects wieder löschen...
                    }
                }
            }
            //_dataset.RefreshClasses();
            this.Refresh();
        }
Esempio n. 7
0
        public void Content_DragDrop(DragEventArgs e, IUserData userdata)
        {
            PlugInManager compMan = new PlugInManager();
            List <IFileFeatureDatabase> databases = new List <IFileFeatureDatabase>();

            foreach (XmlNode dbNode in compMan.GetPluginNodes(Plugins.Type.IFileFeatureDatabase))
            {
                IFileFeatureDatabase db = compMan.CreateInstance(dbNode) as IFileFeatureDatabase;
                if (db == null)
                {
                    continue;
                }

                databases.Add(db);
            }
            if (databases.Count == 0)
            {
                return;
            }

            bool schemaOnly = false;

            if (userdata != null &&
                userdata.GetUserData("gView.Framework.UI.BaseTools.PasteSchema") != null &&
                userdata.GetUserData("gView.Framework.UI.BaseTools.PasteSchema").Equals(true))
            {
                schemaOnly = true;
            }

            foreach (string format in e.Data.GetFormats())
            {
                object ob = e.Data.GetData(format);
                if (ob is IEnumerable <IExplorerObjectSerialization> )
                {
                    ExplorerObjectManager exObjectManager = new ExplorerObjectManager();

                    List <IExplorerObject> exObjects = new List <IExplorerObject>(exObjectManager.DeserializeExplorerObject((IEnumerable <IExplorerObjectSerialization>)ob));
                    if (exObjects == null)
                    {
                        return;
                    }

                    foreach (IExplorerObject exObject in ListOperations <IExplorerObject> .Clone(exObjects))
                    {
                        IFeatureClass fc = exObject.Object as IFeatureClass;
                        if (fc == null)
                        {
                            continue;
                        }
                    }
                    if (exObjects.Count == 0)
                    {
                        return;
                    }

                    FormFeatureclassCopy dlg = new FormFeatureclassCopy(exObjects, databases, this.FullName);
                    dlg.SchemaOnly = schemaOnly;
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        continue;
                    }

                    if (dlg.SelectedFeatureDatabase == null)
                    {
                        return;
                    }
                    IFileFeatureDatabase fileDB = dlg.SelectedFeatureDatabase;
                    _dataset = fileDB[this.FullName];
                    if (_dataset == null)
                    {
                        return;
                    }

                    //_dataset = new ImportFeatureDataset(dlg.SelectedFeatureDatabase);

                    foreach (FeatureClassListViewItem fcItem in dlg.FeatureClassItems)
                    {
                        ImportDatasetObject(fcItem, schemaOnly);
                    }

                    exObjectManager.Dispose(); // alle ExplorerObjects wieder löschen...
                }
            }
        }