示例#1
0
        //MultiLayerLineSymbol
        private void button8_Click(object sender, EventArgs e)
        {
            IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass();
            ISimpleLineSymbol     simpleLineSymbol     = new SimpleLineSymbolClass();

            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
            simpleLineSymbol.Width = 10;
            IRgbColor rgbColor = getRGB(255, 0, 0);

            simpleLineSymbol.Color = rgbColor;
            ISymbol symbol = simpleLineSymbol as ISymbol;

            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();

            cartographicLineSymbol.Cap        = esriLineCapStyle.esriLCSButt;
            cartographicLineSymbol.Join       = esriLineJoinStyle.esriLJSBevel;
            cartographicLineSymbol.Width      = 10;
            cartographicLineSymbol.MiterLimit = 4;
            ILineProperties lineProperties;

            lineProperties        = cartographicLineSymbol as ILineProperties;
            lineProperties.Offset = 0;
            double[] dob = new double[6];
            dob[0] = 0;
            dob[1] = 1;
            dob[2] = 2;
            dob[3] = 3;
            dob[4] = 4;
            dob[5] = 5;
            ITemplate template = new TemplateClass();

            template.Interval = 1;
            for (int i = 0; i < dob.Length; i += 2)
            {
                template.AddPatternElement(dob[i], dob[i + 1]);
            }
            lineProperties.Template = template;

            IPolyline polyline = new PolylineClass();
            IPoint    point    = new PointClass();

            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint             = point;
            rgbColor                     = getRGB(0, 255, 0);
            cartographicLineSymbol.Color = rgbColor;
            multiLayerLineSymbol.AddLayer(simpleLineSymbol);
            multiLayerLineSymbol.AddLayer(cartographicLineSymbol);

            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(multiLayerLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }
示例#2
0
        private ISymbol CreateBikeRouteSymbol()
        {
            IColor color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 90, 250));
            ICharacterMarkerSymbol charMarkerSymbol = new CharacterMarkerSymbolClass();

            charMarkerSymbol.Color          = color;
            charMarkerSymbol.Font           = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Default Marker", 17.0f, FontStyle.Bold));
            charMarkerSymbol.CharacterIndex = 189;
            charMarkerSymbol.Size           = 17;

            IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass();

            markerLineSymbol.Color        = color;
            markerLineSymbol.Width        = 17.0;
            markerLineSymbol.MarkerSymbol = (IMarkerSymbol)charMarkerSymbol;

            // Makes a new Cartographic Line symbol and sets its properties
            ICartographicLineSymbol cartographicLineSymbol = markerLineSymbol as ICartographicLineSymbol;

            // In order to set additional properties like offsets and dash patterns we must create an ILineProperties object
            ILineProperties lineProperties = cartographicLineSymbol as ILineProperties;

            lineProperties.Offset = 0;

            // Here's how to do a template for the pattern of marks and gaps
            double[] hpe = new double[4];
            hpe[0] = 0;
            hpe[1] = 39;
            hpe[2] = 1;
            hpe[3] = 0;

            ITemplate template = new TemplateClass();

            template.Interval = 1;
            for (int i = 0; i < hpe.Length; i = i + 2)
            {
                template.AddPatternElement(hpe[i], hpe[i + 1]);
            }
            lineProperties.Template = template;

            // Set the basic and cartographic line properties
            cartographicLineSymbol.Color = color;

            color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 220, 100));

            // create a simple line
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();

            simpleLineSymbol.Color = color;
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            simpleLineSymbol.Width = 1.2;

            IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass();

            multiLayerLineSymbol.AddLayer((ILineSymbol)cartographicLineSymbol);
            multiLayerLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol);

            return(multiLayerLineSymbol as ISymbol);
        }
