コード例 #1
0
ファイル: CoreFun.cs プロジェクト: 605258778/GISData
 public void CheckMapFullExtent(IEnvelope pEnvelope)
 {
     try
     {
         if (pEnvelope.XMin < double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "XMin")))
         {
             pEnvelope.XMin = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "XMin"));
         }
         if (pEnvelope.XMax > double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "XMax")))
         {
             pEnvelope.XMax = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "XMax"));
         }
         if (pEnvelope.YMin < double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "YMin")))
         {
             pEnvelope.YMin = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "YMin"));
         }
         if (pEnvelope.YMax > double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "YMax")))
         {
             pEnvelope.YMax = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("FullExtent", "YMax"));
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "CheckMapFullExtent", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
コード例 #2
0
ファイル: WorkspaceFun.cs プロジェクト: 605258778/GISData
 public IFeatureWorkspace GetFeatureWorkspace(WorkspaceSource pSourceType)
 {
     try
     {
         if (pSourceType != WorkspaceSource.esriWSSdeWorkspaceFactory)
         {
             return(null);
         }
         IWorkspace workspace = null;
         string     serr      = "";
         string     server    = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "DataSource");
         string     instance  = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "Service");
         string     database  = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "InitialCatalog");
         string     version   = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "Version");
         string     user      = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "UserID");
         string     password  = UtilFactory.GetConfigOpt().GetConfigValue2("SqlServer", "Password");
         workspace = this.open_ArcSDE_Workspace(server, instance, user, password, database, version, out serr);
         if (workspace == null)
         {
             MessageBox.Show("服务名、服务器名、数据库名、用户名或密码输入错误", "数据源链接失败!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(null);
         }
         return(workspace as IFeatureWorkspace);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.WorkspaceFun", "GetFeatureWorkspace", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }
コード例 #3
0
 private bool SetDefaultColor(string sColorKey, IColor pNewColor)
 {
     try
     {
         if (string.IsNullOrEmpty(sColorKey))
         {
             return(false);
         }
         if (pNewColor == null)
         {
             return(false);
         }
         if (!(pNewColor is IRgbColor))
         {
             return(false);
         }
         IRgbColor color = null;
         color = pNewColor as IRgbColor;
         Color black = Color.Black;
         black = Color.FromArgb(color.Red, color.Green, color.Blue);
         UtilFactory.GetConfigOpt().SetConfigValue(sColorKey, black.ToArgb().ToString());
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "SetDefaultColor", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
コード例 #4
0
ファイル: CoreFun.cs プロジェクト: 605258778/GISData
 public bool LoadPageLayoutTemplate(IPageLayoutControl pPageControl, string sTemplateID)
 {
     try
     {
         if (pPageControl == null)
         {
             Interaction.MsgBox("地图模板加载失败,控件 PageLayoutControl 加载失败。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (string.IsNullOrEmpty(Strings.Trim(sTemplateID)))
         {
             Interaction.MsgBox("地图模板加载失败,模板ID " + sTemplateID + " 错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         string configValue = null;
         configValue = UtilFactory.GetConfigOpt().GetConfigValue(sTemplateID);
         if (string.IsNullOrEmpty(configValue))
         {
             Interaction.MsgBox("地图模板加载失败,目录 " + configValue + " 错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (Strings.Right(configValue, 1) != @"\")
         {
             configValue = configValue + @"\";
         }
         string path = null;
         path = configValue + sTemplateID + ".mxt";
         if (!File.Exists(path))
         {
             Interaction.MsgBox("地图模板加载失败,模板文件 " + path + " 不存在。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (!pPageControl.CheckMxFile(path))
         {
             Interaction.MsgBox("地图模板加载失败,模板文件 " + path + " 内存在错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         pPageControl.LoadMxFile(path, null);
         IActiveView activeView = pPageControl.ActiveView;
         if (activeView.GraphicsContainer != null)
         {
             IViewManager manager          = activeView as IViewManager;
             ISelection   elementSelection = manager.ElementSelection;
             activeView.Selection = elementSelection;
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "LoadPageLayoutTemplate", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
コード例 #5
0
 private IColor GetDefaultColor(string sColorKey)
 {
     try
     {
         if (string.IsNullOrEmpty(sColorKey))
         {
             return(null);
         }
         Color black = Color.Black;
         black = Color.FromArgb(int.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("Symbol", sColorKey)));
         return(GISFunFactory.ColorFun.GetRGBColor(black));
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "GetDefaultColor", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }
コード例 #6
0
ファイル: CoreFun.cs プロジェクト: 605258778/GISData
 public bool LoadMapDocument(IMapControlDefault pMapControl, string sMxDocID)
 {
     try
     {
         if (pMapControl == null)
         {
             MessageBox.Show("地图文档加载失败,控件 MapControl 加载失败。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         if (string.IsNullOrEmpty(sMxDocID.Trim()))
         {
             MessageBox.Show("地图文档加载失败,文档ID " + sMxDocID + " 错误。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         string path = null;
         path = UtilFactory.GetConfigOpt().RootPath + @"\" + UtilFactory.GetConfigOpt().GetConfigValue(sMxDocID);
         if (!File.Exists(path))
         {
             MessageBox.Show("地图文档加载失败,文档文件 " + path + " 不存在。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         if (!pMapControl.CheckMxFile(path))
         {
             MessageBox.Show("地图文档加载失败,文档文件 " + path + " 内存在错误。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         pMapControl.LoadMxFile(path, null, null);
         IActiveView activeView = pMapControl.ActiveView;
         if (activeView.GraphicsContainer != null)
         {
             IViewManager manager          = activeView as IViewManager;
             ISelection   elementSelection = manager.ElementSelection;
             activeView.Selection = elementSelection;
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "LoadMapDocument", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
コード例 #7
0
 private bool SetDefaultTextSymbol(ITextSymbol pTextSymbol)
 {
     try
     {
         if (pTextSymbol == null)
         {
             return(false);
         }
         UtilFactory.GetConfigOpt().SetConfigValue("Angle", pTextSymbol.Angle.ToString());
         this.DefaultFontColor = pTextSymbol.Color;
         UtilFactory.GetConfigOpt().SetConfigValue("Size", pTextSymbol.Size.ToString());
         UtilFactory.GetConfigOpt().SetConfigValue("Text", pTextSymbol.Text.ToString());
         UtilFactory.GetConfigOpt().SetConfigValue("HorizontalAlignment", pTextSymbol.HorizontalAlignment.ToString());
         UtilFactory.GetConfigOpt().SetConfigValue("VerticalAlignment", pTextSymbol.VerticalAlignment.ToString());
         if (pTextSymbol.Font != null)
         {
             UtilFactory.GetConfigOpt().SetConfigValue("FontName", pTextSymbol.Font.Name);
             UtilFactory.GetConfigOpt().SetConfigValue("FontSize", pTextSymbol.Font.Size.ToString());
             UtilFactory.GetConfigOpt().SetConfigValue("FontBold", pTextSymbol.Font.Bold.ToString());
             UtilFactory.GetConfigOpt().SetConfigValue("FontItalic", pTextSymbol.Font.Italic.ToString());
             UtilFactory.GetConfigOpt().SetConfigValue("FontUnderline", pTextSymbol.Font.Underline.ToString());
             UtilFactory.GetConfigOpt().SetConfigValue("FontStrikethrough", pTextSymbol.Font.Strikethrough.ToString());
         }
         IFormattedTextSymbol symbol = null;
         symbol = pTextSymbol as IFormattedTextSymbol;
         UtilFactory.GetConfigOpt().SetConfigValue("Direction", symbol.Direction.ToString());
         ISimpleTextSymbol symbol2 = null;
         symbol2 = pTextSymbol as ISimpleTextSymbol;
         UtilFactory.GetConfigOpt().SetConfigValue("XOffset", symbol2.XOffset.ToString());
         UtilFactory.GetConfigOpt().SetConfigValue("YOffset", symbol2.YOffset.ToString());
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "SetDefaultTextSymbol", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
コード例 #8
0
ファイル: FeatureFuncs.cs プロジェクト: 605258778/GISData
 public static void SetFeatureArea(IFeature pFeature)
 {
     if (pFeature != null)
     {
         try
         {
             IGeometry shapeCopy = pFeature.ShapeCopy;
             if (shapeCopy.GeometryType == esriGeometryType.esriGeometryPolygon)
             {
                 double area = ((IArea)GISFunFactory.UnitFun.ConvertPoject(shapeCopy, Editor.UniqueInstance.Map.SpatialReference)).Area;
                 string str  = EditTask.KindCode.Substring(0, 2);
                 string name = "";
                 string str3 = "";
                 string str4 = "";
                 if (str == "01")
                 {
                     area = Math.Round(Math.Abs((double)(area / 10000.0)), 2);
                     name = "Afforest";
                     str3 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "AreaField");
                 }
                 else if (str == "02")
                 {
                     area = Math.Round(Math.Abs((double)(area / 10000.0)), 2);
                     name = "Harvest";
                     str3 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "AreaField");
                     str4 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "ZTAreaField");
                 }
                 else if (str == "06")
                 {
                     area = Math.Round(Math.Abs((double)(area / 10000.0)), 2);
                     name = "Disaster";
                     str4 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "ZTAreaField");
                 }
                 else if (str == "07")
                 {
                     area = Math.Round(Math.Abs((double)(area / 10000.0)), 2);
                     name = "ForestCase";
                     str3 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "AreaField");
                 }
                 else if (str == "04")
                 {
                     area = Math.Round(Math.Abs((double)(area / 10000.0)), 4);
                     name = "Expropriation";
                     str3 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "AreaField");
                     str4 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "ZTAreaField");
                 }
                 else if (str == "05")
                 {
                     area = Math.Round(Math.Abs((double)(area / 10000.0)), 2);
                     name = "Fire";
                     str3 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "AreaField");
                 }
                 else
                 {
                     area = Math.Round(Math.Abs((double)(area / 10000.0)), 2);
                     name = "Sub";
                     str3 = UtilFactory.GetConfigOpt().GetConfigValue2(name, "AreaField");
                 }
                 int index = pFeature.Fields.FindField(str3);
                 if (index > -1)
                 {
                     pFeature.set_Value(index, area);
                 }
                 string[] strArray = str4.Split(new char[] { ',' });
                 for (int i = 0; i < strArray.Length; i++)
                 {
                     index = pFeature.Fields.FindField(strArray[i]);
                     if (index > -1)
                     {
                         pFeature.set_Value(index, area);
                     }
                 }
                 pFeature.Store();
             }
         }
         catch
         {
         }
     }
 }
コード例 #9
0
 private ITextSymbol GetDefaultTextSymbol()
 {
     try
     {
         ITextSymbol symbol = null;
         symbol = new TextSymbolClass {
             Angle = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Angle")),
             Color = this.DefaultFontColor,
             Size  = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Size")),
             Text  = UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Text")
         };
         if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextHorizontalAlignment.esriTHACenter.ToString())
         {
             symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
         }
         else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextHorizontalAlignment.esriTHAFull.ToString())
         {
             symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;
         }
         else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextHorizontalAlignment.esriTHALeft.ToString())
         {
             symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
         }
         else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextHorizontalAlignment.esriTHARight.ToString())
         {
             symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
         }
         if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextVerticalAlignment.esriTVABaseline.ToString())
         {
             symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline;
         }
         else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextVerticalAlignment.esriTVABottom.ToString())
         {
             symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
         }
         else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextVerticalAlignment.esriTVACenter.ToString())
         {
             symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
         }
         else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextVerticalAlignment.esriTVATop.ToString())
         {
             symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
         }
         IFontDisp font = null;
         if (symbol.Font == null)
         {
             font = new StdFontClass() as IFontDisp;
         }
         else
         {
             font = symbol.Font;
         }
         font.Name          = UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontName");
         font.Size          = decimal.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontSize"));
         font.Bold          = bool.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontBold"));
         font.Italic        = bool.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontItalic"));
         font.Underline     = bool.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontUnderline"));
         font.Strikethrough = bool.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontStrikethrough"));
         symbol.Font        = font;
         IFormattedTextSymbol symbol2 = null;
         symbol2 = symbol as IFormattedTextSymbol;
         if (esriTextDirection.esriTDAngle.ToString() == UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Direction"))
         {
             symbol2.Direction = esriTextDirection.esriTDAngle;
         }
         else if (esriTextDirection.esriTDHorizontal.ToString() == UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Direction"))
         {
             symbol2.Direction = esriTextDirection.esriTDHorizontal;
         }
         else if (esriTextDirection.esriTDVertical.ToString() == UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Direction"))
         {
             symbol2.Direction = esriTextDirection.esriTDVertical;
         }
         ISimpleTextSymbol symbol3 = null;
         symbol3         = symbol as ISimpleTextSymbol;
         symbol3.XOffset = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "XOffset"));
         symbol3.YOffset = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "YOffset"));
         return(symbol);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "GetDefaultTextSymbol", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }