⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cenvironment.cs

📁 公布ilrbuivbiu复合带搜ifd回复地鸥鸟个能否地偶女男的
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;

namespace MainSystem
{
	/// <summary>
	/// 
	/// </summary>
	public struct LayerInfo
	{
		public string szName;
		public string szLayerName;
		public string szFileName;
		public string szTableName;
		public string szFieldName;
		public string szType;
		public string szSubType;									//中类
		public string szSubType2;									//小类
		public string szSubType3;
		public bool bCanControl;
		public bool bVisible;										//可显示状态,只能通过图层控制来改变
		public bool bSelected;										
		public bool bCanSelected;									//可选择
		public bool bBackground;
		public bool bLable;
		public double dScale;
		public double dShowScale;
		public int	nCharacterIndex;
		public string szFontName;
		public int  nFontSize;
		public int	nSymSize;
		public uint	nSymColor;

		public MapObjects2.MapLayer	layer;
		public MapObjects2.Recordset	rsSel;
	};

	public class MLine
	{
		public int nPointNumber;
		public MPoint[] pPoint;

		public MLine()
		{
		}
	};	

	public class CloestPath
	{
		public MPoint pt1 = null;
		public MPoint pt2 = null;
	};

	public class MPoint
	{
		public double x;
		public double y;

		public MPoint()
		{
		}
	};

	public class Buses
	{
		public int		nNum;
		public MPoint[] pts;

		public Buses()
		{
			pts = new MPoint[200]; 
		}
	}

	enum MapOpr {MO_NULL=0,MO_ZOOMIN,MO_ZOOMOUT,MO_ZOOMFULL,MO_PAN,MO_POINTSEL,MO_RECTSEL,MO_CIRCLESEL,MO_POLYGONSEL,MO_INFO,MO_LINEMEAS,MO_POLYMEAS,MO_SEACHBYDIST,MO_CLOSEST};
	enum MapDisp {MO_ALL = 0,MO_SCHOOL = 1, MO_TOUR,MO_HOSPITAL,MO_SHOP,MO_HOTEL,MO_GAS,MO_BANK,MO_MOVIE,MO_RESTAURANT,MO_WS,MO_POST,MO_LIBRAY,MO_STATION}

	public struct MapInfo
	{
		public string szName;
		public string szMetaTable;
		public string szIndexTable;
		public string szType;

		public MapObjects2.Rectangle rect;
	};

	public struct IndexInfo
	{
		public string szName;
		public double dX;
		public double dY;
		public MapObjects2.Rectangle m_extent;

	};

	public class CEnvironment
	{
		//常量
		public const string BUSLINE_LAYERNAME = "公交线路";
		public const string BUSSTATION_LAYERNAME = "公交车站";
		public const uint	SYMBOL_COLOR_NONE = 9999;

		public string				m_szDBName = "";
		public string				m_szSDBPath = "";
		public string				m_AppPath = "";
		public string				m_szHelpPath = "";

		public MapObjects2.DataConnection m_db = null;

		public int					m_nCurrMapIndex = -1;
		public int					m_nMapNum = -1;
		public MapInfo[]			m_mapInfos = null;

		public int					m_nLayerNum = -1;
		public LayerInfo[]			m_layerInfos = null;

		public int					m_nIndexNum = -1;
		public IndexInfo[]			m_indexInfos = null;

		public MapObjects2.Symbol m_selSymbol = null;
		public string				m_szfntStation = "";
		public char					m_chStation = 'a';
		public int					m_nfntStation = 10;

		//		public string				m_szFontName = ""; 

		public System.Data.DataSet	m_dataSet = null; 

		public long					m_x,m_y;

		public  int					m_MapOpr;
		public	CloestPath			m_cloestPath = null;

		public double				m_dDistance;		//最短距离查询
		public object				m_selectedFeature = null;
		public MapObjects2.Symbol m_selectedSymbol = null;
		public short				m_selectedSymbolSize;
		public double				m_selectedScale;
		public MLine[]				m_drawLine = null;
		public Buses				m_buses = null;
		public string				m_szBusFilter = "";

		public	bool				m_bPathInit = false;
		public CPath				m_path;

		public string				m_szPlaceName = "";

		public MapObjects2.Rectangle m_shapeRect;

		public MapObjects2.MapLayer m_layerRoad = null;

		public CEnvironment()
		{
			m_MapOpr = (int)MapOpr.MO_NULL;
 
			m_selSymbol = new MapObjects2.Symbol();  
		
			m_selSymbol.SymbolType = MapObjects2.SymbolTypeConstants.moPointSymbol;  
			m_selSymbol.Color = 0xff;  

			m_path = new CPath();
			m_bPathInit = false;

			m_cloestPath = new CloestPath(); 
		}

		public int GetMapIndex(string szMapName)
		{
			int nIndex = -1;

			for (int i = 0; i < m_nMapNum; i ++)
			{
				if (szMapName.Equals(m_mapInfos[i].szName))
				{
					nIndex = i;
					break;
				}
			}

			return nIndex;
		}

		public int GetLayerIndexByName(string szName)
		{
			int nIndex = -1;

			for (int i = 0; i < m_nLayerNum; i ++)
			{
				if (szName.Equals(this.m_layerInfos[i].szName))
				{
					nIndex = i;
					break;
				}
			}

			return nIndex;
		
		}

		/// <summary>
		/// 根据地名得到地名所在的图层名
		/// </summary>
		/// <param name="szName">string 地名名称</param>
		/// <param name="szTblName">string 索引表名称</param>
		/// <returns>图层名称</returns>
		public string GetLayerName(string szName,string szTblName)
		{
			string szTableName = "";

			string strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_szDBName + 
				";Persist Security Info=False";		
			System.Data.OleDb.OleDbConnection  myConnection = new System.Data.OleDb.OleDbConnection(strConnectionString);   
			myConnection.Open();
			System.Data.DataSet dataSet = new System.Data.DataSet("临时库");
			System.Data.OleDb.OleDbDataAdapter myDataAdapter;

			string szSQL;
			szSQL = "Select * From " + szTblName + " Where 名称 ='"+szName+"'";

			myDataAdapter = new System.Data.OleDb.OleDbDataAdapter(szSQL,myConnection);
			myDataAdapter.Fill(dataSet,"地名索引");

			System.Data.DataTable indexTbl = dataSet.Tables["地名索引"];
			
			System.Data.DataRow[] rowsType = indexTbl.Select();

			if (0 == rowsType.Length)
				return "";

			szTableName = rowsType[0]["图层名"].ToString(); 
			
			return szTableName;		
		}

		public string GetFieldName(string szName)
		{
			string szTable = GetTableName(szName,"地名索引");

			string szFieldName = "单位名称";

			string strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_szDBName + 
				";Persist Security Info=False";		
			System.Data.OleDb.OleDbConnection  myConnection = new System.Data.OleDb.OleDbConnection(strConnectionString);   
			myConnection.Open();
			System.Data.DataSet dataSet = new System.Data.DataSet("临时库");
			System.Data.OleDb.OleDbDataAdapter myDataAdapter;

			string szSQL;
			szSQL = "Select * From "+ this.m_mapInfos[this.m_nCurrMapIndex].szMetaTable +  " Where 属性表名 ='"+szTable+"'";

			myDataAdapter = new System.Data.OleDb.OleDbDataAdapter(szSQL,myConnection);
			myDataAdapter.Fill(dataSet,"索引");

			System.Data.DataTable indexTbl = dataSet.Tables["索引"];
			
			System.Data.DataRow[] rowsType = indexTbl.Select();

			if (0 == rowsType.Length)
				return szFieldName;

			szFieldName = rowsType[0]["字段名"].ToString(); 
			
			return szFieldName;

		}

		public string GetTableName(string szName, string szTbleName)
		{
			string szTableName = "";

			string strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_szDBName + 
				";Persist Security Info=False";		
			System.Data.OleDb.OleDbConnection  myConnection = new System.Data.OleDb.OleDbConnection(strConnectionString);   
			myConnection.Open();
			System.Data.DataSet dataSet = new System.Data.DataSet("临时库");
			System.Data.OleDb.OleDbDataAdapter myDataAdapter;

			string szSQL;
			szSQL = "Select * From " + szTbleName + " Where 名称 ='"+szName+"'";

			myDataAdapter = new System.Data.OleDb.OleDbDataAdapter(szSQL,myConnection);
			myDataAdapter.Fill(dataSet,"地名索引");

			System.Data.DataTable indexTbl = dataSet.Tables["地名索引"];
			
			System.Data.DataRow[] rowsType = indexTbl.Select();

			if (0 == rowsType.Length)
				return szTableName;

			szTableName = rowsType[0]["属性表名"].ToString(); 
			
			return szTableName;
		}

		public void ExecuteSpatial(AxMapObjects2.AxMap map,object shape,MapObjects2.SearchMethodConstants sMode,bool bMPoint)
		{
			for (int i = 0; i < this.m_nLayerNum; i ++)
			{
				if (bMPoint)
				{
					double dScale = CalcScale(map);
					if (dScale > 8000)
					{
						dScale = dScale/10000;
						dScale = dScale / 5000;
					}
					else
					{
						dScale = dScale/10000;
						dScale = dScale / 2500;
					}

					if (m_layerInfos[i].layer.Visible && m_layerInfos[i].bCanSelected)  
						m_layerInfos[i].rsSel = m_layerInfos[i].layer.SearchByDistance(shape, dScale,"");
					else
						m_layerInfos[i].rsSel = null;
				}
				else
				{
					if (m_layerInfos[i].layer.Visible && m_layerInfos[i].bCanSelected)  
						m_layerInfos[i].rsSel = m_layerInfos[i].layer.SearchShape(shape, sMode,"");
					else
						m_layerInfos[i].rsSel = null;
				}
			}
		}

