Beispiel #1
0
        public object ESRI_GetSubtypeLayer(ResultBuffer rb)
        {
            object result;

            try
            {
                string argument  = LspUtil.GetArgument(rb, 0, null);
                string argument2 = LspUtil.GetArgument(rb, 1, null);
                if (string.IsNullOrEmpty(argument) || string.IsNullOrEmpty(argument2))
                {
                    result = null;
                }
                else
                {
                    MSCFeatureClass        featureClassOrService  = this.GetFeatureClassOrService(argument);
                    MSCFeatureClassSubType mSCFeatureClassSubType = featureClassOrService.FindSubtypeName(argument2);
                    result = mSCFeatureClassSubType.CadLayerName;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #2
0
        public object ESRI_CoordSys_Assign(ResultBuffer rb)
        {
            object result;

            try
            {
                string argument = LspUtil.GetArgument(rb, 0, null);
                if (string.IsNullOrEmpty(argument))
                {
                    result = null;
                }
                else
                {
                    Document arg_1F_0 = AfaDocData.ActiveDocData.Document;
                    if (AfaDocData.ActiveDocData.DocDataset.FeatureServices.Count > 0)
                    {
                        result = null;
                    }
                    else if (MSCPrj.AssignPRJFile(argument))
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
        public object ESRI_Image_Remove(ResultBuffer rb)
        {
            object result;

            try
            {
                string argument = LspUtil.GetArgument(rb, 0, null);
                if (string.IsNullOrEmpty(argument))
                {
                    result = null;
                }
                else
                {
                    MSCImageService imageService = this.GetImageService(argument);
                    if (imageService == null)
                    {
                        result = null;
                    }
                    else if (imageService.DeleteService())
                    {
                        result = LspUtil.LispTrue;
                    }
                    else
                    {
                        result = null;
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
        public object ESRI_Image_SendBehind(ResultBuffer rb)
        {
            object result;

            try
            {
                string           argument = LspUtil.GetArgument(rb, 0, null);
                MSCRasterService mSCRasterService;
                if (!string.IsNullOrEmpty(argument))
                {
                    mSCRasterService = this.GetImageService(argument);
                }
                else
                {
                    mSCRasterService = AfaDocData.ActiveDocData.CurrentImageService;
                }
                if (mSCRasterService == null)
                {
                    result = null;
                }
                else
                {
                    mSCRasterService.SendBehind();
                    result = LspUtil.LispTrue;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
        public object ESRI_Map_SetCurrent(ResultBuffer rb)
        {
            object result;

            try
            {
                string        argument   = LspUtil.GetArgument(rb, 0, null);
                MSCMapService mapService = this.GetMapService(argument);
                if (mapService == null)
                {
                    result = null;
                }
                else
                {
                    AfaDocData.ActiveDocData.CurrentMapService = mapService;
                    ArcGISRibbon.SetActiveRasterService(mapService);
                    result = LspUtil.LispTrue;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #6
0
        private static object BuildValueFromGroup(List <object> groupedObjects)
        {
            if (groupedObjects.Count == 1)
            {
                return(groupedObjects[0]);
            }
            object result;

            try
            {
                if (groupedObjects.Count == 2)
                {
                    Point2d point2d = LspUtil.BuildPoint2d(groupedObjects);
                    result = point2d;
                }
                else if (groupedObjects.Count == 3)
                {
                    Point3d point3d = LspUtil.BuildPoint3d(groupedObjects);
                    result = point3d;
                }
                else
                {
                    result = null;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #7
0
        private static object FetchAssocParam(ResultBuffer rb, string tag)
        {
            if (rb == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(tag))
            {
                return(null);
            }
            Dictionary <string, object> dictionary = LspUtil.BuildAssocDictionary(rb);

            dictionary.Keys.Any((string key) => key.Equals("key", StringComparison.InvariantCultureIgnoreCase));
            if (!dictionary.ContainsKey(tag))
            {
                return(null);
            }
            object obj = dictionary[tag];

            if (obj == null)
            {
                return(null);
            }
            return(obj);
        }
Beispiel #8
0
        public object ESRI_FeatureClass_Get(ResultBuffer rb)
        {
            object result;

            try
            {
                string          argument = LspUtil.GetArgument(rb, 0, null);
                MSCFeatureClass mSCFeatureClass;
                if (!string.IsNullOrEmpty(argument))
                {
                    mSCFeatureClass = this.GetFeatureClassOrService(argument);
                }
                else
                {
                    mSCFeatureClass = this.GetCurrentFeatureClassOrService();
                }
                if (mSCFeatureClass == null)
                {
                    result = null;
                }
                else
                {
                    string argument2 = LspUtil.GetArgument(rb, 1, null);
                    if (argument2 != null)
                    {
                        mSCFeatureClass = mSCFeatureClass.FindSubtypeName(argument2);
                    }
                    if (mSCFeatureClass == null)
                    {
                        result = null;
                    }
                    else
                    {
                        List <TypedValue> list = new List <TypedValue>();
                        list.Add(new TypedValue(5016, null));
                        LspUtil.AppendDottedPair(ref list, "NAME", mSCFeatureClass.Name);
                        LspUtil.AppendDottedPair(ref list, "GEOMTYPE", MSCFeatureClass.GetGeomString(mSCFeatureClass.GeometryType));
                        if (!string.IsNullOrEmpty(mSCFeatureClass.TypeField))
                        {
                            LspUtil.AppendDottedPair(ref list, "TYPEFIELD", mSCFeatureClass.TypeField);
                        }
                        if (mSCFeatureClass.IsSingleLayerQuery())
                        {
                            LspUtil.AppendDottedPair(ref list, "CADLAYER", mSCFeatureClass.GetFirstLayerFromQuery());
                        }
                        list.Add(new TypedValue(5017, null));
                        ResultBuffer resultBuffer = new ResultBuffer(list.ToArray());
                        result = resultBuffer;
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #9
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);
        }
Beispiel #10
0
        public static string GetAssocParam(ResultBuffer rb, string tag, string defaultValue)
        {
            object obj = LspUtil.FetchAssocParam(rb, tag);

            if (obj == null)
            {
                return(defaultValue);
            }
            if (obj is string)
            {
                return(obj as string);
            }
            return(defaultValue);
        }
Beispiel #11
0
        public static bool GetAssocParam(ResultBuffer rb, string tag, bool defaultValue)
        {
            object obj = LspUtil.FetchAssocParam(rb, tag);

            if (obj == null)
            {
                return(defaultValue);
            }
            string value = obj.ToString();

            if (!LspUtil.BoolParser.CanParse(value))
            {
                return(defaultValue);
            }
            return(LspUtil.BoolParser.GetValue(value));
        }
Beispiel #12
0
        public static double GetAssocParam(ResultBuffer rb, string tag, double defaultValue)
        {
            object obj = LspUtil.FetchAssocParam(rb, tag);

            if (obj == null)
            {
                return(defaultValue);
            }
            string s = obj.ToString();
            double result;

            if (double.TryParse(s, out result))
            {
                return(result);
            }
            return(defaultValue);
        }
        public object ESRI_FeatureService_remove(ResultBuffer rb)
        {
            object result;

            try
            {
                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
                {
                    bool queryOnly = mSCFeatureService.QueryOnly;
                    if (mSCFeatureService.DeleteService())
                    {
                        AfaDocData.ActiveDocData.DocDataset.FeatureServices.Remove(argument);
                        MSCDataset.SetDefaultActiveFeatureClass();
                        if (AfaDocData.ActiveDocData.DocDataset.FeatureServices.Count == 0)
                        {
                            ArcGISRibbon.EnableFeatureServiceButtons(false);
                        }
                        if (!queryOnly)
                        {
                            ToolPalette.UpdatePalette(AfaDocData.ActiveDocData.DocDataset.ParentDocument, AfaDocData.ActiveDocData.DocDataset, false);
                        }
                    }
                    result = true;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #14
0
        public static Point3d GetAssocParam(ResultBuffer rb, string tag, Point3d defaultValue)
        {
            object obj = LspUtil.FetchAssocParam(rb, tag);

            if (obj == null)
            {
                return(defaultValue);
            }
            if (obj is Point3d)
            {
                return((Point3d)obj);
            }
            if (obj is Point2d)
            {
                Point2d point2d = (Point2d)obj;
                Point3d result  = new Point3d(point2d.X, point2d.Y, 0.0);
                return(result);
            }
            return(defaultValue);
        }
Beispiel #15
0
        public object ESRI_Subytpe_Names(ResultBuffer rb)
        {
            object result;

            try
            {
                string          argument = LspUtil.GetArgument(rb, 0, null);
                MSCFeatureClass mSCFeatureClass;
                if (!string.IsNullOrEmpty(argument))
                {
                    mSCFeatureClass = this.GetFeatureClassOrService(argument);
                }
                else
                {
                    mSCFeatureClass = this.GetCurrentFeatureClassOrService();
                }
                if (mSCFeatureClass == null)
                {
                    result = null;
                }
                else if (mSCFeatureClass.SubTypes.Count == 0)
                {
                    result = null;
                }
                else
                {
                    ResultBuffer resultBuffer = new ResultBuffer();
                    foreach (MSCFeatureClassSubType current in mSCFeatureClass.SubTypes)
                    {
                        resultBuffer.Add(new TypedValue(5005, current.Name));
                    }
                    result = resultBuffer;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #16
0
        public object ESRI_RemoveFeatureClass(ResultBuffer rb)
        {
            object result;

            try
            {
                string          argument = LspUtil.GetArgument(rb, 0, null);
                MSCFeatureClass mSCFeatureClass;
                if (!string.IsNullOrEmpty(argument))
                {
                    mSCFeatureClass = this.GetFeatureClassOrService(argument);
                }
                else
                {
                    mSCFeatureClass = this.GetCurrentFeatureClassOrService();
                }
                if (mSCFeatureClass == null)
                {
                    result = null;
                }
                else
                {
                    MSCFeatureClass activeFeatureClassOrSubtype = AfaDocData.ActiveDocData.GetActiveFeatureClassOrSubtype();
                    bool            flag = mSCFeatureClass == activeFeatureClassOrSubtype;
                    AfaDocData.ActiveDocData.DocDataset.RemoveFeatureClass(mSCFeatureClass);
                    if (flag)
                    {
                        MSCDataset.SetDefaultActiveFeatureClass();
                    }
                    result = LspUtil.LispTrue;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #17
0
        public static ObjectId GetArgument(ResultBuffer rb, int index, ObjectId defaultValue)
        {
            ObjectId result;

            try
            {
                if (rb == null)
                {
                    result = defaultValue;
                }
                else
                {
                    TypedValue[] array = rb.AsArray();
                    if (array.Count <TypedValue>() < index + 1)
                    {
                        result = defaultValue;
                    }
                    else
                    {
                        object typedValue = LspUtil.GetTypedValue(array[index]);
                        if (typedValue is ObjectId)
                        {
                            result = (ObjectId)typedValue;
                        }
                        else
                        {
                            result = defaultValue;
                        }
                    }
                }
            }
            catch
            {
                result = defaultValue;
            }
            return(result);
        }
        public object ESRI_Map_Get(ResultBuffer rb)
        {
            object result;

            try
            {
                string        argument      = LspUtil.GetArgument(rb, 0, null);
                MSCMapService mSCMapService = null;
                if (!string.IsNullOrEmpty(argument))
                {
                    mSCMapService = this.GetMapService(argument);
                }
                else
                {
                    mSCMapService = AfaDocData.ActiveDocData.CurrentMapService;
                }
                if (mSCMapService == null)
                {
                    result = null;
                }
                else
                {
                    List <TypedValue> list = new List <TypedValue>();
                    list.Add(new TypedValue(5016, null));
                    if (mSCMapService.ExportOptions != null)
                    {
                        LspUtil.AppendDottedPair(ref list, 5005, "DYNAMIC", 5003, mSCMapService.ExportOptions.Dynamic);
                        LspUtil.AppendDottedPair(ref list, 5005, "TRANSPARENCY", 5003, mSCMapService.ExportOptions.Transparency);
                        try
                        {
                            if (mSCMapService.BoundaryExtent.IsValid())
                            {
                                LspUtil.AppendDottedPair(ref list, "EXT", mSCMapService.BoundaryExtent);
                            }
                        }
                        catch
                        {
                        }
                        if (!string.IsNullOrEmpty(mSCMapService.ExportOptions.Format))
                        {
                            LspUtil.AppendDottedPair(ref list, 5005, "FORMAT", 5005, mSCMapService.ExportOptions.Format);
                        }
                    }
                    LspUtil.AppendDottedPair(ref list, 5005, "VISIBILE", 5003, mSCMapService.GetVisibility());
                    LspUtil.AppendDottedPair(ref list, 5005, "NAME", 5005, mSCMapService.Name);
                    LspUtil.AppendDottedPair(ref list, 5005, "ENAME", 5006, mSCMapService.RasterObjectId);
                    if (!string.IsNullOrEmpty(mSCMapService.ConnectionURL))
                    {
                        LspUtil.AppendDottedPair(ref list, 5005, "URL", 5005, mSCMapService.ConnectionURL);
                    }
                    if (!string.IsNullOrEmpty(mSCMapService.RestEndpoint))
                    {
                        LspUtil.AppendDottedPair(ref list, 5005, "RESTURL", 5005, mSCMapService.RestEndpoint);
                    }
                    try
                    {
                        AGSConnection parent = mSCMapService.ParentService.Parent;
                        if (!string.IsNullOrEmpty(parent.Name))
                        {
                            LspUtil.AppendDottedPair(ref list, 5005, "CONNECTION_NAME", 5005, parent.Name);
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        if (!string.IsNullOrEmpty(mSCMapService.CurrentFileName))
                        {
                            LspUtil.AppendDottedPair(ref list, "CURRENTFILE", 5005, mSCMapService.CurrentFileName);
                        }
                        mSCMapService.ParentService.GetWKT();
                        if (mSCMapService.ParentService != null)
                        {
                            foreach (KeyValuePair <string, object> current in mSCMapService.ParentService.Properties)
                            {
                                try
                                {
                                    LspUtil.AppendDottedPair(ref list, current.Key, current.Value);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                    list.Add(new TypedValue(5017, null));
                    ResultBuffer resultBuffer = new ResultBuffer(list.ToArray());
                    result = resultBuffer;
                }
            }
            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_Image_Get(ResultBuffer rb)
        {
            object result;

            try
            {
                string          argument        = LspUtil.GetArgument(rb, 0, null);
                MSCImageService mSCImageService = null;
                if (!string.IsNullOrEmpty(argument))
                {
                    mSCImageService = this.GetImageService(argument);
                }
                else
                {
                    mSCImageService = AfaDocData.ActiveDocData.CurrentImageService;
                }
                if (mSCImageService == null)
                {
                    result = null;
                }
                else
                {
                    List <TypedValue> list = new List <TypedValue>();
                    list.Add(new TypedValue(5016, null));
                    if (mSCImageService.ExportOptions != null)
                    {
                        LspUtil.AppendDottedPair(ref list, 5005, "DYNAMIC", 5003, mSCImageService.ExportOptions.Dynamic);
                        LspUtil.AppendDottedPair(ref list, 5005, "TRANSPARENCY", 5003, mSCImageService.ExportOptions.Transparency);
                        try
                        {
                            if (mSCImageService.BoundaryExtent.IsValid())
                            {
                                LspUtil.AppendDottedPair(ref list, "EXT", mSCImageService.BoundaryExtent);
                            }
                        }
                        catch
                        {
                        }
                        LspUtil.AppendDottedPair(ref list, 5005, "VISIBILE", 5003, mSCImageService.GetVisibility());
                        if (!string.IsNullOrEmpty(mSCImageService.ExportOptions.Format))
                        {
                            LspUtil.AppendDottedPair(ref list, 5005, "FORMAT", 5005, mSCImageService.ExportOptions.Format);
                        }
                        if (!string.IsNullOrEmpty(mSCImageService.ConnectionURL))
                        {
                            LspUtil.AppendDottedPair(ref list, 5005, "URL", 5005, mSCImageService.RestEndpoint);
                        }
                        if (!string.IsNullOrEmpty(mSCImageService.RestEndpoint))
                        {
                            LspUtil.AppendDottedPair(ref list, 5005, "RESTURL", 5005, mSCImageService.RestEndpoint);
                        }
                        LspUtil.AppendDottedPair(ref list, "COMPRESSION", mSCImageService.ExportOptions.TransCompression);
                        LspUtil.AppendDottedPair(ref list, "MOSAICMETHOD", mSCImageService.ExportOptions.MosaicMethod);
                        LspUtil.AppendDottedPair(ref list, "MOSAICOPERATOR", mSCImageService.ExportOptions.MosaicOperator);
                        LspUtil.AppendDottedPair(ref list, "MOSAICRULE", mSCImageService.ExportOptions.MosaicRule);
                        LspUtil.AppendDottedPair(ref list, "ASCENDING", mSCImageService.ExportOptions.Ascending);
                        LspUtil.AppendDottedPair(ref list, "BANDIDS", mSCImageService.ExportOptions.BandIds);
                        LspUtil.AppendDottedPair(ref list, "INTERPOLATION", mSCImageService.ExportOptions.Interpolation);
                        LspUtil.AppendDottedPair(ref list, "LOCKRASTERID", mSCImageService.ExportOptions.LockRasterID);
                        LspUtil.AppendDottedPair(ref list, "NODATAVALUE", mSCImageService.ExportOptions.NoDataValue);
                        LspUtil.AppendDottedPair(ref list, "ORDERBASEVALUE", mSCImageService.ExportOptions.OrderBaseValue);
                        LspUtil.AppendDottedPair(ref list, "ORDERFIELD", mSCImageService.ExportOptions.OrderField);
                        LspUtil.AppendDottedPair(ref list, "RENDERINGRULE", mSCImageService.ExportOptions.RenderingRule);
                        LspUtil.AppendDottedPair(ref list, "PIXELTYPE", mSCImageService.ExportOptions.PixelType);
                        LspUtil.AppendDottedPair(ref list, "QUALITY", mSCImageService.ExportOptions.Quality);
                    }
                    LspUtil.AppendDottedPair(ref list, 5005, "NAME", 5005, mSCImageService.Name);
                    LspUtil.AppendDottedPair(ref list, 5005, "ENAME", 5006, mSCImageService.RasterObjectId);
                    if (!string.IsNullOrEmpty(mSCImageService.ConnectionURL))
                    {
                        LspUtil.AppendDottedPair(ref list, 5005, "URL", 5005, mSCImageService.ConnectionURL);
                    }
                    try
                    {
                        AGSConnection parent = mSCImageService.ParentService.Parent;
                        if (!string.IsNullOrEmpty(parent.Name))
                        {
                            LspUtil.AppendDottedPair(ref list, 5005, "CONNECTION_NAME", 5005, parent.Name);
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        if (!string.IsNullOrEmpty(mSCImageService.CurrentFileName))
                        {
                            LspUtil.AppendDottedPair(ref list, "CURRENTFILE", 5005, mSCImageService.CurrentFileName);
                        }
                        mSCImageService.ParentService.GetWKT();
                        if (mSCImageService.ParentService != null)
                        {
                            foreach (KeyValuePair <string, object> current in mSCImageService.ParentService.Properties)
                            {
                                try
                                {
                                    LspUtil.AppendDottedPair(ref list, current.Key, current.Value);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                    list.Add(new TypedValue(5017, null));
                    ResultBuffer resultBuffer = new ResultBuffer(list.ToArray());
                    result = resultBuffer;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #21
0
 public static void AppendDottedPair(ref List <TypedValue> list, string key, object value)
 {
     if (value == null)
     {
         return;
     }
     if (value is TypedValue)
     {
         TypedValue typedValue = (TypedValue)value;
         LspUtil.AppendDottedPair(ref list, key, (int)typedValue.TypeCode, typedValue.Value);
         return;
     }
     if (value is string)
     {
         string value2 = value.ToString();
         if (!string.IsNullOrEmpty(value2))
         {
             LspUtil.AppendDottedPair(ref list, key, 5005, value);
             return;
         }
     }
     else
     {
         if (value is short)
         {
             LspUtil.AppendDottedPair(ref list, key, 5003, value);
             return;
         }
         if (value is int)
         {
             LspUtil.AppendDottedPair(ref list, key, 5010, value);
             return;
         }
         if (value is double)
         {
             LspUtil.AppendDottedPair(ref list, key, 5001, value);
             return;
         }
         if (value is bool)
         {
             try
             {
                 LspUtil.AppendDottedPair(ref list, key, 5003, Convert.ToInt16((bool)value));
                 return;
             }
             catch
             {
                 return;
             }
         }
         if (value is bool)
         {
             try
             {
                 LspUtil.AppendDottedPair(ref list, key, 5003, Convert.ToInt16((bool)value));
                 return;
             }
             catch
             {
                 return;
             }
         }
         if (value is Extent)
         {
             Extent  extent   = (Extent)value;
             Point2d minPoint = extent.MinPoint;
             Point2d maxPoint = extent.MaxPoint;
             LspUtil.AppendDottedPair(ref list, key + "MIN", 5002, minPoint);
             LspUtil.AppendDottedPair(ref list, key + "MAX", 5002, maxPoint);
             return;
         }
         try
         {
             string text = value.ToString();
             if (!string.IsNullOrEmpty(text))
             {
                 LspUtil.AppendDottedPair(ref list, key, 5005, text);
             }
         }
         catch
         {
         }
     }
 }
Beispiel #22
0
 public static void AppendDottedPair(ref List <TypedValue> list, string key, int type2, object value2)
 {
     LspUtil.AppendDottedPair(ref list, 5005, key, type2, value2);
 }
Beispiel #23
0
        public object ESRI_SetFeatureClassAttributes(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 3)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5006)
                    {
                        result = null;
                    }
                    else
                    {
                        ObjectId   id          = (ObjectId)typedValue.Value;
                        TypedValue typedValue2 = array[1];
                        if (typedValue2.TypeCode != 5005)
                        {
                            result = null;
                        }
                        else
                        {
                            string          name         = typedValue2.Value.ToString();
                            MSCFeatureClass featureClass = this.GetFeatureClass(name, null);
                            if (featureClass == null)
                            {
                                result = null;
                            }
                            else
                            {
                                Dictionary <string, object> dictionary = LspUtil.BuildAssocDictionary(rb);
                                if (dictionary.Count == 0)
                                {
                                    result = null;
                                }
                                else
                                {
                                    List <CadField> list = new List <CadField>();
                                    foreach (KeyValuePair <string, object> current in dictionary)
                                    {
                                        CadField cadField = this.CreateAttributeValue(featureClass, current.Key, current.Value);
                                        if (cadField != null)
                                        {
                                            list.Add(cadField);
                                        }
                                    }
                                    if (list.Count == 0)
                                    {
                                        result = null;
                                    }
                                    else
                                    {
                                        result = CadField.AddCadAttributesToEntity(id, list);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            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_GetConnection(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 1)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5005)
                    {
                        result = null;
                    }
                    else
                    {
                        string b = typedValue.Value.ToString();
                        if (!AGSConnection.bConnectionsLoaded)
                        {
                            AGSConnection.LoadConnections();
                        }
                        if (App.Connections.Count > 0)
                        {
                            foreach (AGSConnection current in App.Connections)
                            {
                                if (string.Equals(current.Name, b, StringComparison.CurrentCultureIgnoreCase))
                                {
                                    List <TypedValue> list = new List <TypedValue>();
                                    list.Add(new TypedValue(5016, null));
                                    LspUtil.AppendDottedPair(ref list, 5005, "NAME", 5005, current.Name);
                                    LspUtil.AppendDottedPair(ref list, 5005, "URL", 5005, current.URL);
                                    if (!string.IsNullOrEmpty(current.Version))
                                    {
                                        LspUtil.AppendDottedPair(ref list, 5005, "VERSION", 5005, current.Version.ToString());
                                    }
                                    if (!string.IsNullOrEmpty(current.UserName))
                                    {
                                        LspUtil.AppendDottedPair(ref list, 5005, "USER", 5005, current.UserName);
                                    }
                                    list.Add(new TypedValue(5017, null));
                                    ResultBuffer resultBuffer = new ResultBuffer(list.ToArray());
                                    result = resultBuffer;
                                    return(result);
                                }
                            }
                            result = null;
                        }
                        else
                        {
                            result = null;
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #26
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_FeatureService_Get(ResultBuffer rb)
        {
            object result;

            try
            {
                string            argument          = LspUtil.GetArgument(rb, 0, null);
                MSCFeatureService mSCFeatureService = null;
                if (!string.IsNullOrEmpty(argument))
                {
                    mSCFeatureService = this.GetFeatureService(argument);
                }
                else
                {
                    mSCFeatureService = this.GetCurrentFeatureService();
                }
                if (mSCFeatureService == null)
                {
                    result = null;
                }
                else
                {
                    List <TypedValue> list = new List <TypedValue>();
                    list.Add(new TypedValue(5016, null));
                    LspUtil.AppendDottedPair(ref list, "SERVICENAME", mSCFeatureService.Name);
                    LspUtil.AppendDottedPair(ref list, "GEOMTYPE", MSCFeatureClass.GetGeomString(mSCFeatureService.GeometryType));
                    if (!string.IsNullOrEmpty(mSCFeatureService.TypeField))
                    {
                        LspUtil.AppendDottedPair(ref list, "TYPEFIELD", mSCFeatureService.TypeField);
                    }
                    LspUtil.AppendDottedPair(ref list, "CADLAYER", mSCFeatureService.LayerName);
                    LspUtil.AppendDottedPair(ref list, "LAYERID", mSCFeatureService.ServiceLayerID);
                    if (mSCFeatureService.ExportOptions != null)
                    {
                        LspUtil.AppendDottedPair(ref list, 5005, "EDITMODE", 5003, mSCFeatureService.ExportOptions.Dynamic);
                        try
                        {
                            if (mSCFeatureService.ExportOptions.BoundingBox.IsValid())
                            {
                                LspUtil.AppendDottedPair(ref list, "EXT", mSCFeatureService.ExportOptions.BoundingBox);
                            }
                        }
                        catch
                        {
                        }
                    }
                    LspUtil.AppendDottedPair(ref list, 5005, "NAME", 5005, mSCFeatureService.Name);
                    if (!string.IsNullOrEmpty(mSCFeatureService.ConnectionURL))
                    {
                        LspUtil.AppendDottedPair(ref list, 5005, "URL", 5005, mSCFeatureService.ConnectionURL);
                    }
                    try
                    {
                        AGSConnection parent = mSCFeatureService.ParentService.Parent;
                        if (!string.IsNullOrEmpty(parent.Name))
                        {
                            LspUtil.AppendDottedPair(ref list, 5005, "CONNECTION_NAME", 5005, parent.Name);
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        mSCFeatureService.ParentService.GetWKT();
                        if (mSCFeatureService.ParentService != null)
                        {
                            foreach (KeyValuePair <string, object> current in mSCFeatureService.ParentService.Properties)
                            {
                                try
                                {
                                    LspUtil.AppendDottedPair(ref list, current.Key, current.Value);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                    list.Add(new TypedValue(5017, null));
                    ResultBuffer resultBuffer = new ResultBuffer(list.ToArray());
                    result = resultBuffer;
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #28
0
        public object ESRI_GetFeatureClassFieldDefinition(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 2)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5005)
                    {
                        result = null;
                    }
                    else
                    {
                        string name        = typedValue.Value.ToString();
                        string subtypeName = null;
                        if (array.Count <TypedValue>() == 3)
                        {
                            TypedValue typedValue2 = array[2];
                            if (typedValue2.TypeCode != 5005)
                            {
                                result = null;
                                return(result);
                            }
                            subtypeName = typedValue2.Value.ToString();
                        }
                        MSCFeatureClass featureClassOrService = this.GetFeatureClassOrService(name, subtypeName);
                        if (featureClassOrService == null)
                        {
                            result = null;
                        }
                        else
                        {
                            TypedValue typedValue3 = array[1];
                            if (typedValue3.TypeCode != 5005)
                            {
                                result = null;
                            }
                            else
                            {
                                string fieldName = typedValue3.Value.ToString();
                                if (featureClassOrService.Fields.Count == 0)
                                {
                                    result = null;
                                }
                                else
                                {
                                    CadField cadField = FeatureClassAPI.FindField(featureClassOrService.Fields, fieldName);
                                    if (cadField == null)
                                    {
                                        result = null;
                                    }
                                    else
                                    {
                                        List <TypedValue> list = new List <TypedValue>();
                                        list.Add(new TypedValue(5016, null));
                                        LspUtil.AppendDottedPair(ref list, 5005, "NAME", 5005, cadField.Name);
                                        LspUtil.AppendDottedPair(ref list, 5005, "TYPE", 5005, CadField.CodeString((int)cadField.FieldType));
                                        LspUtil.AppendDottedPair(ref list, 5005, "RO", 5003, cadField.ReadOnly);
                                        if (cadField.FieldType == CadField.CadFieldType.String)
                                        {
                                            LspUtil.AppendDottedPair(ref list, 5005, "LENGTH", 5003, cadField.Length);
                                        }
                                        LspUtil.AppendDottedPair(ref list, "VALUE", cadField.Value);
                                        list.Add(new TypedValue(5017, null));
                                        ResultBuffer resultBuffer = new ResultBuffer(list.ToArray());
                                        result = resultBuffer;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Beispiel #29
0
        public static Dictionary <string, object> BuildAssocDictionary(ResultBuffer rb)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);

            TypedValue[]  array = rb.AsArray();
            object        obj   = null;
            List <object> list  = new List <object>();

            TypedValue[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                TypedValue typedValue = array2[i];
                if (typedValue.TypeCode == 5016)
                {
                    list.Clear();
                    obj = null;
                }
                else if (typedValue.TypeCode == 5017)
                {
                    if (obj != null && list.Count > 0)
                    {
                        string key  = obj.ToString();
                        object obj2 = LspUtil.BuildValueFromGroup(list);
                        if (obj2 != null)
                        {
                            dictionary.Add(key, obj2);
                        }
                        list.Clear();
                        obj = null;
                    }
                }
                else if (typedValue.TypeCode == 5018)
                {
                    if (obj != null && list.Count > 0)
                    {
                        string key2 = obj.ToString();
                        object obj3 = LspUtil.BuildValueFromGroup(list);
                        if (obj3 != null)
                        {
                            dictionary.Add(key2, obj3);
                        }
                        list.Clear();
                        obj = null;
                    }
                }
                else if (obj == null)
                {
                    obj = typedValue.Value;
                }
                else
                {
                    list.Add(typedValue.Value);
                }
            }
            if (obj != null && list.Count > 0)
            {
                string key3 = obj.ToString();
                object obj4 = LspUtil.BuildValueFromGroup(list);
                if (obj4 != null)
                {
                    dictionary.Add(key3, obj4);
                }
                list.Clear();
            }
            return(dictionary);
        }
        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);
        }