示例#3
0
        private void ReadTemplate(EventArgs e)
        {
            this.TemplatelistView.ForeColor = SystemColors.WindowText;
            ITemplate template = new TemplateClass
            {
                Interval = this.m_LineProperties.Template.Interval
            };
            double mark = 0.0;
            double gap  = 0.0;

            try
            {
                double num3 = 0.0;
                for (int i = 0; i < this.TemplatelistView.Items.Count; i += 2)
                {
                    mark = Convert.ToDouble(this.TemplatelistView.Items[i].SubItems[1].Text);
                    gap  = Convert.ToDouble(this.TemplatelistView.Items[i + 1].SubItems[1].Text);
                    if ((mark < 0.0) || (gap < 0.0))
                    {
                        MessageBox.Show("实步长或虚步长不能为负数!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        this.TemplatelistView.ForeColor = Color.Red;
                        return;
                    }
                    mark /= this.m_unit;
                    gap  /= this.m_unit;
                    num3  = (num3 + mark) + gap;
                    template.AddPatternElement(mark, gap);
                }
                if (num3 == 0.0)
                {
                    MessageBox.Show("模板总长不能为0!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    this.TemplatelistView.ForeColor = Color.Red;
                }
                else
                {
                    this.m_LineProperties.Template = template;
                    this.refresh(e);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("数据类型错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                this.TemplatelistView.ForeColor = Color.Red;
            }
        }
示例#4
0
        //HashLineSymbol
        private void button9_Click(object sender, EventArgs e)
        {
            IHashLineSymbol hashLineSymbol = new HashLineSymbolClass();
            ILineProperties lineProperties = hashLineSymbol as ILineProperties;

            lineProperties.Offset = 0;
            double[] dob = new double[6];
            dob[0] = 0;
            dob[1] = 1;
            dob[2] = 2;
            dob[3] = 3;
            dob[4] = 4;
            dob[5] = 5;
            ITemplate template = new TemplateClass();

            template.Interval = 1;
            for (int i = 0; i < dob.Length; i += 2)
            {
                template.AddPatternElement(dob[i], dob[i + 1]);
            }
            lineProperties.Template = template;

            hashLineSymbol.Width = 2;
            hashLineSymbol.Angle = 45;
            IRgbColor hashColor = new RgbColor();

            hashColor            = getRGB(0, 0, 255);
            hashLineSymbol.Color = hashColor;

            IPolyline polyline = new PolylineClass();
            IPoint    point    = new PointClass();

            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(hashLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }
    private ISymbol CreateBikeRouteSymbol()
    {
        IColor color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 90, 250));
      ICharacterMarkerSymbol charMarkerSymbol = new CharacterMarkerSymbolClass();
      charMarkerSymbol.Color = color;
      charMarkerSymbol.Font = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Default Marker", 17.0f, FontStyle.Bold));
      charMarkerSymbol.CharacterIndex = 189;
      charMarkerSymbol.Size = 17;

      IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass();
      markerLineSymbol.Color = color;
      markerLineSymbol.Width = 17.0;
      markerLineSymbol.MarkerSymbol = (IMarkerSymbol)charMarkerSymbol;

      // Makes a new Cartographic Line symbol and sets its properties
      ICartographicLineSymbol cartographicLineSymbol = markerLineSymbol as ICartographicLineSymbol;

      // In order to set additional properties like offsets and dash patterns we must create an ILineProperties object
      ILineProperties lineProperties = cartographicLineSymbol as ILineProperties;
      lineProperties.Offset = 0;

      // Here's how to do a template for the pattern of marks and gaps
      double[] hpe = new double[4];
      hpe[0] = 0;
      hpe[1] = 39;
      hpe[2] = 1;
      hpe[3] = 0;

      ITemplate template = new TemplateClass();
      template.Interval = 1;
      for (int i = 0; i < hpe.Length; i = i + 2)
      {
        template.AddPatternElement(hpe[i], hpe[i + 1]);
      }
      lineProperties.Template = template;

      // Set the basic and cartographic line properties
      cartographicLineSymbol.Color = color;

      color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 220, 100));

      // create a simple line
      ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
      simpleLineSymbol.Color = color;
      simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
      simpleLineSymbol.Width = 1.2;

      IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass();
      multiLayerLineSymbol.AddLayer((ILineSymbol)cartographicLineSymbol);
      multiLayerLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol);

      return multiLayerLineSymbol as ISymbol;
    }
示例#6
0
        private void btnChangeY_Click(object sender, EventArgs e)
        {
            maploaded = true;
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            if ((cboBotYear.Text != "") && (cboTopYear.Text != ""))
            {
                label3.Text = cboTopYear.Text;
                label4.Text = cboBotYear.Text;
                if (!(topPublicMosaicLayer == null))
                {
                    //Delete old top layer, ??check still the same top to save time?
                    m_MapControl.ActiveView.FocusMap.DeleteLayer((ILayer)topPublicMosaicLayer);
                    m_MapControltop.ActiveView.FocusMap.DeleteLayer((ILayer)topPublicMosaicLayer);
                }
                if (!(botPublicMosaicLayer == null))
                {
                    //Delete old bot layer, ??check still the same bot to save time?
                    m_MapControl.ActiveView.FocusMap.DeleteLayer((ILayer)botPublicMosaicLayer);
                    m_MapControlbase.ActiveView.FocusMap.DeleteLayer((ILayer)botPublicMosaicLayer);
                }
                //This version, we will use mosaicdataset========================
                IMosaicWorkspaceExtensionHelper MosaicWsHelper = new MosaicWorkspaceExtensionHelperClass();
                IWorkspaceFactory2 workspaceFactory = new FileGDBWorkspaceFactoryClass();
                string mosaicdatabase = ConfigurationManager.AppSettings["MosaicDatabase"];
                IWorkspace ws = workspaceFactory.OpenFromFile(mosaicdatabase, 0);
                IMosaicWorkspaceExtension mosaicWsExtension = MosaicWsHelper.FindExtension(ws);

                //BOT
                strBaseYr = "AmherstOrthoMosaic" + cboBotYear.Text;
                IMosaicDataset pMosaicDatasetBot = mosaicWsExtension.OpenMosaicDataset(strBaseYr);
                botPublicMosaicLayer = new MosaicLayerClass();
                botPublicMosaicLayer.CreateFromMosaicDataset(pMosaicDatasetBot);
                if (!(botPublicMosaicLayer == null))
                {
                    IFeatureLayer footprint = (IFeatureLayer)botPublicMosaicLayer.FootprintLayer;
                    ((ILayer)footprint).Visible = false;
                    ILayer botLayer = (ILayer)botPublicMosaicLayer;
                    botLayer.MinimumScale = 6000;
                    m_MapControl.ActiveView.FocusMap.AddLayer(botLayer);
                    m_MapControlbase.ActiveView.FocusMap.AddLayer(botLayer);
                }
                //TOP
                strTopYr = "AmherstOrthoMosaic" + cboTopYear.Text;
                IMosaicDataset pMosaicDatasetTop = mosaicWsExtension.OpenMosaicDataset(strTopYr);
                topPublicMosaicLayer = new MosaicLayerClass();
                topPublicMosaicLayer.CreateFromMosaicDataset(pMosaicDatasetTop);
                if (!(topPublicMosaicLayer == null))
                {
                    IFeatureLayer footprint = (IFeatureLayer)topPublicMosaicLayer.FootprintLayer;
                    ((ILayer)footprint).Visible = false;
                    ILayer topLayer = (ILayer)topPublicMosaicLayer;
                    topLayer.MinimumScale = 6000;
                    m_MapControl.ActiveView.FocusMap.AddLayer(topLayer);
                    m_MapControltop.ActiveView.FocusMap.AddLayer(topLayer);
                    ILayerEffectProperties lepSwip = m_CommandsEnvironment as ILayerEffectProperties;
                    lepSwip.SwipeLayer = topLayer;
                    //===possible problem toplayer is not public variable any more
                }

                IFeatureLayer featurelayerParcel = new FeatureLayerClass();
                featurelayerParcel.FeatureClass = featureClassParcels;
                featurelayerParcel.Name = "parcels";
                featurelayerParcel.MinimumScale = 6000;
                featurelayerParcel.Visible = false;
                IRgbColor pLColor = new RgbColorClass();
                pLColor.Red = 255;
                pLColor.Green = 255;
                pLColor.Blue = 255;

                ISimpleFillSymbol pSFS = new SimpleFillSymbolClass();
                ICartographicLineSymbol pCLineS = new CartographicLineSymbolClass();
                pCLineS.Color = pLColor;
                ILineProperties lineProperties = pCLineS as ILineProperties;
                lineProperties.Offset = 0;
                System.Double[] hpe = new System.Double[4];
                hpe[0] = 7;
                hpe[1] = 2;
                hpe[2] = 1;
                hpe[3] = 2;

                ITemplate template = new TemplateClass();
                template.Interval = 3;
                for (int i = 0; i < hpe.Length; i = i + 2)
                {
                    template.AddPatternElement(hpe[i], hpe[i + 1]);
                }
                lineProperties.Template = template;
                pCLineS.Width = 1;
                pCLineS.Cap = esriLineCapStyle.esriLCSButt;
                pCLineS.Join = esriLineJoinStyle.esriLJSBevel;
                pCLineS.Color = pLColor;
                pSFS.Outline = pCLineS;
                pSFS.Style = esriSimpleFillStyle.esriSFSHollow;

                IGeoFeatureLayer pGFL = (IGeoFeatureLayer)featurelayerParcel;
                ISimpleRenderer pRend = pGFL.Renderer as ISimpleRenderer;
                pRend.Symbol = pSFS as ISymbol;

                if ((Helper.FindMyFeatureLayer(m_MapControl.ActiveView.FocusMap, "parcels") == null))
                {
                    if (!(featurelayerParcel == null))
                    {
                        m_MapControl.ActiveView.FocusMap.AddLayer(featurelayerParcel);
                        m_MapControltop.ActiveView.FocusMap.AddLayer(featurelayerParcel);
                        m_MapControlbase.ActiveView.FocusMap.AddLayer(featurelayerParcel);
                    }
                }
                else
                {
                    //is this temp necessary???????
                    IFeatureLayer parcellayertemp = Helper.FindMyFeatureLayer(m_MapControl.ActiveView.FocusMap, "parcels");
                    m_MapControl.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0);
                    m_MapControltop.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0);
                    m_MapControlbase.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0);
                }
                //MessageBox.Show("Top aerophoto is taken on: " + cboTopYear.Text + ".\r\nBottom areophoto is taken on: " + cboBotYear.Text + ".");
            }
            else
            {
                MessageBox.Show("Please select two years to compare");

            }
            GeneratePageLayout();
            System.Windows.Forms.Cursor.Current = Cursors.Default;
        }