		public void ClearSelRsts()
		{
			for (int i = 0; i < this.m_nLayerNum; i ++)
			{
		
				m_layerInfos[i].rsSel = null;
			}
		}

		public void DrawRecordset(AxMapObjects2.AxMap map)
		{

			for (int i = 0; i < this.m_nLayerNum; i ++)
			{
				if (m_layerInfos[i].layer.Visible)
				{
					
					if (m_layerInfos[i].rsSel != null)
					{
						MapObjects2.Symbol sym = new MapObjects2.Symbol(); 
						sym.SymbolType = m_layerInfos[i].layer.Symbol.SymbolType; 
						sym.Style = m_layerInfos[i].layer.Symbol.Style;
						sym.Size = m_layerInfos[i].layer.Symbol.Size;
						sym.Color = 0xff;

						if (m_layerInfos[i].nCharacterIndex >= 0 && m_layerInfos[i].layer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePoint )
						{
							//							sym = m_layerInfos[i].layer.Symbol; 
							//							sym.Color = 0xff;

							sym.SymbolType = MapObjects2.SymbolTypeConstants.moPointSymbol;
							sym.Font.Name  = m_layerInfos[i].szFontName;
							sym.Style = 4;
							sym.Size = m_layerInfos[i].layer.Symbol.Size;
							sym.CharacterIndex = (short)m_layerInfos[i].nCharacterIndex;
						}

						m_layerInfos[i].rsSel.MoveFirst();
	
						while  (!m_layerInfos[i].rsSel.EOF)
						{
							map.DrawShape(m_layerInfos[i].rsSel.Fields.Item("Shape").Value,sym);
							m_layerInfos[i].rsSel.MoveNext(); 
						}	
					}
				}

			}

		}

		public void DrawSelectedShape(AxMapObjects2.AxMap map, frmMain frm)
		{
			MapObjects2.Symbol sym = new MapObjects2.Symbol(); 
			sym.Color = 0xff;

			if (this.m_selectedSymbol == null)
				map.DrawShape(m_selectedFeature,sym );
			else
			{
				double dScale = this.CalcScale(map);

				//				if (m_selectedScale > dScale)
			{
				m_selectedSymbol.Size = frm.ReCalcFontSize(m_selectedSymbolSize,dScale);
				map.DrawShape(m_selectedFeature,m_selectedSymbol );
			}
			}

		}
		

		/////////////////////////////////////////////////////////////////// 
		/// 功能:判断图层是否可见
		/// 参数:
		/// 返回值:
		/// ///////////////////////////////////////////////////////////////
		public bool GetLayerVisible(int disp)
		{
			bool bVisible = true;
			int  nType = 2;
			string szSubType = "";

			switch ((MapDisp)disp)
			{
				case MapDisp.MO_ALL:
					nType = 1;
					break;
				case MapDisp.MO_HOSPITAL:
					szSubType = "医院";
					break;
				case MapDisp.MO_SCHOOL:
					szSubType = "教育";
					break;
				case MapDisp.MO_SHOP:
					szSubType = "零售";
					break;
				case MapDisp.MO_TOUR:
					szSubType = "旅游";
					break;
				case MapDisp.MO_GAS:
					break;
				case MapDisp.MO_HOTEL: 
					szSubType = "住宿";
					break;
				case MapDisp.MO_LIBRAY:
					szSubType = "图书馆";
					nType = 3;
					break;
				case MapDisp.MO_MOVIE:
					szSubType = "影剧院、音乐厅";
					nType = 3;
					break;
				case MapDisp.MO_POST:
					szSubType = "邮政";
					break;
				case MapDisp.MO_RESTAURANT:
					szSubType = "餐饮";
					break;
				case MapDisp.MO_WS:
					szSubType = "dddd";
					break;
				case MapDisp.MO_STATION:
					szSubType = "站点";
					nType = 4;
					break;
			}

			int nCount = 0;

			for (int i = 0; i < this.m_nLayerNum; i ++)
			{
				if (m_layerInfos[i].bCanControl) 
				{
					switch (nType)
					{
						case 1:
							nCount ++;
							if (!m_layerInfos[i].bVisible)
							{
								return false;
							}

							break;
						case 2:
							if (szSubType == m_layerInfos[i].szSubType)
							{
								nCount ++;
								if (!m_layerInfos[i].bVisible)
								{
									return false;
								}
							}
							break;
						case 3:
							if (szSubType == m_layerInfos[i].szSubType2)
							{
								nCount ++;
								if (!m_layerInfos[i].bVisible)
								{
									return false;
								}
							}
							break;
						case 4:
							if (szSubType == m_layerInfos[i].szSubType3)
							{
								nCount ++;
								if (!m_layerInfos[i].bVisible)
								{
									return false;
								}
							}
							break;
					}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -