Пример #1
0
        private void GetAttStructCallBack(object sender, UploadStringCompletedEventArgs e)
        {
            CAttStruct curLayerAttStru = ActiveMapDoc.OnGetMapLayerAttStruct(e);

            ActiveMapDoc.ActiveLayerAttStruct = curLayerAttStru;
            SetAttStruct(curLayerAttStru);
        }
Пример #2
0
        private void SubmitForAdd(object sender, RoutedEventArgs e)
        {
            CMapFeatureInfo fIno = GetMapFeatureInfo();

            if (fIno == null)
            {
                return;
            }
            ActiveMapDoc.AddFeature(fIno, new UploadStringCompletedEventHandler(GetAddOperResult));
        }
Пример #3
0
        /// <summary>
        /// 获取激活图层属性结构
        /// </summary>
        private void GetActiveLayerAttStruct()
        {
            CAttStruct curLayerAttStru = ActiveMapDoc.ActiveLayerAttStruct;

            if (curLayerAttStru != null)
            {
                SetAttStruct(curLayerAttStru);
            }
            else
            {
                ActiveMapDoc.GetMapLayerAttStruct(ActiveMapDoc.ActiveLayerIndex, new UploadStringCompletedEventHandler(GetAttStructCallBack));
            }
        }
Пример #4
0
        private void GetAddOperResult(object sender, UploadStringCompletedEventArgs e)
        {
            COperResult rlt = ActiveMapDoc.OnAddFeature(e);

            if (rlt.OperResult == true)
            {
                MessageBox.Show("添加成功", "提示", MessageBoxButton.OK);
                this.Close();
                ActiveMapDoc.MapContainer.OperType = IMSOperType.Refresh;
                //this.m_activeMapDoc.Refresh();
            }
            else
            {
                MessageBox.Show("添加失败,错误信息:" + rlt.ErrorInfo, "提示", MessageBoxButton.OK);
            }
        }
Пример #5
0
 private void GetEditOperResult(object sender, UploadStringCompletedEventArgs e)
 {
     if (m_mapDocDataViewer != null)
     {
         //COperResult rlt = ActiveMapDoc.OnAddFeature(e);
         if (ActiveMapDoc.OnUpdateFeature(e).OperResult == true)
         {
             MessageBox.Show("编辑成功", "提示", MessageBoxButton.OK);
             this.Close();
             ActiveMapDoc.MapContainer.OperType = IMSOperType.Refresh;
             //this.m_activeMapDoc.Refresh();
         }
         else
         {
             MessageBox.Show("编辑失败,错误信息:" + ActiveMapDoc.OnUpdateFeature(e).ErrorInfo, "提示", MessageBoxButton.OK);
         }
     }
 }
Пример #6
0
        private void OnGetStyle(object sender, UploadStringCompletedEventArgs e)
        {
            WebGraphicsInfo gInfo = ActiveMapDoc.OnGetFeatureStyleInfo(e);

            m_featureStyle = gInfo;
            switch (gInfo.InfoType)
            {
            case GInfoType.PntInfo:
                m_style = new PointStyle(gInfo);
                break;

            case GInfoType.LinInfo:
                m_style = new LineStyle(gInfo);
                break;

            case GInfoType.RegInfo:
                m_style = new PolygonStyle(gInfo);
                break;
            }
            grid2.Children.Add(m_style as UIElement);
        }
Пример #7
0
 private void EditPoint(object sender, RoutedEventArgs e)
 {
     if (GraphicsLayer != null)
     {
         if (m_graphics != null)
         {
             GraphicsLayer.RemoveGraphics(m_graphics);
             m_graphics = null;
         }
         CGetObjByID getGeo = new CGetObjByID();
         getGeo.MapDocIndex = 0;
         getGeo.LayerIndex  = ActiveMapDoc.ActiveLayerIndex;
         getGeo.FeatureID   = m_featureID;
         COpenMap openmap = new COpenMap();
         openmap.MapName = new string[1] {
             ActiveMapDoc.MapDocName
         };
         getGeo.MapName = openmap;
         ActiveMapDoc.GetGeomByID(getGeo, new UploadStringCompletedEventHandler(DrawFeature));
     }
 }
Пример #8
0
        private void SubmitForEdit(object sender, RoutedEventArgs e)
        {
            if (GraphicsLayer != null && m_graphics != null)
            {
                SFeatureGeometry geoObj = m_targetGeo as SFeatureGeometry;
                int n = 0;
                if (geoObj != null)
                {
                    if (geoObj.LinGeom != null && geoObj.LinGeom.Length > 0)
                    {
                        List <Point> pntArr = new List <Point>();
                        for (int i = 0; i < geoObj.LinGeom.Length; i++)
                        {
                            for (int j = 0; j < geoObj.LinGeom[i].Line.Arcs.Length; j++)
                            {
                                for (int k = 0; k < geoObj.LinGeom[i].Line.Arcs[j].Dots.Length; k++)
                                {
                                    geoObj.LinGeom[i].Line.Arcs[j].Dots[k].x = m_graphics.Points[n].X;
                                    geoObj.LinGeom[i].Line.Arcs[j].Dots[k].y = m_graphics.Points[n++].Y;
                                }
                            }
                        }
                    }
                    if (geoObj.PntGeom != null && geoObj.PntGeom.Length > 0)
                    {
                        geoObj.PntGeom[0].Dot.x = m_graphics.Points[0].X;
                        geoObj.PntGeom[0].Dot.y = m_graphics.Points[0].Y;
                    }
                    if (geoObj.RegGeom != null && geoObj.RegGeom.Length > 0)
                    {
                        List <Point> pntArr = new List <Point>();
                        for (int i = 0; i < geoObj.RegGeom[0].Rings.Length; i++)
                        {
                            for (int j = 0; j < geoObj.RegGeom[0].Rings[i].Arcs.Length; j++)
                            {
                                for (int k = 0; k < geoObj.RegGeom[0].Rings[i].Arcs[j].Dots.Length; k++)
                                {
                                    geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].x = m_graphics.Points[n].X;
                                    geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].y = m_graphics.Points[n++].Y;
                                }
                            }
                        }
                    }
                }
                GraphicsLayer.RemoveGraphics(m_graphics);
                m_graphics = null;
            }
            CMapFeatureInfo fIno = GetMapFeatureInfo();

            if (fIno == null)
            {
                return;
            }
            ActiveMapDoc.UpdateFeature(fIno, new UploadStringCompletedEventHandler((s, evt) =>
            {
                if (m_mapDocDataViewer != null)
                {
                    m_mapDocDataViewer.UpdateRecord(fIno.FSet.AttValue);
                }
                GetEditOperResult(s, evt);
            }));
        }
Пример #9
0
        private void DrawFeature(object sender, UploadStringCompletedEventArgs e)
        {
            SFeatureGeometry geoObj = null;

            try
            {
                geoObj = ActiveMapDoc.OnGetGeomByID(e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("获取该要素空间信息失败!" + ex.Message);
                return;
            }
            m_targetGeo = geoObj;
            bool flg = false;

            if (geoObj.LinGeom != null && geoObj.LinGeom.Length > 0)
            {
                List <Point> pntArr = new List <Point>();
                for (int i = 0; i < geoObj.LinGeom.Length; i++)
                {
                    for (int j = 0; j < geoObj.LinGeom[i].Line.Arcs.Length; j++)
                    {
                        for (int k = 0; k < geoObj.LinGeom[i].Line.Arcs[j].Dots.Length; k++)
                        {
                            pntArr.Add(new Point(geoObj.LinGeom[i].Line.Arcs[j].Dots[k].x, geoObj.LinGeom[i].Line.Arcs[j].Dots[k].y));
                        }
                    }
                }
                if (pntArr[0].X <ActiveMapDoc.MapContainer.WinViewBound.XMin || pntArr[0].X> ActiveMapDoc.MapContainer.WinViewBound.XMax ||
                    pntArr[0].Y <ActiveMapDoc.MapContainer.WinViewBound.YMin || pntArr[0].Y> ActiveMapDoc.MapContainer.WinViewBound.YMax)
                {
                    ActiveMapDoc.MapContainer.PanTo(pntArr[0].X, pntArr[0].Y);
                }
                m_graphics = new IMSPolyline(CoordinateType.Logic)
                {
                    Points          = pntArr,
                    StrokeThickness = 4
                };
                flg = true;
            }
            if (geoObj.PntGeom != null && geoObj.PntGeom.Length > 0)
            {
                if (geoObj.PntGeom[0].Dot.x <ActiveMapDoc.MapContainer.WinViewBound.XMin || geoObj.PntGeom[0].Dot.x> ActiveMapDoc.MapContainer.WinViewBound.XMax ||
                    geoObj.PntGeom[0].Dot.y <ActiveMapDoc.MapContainer.WinViewBound.YMin || geoObj.PntGeom[0].Dot.y> ActiveMapDoc.MapContainer.WinViewBound.YMax)
                {
                    ActiveMapDoc.MapContainer.PanTo(geoObj.PntGeom[0].Dot.x, geoObj.PntGeom[0].Dot.y);
                }
                m_graphics = new IMSCircle(CoordinateType.Logic)
                {
                    CenX     = geoObj.PntGeom[0].Dot.x,
                    CenY     = geoObj.PntGeom[0].Dot.y,
                    RadiusEx = 6
                };
                flg = true;
            }
            if (geoObj.RegGeom != null && geoObj.RegGeom.Length > 0)
            {
                List <Point> pntArr = new List <Point>();
                for (int i = 0; i < geoObj.RegGeom[0].Rings.Length; i++)
                {
                    for (int j = 0; j < geoObj.RegGeom[0].Rings[i].Arcs.Length; j++)
                    {
                        for (int k = 0; k < geoObj.RegGeom[0].Rings[i].Arcs[j].Dots.Length; k++)
                        {
                            pntArr.Add(new Point(geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].x, geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].y));
                        }
                    }
                }
                if (pntArr[0].X <ActiveMapDoc.MapContainer.WinViewBound.XMin || pntArr[0].X> ActiveMapDoc.MapContainer.WinViewBound.XMax ||
                    pntArr[0].Y <ActiveMapDoc.MapContainer.WinViewBound.YMin || pntArr[0].Y> ActiveMapDoc.MapContainer.WinViewBound.YMax)
                {
                    ActiveMapDoc.MapContainer.PanTo(pntArr[0].X, pntArr[0].Y);
                }
                m_graphics = new IMSPolygon(CoordinateType.Logic)
                {
                    Points = pntArr
                };
                flg = true;
            }
            if (flg)
            {
                GraphicsLayer.AddGraphics(m_graphics);
                m_graphics.EnableEdit      = true;
                m_graphics.EnableEditMark2 = false;
                m_graphics.Draw();
            }
        }
