Ejemplo n.º 1
0
        public object ESRI_Attributes_Get(ResultBuffer rb)
        {
            object result;

            try
            {
                ObjectId argument = LspUtil.GetArgument(rb, 0, ObjectId.Null);
                if (argument == ObjectId.Null)
                {
                    result = null;
                }
                else
                {
                    string          assocParam   = LspUtil.GetAssocParam(rb, "FCNAME", null);
                    string          assocParam2  = LspUtil.GetAssocParam(rb, "STNAME", null);
                    string          fieldName    = LspUtil.GetAssocParam(rb, "FIELDNAME", null);
                    MSCFeatureClass featureClass = this.GetFeatureClass(assocParam, assocParam2);
                    List <CadField> list;
                    if (featureClass == null)
                    {
                        list = CadField.EntityCadFields(argument);
                    }
                    else
                    {
                        list = featureClass.GetEntityFields(argument);
                    }
                    if (!string.IsNullOrEmpty(fieldName))
                    {
                        list = (from x in list
                                where x.Name == fieldName
                                select x).ToList <CadField>();
                    }
                    if (list.Count == 0)
                    {
                        result = null;
                    }
                    else
                    {
                        List <TypedValue> list2 = new List <TypedValue>();
                        list2.Add(new TypedValue(5016, null));
                        foreach (CadField current in list)
                        {
                            LspUtil.AppendDottedPair(ref list2, current.Name, current.Value.Value);
                        }
                        list2.Add(new TypedValue(5017, null));
                        ResultBuffer resultBuffer = new ResultBuffer(list2.ToArray());
                        result = resultBuffer;
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public object ESRI_AddFeatureClass(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() == 0)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5005)
                    {
                        result = null;
                    }
                    else
                    {
                        string          text = typedValue.Value.ToString();
                        MSCFeatureClass localFeatureClass = this.GetLocalFeatureClass(text);
                        if (localFeatureClass != null)
                        {
                            result = null;
                        }
                        else
                        {
                            string assocParam  = LspUtil.GetAssocParam(rb, "GeomType", "Point");
                            string assocParam2 = LspUtil.GetAssocParam(rb, "LayerFilter", "*");
                            if (string.IsNullOrEmpty(text))
                            {
                                result = null;
                            }
                            else if (string.IsNullOrEmpty(assocParam))
                            {
                                result = null;
                            }
                            else if (string.IsNullOrEmpty(assocParam2))
                            {
                                result = null;
                            }
                            else
                            {
                                MSCFeatureClass mSCFeatureClass = AfaDocData.ActiveDocData.DocDataset.CreateFeatureClass(text);
                                mSCFeatureClass.GeometryType = MSCFeatureClass.GetGeomType(assocParam);
                                TypedValue typedValue2 = new TypedValue(8, assocParam2);
                                mSCFeatureClass.Query = new ResultBuffer(new TypedValue[]
                                {
                                    typedValue2
                                });
                                mSCFeatureClass.Write(AfaDocData.ActiveDocData.Document);
                                AfaDocData.ActiveDocData.DocDataset.FeatureClasses.Add(text, mSCFeatureClass);
                                AfaDocData.ActiveDocData.DocDataset.FeatureClassViewList.Add(new FCView(mSCFeatureClass));
                                AfaDocData.ActiveDocData.SetActiveFeatureClass(mSCFeatureClass);
                                ArcGISRibbon.SetActiveFeatureClass(mSCFeatureClass);
                                result = mSCFeatureClass.Name;
                            }
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
        public object ESRI_Image_Update(ResultBuffer rb)
        {
            object result;

            try
            {
                if (null == Application.DocumentManager.MdiActiveDocument)
                {
                    result = null;
                }
                else
                {
                    string          argument = LspUtil.GetArgument(rb, 0, null);
                    MSCImageService mSCImageService;
                    if (!string.IsNullOrEmpty(argument))
                    {
                        mSCImageService = this.GetImageService(argument);
                    }
                    else
                    {
                        mSCImageService = AfaDocData.ActiveDocData.CurrentImageService;
                    }
                    if (mSCImageService == null)
                    {
                        result = null;
                    }
                    else
                    {
                        short   num         = short.Parse(mSCImageService.GetTransparency().ToString());
                        Point2d minPoint    = mSCImageService.ExportOptions.BoundingBox.MinPoint;
                        Point2d maxPoint    = mSCImageService.ExportOptions.BoundingBox.MaxPoint;
                        bool    assocParam  = LspUtil.GetAssocParam(rb, "DYNAMIC", mSCImageService.Dynamic);
                        bool    assocParam2 = LspUtil.GetAssocParam(rb, "VISIBLE", mSCImageService.GetVisibility());
                        short   assocParam3 = LspUtil.GetAssocParam(rb, "TRANSPARENCY", num);
                        Point2d assocParam4 = LspUtil.GetAssocParam(rb, "EXTMIN", minPoint);
                        Point2d assocParam5 = LspUtil.GetAssocParam(rb, "EXTMAX", maxPoint);
                        string  assocParam6 = LspUtil.GetAssocParam(rb, "FORMAT", mSCImageService.ExportOptions.Format);
                        string  text        = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument);
                        if (mSCImageService != null)
                        {
                            mSCImageService.SetVisbility(assocParam2);
                            if (assocParam3 != num)
                            {
                                mSCImageService.SetTransparency((int)assocParam3);
                            }
                            if (assocParam != mSCImageService.Dynamic)
                            {
                                mSCImageService.Dynamic = assocParam;
                            }
                            mSCImageService.ExportOptions.Format    = assocParam6;
                            mSCImageService.ExportOptions.OutputWKT = text;
                            Extent extent = new Extent(assocParam4, assocParam5);
                            if (extent.IsValid())
                            {
                                extent.SetWKTFrom(text);
                                mSCImageService.UpdateExtentLimit(extent);
                            }
                            mSCImageService.Write();
                            mSCImageService.RefreshService();
                            Mouse.OverrideCursor = null;
                            result = true;
                        }
                        else
                        {
                            result = null;
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
        public object ESRI_Image_Add(ResultBuffer rb)
        {
            object result;

            try
            {
                if (null == Application.DocumentManager.MdiActiveDocument)
                {
                    result = null;
                }
                else
                {
                    string  assocParam  = LspUtil.GetAssocParam(rb, "URL", null);
                    bool    assocParam2 = LspUtil.GetAssocParam(rb, "DYNAMIC", true);
                    bool    assocParam3 = LspUtil.GetAssocParam(rb, "VISIBLE", true);
                    short   num         = LspUtil.GetAssocParam(rb, "TRANSPARENCY", 0);
                    Point2d assocParam4 = LspUtil.GetAssocParam(rb, "EXTMIN", Point2d.Origin);
                    Point2d assocParam5 = LspUtil.GetAssocParam(rb, "EXTMAX", Point2d.Origin);
                    string  assocParam6 = LspUtil.GetAssocParam(rb, "FORMAT", "PNG24");
                    if (string.IsNullOrEmpty(assocParam))
                    {
                        result = null;
                    }
                    else
                    {
                        Mouse.OverrideCursor = Cursors.Wait;
                        AGSImageService aGSImageService = AGSImageService.BuildImageServiceFromURL(null, assocParam);
                        if (aGSImageService != null)
                        {
                            string text = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument);
                            if (string.IsNullOrEmpty(text))
                            {
                                text = MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, aGSImageService.GetWKT());
                            }
                            aGSImageService.ExportOptions.Dynamic = assocParam2;
                            aGSImageService.ExportOptions.Format  = assocParam6;
                            if (num == 100)
                            {
                                num = 99;
                            }
                            aGSImageService.ExportOptions.Transparency = byte.Parse(num.ToString());
                            Extent extent = new Extent(assocParam4, assocParam5);
                            if (extent.IsValid())
                            {
                                extent.SetWKTFrom(text);
                                aGSImageService.ExportOptions.BoundingBox = extent;
                            }
                            aGSImageService.ExportOptions.OutputWKT = text;
                            if (!aGSImageService.AddService(aGSImageService.ExportOptions))
                            {
                                Mouse.OverrideCursor = null;
                                result = null;
                            }
                            else
                            {
                                Mouse.OverrideCursor = null;
                                MSCImageService currentImageService = AfaDocData.ActiveDocData.CurrentImageService;
                                if (!assocParam3)
                                {
                                    currentImageService.Visible = false;
                                }
                                result = currentImageService.Name;
                            }
                        }
                        else
                        {
                            result = null;
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
        public object ESRI_AddFeatureService(ResultBuffer rb)
        {
            if (null == Application.DocumentManager.MdiActiveDocument)
            {
                return(null);
            }
            string  assocParam  = LspUtil.GetAssocParam(rb, "URL", null);
            string  assocParam2 = LspUtil.GetAssocParam(rb, "EDITMODE", "EDIT");
            Point2d assocParam3 = LspUtil.GetAssocParam(rb, "EXTMIN", Point2d.Origin);
            Point2d assocParam4 = LspUtil.GetAssocParam(rb, "EXTMAX", Point2d.Origin);
            string  assocParam5 = LspUtil.GetAssocParam(rb, "LAYERIDS", "");
            bool    assocParam6 = LspUtil.GetAssocParam(rb, "EXTRACT", false);

            if (string.IsNullOrEmpty(assocParam))
            {
                return(null);
            }
            object result;

            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                string            text = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument);
                AGSFeatureService aGSFeatureService = AGSFeatureService.BuildFeatureServiceFromURL(null, assocParam);
                if (aGSFeatureService != null)
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        text = MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, aGSFeatureService.GetWKT());
                    }
                    if (assocParam2 != "EDIT")
                    {
                        aGSFeatureService.ExportOptions.Dynamic = false;
                    }
                    Extent extent = new Extent(assocParam3, assocParam4);
                    aGSFeatureService.ExportOptions.OutputWKT = text;
                    if (extent.IsValid())
                    {
                        extent.SetWKTFrom(text);
                        aGSFeatureService.ExportOptions.BoundingBox = extent;
                    }
                    List <int> layerList = null;
                    bool       flag;
                    if (!string.IsNullOrEmpty(assocParam5))
                    {
                        string[] array = assocParam5.Split(new char[]
                        {
                            ','
                        });
                        int[] collection = Array.ConvertAll <string, int>(array, new Converter <string, int>(int.Parse));
                        layerList = new List <int>(collection);
                        if (assocParam6)
                        {
                            flag = aGSFeatureService.ExtractService(layerList);
                        }
                        else
                        {
                            flag = aGSFeatureService.AddService(layerList);
                        }
                    }
                    else if (assocParam6)
                    {
                        flag = aGSFeatureService.ExtractService(layerList);
                    }
                    else
                    {
                        flag = aGSFeatureService.AddService(layerList);
                    }
                    Mouse.OverrideCursor = null;
                    if (flag)
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    Mouse.OverrideCursor = null;
                    result = null;
                }
            }
            catch
            {
                Mouse.OverrideCursor = null;
                result = null;
            }
            return(result);
        }
        public object ESRI_FeatureService_set(ResultBuffer rb)
        {
            object result;

            try
            {
                if (null == Application.DocumentManager.MdiActiveDocument)
                {
                    result = null;
                }
                else
                {
                    string            argument = LspUtil.GetArgument(rb, 0, null);
                    MSCFeatureService mSCFeatureService;
                    if (!string.IsNullOrEmpty(argument))
                    {
                        mSCFeatureService = this.GetFeatureService(argument);
                    }
                    else
                    {
                        mSCFeatureService = this.GetCurrentFeatureService();
                    }
                    if (mSCFeatureService == null)
                    {
                        result = null;
                    }
                    else
                    {
                        AGSExportOptions exportOptions = mSCFeatureService.ExportOptions;
                        bool             assocParam    = LspUtil.GetAssocParam(rb, "EDITMODE", exportOptions.Dynamic);
                        Point2d          assocParam2   = LspUtil.GetAssocParam(rb, "EXTMIN", exportOptions.BoundingBox.MinPoint);
                        Point2d          assocParam3   = LspUtil.GetAssocParam(rb, "EXTMAX", exportOptions.BoundingBox.MaxPoint);
                        string           text          = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument);
                        if (mSCFeatureService != null)
                        {
                            if (assocParam)
                            {
                                mSCFeatureService.QueryOnly = false;
                                mSCFeatureService.SetLayerLock(false);
                            }
                            else
                            {
                                mSCFeatureService.QueryOnly = true;
                                mSCFeatureService.SetLayerLock(true);
                            }
                            mSCFeatureService.ExportOptions.Dynamic   = assocParam;
                            mSCFeatureService.ExportOptions.OutputWKT = text;
                            Extent extent = new Extent(assocParam2, assocParam3);
                            if (extent.IsValid())
                            {
                                extent.SetWKTFrom(text);
                                mSCFeatureService.UpdateExtentLimit(extent);
                            }
                            mSCFeatureService.Write();
                            Mouse.OverrideCursor = null;
                            result = true;
                        }
                        else
                        {
                            result = null;
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }