コード例 #1
0
        public static SpatialReference SpRefFromString(string str)
        {
            SpatialReference result;

            try
            {
                SpatialReference spatialReference;
                if (AGSSpatialReference.IsInteger(str))
                {
                    int num = int.Parse(str);
                    spatialReference = AGSSpatialReference.SpRefFromWKID(ref num);
                }
                else
                {
                    string text = str;
                    spatialReference = AGSSpatialReference.SpRefFromWKT(ref text);
                }
                result = spatialReference;
            }
            catch
            {
                result = null;
            }
            return(result);
        }
コード例 #2
0
 public void ExportImage(AGSExportOptions eo, ExportImageEventHandler action)
 {
     try
     {
         string        arg  = base.Parent.URL + "/" + base.FullName + "/ImageServer/exportImage";
         StringBuilder arg2 = this.BuildURIRequest(eo);
         Mouse.OverrideCursor = Cursors.Wait;
         IDictionary <string, object> dictionary = base.Parent.MakeDictionaryRequest(arg + arg2);
         if (dictionary == null)
         {
             Mouse.OverrideCursor = null;
             if (string.IsNullOrEmpty(base.Parent.ErrorMessage))
             {
                 ErrorReport.ShowErrorMessage(AfaStrings.AnUnexpectedErrorOccured);
             }
             else
             {
                 ErrorReport.ShowErrorMessage(base.Parent.ErrorMessage);
             }
             return;
         }
         SpatialReference spatialReference = null;
         if (dictionary != null)
         {
             object obj;
             if (!dictionary.TryGetValue("href", out obj))
             {
                 string text = AfaStrings.Error;
                 if (dictionary.ContainsKey("error"))
                 {
                     IDictionary <string, object> dictionary2 = dictionary["error"] as IDictionary <string, object>;
                     if (dictionary2.ContainsKey("details"))
                     {
                         object obj2;
                         if (dictionary2.TryGetValue("details", out obj2))
                         {
                             object[] array = obj2 as object[];
                             if (array != null)
                             {
                                 text = text + " - " + array[0].ToString();
                             }
                         }
                     }
                     else
                     {
                         text += AfaStrings.UnknownError;
                     }
                 }
                 Mouse.OverrideCursor = null;
                 ErrorReport.ShowErrorMessage(text);
                 return;
             }
             string text2 = obj as string;
             if (text2.Length > 0)
             {
                 ExportedImage exportedImage = new ExportedImage(this, text2);
                 if (dictionary.TryGetValue("width", out obj))
                 {
                     exportedImage.Properties.Add("width", obj);
                 }
                 if (dictionary.TryGetValue("height", out obj))
                 {
                     exportedImage.Properties.Add("height", obj);
                 }
                 if (dictionary.TryGetValue("scale", out obj))
                 {
                     exportedImage.Properties.Add("scale", obj);
                 }
                 if (dictionary.TryGetValue("extent", out obj))
                 {
                     IDictionary <string, object> dictionary3 = obj as IDictionary <string, object>;
                     object obj3;
                     if (dictionary3.TryGetValue("xmin", out obj3))
                     {
                         exportedImage.Properties.Add("xmin", obj3);
                     }
                     if (dictionary3.TryGetValue("xmax", out obj3))
                     {
                         exportedImage.Properties.Add("xmax", obj3);
                     }
                     if (dictionary3.TryGetValue("ymax", out obj3))
                     {
                         exportedImage.Properties.Add("ymax", obj3);
                     }
                     if (dictionary3.TryGetValue("ymin", out obj3))
                     {
                         exportedImage.Properties.Add("ymin", obj3);
                     }
                     if (dictionary3.TryGetValue("spatialReference", out obj3))
                     {
                         IDictionary <string, object> dictionary4 = obj3 as IDictionary <string, object>;
                         object obj4;
                         if (dictionary4.TryGetValue("wkid", out obj4))
                         {
                             exportedImage.Properties.Add("spatialReference", obj4);
                             int num = int.Parse(obj4.ToString());
                             spatialReference = AGSSpatialReference.SpRefFromWKID(ref num);
                         }
                         else if (dictionary4.TryGetValue("wkt", out obj4))
                         {
                             exportedImage.Properties.Add("spatialReference", obj4);
                             string text3 = obj4.ToString();
                             spatialReference = AGSSpatialReference.SpRefFromWKT(ref text3);
                         }
                     }
                     PointN pointN = new PointN();
                     if (spatialReference != null)
                     {
                         pointN.SpatialReference = spatialReference;
                     }
                     double num2 = double.Parse(exportedImage.Properties["xmin"].ToString());
                     double num3 = double.Parse(exportedImage.Properties["ymin"].ToString());
                     double num4 = double.Parse(exportedImage.Properties["xmax"].ToString());
                     double num5 = double.Parse(exportedImage.Properties["ymax"].ToString());
                     pointN.X = num2;
                     pointN.Y = num3;
                     pointN.Z = 0.0;
                     PointN[] points = new PointN[]
                     {
                         pointN,
                         new PointN
                         {
                             SpatialReference = spatialReference,
                             X = num4,
                             Y = num3,
                             Z = 0.0
                         },
                         new PointN
                         {
                             SpatialReference = spatialReference,
                             X = num2,
                             Y = num5,
                             Z = 0.0
                         }
                     };
                     try
                     {
                         if (File.Exists(eo.OutputFile))
                         {
                             File.Delete(eo.OutputFile);
                             if (App.TempFiles.Contains(eo.OutputFile))
                             {
                                 App.TempFiles.Remove(eo.OutputFile);
                             }
                         }
                         new WebClient();
                         if (!base.Parent.DownloadFile(text2, eo.OutputFile))
                         {
                             eo.OutputFile = text2;
                             if (string.IsNullOrEmpty(eo.OutputFile))
                             {
                                 ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile);
                             }
                         }
                     }
                     catch
                     {
                         eo.OutputFile = text2;
                         if (string.IsNullOrEmpty(eo.OutputFile))
                         {
                             ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile);
                         }
                     }
                     finally
                     {
                         if (action != null)
                         {
                             action(this, new ExportedImageEventArgs(this, eo, points));
                         }
                     }
                     Mouse.OverrideCursor = null;
                     return;
                 }
             }
         }
     }
     catch
     {
         Mouse.OverrideCursor = null;
     }
     Mouse.OverrideCursor = null;
 }
コード例 #3
0
 private void DoTask()
 {
     try
     {
         IDictionary <string, object> dictionary = this.Parent.MakeDictionaryRequest(this.RequestURL);
         if (dictionary == null)
         {
             string text = this.Parent.ErrorMessage;
             if (string.IsNullOrEmpty(text))
             {
                 text = AfaStrings.AnUnexpectedErrorOccured;
             }
             ErrorReport.ShowErrorMessage(text);
         }
         this.UpdateForm.SetReady(false);
         SpatialReference spatialReference = null;
         if (dictionary != null)
         {
             object obj;
             if (!dictionary.TryGetValue("href", out obj))
             {
                 string text2 = AfaStrings.Error;
                 if (dictionary.ContainsKey("error"))
                 {
                     IDictionary <string, object> dictionary2 = dictionary["error"] as IDictionary <string, object>;
                     object obj2;
                     if (dictionary2.ContainsKey("details") && dictionary2.TryGetValue("details", out obj2))
                     {
                         object[] array = obj2 as object[];
                         if (array != null)
                         {
                             text2 = text2 + " - " + array[0].ToString();
                         }
                     }
                 }
                 Mouse.OverrideCursor = null;
                 ErrorReport.ShowErrorMessage(text2);
             }
             else
             {
                 string text3 = obj as string;
                 if (text3.Length > 0)
                 {
                     decimal value  = 0m;
                     decimal value2 = 0m;
                     decimal value3 = 0m;
                     decimal value4 = 0m;
                     if (dictionary.TryGetValue("extent", out obj))
                     {
                         IDictionary <string, object> dictionary3 = obj as IDictionary <string, object>;
                         object obj3;
                         if (dictionary3.TryGetValue("spatialReference", out obj3))
                         {
                             IDictionary <string, object> dictionary4 = obj3 as IDictionary <string, object>;
                             object obj4;
                             if (dictionary4.TryGetValue("wkid", out obj4))
                             {
                                 int num = int.Parse(obj4.ToString());
                                 spatialReference = AGSSpatialReference.SpRefFromWKID(ref num);
                             }
                             else if (dictionary4.TryGetValue("wkt", out obj4))
                             {
                                 string text4 = obj4.ToString();
                                 spatialReference = AGSSpatialReference.SpRefFromWKT(ref text4);
                             }
                         }
                         if (dictionary3.TryGetValue("xmin", out obj3))
                         {
                             value = (decimal)obj3;
                         }
                         if (dictionary3.TryGetValue("xmax", out obj3))
                         {
                             value3 = (decimal)obj3;
                         }
                         if (dictionary3.TryGetValue("ymax", out obj3))
                         {
                             value4 = (decimal)obj3;
                         }
                         if (dictionary3.TryGetValue("ymin", out obj3))
                         {
                             value2 = (decimal)obj3;
                         }
                         PointN pointN = new PointN();
                         if (spatialReference != null)
                         {
                             pointN.SpatialReference = spatialReference;
                         }
                         pointN.X = (double)value;
                         pointN.Y = (double)value2;
                         pointN.Z = 0.0;
                         PointN[] array2 = new PointN[]
                         {
                             pointN,
                             new PointN
                             {
                                 SpatialReference = spatialReference,
                                 X = (double)value3,
                                 Y = (double)value2,
                                 Z = 0.0
                             },
                             new PointN
                             {
                                 SpatialReference = spatialReference,
                                 X = (double)value,
                                 Y = (double)value4,
                                 Z = 0.0
                             }
                         };
                         try
                         {
                             if (File.Exists(this.OutputFile))
                             {
                                 File.Delete(this.OutputFile);
                                 if (App.TempFiles.Contains(this.OutputFile))
                                 {
                                     App.TempFiles.Remove(this.OutputFile);
                                 }
                             }
                             if (!this.Parent.DownloadFile(text3, this.OutputFile))
                             {
                                 this.OutputFile = text3;
                                 if (string.IsNullOrEmpty(this.OutputFile))
                                 {
                                     ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile);
                                     return;
                                 }
                             }
                         }
                         catch
                         {
                             this.OutputFile = text3;
                             if (string.IsNullOrEmpty(this.OutputFile))
                             {
                                 ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile);
                                 return;
                             }
                         }
                         this.UpdateForm.SetReady(false);
                         Point3d point3d  = new Point3d(pointN.X, array2[0].Y, 0.0);
                         Point3d point3d2 = new Point3d(array2[1].X, array2[1].Y, 0.0);
                         Point3d point3d3 = new Point3d(array2[2].X, array2[2].Y, 0.0);
                         this.UpdateForm.V1        = point3d2 - point3d;
                         this.UpdateForm.V2        = point3d3 - point3d;
                         this.UpdateForm.BasePoint = point3d;
                         this.UpdateForm.ImageURL  = this.OutputFile;
                         this.UpdateForm.SetReady(true);
                     }
                 }
             }
         }
     }
     catch (SystemException ex)
     {
         this.UpdateForm.SetReady(false);
         this._errMsg.Append(ex.Message);
     }
 }