Пример #10
0
        public void SetAttStruct(CAttStruct attStruct, BindClass values = null, MapDocDataViewer mapDocDataViewer = null)
        {
            m_mapDocDataViewer = mapDocDataViewer;
            m_attStruct        = attStruct;
            m_featureStyle     = null;
            Clear();
            Label   label;
            TextBox txtbox;

            if (values != null && values.ColumnCount > 0)
            {
                m_featureID = Convert.ToInt32(values.keyarr[0]);
            }
            for (int i = 0; i < m_attStruct.FldNumber; i++)
            {
                grid1.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(30)
                });
                label = new Label()
                {
                    Content = m_attStruct.FldName[i] + ":", Width = 60
                };
                grid1.Children.Add(label);
                Grid.SetRow(label, i);
                txtbox = new TextBox()
                {
                    Width = 120, Height = 23, Text = "0"
                };                                                              //, Name = "Fld_" + m_attStruct.FldName[i] };
                grid1.Children.Add(txtbox);
                m_textBoxArr.Add(txtbox);
                if (values != null && values.ColumnCount > i + 1)
                {
                    txtbox.Text = values.keyarr[i + 1];
                }
                Grid.SetRow(txtbox, i);
                Grid.SetColumn(txtbox, 1);
            }
            if (values == null)
            {
                switch ((m_targetGeo as IWebGeometry).GetGeomType())
                {
                case WebGeomType.Point:
                    m_style = new PointStyle();
                    break;

                case WebGeomType.Line:
                    m_style = new LineStyle();
                    break;

                case WebGeomType.Polygon:
                    m_style = new PolygonStyle();
                    break;
                }
                grid2.Children.Add(m_style as UIElement);
            }
            else
            {
                CGetObjByID feature = new CGetObjByID();
                feature.FeatureID  = this.m_featureID;
                feature.LayerIndex = this.ActiveMapDoc.ActiveLayerIndex;
                ActiveMapDoc.GetFeatureStyleInfo(feature, new UploadStringCompletedEventHandler(OnGetStyle));
            }
            Button btn = new Button()
            {
                Width = 70
            };

            btn.Content = "提交";
            if (values == null)
            {
                btn.Click += new RoutedEventHandler(SubmitForAdd);
            }
            else
            {
                btn.Click += new RoutedEventHandler(SubmitForEdit);
            }
            grid3.Children.Add(btn);
            btn = new Button()
            {
                Width = 70
            };
            btn.Content = "关闭";
            btn.Click  += new RoutedEventHandler(Close);
            grid3.Children.Add(btn);
            Grid.SetColumn(btn, 1);
            if (values != null)
            {
                grid3.ColumnDefinitions.Add(new ColumnDefinition());// { Width = new GridLength(120) });
                btn = new Button()
                {
                    Width = 90
                };
                btn.Content = "调整要素位置";
                btn.Click  += new RoutedEventHandler(EditPoint);
                grid3.Children.Add(btn);
                Grid.SetColumn(btn, 2);
            }
            this.Show();
        }