Esempio n. 1
0
 public PointStyle(WebGraphicsInfo gInfo = null)
 {
     InitializeComponent();
     m_gInfo = gInfo;
     if (gInfo != null)
     {
         this.Loaded += new RoutedEventHandler(OnLoaded);
     }
     else
     {
         patternID.SelectedIndex    = 0;
         patternColor.SelectedIndex = 0;
     }
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取要素信息
        /// </summary>
        /// <returns></returns>
        private CMapFeatureInfo GetMapFeatureInfo()
        {
            CMapFeatureInfo fInfo = new CMapFeatureInfo();
            SFeature        sf    = new SFeature();

            sf.AttValue = new string[m_attStruct.FldNumber];
            for (int i = 0; i < m_attStruct.FldNumber; i++)
            {
                sf.AttValue[i] = m_textBoxArr[i].Text;
                switch (this.m_attStruct.FldType[i])
                {
                case "double":
                case "integer":
                case "long":
                case "short":
                    if (!CommFun.IsNumber(sf.AttValue[i]))
                    {
                        MessageBox.Show("字段【Fld_" + this.m_attStruct.FldName[i] + "】输入的数据格式不正确。请重新输入!", "提示", MessageBoxButton.OK);
                        return(null);
                    }
                    break;
                }
            }
            SFeatureGeometry sfGeo = null;
            SFclsGeomType    curFGeoType;

            if (m_targetGeo != null)
            {
                sfGeo = m_targetGeo as SFeatureGeometry;
                if (sfGeo == null) //add feature
                {
                    sfGeo = new SFeatureGeometry();
                    switch ((m_targetGeo as IWebGeometry).GetGeomType())
                    {
                    case WebGeomType.Point:
                        sf.ftype = SFclsGeomType.Pnt;
                        GPoint pnt = new GPoint();
                        pnt.Dot       = m_targetGeo as Dot_2D;
                        sfGeo.PntGeom = new GPoint[] { pnt };
                        break;

                    case WebGeomType.Line:
                        sf.ftype = SFclsGeomType.Lin;
                        GLine line = new GLine();
                        line.Line     = m_targetGeo as AnyLine;
                        sfGeo.LinGeom = new GLine[] { line };
                        break;

                    case WebGeomType.Polygon:
                        sf.ftype = SFclsGeomType.Reg;
                        GRegion polygon = new GRegion();
                        AnyLine circle  = new AnyLine();
                        circle.Arcs         = new Arc[1];
                        circle.Arcs[0]      = new Arc();
                        circle.Arcs[0].Dots = (m_targetGeo as ZDIMS.BaseLib.Polygon).Dots;
                        polygon.Rings       = new AnyLine[] { circle };
                        sfGeo.RegGeom       = new GRegion[] { polygon };
                        break;

                    default:
                        sfGeo = null;
                        break;
                    }
                }
            }
            curFGeoType = ActiveMapDoc.ActiveLayerGeoType;
            if (this.m_featureStyle == null)
            {
                this.m_featureStyle = new WebGraphicsInfo();
            }
            this.m_style.Update();
            switch (curFGeoType)
            {
            case SFclsGeomType.Pnt:
                this.m_featureStyle.InfoType = GInfoType.PntInfo;
                PointStyle newPntStyle = this.m_style as PointStyle;
                this.m_featureStyle.PntInfo = new CPointInfo();
                if (newPntStyle.patternAngle.Text == "")
                {
                    this.m_featureStyle.PntInfo.Angle = 0.0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.Angle = Convert.ToDouble(newPntStyle.patternAngle.Text);
                }
                if (newPntStyle.patternColor._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.PntInfo.Color = 0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.Color = Convert.ToInt32(newPntStyle.patternColor._TextBoxInput.Text.Split(':')[0]);
                }
                if (newPntStyle.patternHeight.Text == "")
                {
                    this.m_featureStyle.PntInfo.SymHeight = 0.0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.SymHeight = Convert.ToDouble(newPntStyle.patternHeight.Text);
                }
                if (newPntStyle.patternID._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.PntInfo.SymID = 0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.SymID = Convert.ToInt32(newPntStyle.patternID._TextBoxInput.Text.Split(':')[0]);
                }
                if (newPntStyle.patternWidth.Text == "")
                {
                    this.m_featureStyle.PntInfo.SymWidth = 0.0;
                }
                else
                {
                    this.m_featureStyle.PntInfo.SymWidth = Convert.ToDouble(newPntStyle.patternWidth.Text);
                }
                break;

            case SFclsGeomType.Lin:
                this.m_featureStyle.InfoType = GInfoType.LinInfo;
                LineStyle newLineStyle = this.m_style as LineStyle;
                this.m_featureStyle.LinInfo = new CLineInfo();
                if (newLineStyle.color._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.LinInfo.Color = 0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.Color = Convert.ToInt32(newLineStyle.color._TextBoxInput.Text.Split(':')[0]);
                }
                if (newLineStyle.patternID._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.LinInfo.LinStyleID = 0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.LinStyleID = Convert.ToInt32(newLineStyle.patternID._TextBoxInput.Text.Split(':')[0]);
                }
                if (newLineStyle.patternID2._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.LinInfo.LinStyleID2 = 0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.LinStyleID2 = Convert.ToInt32(newLineStyle.patternID2._TextBoxInput.Text.Split(':')[0]);
                }
                if (newLineStyle.penWidth.Text == "")
                {
                    this.m_featureStyle.LinInfo.LinWidth = 0.0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.LinWidth = Convert.ToDouble(newLineStyle.penWidth.Text);
                }
                if (newLineStyle.lineScaleX.Text == "")
                {
                    this.m_featureStyle.LinInfo.Xscale = 0.0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.Xscale = Convert.ToDouble(newLineStyle.lineScaleX.Text);
                }
                if (newLineStyle.lineScaleY.Text == "")
                {
                    this.m_featureStyle.LinInfo.Yscale = 0.0;
                }
                else
                {
                    this.m_featureStyle.LinInfo.Yscale = Convert.ToDouble(newLineStyle.lineScaleY.Text);
                }
                break;

            case SFclsGeomType.Reg:
                this.m_featureStyle.InfoType = GInfoType.RegInfo;
                PolygonStyle newRegStyle = this.m_style as PolygonStyle;
                this.m_featureStyle.RegInfo = new CRegionInfo();
                if (newRegStyle.fillcolor._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.RegInfo.FillColor = 0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.FillColor = Convert.ToInt32(newRegStyle.fillcolor._TextBoxInput.Text.Split(':')[0]);
                }
                if (newRegStyle.patternColor._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.RegInfo.PatColor = 0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.PatColor = Convert.ToInt32(newRegStyle.patternColor._TextBoxInput.Text.Split(':')[0]);
                }
                if (newRegStyle.patternHeight.Text == "")
                {
                    this.m_featureStyle.RegInfo.PatHeight = 0.0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.PatHeight = Convert.ToDouble(newRegStyle.patternHeight.Text);
                }
                if (newRegStyle.patternID._TextBoxInput.Text.Split(':')[0] == "")
                {
                    this.m_featureStyle.RegInfo.PatID = 0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.PatID = Convert.ToInt32(newRegStyle.patternID._TextBoxInput.Text.Split(':')[0]);
                }
                if (newRegStyle.patternPenWidth.Text == "")
                {
                    this.m_featureStyle.RegInfo.OutPenWidth = 0.0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.OutPenWidth = Convert.ToDouble(newRegStyle.patternPenWidth.Text);
                }
                if (newRegStyle.patternWidth.Text == "")
                {
                    this.m_featureStyle.RegInfo.PatWidth = 0.0;
                }
                else
                {
                    this.m_featureStyle.RegInfo.PatWidth = Convert.ToDouble(newRegStyle.patternWidth.Text);
                }
                break;
            }

            sf.fGeom              = sfGeo;
            sf.FID                = m_featureID;
            fInfo.GInfo           = this.m_featureStyle;
            fInfo.FSet            = sf;
            fInfo.LayerIndex      = ActiveMapDoc.ActiveLayerIndex;
            fInfo.MapName         = new COpenMap();
            fInfo.MapName.MapName = new string[] { ActiveMapDoc.MapDocName };
            return(fInfo);
        }
Esempio n. 4
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();
        }