Esempio n. 1
0
        /// <summary>
        /// 选择特定的路由。
        /// Select a specified route
        /// </summary>
        /// <param name="index"></param>
        public void SelectRoute(int index)
        {
            try
            {
                FillDataGridView(index);

                int lineIndex = m_trackingLayer.IndexOf("selectedLineM");
                if (lineIndex != -1)
                {
                    m_trackingLayer.Remove(lineIndex);
                }
                m_count = 0;
                m_lineM = m_result.Routes[index];
                GeoStyle style = new GeoStyle();
                style.LineColor = Color.Red;
                style.LineWidth = 0.8;
                m_lineM.Style   = style;
                m_mapControl.Map.EnsureVisible(m_lineM, 0.5);
                m_trackingLayer.Add(m_lineM, "selectedLineM");
                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加等级符号专题图
        /// Add the theme of graduated symbol
        /// </summary>
        public void ThemeRangeThemeDisplay()
        {
            try
            {
                Map    map    = m_mapControl.Map;
                Layers layers = map.Layers;
                Int32  count  = layers.Count;

                Datasources   datasources   = m_workspace.Datasources;
                Datasource    datasource    = datasources[0];
                Datasets      datasets      = datasource.Datasets;
                DatasetVector datasetVector = datasets["BaseMap_R"] as DatasetVector;

                ThemeGraduatedSymbol themeGraduatedSymbol = new ThemeGraduatedSymbol();
                themeGraduatedSymbol.Expression    = "Urban";
                themeGraduatedSymbol.BaseValue     = 150.00000;
                themeGraduatedSymbol.GraduatedMode = GraduatedMode.SquareRoot;
                themeGraduatedSymbol.IsFlowEnabled = false;

                GeoStyle geoStyle = themeGraduatedSymbol.PositiveStyle;
                geoStyle.LineColor = Color.Pink;

                m_layer          = layers.Add(datasetVector, themeGraduatedSymbol, true);
                m_themeLayerName = m_layer.Name;

                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 显示结果。
        /// Show result
        /// </summary>
        public void ShowResult()
        {
            try
            {
                GeoLineM[] geoLineMs = m_analystResult.Routes;
                GeoLineM   geoLineM  = geoLineMs[0];
                GeoStyle   style     = new GeoStyle();
                style.LineColor = Color.Blue;
                style.LineWidth = 1;
                geoLineM.Style  = style;
                for (Int32 i = 0; i < m_trackingLayer.Count; i++)
                {
                    // 清除上次结果
                    // Clear the last result
                    if (m_trackingLayer.Get(i).Type == GeometryType.GeoLineM)
                    {
                        m_trackingLayer.Remove(i);
                    }
                }
                m_trackingLayer.Add(geoLineM, "route");

                m_mapControl.Map.Refresh();
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 模拟物流配送。
 /// Simulate the logistics
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void m_timer_Tick(object sender, EventArgs e)
 {
     try
     {
         int index = m_trackingLayer.IndexOf("playPoint");
         if (index != -1)
         {
             m_trackingLayer.Remove(index);
         }
         if (m_lineM.Length != 0)
         {
             PointM   pointM = m_lineM.GetPart(0)[m_count];
             GeoPoint point  = new GeoPoint(pointM.X, pointM.Y);
             GeoStyle style  = new GeoStyle();
             style.LineColor  = Color.FromArgb(0, 255, 255);
             style.MarkerSize = new Size2D(8, 8);
             point.Style      = style;
             m_trackingLayer.Add(point, "playPoint");
             m_count++;
             if (m_count >= m_lineM.GetPart(0).Count)
             {
                 m_count = 0;
             }
         }
         m_mapControl.Map.Refresh();
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
Esempio n. 5
0
        public void UpdateMapView(string strID)
        {
            if (m_workspace.Datasources.Count <= 0)
            {
                return;
            }

            Datasource datasource = m_workspace.Datasources[0];

            for (int ModelIndex = 0; ModelIndex < UserHelper.nDeviceNum; ModelIndex++)
            {
                DatasetVector pointDataset = datasource.Datasets[UserHelper.sDeviceName[ModelIndex]] as DatasetVector;
                Recordset     recordSet    = null;
                try
                {
                    if (pointDataset != null)
                    {
                        recordSet = pointDataset.Query(m_filedName + "='" + strID + "'", CursorType.Dynamic);
                        int recCount = recordSet.RecordCount;
                        if (recCount == 1)
                        {
                            //if (pointColor >= 255)
                            //{
                            //    pointColor = 0;
                            //}

                            pointColor = pointColor == 120 ? 255 : 120;

                            GeoStyle style = new GeoStyle();
                            style.MarkerSize = new Size2D(8, 8);
                            style.LineColor  = Color.FromArgb(0, 0, pointColor, 0);
                            //pointColor += 60;
                            GeoPoint point = recordSet.GetGeometry() as GeoPoint;
                            point.Style = style;

                            int index = m_MapControl.Map.TrackingLayer.IndexOf(strID);
                            if (index >= 0)
                            {
                                m_MapControl.Map.TrackingLayer.Remove(index);
                            }

                            m_MapControl.Map.TrackingLayer.Add(point, strID);

                            //recordSet.Edit();
                            //recordSet.Update();
                            //recordSet.Close();
                            //recordSet.Dispose();
                            break;
                        }
                        //recordSet.Close();
                        //recordSet.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            m_MapControl.Map.Refresh();
        }
Esempio n. 6
0
        /// <summary>
        /// 设置ThemeDotDensity的属性,添加点密度专题图图层到地图
        /// Set the ThemeDotDensity property and add the dot density theme layer into the map
        /// </summary>
        public void AddThemeDotDensityLayer()
        {
            try
            {
                ThemeDotDensity dotDensity = new ThemeDotDensity();
                dotDensity.DotExpression = "Pop_Density99";
                dotDensity.Value         = 0.00030;

                GeoStyle geostyle = new GeoStyle();
                geostyle.LineColor  = Color.Red;
                geostyle.MarkerSize = new Size2D(0.8, 0.8);

                dotDensity.Style = geostyle;
                // 将制作好的专题图添加到地图中显示
                // Display the theme in the map
                Layer themeLayer = m_mapControl.Map.Layers.Add(m_dataset, dotDensity, true);
                m_mapControl.Map.Layers.MoveDown(0);
                m_themeLayerName = themeLayer.Name;

                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 设置站点几何风格,用于在跟踪层上绘制
        /// Set the stop geometry style, which is used to draw in tracking layer
        /// </summary>
        /// <param name="size2D"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        private GeoStyle GetStopStyle(Size2D size2D, Color color)
        {
            GeoStyle style = new GeoStyle();

            style.MarkerSize = size2D;
            style.LineColor  = color;
            return(style);
        }
Esempio n. 8
0
        /// <summary>
        /// 初始化控件及数据。
        /// Initialize data and control
        /// </summary>
        private void Initialize()
        {
            try
            {
                DatasourceConnectionInfo connectionInfo = new DatasourceConnectionInfo(
                    @"..\..\SampleData\City\Changchun.udb", "findClosestFacility", "");
                connectionInfo.EngineType = EngineType.UDB;
                m_workspace.Datasources.Open(connectionInfo);
                m_datasetLine = (DatasetVector)m_workspace.Datasources[0]
                                .Datasets[m_datasetName] as DatasetVector;
                m_datasetPoint       = m_datasetLine.ChildDataset;
                m_selectFacilityNode = true;
                m_selectBarrier      = false;
                m_selectEventNode    = false;
                m_Points             = new Point2Ds();
                m_barrierEdges       = new List <Int32>();
                m_barrierNodes       = new List <Int32>();
                m_selectMode         = SelectMode.SELECTPOINT;
                m_nodesList          = new List <Int32>();
                m_trackingLayer      = m_mapControl.Map.TrackingLayer;

                // 加载点数据集及线数据集并设置各自风格
                // Add point, line datasets and set their styles
                m_layerLine = m_mapControl.Map.Layers.Add(m_datasetLine, true);
                LayerSettingVector lineSetting = (LayerSettingVector)m_layerLine
                                                 .AdditionalSetting;
                GeoStyle lineStyle = new GeoStyle();
                lineStyle.LineColor = Color.LightGray;
                lineStyle.LineWidth = 0.1;
                lineSetting.Style   = lineStyle;

                m_layerPoint = m_mapControl.Map.Layers.Add(
                    m_datasetPoint, true);
                LayerSettingVector pointSetting = (LayerSettingVector)m_layerPoint
                                                  .AdditionalSetting;
                GeoStyle pointStyle = new GeoStyle();
                pointStyle.LineColor  = Color.DarkGray;
                pointStyle.MarkerSize = new Size2D(2.5, 2.5);
                pointSetting.Style    = pointStyle;

                // 调整mapControl的状态
                // Adjust the status of mapControl
                m_mapControl.Action = SuperMap.UI.Action.Select;
                m_mapControl.IsWaitCursorEnabled = false;
                m_mapControl.Map.Refresh();
                m_mapControl.MouseDown += new MouseEventHandler(m_mapControl_MouseDown);
                m_mapControl.MouseMove += new MouseEventHandler(m_mapControl_MouseMove);

                // 加载模型
                // Add model
                Load();
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 构造分段专题图并添加分段专题图图层
        /// Initialize the theme and add the theme layer to the map
        /// </summary>
        public void AddThemeRangeLayer()
        {
            try
            {
                // 构造分段专题图对象并设置分段字段表达式
                // Initialize the theme of range and set the range expression
                ThemeRange themeRange = new ThemeRange();
                themeRange.RangeExpression = "UrbanRural";

                GeoStyle style = new GeoStyle();
                style.LineColor = Color.White;
                style.LineWidth = 0.3;
                // 初始化分段专题图子项并设置各自的风格
                // Initialize the theme items and set them styles
                ThemeRangeItem item0 = new ThemeRangeItem();
                item0.Start         = double.MinValue;
                item0.End           = 50;
                style.FillForeColor = Color.FromArgb(209, 182, 210);
                item0.Style         = style;

                ThemeRangeItem item1 = new ThemeRangeItem();
                item1.Start         = 50;
                item1.End           = 60;
                style.FillForeColor = Color.FromArgb(205, 167, 183);
                item1.Style         = style;

                ThemeRangeItem item2 = new ThemeRangeItem();
                item2.Start         = 60;
                item2.End           = 70;
                style.FillForeColor = Color.FromArgb(183, 128, 151);
                item2.Style         = style;

                ThemeRangeItem item3 = new ThemeRangeItem();
                item3.Start         = 70;
                item3.End           = 90;
                style.FillForeColor = Color.FromArgb(164, 97, 136);
                item3.Style         = style;
                // 将分段专题图子项依次添加到分段专题图
                // Add the items to the theme of range
                themeRange.AddToHead(item0);
                themeRange.AddToTail(item1);
                themeRange.AddToTail(item2);
                themeRange.AddToTail(item3);
                // 添加分段专题图层
                // Add the theme layer to the map
                Layers layers = m_mapControl.Map.Layers;
                Int32  index  = layers.IndexOf(m_dataset.Name + "@" + m_datasource.Alias);
                m_layer          = layers.Insert(index, m_dataset, themeRange);
                m_themeLayerName = m_layer.Name;

                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 对象选择事件。
        /// GeometrySelectedEvent
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void m_mapControl_GeometrySelected(Object sender, SuperMap.UI.GeometrySelectedEventArgs e)
        {
            if (m_selectMode != SelectMode.SelectBarrier)
            {
                return;
            }
            Selection selection = m_layerPoint.Selection;

            if (selection.Count <= 0)
            {
                selection = m_layerLine.Selection;
            }
            GeoStyle style = new GeoStyle();

            style.LineColor = Color.Red;
            Recordset recordset = selection.ToRecordset();

            try
            {
                Geometry geometry = recordset.GetGeometry();

                // 捕捉到点时,将捕捉到的点添加到障碍点列表中
                // If a point is snapped, the point is added to the barrier list
                if (geometry.Type == GeometryType.GeoPoint)
                {
                    GeoPoint geoPoint = (GeoPoint)geometry;
                    int      id       = recordset.GetID();
                    m_barrierNodes.Add(id);
                    style.MarkerSize = new Size2D(4, 4);
                    geoPoint.Style   = style;
                    m_trackingLayer.Add(geoPoint, "barrierNode");
                }

                // 捕捉到线时,将线对象添加到障碍线列表中
                // If a line is snapped, the line is added to the barrier list
                if (geometry.Type == GeometryType.GeoLine)
                {
                    GeoLine geoLine = (GeoLine)geometry;
                    int     id      = recordset.GetID();
                    m_barrierEdges.Add(id);

                    style.LineWidth = 0.6;
                    geoLine.Style   = style;
                    m_trackingLayer.Add(geoLine, "barrierEdge");
                }
                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            finally
            {
                recordset.Dispose();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 打开需要的工作空间,加载数据到地图上
        /// Open the workspace and add data to the map
        /// </summary>
        private void Initialize()
        {
            try
            {
                // 打开工作空间
                // Open the workspace
                String filePath = @"..\..\..\..\DATA\City\Changchun.smwu";
                WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(filePath);
                info.Type = WorkspaceType.SMWU;
                m_workspace.Open(info);

                // 加载底图
                // Load the base map
                if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                {
                    m_mapControl.Map.Open("ChangChunCityMap");
                }
                else
                {
                    m_mapControl.Map.Open("长春市区图");
                }
                // 获取公交线路(BusLine)、站点(BusStop)和网络数据集
                // Get BusLine, BusStop and network dataset
                m_datasource     = m_workspace.Datasources["changchun"];
                m_datasetLine    = m_datasource.Datasets["BusLine"] as DatasetVector;
                m_datasetStop    = m_datasource.Datasets["BusPoint"] as DatasetVector;
                m_datasetNetwork = m_datasource.Datasets["RoadNet"] as DatasetVector;

                // 底图中有线路数据集的图层,因此不再添加
                // 为突出显示站点,将站点添加到地图上并设置风格
                // The base map has a path dataset
                // Add stops the map and set their style
                m_layerStop = m_mapControl.Map.Layers.Add(m_datasetStop, true);
                m_layerStop.IsSelectable = true;

                // 设置站点数据集的图层风格
                // Set the layer style for the stops
                LayerSettingVector stopSetting = new LayerSettingVector();
                GeoStyle           stopStyle   = new GeoStyle();
                stopStyle.LineColor           = Color.FromArgb(170, 0, 192);
                stopStyle.MarkerSize          = new Size2D(4, 4);
                stopSetting.Style             = stopStyle;
                m_layerStop.AdditionalSetting = stopSetting;

                m_mapControl.Map.IsAntialias = true;
                m_mapControl.Map.Refresh();

                // 设置跟踪图层
                // Set the tracking layer
                m_trackingLayer = m_mapControl.Map.TrackingLayer;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 打开需要的工作空间文件及地图
        /// </summary>
        private void Initialize()
        {
            try
            {
                //初始化点线面
                m_point = new GeoPoint(25, 25);

                Point2Ds point2DsLine = new Point2Ds();
                point2DsLine.Add(new Point2D(5, 35));
                point2DsLine.Add(new Point2D(65, 35));
                m_line = new GeoLine(point2DsLine);

                Point2Ds point2DsRegion = new Point2Ds();
                point2DsRegion.Add(new Point2D(5, 5));
                point2DsRegion.Add(new Point2D(5, 69));
                point2DsRegion.Add(new Point2D(69, 69));
                point2DsRegion.Add(new Point2D(69, 5));
                m_region = new GeoRegion(point2DsRegion);
                //初始化点线面符号的风格
                m_markerGeoStyle            = new GeoStyle();
                m_markerGeoStyle.LineColor  = Color.Blue;
                m_markerGeoStyle.MarkerSize = new Size2D(12, 12);
                m_point.Style = m_markerGeoStyle;

                m_lineGeoStyle           = new GeoStyle();
                m_lineGeoStyle.LineColor = Color.Blue;
                m_lineGeoStyle.LineWidth = 0.5;
                m_line.Style             = m_lineGeoStyle;

                m_fillGeoStyle = new GeoStyle();
                m_fillGeoStyle.FillForeColor  = Color.Blue;
                m_fillGeoStyle.FillBackOpaque = false;
                m_region.Style = m_fillGeoStyle;

                // 得到点线面的RootGroup
                Resources     resources           = m_workspace.Resources;
                SymbolLibrary symbolMarkerLibrary = resources.MarkerLibrary;
                m_symbolMarkerRootGroup = symbolMarkerLibrary.RootGroup;

                SetTreeGroup(m_symbolMarkerRootGroup);

                SymbolLibrary symbolLineLibrary = resources.LineLibrary;
                m_symbolLineRootGroup = symbolLineLibrary.RootGroup;

                SymbolLibrary symbolFillLibrary = resources.FillLibrary;
                m_symbolFillRootGroup = symbolFillLibrary.RootGroup;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 /// <summary>
 /// 设置图层的一些属性
 /// Set the properties of the layer
 /// </summary>
 private void SetLayerStyle(Layer layer, Color color, Double width)
 {
     try
     {
         LayerSettingVector layerSetting = new LayerSettingVector();
         GeoStyle           style        = new GeoStyle();
         style.FillForeColor     = Color.SkyBlue;
         style.LineColor         = color;
         style.LineWidth         = width;
         layerSetting.Style      = style;
         layer.AdditionalSetting = layerSetting;
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
Esempio n. 14
0
        /// <summary>
        /// 显示结果。
        /// Show result
        /// </summary>
        public void ShowResult()
        {
            try
            {
                // 删除原有结果
                // Delete the original result
                int count = m_trackingLayer.Count;
                for (int i = 0; i < count; i++)
                {
                    int index = m_trackingLayer.IndexOf("result");
                    if (index != -1)
                    {
                        m_trackingLayer.Remove(index);
                    }
                }

                // 填充路由列表
                // Fill the routing table
                for (int i = 0; i < m_result.Routes.Length; i++)
                {
                    GeoLineM geoLineM = m_result.Routes[i];
                    GeoStyle style    = new GeoStyle();
                    style.LineColor = Color.Blue;
                    style.LineWidth = 0.8;
                    geoLineM.Style  = style;
                    m_trackingLayer.Add(geoLineM, "result");
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        m_comboBoxRoutes.Items.Add("The" + (i + 1) + "th path");
                    }
                    else
                    {
                        m_comboBoxRoutes.Items.Add("第" + (i + 1) + "条路径");
                    }
                }
                m_comboBoxRoutes.SelectedIndex = 0;
                SelectRoute(0);
                m_mapControl.Map.ViewEntire();
                m_mapControl.Map.Refresh();
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 是否按照自定义风格显示
        /// </summary>
        /// <param name="isCustom"></param>
        public void ShowCustomStyle(Boolean isCustom)
        {
            try
            {
                Map       map       = mapControl1.Map;
                Selection selection = map.Layers[0].Selection;

                selection.SetStyleOptions(StyleOptions.FillBackColor, true);
                selection.SetStyleOptions(StyleOptions.FillBackOpaque, true);
                selection.SetStyleOptions(StyleOptions.FillForeColor, true);
                selection.SetStyleOptions(StyleOptions.FillGradientAngle, true);
                selection.SetStyleOptions(StyleOptions.FillGradientMode, true);
                selection.SetStyleOptions(StyleOptions.FillGradientOffsetRatioX, true);
                selection.SetStyleOptions(StyleOptions.FillGradientOffsetRatioY, true);
                selection.SetStyleOptions(StyleOptions.FillOpaqueRate, true);
                selection.SetStyleOptions(StyleOptions.FillSymbolID, true);
                selection.SetStyleOptions(StyleOptions.LineColor, true);
                selection.SetStyleOptions(StyleOptions.LineSymbolID, true);
                selection.SetStyleOptions(StyleOptions.LineWidth, true);
                selection.SetStyleOptions(StyleOptions.MarkerAngle, true);
                selection.SetStyleOptions(StyleOptions.MarkerSize, true);
                selection.SetStyleOptions(StyleOptions.MarkerSymbolID, true);

                selection.IsDefaultStyleEnabled = !isCustom;

                GeoStyle geoStyle = selection.Style;
                if (isCustom)
                {
                    geoStyle.FillForeColor  = Color.Yellow;
                    geoStyle.FillBackOpaque = false;
                    geoStyle.FillBackColor  = Color.Blue;
                    geoStyle.FillSymbolID   = 0;
                    geoStyle.FillOpaqueRate = 25;
                    geoStyle.LineColor      = Color.Red;
                    geoStyle.LineWidth      = 1.0;
                }

                map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 添加配送目的地。
        /// Add it to the destination
        /// </summary>
        public void AddTarget(Point2D mapPoint)
        {
            try
            {
                // 在跟踪图层上添加点
                // Add points on the tracking layer
                m_targets.Add(mapPoint);
                GeoPoint geoPoint = new GeoPoint(mapPoint);
                GeoStyle style    = new GeoStyle();
                style.LineColor  = Color.FromArgb(252, 144, 0);
                style.MarkerSize = new Size2D(6, 6);
                geoPoint.Style   = style;
                m_trackingLayer.Add(geoPoint, "Target");

                // 在跟踪图层上添加文本对象
                // Add text objects on the tracking layer
                TextPart part = new TextPart();
                part.X = geoPoint.X;
                part.Y = geoPoint.Y;
                if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                {
                    part.Text = "Destination" + m_targetCount.ToString();
                }
                else
                {
                    part.Text = "目的地" + m_targetCount.ToString();
                }
                m_targetCount++;
                GeoText   text      = new GeoText(part);
                TextStyle textStyle = new TextStyle();
                textStyle.FontName   = "微软雅黑";
                textStyle.FontHeight = 4;
                textStyle.ForeColor  = Color.Black;
                textStyle.Bold       = true;
                text.TextStyle       = textStyle;
                m_trackingLayer.Add(text, "text");
                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 添加配送中心点。
        /// Add it to the center
        /// </summary>
        public void AddCenter(Point2D mapPoint)
        {
            try
            {
                m_centers.Add(mapPoint);

                GeoPoint geoPoint = new GeoPoint(mapPoint);
                GeoStyle style    = new GeoStyle();
                style.LineColor  = Color.Green;
                style.MarkerSize = new Size2D(6, 6);
                geoPoint.Style   = style;
                m_trackingLayer.Add(geoPoint, "center");

                TextPart part = new TextPart();
                part.X = geoPoint.X;
                part.Y = geoPoint.Y;
                if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                {
                    part.Text = "Center" + m_centerCount.ToString();
                }
                else
                {
                    part.Text = "中心点" + m_centerCount.ToString();
                }
                m_centerCount++;
                GeoText   text      = new GeoText(part);
                TextStyle textStyle = new TextStyle();
                textStyle.FontName   = "微软雅黑";
                textStyle.FontHeight = 4;
                textStyle.ForeColor  = Color.Black;
                textStyle.Bold       = true;
                text.TextStyle       = textStyle;
                m_trackingLayer.Add(text, "text");
                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 按照指定风格显示矩形框
        /// </summary>
        /// <param name="rectDisplay"></param>
        private void DisplayRect(Rectangle2D rectangleDisplay)
        {
            try
            {
                m_engleRectangle = rectangleDisplay;

                Double rectangleWidth  = rectangleDisplay.Width;
                Double rectangleHeight = rectangleDisplay.Height;
                Double pntLeftTopX     = rectangleDisplay.Left;
                Double pntLeftTopY     = rectangleDisplay.Top;
                //设置图框四点坐标
                Point2Ds points = new Point2Ds();

                Point2D pntLeftTop = new Point2D(pntLeftTopX, pntLeftTopY);
                points.Add(pntLeftTop);
                Point2D pntLeftBottom = new Point2D(pntLeftTopX, pntLeftTopY - rectangleHeight);
                points.Add(pntLeftBottom);
                Point2D pntRightBottom = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY - rectangleHeight);
                points.Add(pntRightBottom);
                Point2D pntRightTop = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY);
                points.Add(pntRightTop);
                points.Add(pntLeftTop);
                //将点连成线,并设置样式

                GeoLine rectangleBoundary = new GeoLine();
                rectangleBoundary.AddPart(points);

                GeoStyle rectangleStyle = new GeoStyle();
                rectangleStyle.LineColor = Color.FromArgb(255, 0, 0);
                rectangleStyle.LineWidth = 0.5;

                rectangleBoundary.Style = rectangleStyle;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 19
0
 private void timer_Blink_Tick(object sender, EventArgs e)
 {
     if (_blinkCount > 3)
     {
         _currentMapCtl.Map.TrackingLayer.Clear();
         _currentMapCtl.Map.RefreshTrackingLayer();
         _blinkCount = 0;
         timer_Blink.Stop();
         _blinkRs.Close();
         _blinkRs.Dispose();
     }
     else
     {
         if (_isBlink)
         {
             _blinkRs.MoveFirst();
             while (!_blinkRs.IsEOF)
             {
                 var geo        = _blinkRs.GetGeometry();
                 var blinkStyle = new GeoStyle
                 {
                     FillForeColor = Color.Red, FillOpaqueRate = 60, LineColor = Color.Red, LineWidth = 2, MarkerSize = new Size2D(10, 10)
                 };
                 geo.Style = blinkStyle;
                 _currentMapCtl.Map.TrackingLayer.Add(geo, "blink");
                 _currentMapCtl.Map.RefreshTrackingLayer();
                 _blinkRs.MoveNext();
             }
             _blinkCount++;
         }
         else
         {
             _currentMapCtl.Map.TrackingLayer.Clear();
             _currentMapCtl.Map.RefreshTrackingLayer();
         }
     }
     _isBlink = !_isBlink;
 }
Esempio n. 20
0
        private void DisplayRect(Rectangle2D rectangleDisplay)
        {
            try
            {
                m_engleRectangle            = rectangleDisplay;
                m_mapControlEagleEye.Cursor = Cursors.Cross;

                Double   rectangleWidth  = rectangleDisplay.Width;
                Double   rectangleHeight = rectangleDisplay.Height;
                Double   pntLeftTopX     = rectangleDisplay.Left;
                Double   pntLeftTopY     = rectangleDisplay.Top;
                Point2Ds points          = new Point2Ds();
                Point2D  pntLeftTop      = new Point2D(pntLeftTopX, pntLeftTopY);
                points.Add(pntLeftTop);
                Point2D pntLeftBottom = new Point2D(pntLeftTopX, pntLeftTopY - rectangleHeight);
                points.Add(pntLeftBottom);
                Point2D pntRightBottom = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY - rectangleHeight);
                points.Add(pntRightBottom);
                Point2D pntRightTop = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY);
                points.Add(pntRightTop);
                points.Add(pntLeftTop);
                GeoLine rectangleBoundary = new GeoLine();
                rectangleBoundary.AddPart(points);

                GeoStyle rectangleStyle = new GeoStyle();
                rectangleStyle.LineColor = Color.FromArgb(255, 0, 0);
                rectangleStyle.LineWidth = 0.5;

                rectangleBoundary.Style = rectangleStyle;
                m_mapControlEagleEye.Map.TrackingLayer.Clear();
                m_mapControlEagleEye.Map.TrackingLayer.Add((Geometry)rectangleBoundary, "");
                m_mapControlEagleEye.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 打开需要的工作空间文件及事件注册
        /// </summary>
        private void Initialize()
        {
            try
            {
                //打开工作空间及地图
                WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(mFilePath);
                mWorkspace.Open(conInfo);
                //创建数据集
                CreateDatasets();
                //禁用鼠标等待
                mMapControl.IsWaitCursorEnabled = false;          //当前窗口的等待光标是否有效
                mMapControl.TrackMode           = TrackMode.Edit; //TrackMode.Edit在图层中创建一个新对象
                //该枚举定义了绘制方式类型常量。用来定义地图控件中绘制对象时,是在图层中创建一个新对象还是在内存中创建一个新对象,或者是在CAD图层中绘制地图几何对象(GeoMap)。

                //获得默认的对象风格
                mDefaultSetting = new LayerSettingVector();   //构造矢量图层设置新实例
                GeoStyle defaultStyle = new GeoStyle();       //构造 几何风格 对象
                defaultStyle.LineColor = Color.Green;         //颜色
                defaultStyle.LineWidth = 0.3;                 //宽度
                mDefaultSetting.Style  = defaultStyle;        //设置矢量图层的风格 为 defaultStyle
                //初始化背景图片显示时对象的风格
                mBackgroudSetting = new LayerSettingVector(); //
                GeoStyle backgroudStyle = new GeoStyle();
                backgroudStyle.FillForeColor = Color.PaleGreen;;
                backgroudStyle.LineColor     = Color.Red;
                backgroudStyle.LineWidth     = 0.3;
                mBackgroudSetting.Style      = backgroudStyle;

                mMapControl.Tracked += new TrackedEventHandler(m_mapControl_Tracked); //在地图窗口中绘制几何对象 结束后发生

                DrawPoint();                                                          //绘制点
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 22
0
        public MapControlWnd(Workspace workspace, MapControl mapcontrol)
        {
            m_workspace  = workspace;
            m_MapControl = mapcontrol;

            InitializeComponent();

            // 调整mapControl的状态
            m_MapControl.Action = SuperMap.UI.Action.Pan;

            m_MapControl.MouseDown        += new MouseEventHandler(map_MouseDown);
            m_MapControl.GeometrySelected += new SuperMap.UI.GeometrySelectedEventHandler(m_mapControl_GeometrySelected);
            //m_MapControl.Paint += new PaintEventHandler(m_mapControl_Paint);
            //m_MapControl.Click += new EventHandler(map_Click);

            pStyle           = new GeoStyle();
            pStyle.LineColor = System.Drawing.Color.Red;
            pStyle.LineWidth = 2;

            //设置跟踪层图标大小
            size        = new Size2D();
            size.Height = 10;
            size.Width  = 10;
        }
Esempio n. 23
0
        /// <summary>
        /// 进行行驶导引。
        /// Path guide
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_timer_Tick(object sender, EventArgs e)
        {
            try
            {
                int index = m_trackingLayer.IndexOf("playPoint");
                if (index != -1)
                {
                    m_trackingLayer.Remove(index);
                }

                GeoLineM lineM  = m_result.Routes[0];
                PointM   pointM = lineM.GetPart(0)[m_count];

                // 构造模拟对象
                // Build simulation object
                GeoPoint point = new GeoPoint(pointM.X, pointM.Y);
                GeoStyle style = new GeoStyle();
                style.LineColor  = Color.Red;
                style.MarkerSize = new Size2D(5, 5);
                point.Style      = style;
                m_trackingLayer.Add(point, "playPoint");

                // 跟踪对象
                // Tracking object
                m_count++;
                if (m_count >= lineM.GetPart(0).Count)
                {
                    m_count = 0;
                }
                m_mapControl.Map.RefreshTrackingLayer();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 24
0
 private void timer_Blink_Tick(object sender, EventArgs e)
 {
     if(_blinkCount>3)
     {
         _currentMapCtl.Map.TrackingLayer.Clear();
         _currentMapCtl.Map.RefreshTrackingLayer();
         _blinkCount = 0;
         timer_Blink.Stop();
         _blinkRs.Close();
         _blinkRs.Dispose();
     }
     else
     {
         if(_isBlink)
         {
             _blinkRs.MoveFirst();
             while (!_blinkRs.IsEOF)
             {
                 var geo = _blinkRs.GetGeometry();
                 var blinkStyle = new GeoStyle
                                      {FillForeColor = Color.Red,FillOpaqueRate = 60, LineColor = Color.Red,LineWidth = 2,MarkerSize = new Size2D(10,10)};
                 geo.Style = blinkStyle;
                 _currentMapCtl.Map.TrackingLayer.Add(geo,"blink");
                 _currentMapCtl.Map.RefreshTrackingLayer();
                 _blinkRs.MoveNext();
             }
             _blinkCount++;
         }
         else
         {
             _currentMapCtl.Map.TrackingLayer.Clear();
             _currentMapCtl.Map.RefreshTrackingLayer();
         }
     }
     _isBlink = !_isBlink;
 }
Esempio n. 25
0
        /// <summary>
        /// 在地图上显示换乘的图形导引,在DataGridView中显示详细信息
        /// Display the graphical guide on the map. And display the details on DataGridView
        /// </summary>
        public void ShowReslut()
        {
            if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
            {
                m_dataGridView.Columns[1].HeaderText = "Guilde";
                m_dataGridView.Columns[2].HeaderText = "Distance";
                m_dataGridView.Columns[3].HeaderText = "Cost";
            }
            else
            {
                m_dataGridView.Columns[1].HeaderText = "导引";
                m_dataGridView.Columns[2].HeaderText = "距离";
                m_dataGridView.Columns[3].HeaderText = "费用";
            }
            // 删除跟踪图层上除起始、终止站点及其名称外的几何对象
            // Delete objects on the tracking layer except the start and end stop
            for (Int32 i = m_trackingLayer.Count - 1; i >= 0; i--)
            {
                String tag = m_trackingLayer.GetTag(i);
                if (tag != "StartStop" && tag != "EndStop" && tag != "StartStopName" && tag != "EndStopName")
                {
                    m_trackingLayer.Remove(i);
                }
            }
            m_mapControl.Map.RefreshTrackingLayer();

            TransferSolution solution = null;

            if (m_comboGuide.SelectedIndex == -1)
            {
                solution = m_solutions[0];
            }
            else
            {
                solution = m_solutions[m_comboGuide.SelectedIndex];
            }

            // 提取换乘方案中的第一条换乘路线,即每段乘车段集合中的第一段乘车路线的组合对应的完整路线
            // Extract the first transfer path
            TransferLine[] linesOnOne = new TransferLine[solution.TransferTime + 1];
            for (int j = 0; j < solution.TransferTime + 1; j++)
            {
                linesOnOne[j] = solution[j][0];
            }
            // 获取换乘导引
            // gat the transfer guide
            TransferGuide transferGuide = m_transferAnalyst.GetDetailInfo(m_startStopID, m_endStopID, linesOnOne);

            // 从换乘导引中提取详细的导引信息
            // Extract the details from transfer guide
            if (transferGuide != null)
            {
                for (Int32 i = 0; i < transferGuide.Count; i++)
                {
                    TransferGuideItem item = transferGuide[i];
                    // 获取换乘导引子项的路径对象
                    // Get the path objects of the guide items
                    GeoLine  path  = item.Route;
                    GeoStyle style = new GeoStyle();
                    if (item.IsWalking)
                    {
                        style.LineColor    = Color.FromArgb(255, 87, 87);
                        style.LineWidth    = 0.6;
                        style.LineSymbolID = 12;
                    }
                    else
                    {
                        style.LineColor = Color.Blue;
                        style.LineWidth = 1.0;
                    }

                    path.Style = style;

                    // 在跟踪层上绘制每个换乘导引子项的路径对象
                    // Draw the path object of transfer guide item on the tracking layer
                    m_trackingLayer.Add(path, "Path");

                    // 绘制中间站点
                    // Draw mid-stops
                    GeoPoint transferStop = new GeoPoint(item.StartPosition.X, item.StartPosition.Y);
                    transferStop.Style = GetStopStyle(new Size2D(5, 5), Color.FromArgb(87, 255, 255));

                    GeoText  transferStopName = new GeoText();
                    TextPart part             = new TextPart(item.StartName, new Point2D(transferStop.X, transferStop.Y));
                    transferStopName.AddPart(part);
                    transferStopName.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(89, 89, 89));
                    if (i != 0)
                    {
                        m_trackingLayer.Add(transferStop, "transferStop");
                    }
                    m_trackingLayer.Add(transferStopName, "transferStopName");

                    transferStop       = new GeoPoint(item.EndPosition.X, item.EndPosition.Y);
                    transferStop.Style = GetStopStyle(new Size2D(5, 5), Color.FromArgb(87, 255, 255));

                    transferStopName = new GeoText();
                    part             = new TextPart(item.EndName, new Point2D(transferStop.X, transferStop.Y));
                    transferStopName.AddPart(part);
                    transferStopName.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(89, 89, 89));
                    if (i != transferGuide.Count - 1)
                    {
                        m_trackingLayer.Add(transferStop, "transferStop");
                    }
                    m_trackingLayer.Add(transferStopName, "transferStopName");

                    m_mapControl.Map.RefreshTrackingLayer();
                }
                m_mapControl.Map.RefreshTrackingLayer();

                // 添加信息到DataGridView
                // Add information to DataGridView
                FillGuidesInfo(transferGuide);
            }
            else
            {
                if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                {
                    MessageBox.Show("Sorry! There is no proper transfer line!");
                }
                else
                {
                    MessageBox.Show("抱歉!公交方案详细信息提取出错!");
                }
            }
        }
Esempio n. 26
0
        /// <summary>
        /// 根据线路查询站点
        /// Query stop by the path
        /// </summary>
        /// <param name="lineID"></param>
        public void FindStopsByLine(Int64 lineID)
        {
            try
            {
                if (m_isLoad)
                {
                    m_comboGuide.Items.Clear();
                    m_dataGridView.Rows.Clear();
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        m_dataGridView.Columns[1].HeaderText = "Stop ID";
                        m_dataGridView.Columns[2].HeaderText = "Name";
                    }
                    else
                    {
                        m_dataGridView.Columns[1].HeaderText = "站点ID";
                        m_dataGridView.Columns[2].HeaderText = "名称";
                    }
                    m_dataGridView.Columns[3].HeaderText = "----";

                    // 清除跟踪层上的对象
                    // Clear object on the tracking layer
                    m_trackingLayer.Clear();
                    m_mapControl.Map.RefreshTrackingLayer();

                    // 查询经过指定站点的线路
                    // Query the path by stops
                    StopInfo[] stopInfos = m_transferAnalyst.FindStopsByLine(lineID);
                    if (stopInfos.Length > 0)
                    {
                        // 将该线路添加到跟踪层上显示
                        // Add the path to the tracking layer
                        LineInfo[] lineInfos = m_transferAnalyst.FindLinesByStop(stopInfos[0].StopID);
                        for (Int32 i = 0; i < lineInfos.Length; i++)
                        {
                            if (lineInfos[i].LineID == lineID)
                            {
                                GeoLine line = lineInfos[i].TotalLine;
                                m_mapControl.Map.CustomBounds          = line.Bounds;
                                m_mapControl.Map.IsCustomBoundsEnabled = true;
                                m_mapControl.Map.ViewEntire();

                                GeoStyle style = new GeoStyle();
                                style.LineColor = Color.DeepSkyBlue;
                                style.LineWidth = 1.0;
                                line.Style      = style;
                                m_trackingLayer.Add(line, "Line");
                                break;
                            }
                        }
                        // 添加站点信息
                        // Add the stops
                        for (Int32 j = 0; j < stopInfos.Length; j++)
                        {
                            // 将线路信息添加到DataGridView中
                            // Add the line information to DataGridView
                            Object[] values = new Object[4];
                            values[0] = j + 1;
                            values[1] = stopInfos[j].StopID;
                            values[2] = stopInfos[j].Name;
                            values[3] = "----";
                            m_dataGridView.Rows.Add(values);

                            // 在跟踪图层中绘制查询出的站点及其名称
                            // Draw stops and names on the tracking layer
                            Point2D  point2D = stopInfos[j].Position;
                            GeoPoint point   = new GeoPoint(point2D);
                            point.Style = GetStopStyle(new Size2D(5, 5), Color.Orange);
                            m_trackingLayer.Add(point, "Stops");

                            GeoText  geoText = new GeoText();
                            TextPart part    = new TextPart(stopInfos[j].Name, point2D);
                            geoText.AddPart(part);
                            geoText.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(153, 0, 255));
                            m_trackingLayer.Add(geoText, "StopNames");
                        }
                        m_mapControl.Map.RefreshTrackingLayer();
                    }
                }
                else
                {
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        MessageBox.Show("Sorry! There is no stop on this path!");
                    }
                    else
                    {
                        MessageBox.Show("抱歉!没有查找到该线路上的站点!");
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// 根据站点查询线路
        /// Query the path by stops
        /// </summary>
        public void FindLinesByStop(Int64 stopID)
        {
            try
            {
                if (m_isLoad)
                {
                    m_comboGuide.Items.Clear();
                    m_comboGuide.Text = "";
                    m_dataGridView.Rows.Clear();
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        m_dataGridView.Columns[1].HeaderText = "Path ID";
                        m_dataGridView.Columns[2].HeaderText = "Name";
                        m_dataGridView.Columns[3].HeaderText = "Length";
                    }
                    else
                    {
                        m_dataGridView.Columns[1].HeaderText = "线路ID";
                        m_dataGridView.Columns[2].HeaderText = "名称";
                        m_dataGridView.Columns[3].HeaderText = "总长度";
                    }

                    // 清除跟踪层上已有的线路
                    // Clear items of tracking layer
                    for (Int32 i = m_trackingLayer.Count - 1; i >= 0; i--)
                    {
                        if (m_trackingLayer.GetTag(i) != "StartStop" && m_trackingLayer.GetTag(i) != "StartStopName")
                        {
                            m_trackingLayer.Remove(i);
                        }
                    }
                    m_mapControl.Map.RefreshTrackingLayer();

                    // 查询经过指定站点的线路
                    // Query the path by stops
                    LineInfo[] lineInfos = m_transferAnalyst.FindLinesByStop(stopID);
                    if (lineInfos.Length > 0)
                    {
                        for (Int32 i = 0; i < lineInfos.Length; i++)
                        {
                            // 将线路信息添加到DataGridView中
                            // Add the line information to the DataGridView
                            Object[] values = new Object[4];
                            values[0] = i + 1;
                            values[1] = lineInfos[i].LineID;
                            values[2] = lineInfos[i].Name;
                            values[3] = lineInfos[i].TotalDistance;
                            m_dataGridView.Rows.Add(values);

                            // 在跟踪图层中绘制查询出的线路
                            // Draw the path on the tracking layer
                            GeoLine  line  = lineInfos[i].TotalLine;
                            GeoStyle Style = new GeoStyle();
                            Style.LineColor = GetRandomColor();
                            Style.LineWidth = 1.0;
                            line.Style      = Style;
                            m_trackingLayer.Add(line, "lines");
                        }
                        m_mapControl.Map.RefreshTrackingLayer();
                        m_mapControl.Map.IsCustomBoundsEnabled = true;
                        m_mapControl.Map.CustomBounds          = m_datasetLine.Bounds;
                        m_mapControl.Map.ViewEntire();
                    }
                }
                else
                {
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        MessageBox.Show("Sorry! There is no path that goes through this stop!");
                    }
                    else
                    {
                        MessageBox.Show("抱歉!没有查找到经过该站点的线路!");
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// 添加分析经过点。
        /// Add points
        /// </summary>
        /// <param name="geometry"></param>
        public void AddPoint(Geometry geometry)
        {
            try
            {
                // 在跟踪图层上添加点
                // Add points on the tracking layer
                GeoPoint geoPoint = new GeoPoint();
                if (geometry.Type == GeometryType.GeoPoint)
                {
                    geoPoint = (GeoPoint)geometry;
                }
                else
                {
                    geoPoint = new GeoPoint(((GeoLine)geometry).InnerPoint);
                }
                GeoStyle style = new GeoStyle();
                if (m_selectFacilityNode)
                {
                    style.MarkerSize = new Size2D(10, 10);
                    style.LineColor  = Color.LightGreen;
                    geoPoint.Style   = style;
                    int id = m_recordset.GetID();
                    if (geometry.Type == GeometryType.GeoPoint)
                    {
                        m_nodesList.Add(m_recordset.GetID());
                        m_trackingLayer.Add(geoPoint, "FacilityNode" + id);
                    }
                }
                else if (m_selectBarrier)
                {
                    style.LineColor      = Color.Red;
                    style.MarkerSymbolID = 8622;
                    style.MarkerSize     = new Size2D(10, 10);
                    geoPoint.Style       = style;

                    // 构造障碍点
                    // Build barriers
                    Int32 id = m_recordset.GetID();
                    if (geometry.Type == GeometryType.GeoPoint)
                    {
                        m_barrierNodes.Add(m_recordset.GetID());
                        m_trackingLayer.Add(geoPoint, "barrierNode" + id);
                    }
                    else
                    {
                        m_barrierEdges.Add(m_recordset.GetID());
                        m_trackingLayer.Add(geoPoint, "barrierEdge" + id);
                    }

                    m_mapControl.Map.Refresh();
                }
                else if (m_selectEventNode)
                {
                    style.MarkerSize = new Size2D(10, 10);
                    style.LineColor  = Color.Orange;
                    geoPoint.Style   = style;
                    m_eventNode      = m_recordset.GetID();
                    if (geometry.Type == GeometryType.GeoPoint)
                    {
                        int index = m_trackingLayer.IndexOf("EventNode");
                        if (index != -1)
                        {
                            m_trackingLayer.Remove(index);
                            m_mapControl.Map.Refresh();
                        }
                        m_trackingLayer.Add(geoPoint, "EventNode");
                    }
                    else
                    {
                        int index = m_trackingLayer.IndexOf("EventNode");
                        if (index != -1)
                        {
                            m_trackingLayer.Remove(index);
                            m_mapControl.Map.Refresh();
                        }
                        m_eventNode = -1;
                        if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                        {
                            MessageBox.Show("Failed. Reselect, please.");
                        }
                        else
                        {
                            MessageBox.Show("选择失败,请重新选择。");
                        }
                    }
                }
                geoPoint.Style = style;

                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 29
0
        public void setThemeGraphBar3DVisible(Workspace workspaceN)
        {
            Workspace wp = workspaceN;

            m_layerThemeGraphBar3D = null;
            try
            {
                if (m_layerThemeGraphBar3D == null)
                {
                    m_datasetVector = wp.Datasources[0].Datasets["盘锦行政区划"] as DatasetVector;
                    //构造统计专题图
                    ThemeGraph graphBar3D = new ThemeGraph();

                    //初始化子项,及子项的风格
                    GeoStyle geoStyle = new GeoStyle();
                    geoStyle.LineWidth        = 0.1;
                    geoStyle.FillGradientMode = FillGradientMode.Linear;

                    ThemeGraphItem item0 = new ThemeGraphItem();
                    item0.GraphExpression  = dilei + "00";
                    geoStyle.FillForeColor = Color.FromArgb(231, 154, 0);
                    item0.UniformStyle     = geoStyle;

                    ThemeGraphItem item1 = new ThemeGraphItem();
                    item1.GraphExpression  = dilei + "09";
                    geoStyle.FillForeColor = Color.FromArgb(70, 153, 255);
                    item1.UniformStyle     = geoStyle;



                    //添加子项
                    graphBar3D.Add(item0);
                    graphBar3D.Add(item1);


                    //设置偏移量,和非固定偏移,即随图偏移
                    //graphBar3D.IsOffsetFixed = false;
                    //graphBar3D.OffsetY = "13000";

                    ////设置非流动显示
                    //graphBar3D.IsFlowEnabled = false;

                    ////设置非避让方式显示
                    //graphBar3D.IsOverlapAvoided = false;

                    ////设置统计图显示的最大值和最小值,和非固定大小,即随图缩放
                    //graphBar3D.MaxGraphSize = 10000000.0000;
                    //graphBar3D.MinGraphSize = 0.0000;

                    ////显示统计图文本,并设置文本显示模式
                    //graphBar3D.IsGraphTextDisplayed = true;
                    //graphBar3D.GraphTextFormat = ThemeGraphTextFormat.Value;

                    //设置统计图类型
                    graphBar3D.GraphType = ThemeGraphType.Bar3D;

                    TextStyle textStyle = graphBar3D.GraphTextStyle;
                    textStyle.IsSizeFixed = false;
                    textStyle.FontHeight  = 10000;

                    //添加三维柱状统计图图层
                    m_layerThemeGraphBar3D = mapControl1.Map.Layers.Add(m_datasetVector, graphBar3D, true);
                }

                //设置图层是否可显示,并刷新地图
                m_layerThemeGraphBar3D.IsVisible = true;
                mapControl1.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 30
0
        private void 图例ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutElements layoutElements = mapLayoutControl1.MapLayout.Elements;

            layoutElements.SeekID(GetMapID());

            GeoMap geoMapUse = (GeoMap)layoutElements.GetGeometry();

            string geoMapName = geoMapUse.MapName;

            GeoLegend geoLegend = new GeoLegend(geoMapName, workspace1);

            geoLegend.Height = 175;

            geoLegend.Width = 350;

            geoLegend.Center = new Point2D(1375, 1855);

            GeoStyle geoLegendStyle = new GeoStyle();

            geoLegendStyle.FillForeColor = Color.FromArgb(255, 235, 175);

            geoLegendStyle.FillOpaqueRate = 30;

            geoLegendStyle.LineWidth = 0.5;

            geoLegendStyle.LineColor = Color.FromArgb(65, 65, 65);

            geoLegend.BackGroundStyle = geoLegendStyle;

            geoLegend.ColumnCount = 3;


            //设置图例项和图例子项的说明文本的风格

            TextStyle geoLegendtextStyle = new TextStyle();

            geoLegendtextStyle.BackColor = Color.Yellow;

            geoLegendtextStyle.ForeColor = Color.Blue;

            geoLegendtextStyle.FontName = "宋体";

            geoLegendtextStyle.FontHeight = 20.0;

            geoLegendtextStyle.FontWidth = 12.0;

            geoLegendtextStyle.IsSizeFixed = false;

            geoLegend.ItemTextStyle = geoLegendtextStyle;

            geoLegend.SubItemTextStyle = geoLegendtextStyle;

            //设置图例标题风格

            TextStyle titleTextStyle = new TextStyle();

            titleTextStyle.BackColor = Color.Yellow;

            titleTextStyle.ForeColor = Color.Blue;

            titleTextStyle.FontName = "宋体";

            titleTextStyle.FontHeight = 40.0;

            titleTextStyle.FontWidth = 25.0;

            titleTextStyle.Italic = true;

            titleTextStyle.Bold = true;

            titleTextStyle.IsSizeFixed = false;

            titleTextStyle.Weight = 200;

            geoLegend.Title = "图例";

            geoLegend.TitleStyle = titleTextStyle;

            //将图例添加到布局图层,而非屏幕图层。

            geoLegend.Load(false);

            mapLayoutControl1.MapLayout.Elements.AddNew(geoLegend);
        }
Esempio n. 31
0
        /// <summary>
        /// 打开网络数据集并初始化相应变量。
        /// Open the network dataset and initialize variables
        /// </summary>
        private void Initialize()
        {
            try
            {
                // 打开数据源,得到点线数据集
                // Open datasource and get the point , line datasets
                DatasourceConnectionInfo connectionInfo = new DatasourceConnectionInfo(
                    @"..\..\SampleData\City\Changchun.udb", "FindPath2D", "");
                connectionInfo.EngineType = EngineType.UDB;
                m_workspace.Datasources.Open(connectionInfo);
                m_datasetLine               = (DatasetVector)m_workspace.Datasources[0].Datasets[m_datasetName];
                m_datasetPoint              = m_datasetLine.ChildDataset;
                m_trackingLayer             = m_mapControl.Map.TrackingLayer;
                m_trackingLayer.IsAntialias = true;

                // 初始化各变量
                // Initialzie variables
                m_flag         = 1;
                m_Points       = new Point2Ds();
                m_style        = new GeoStyle();
                m_barrierNodes = new List <Int32>();
                m_barrierEdges = new List <Int32>();
                m_selectMode   = SelectMode.SelectPoint;

                m_timer          = new Timer();
                m_timer.Interval = 200;
                m_timer.Enabled  = false;

                // 加载点数据集及线数据集并设置各自风格
                // Add point, line datasets and set their styles
                m_layerLine = m_mapControl.Map.Layers.Add(m_datasetLine, true);
                m_layerLine.IsSelectable = false;
                LayerSettingVector lineSetting = (LayerSettingVector)m_layerLine.AdditionalSetting;
                GeoStyle           lineStyle   = new GeoStyle();
                lineStyle.LineColor = Color.LightGray;
                lineStyle.LineWidth = 0.1;
                lineSetting.Style   = lineStyle;

                m_layerPoint = m_mapControl.Map.Layers.Add(m_datasetPoint, true);
                LayerSettingVector pointSetting = (LayerSettingVector)m_layerPoint.AdditionalSetting;
                GeoStyle           pointStyle   = new GeoStyle();
                pointStyle.LineColor  = Color.DarkGray;
                pointStyle.MarkerSize = new Size2D(2.5, 2.5);
                pointSetting.Style    = pointStyle;

                // 调整mapControl的状态
                // Adjust the status of mapControl
                m_mapControl.Action              = SuperMap.UI.Action.Select;
                m_mapControl.Map.IsAntialias     = true;
                m_mapControl.IsWaitCursorEnabled = false;
                m_mapControl.Map.Refresh();

                m_mapControl.MouseDown        += new MouseEventHandler(m_mapControl_MouseDown);
                m_mapControl.GeometrySelected += new GeometrySelectedEventHandler(m_mapControl_GeometrySelected);
                m_timer.Tick += new EventHandler(m_timer_Tick);
                Load();
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }
        }