Example #1
0
        async public Task <IExplorerObject> CreateExplorerObject(IExplorerObject parentExObject)
        {
            SQLiteFDBDatasetExplorerObject parent = (SQLiteFDBDatasetExplorerObject)parentExObject;

            IFeatureDataset dataset = await parent.GetInstanceAsync() as IFeatureDataset;

            if (dataset == null)
            {
                return(null);
            }

            AccessFDB fdb = dataset.Database as AccessFDB;

            if (fdb == null)
            {
                return(null);
            }

            List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>();

            filters.Add(new OpenFeatureclassFilter());
            ExplorerDialog dlg = new ExplorerDialog("Select Featureclass", filters, true);

            IExplorerObject ret = null;

            if (dlg.ShowDialog() == DialogResult.OK &&
                dlg.ExplorerObjects != null)
            {
                foreach (IExplorerObject exObj in dlg.ExplorerObjects)
                {
                    var exObjectInstance = await exObj?.GetInstanceAsync();

                    if (exObjectInstance is IFeatureClass)
                    {
                        int fcid = await fdb.CreateLinkedFeatureClass(dataset.DatasetName, (IFeatureClass)exObjectInstance);

                        if (ret == null)
                        {
                            IDatasetElement element = await dataset.Element(((IFeatureClass)exObjectInstance).Name);

                            if (element != null)
                            {
                                ret = new SQLiteFDBFeatureClassExplorerObject(
                                    parent,
                                    parent.FileName,
                                    parent.Name,
                                    element);
                            }
                        }
                    }
                }
            }
            return(ret);
        }
Example #2
0
        async public Task <IExplorerObject> CreateExplorerObject(IExplorerObject parentExObject)
        {
            if (!(parentExObject is SQLiteFDBDatasetExplorerObject))
            {
                return(null);
            }

            SQLiteFDBDatasetExplorerObject parent = (SQLiteFDBDatasetExplorerObject)parentExObject;

            IFeatureDataset dataset = await((SQLiteFDBDatasetExplorerObject)parentExObject).GetInstanceAsync() as IFeatureDataset;

            if (dataset == null || !(dataset.Database is SQLiteFDB))
            {
                return(null);
            }

            FormNewNetworkclass dlg = new FormNewNetworkclass(dataset, typeof(CreateFDBNetworkFeatureclass));

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

            CreateFDBNetworkFeatureclass creator = new CreateFDBNetworkFeatureclass(
                dataset, dlg.NetworkName,
                dlg.EdgeFeatureclasses,
                dlg.NodeFeatureclasses);

            creator.SnapTolerance    = dlg.SnapTolerance;
            creator.ComplexEdgeFcIds = await dlg.ComplexEdgeFcIds();

            creator.GraphWeights = dlg.GraphWeights;
            creator.SwitchNodeFcIdAndFieldnames = dlg.SwitchNodeFcIds;
            creator.NodeTypeFcIds = dlg.NetworkNodeTypeFcIds;

            FormTaskProgress progress = new FormTaskProgress();

            progress.ShowProgressDialog(creator, creator.Run());

            IDatasetElement element = await dataset.Element(dlg.NetworkName);

            return(new SQLiteFDBFeatureClassExplorerObject(
                       parent,
                       parent.FileName,
                       parent.Name,
                       element));
        }
Example #3
0
        async public Task <IExplorerObject> CreateInstanceByFullName(string FullName, ISerializableExplorerObjectCache cache)
        {
            if (cache.Contains(FullName))
            {
                return(cache[FullName]);
            }

            FullName = FullName.Replace("/", @"\");
            int lastIndex = FullName.LastIndexOf(@"\");

            if (lastIndex == -1)
            {
                return(null);
            }

            string dsName = FullName.Substring(0, lastIndex);
            string fcName = FullName.Substring(lastIndex + 1, FullName.Length - lastIndex - 1);

            SQLiteFDBDatasetExplorerObject dsObject = new SQLiteFDBDatasetExplorerObject();

            dsObject = await dsObject.CreateInstanceByFullName(dsName, cache) as SQLiteFDBDatasetExplorerObject;

            if (dsObject == null || await dsObject.ChildObjects() == null)
            {
                return(null);
            }

            foreach (IExplorerObject exObject in await dsObject.ChildObjects())
            {
                if (exObject.Name == fcName)
                {
                    cache.Append(exObject);
                    return(exObject);
                }
            }
            return(null);
        }
Example #4
0
        public SQLiteFDBFeatureClassExplorerObject(SQLiteFDBDatasetExplorerObject parent, string filename, string dsname, IDatasetElement element)
            : base(parent, typeof(FeatureClass), 1)
        {
            if (element == null)
            {
                return;
            }

            _parent   = parent;
            _filename = filename;
            _dsname   = dsname;
            _fcname   = element.Title;

            string typePrefix = String.Empty;
            bool   isLinked   = false;

            if (element.Class is LinkedFeatureClass)
            {
                typePrefix = "Linked ";
                isLinked   = true;
            }

            if (element.Class is IRasterCatalogClass)
            {
                _icon = new AccessFDBRasterIcon();
                _type = typePrefix + "Raster Catalog Layer";
                _rc   = (IRasterClass)element.Class;
            }
            else if (element.Class is IRasterClass)
            {
                _icon = new AccessFDBRasterIcon();
                _type = typePrefix + "Raster Layer";
                _rc   = (IRasterClass)element.Class;
            }
            else if (element.Class is IFeatureClass)
            {
                _fc = (IFeatureClass)element.Class;
                switch (_fc.GeometryType)
                {
                case geometryType.Envelope:
                case geometryType.Polygon:
                    if (isLinked)
                    {
                        _icon = new AccessFDBLinkedPolygonIcon();
                    }
                    else
                    {
                        _icon = new AccessFDBPolygonIcon();
                    }

                    _type = typePrefix + "Polygon Featureclass";
                    break;

                case geometryType.Multipoint:
                case geometryType.Point:
                    if (isLinked)
                    {
                        _icon = new AccessFDBLinkedPointIcon();
                    }
                    else
                    {
                        _icon = new AccessFDBPointIcon();
                    }

                    _type = typePrefix + "Point Featureclass";
                    break;

                case geometryType.Polyline:
                    if (isLinked)
                    {
                        _icon = new AccessFDBLinkedLineIcon();
                    }
                    else
                    {
                        _icon = new AccessFDBLineIcon();
                    }

                    _type = typePrefix + "Polyline Featureclass";
                    break;

                case geometryType.Network:
                    _icon      = new AccessFDBNetworkIcon();
                    _type      = "Networkclass";
                    _isNetwork = true;
                    break;
                }
            }

            if (!_isNetwork)
            {
                _contextItems    = new ToolStripItem[1];
                _contextItems[0] = new ToolStripMenuItem("Tasks");

                //_contextItems = new ToolStripItem[1];
                //_contextItems[0] = new ToolStripMenuItem("Rebuild Spatial Index...");
                //_contextItems[0].Click += new EventHandler(RebuildSpatialIndex_Click);
                ToolStripMenuItem item = new ToolStripMenuItem("Shrink Spatial Index...");
                item.Click += new EventHandler(ShrinkSpatialIndex_Click);
                ((ToolStripMenuItem)_contextItems[0]).DropDownItems.Add(item);
                item        = new ToolStripMenuItem("Spatial Index Definition...");
                item.Click += new EventHandler(SpatialIndexDef_Click);
                ((ToolStripMenuItem)_contextItems[0]).DropDownItems.Add(item);
                item        = new ToolStripMenuItem("Repair Spatial Index...");
                item.Click += new EventHandler(RepairSpatialIndex_Click);
                ((ToolStripMenuItem)_contextItems[0]).DropDownItems.Add(item);
                ((ToolStripMenuItem)_contextItems[0]).DropDownItems.Add(new ToolStripSeparator());
                item        = new ToolStripMenuItem("Truncate");
                item.Click += new EventHandler(Truncate_Click);
                ((ToolStripMenuItem)_contextItems[0]).DropDownItems.Add(item);
            }
        }