Пример #1
0
        /// <summary>
        /// Save a feature layer of IPolygon to Ipe
        /// </summary>
        public static string TranIpgBoundToIpe(IPolygon ipg,
                                               IEnvelope pFLayerEnv, CEnvelope pIpeEnv, CColor StrokeColor,
                                               string strBoundWidth = "normal", string strDash = "normal")
        {
            ////get the color of the filled part
            ////we are not allowed to directly use "var pFillRgbColor = pFillSymbol.Color as IRgbColor;"
            ////Nor can we use "var pFillRgbColor = pFillSymbol.Color.RGB as IRgbColor;"
            ////pFillSymbol.Color.RGB has type 'int'
            //IColor pFillSymbolColor = new RgbColorClass();
            //pFillSymbolColor.RGB = pFillSymbol.Color.RGB;
            //var pFillSymbolRgbColor = pFillSymbolColor as IRgbColor;

            ////get the color of the out line
            //var pOutlineRgbColor = pFillSymbol.Outline.Color as IRgbColor;
            //if (strBoundWidth == "")
            //{
            //    strBoundWidth = pFillSymbol.Outline.Width.ToString();
            //}

            //get the feature
            CPolygon cpg = new CPolygon(0, ipg as IPolygon4);

            //append the string
            return(CIpeDraw.DrawCpgBound(cpg, pFLayerEnv, pIpeEnv, StrokeColor, strBoundWidth, strDash));
        }
Пример #2
0
        public void MakeAnimations(string strSimplification, string strBufferStyle, double dblMiterLimit)
        {
            CConstants.dblVerySmallCoord *= CConstants.dblFclipper;
            int intLayerNum    = 10;
            var strLayerNameLt = new List <string>(intLayerNum + 1);

            for (int i = 0; i <= intLayerNum; i++)
            {
                strLayerNameLt.Add(String.Format("{0:0.00}", Convert.ToDouble(i) / intLayerNum));
            }

            string strContent = CIpeDraw.GetDataOfLayerNames(strLayerNameLt);

            strContent += CIpeDraw.GetDataOfViews(strLayerNameLt, false);

            //The Content of animations are obtained here
            strContent += strDataOfLayers(intLayerNum, strLayerNameLt,
                                          _ParameterInitialize.pFLayerLt[0], _ParameterInitialize.pFLayerLt[0].AreaOfInterest, CConstants.pIpeEnv, "0.05",
                                          strSimplification, strBufferStyle, dblMiterLimit);

            string strFullName = _ParameterInitialize.strSavePath + "\\" + CHelpFunc.GetTimeStamp() + ".ipe";

            using (var writer = new System.IO.StreamWriter(strFullName, true))
            {
                writer.Write(CIpeDraw.GenerateIpeContentByDataWithLayerInfo(strContent));
            }

            CConstants.dblVerySmallCoord /= CConstants.dblFclipper;
            System.Diagnostics.Process.Start(@strFullName);
        }
Пример #3
0
        /// <summary>
        /// Save a feature layer of IPolygon to Ipe
        /// </summary>
        public static string TranCpgToIpe(CPolygon cpg, IFillSymbol pFillSymbol,
                                          IEnvelope pFLayerEnv, CEnvelope pIpeEnv, string strBoundWidth = "normal")
        {
            //get the color of the filled part
            //we are not allowed to directly use "var pFillRgbColor = pFillSymbol.Color as IRgbColor;"
            //Nor can we use "var pFillRgbColor = pFillSymbol.Color.RGB as IRgbColor;"
            //pFillSymbol.Color.RGB has type 'int'
            IColor pFillSymbolColor = new RgbColorClass();

            pFillSymbolColor.RGB = pFillSymbol.Color.RGB;
            CColor cColor            = new CUtility.CColor(pFillSymbolColor as IRgbColor);
            var    pSimpleFillSymbol = pFillSymbol as ISimpleFillSymbol;

            if (pSimpleFillSymbol != null)
            {
                if (pSimpleFillSymbol.Style == esriSimpleFillStyle.esriSFSHollow ||
                    pSimpleFillSymbol.Style == esriSimpleFillStyle.esriSFSNull)
                {
                    cColor = null;
                }
            }


            //get the color of the out line
            var pOutlineRgbColor = pFillSymbol.Outline.Color as IRgbColor;

            if (strBoundWidth == "")
            {
                strBoundWidth = pFillSymbol.Outline.Width.ToString();
            }

            //append the string
            return(CIpeDraw.DrawCpg(cpg, pFLayerEnv, pIpeEnv, new CColor(pOutlineRgbColor), cColor, strBoundWidth));
        }
Пример #4
0
        public static void SaveToIpe(List <IFeatureLayer> pFLayerLt, IEnvelope pFLayerEnv, CEnvelope pIpeEnv,
                                     bool blnGroup, string strBoundWidth, CParameterInitialize ParameterInitialize, bool blnLayerToLeft = true)
        {
            var strContent = GetScaleLegend(pFLayerEnv, pIpeEnv, CHelpFunc.GetUnits(ParameterInitialize.m_mapControl.MapUnits));

            for (int i = 0; i < pFLayerLt.Count; i++)
            {
                var pFLayer         = pFLayerLt[i] as IFeatureLayer;
                var strDataOfFLayer = CToIpe.GetDataOfFeatureLayer(pFLayer, pFLayerEnv, pIpeEnv, strBoundWidth, true);

                if (blnGroup == true)
                {
                    strDataOfFLayer = "<group>\n" + strDataOfFLayer + "</group>\n";
                }
                strContent += strDataOfFLayer;

                if (blnLayerToLeft == true)
                {
                    pIpeEnv.XMin -= pIpeEnv.Width;
                    pIpeEnv.XMax -= pIpeEnv.Width;
                }
            }

            string strFullName = ParameterInitialize.strSavePath + "\\" + CHelpFunc.GetTimeStamp() + ".ipe";

            using (var writer = new System.IO.StreamWriter(strFullName, true))
            {
                writer.Write(CIpeDraw.GenerateIpeXMLWithContent(strContent));
            }

            System.Diagnostics.Process.Start(@strFullName);
        }
Пример #5
0
        public static void SaveToIpe(List <IFeatureLayer> pFLayerLt, IEnvelope pFLayerEnv, CEnvelope pIpeEnv,
                                     bool blnGroup, string strBoundWidth, CParameterInitialize ParameterInitialize, bool blnLayerToLeft = true)
        {
            //save path
            //CHelpFunc.SetSavePath(ParameterInitialize);

            //        double dblFactorIpeToLayer = pIpeEnv.Height / pFLayerEnv.Height;
            //        double dblLegend16 = 16 / dblFactorIpeToLayer;
            //        int intLegendInt = CMath.GetNumberTidy(dblLegend16);
            //        double dblLegentInt = intLegendInt * dblFactorIpeToLayer;


            //        //add legend (unit and a sample line), draw a line with length 32 in ipe
            //        string strData = CIpeDraw.writeIpeText(dblLegend16 + " " + ParameterInitialize.m_mapControl.MapUnits.ToString(), 320, 80) +
            //            CIpeDraw.drawIpeEdge(320, 64, 336, 64);

            //        strData += CIpeDraw.writeIpeText(intLegendInt + " " + ParameterInitialize.m_mapControl.MapUnits.ToString(), 320, 32) +
            //CIpeDraw.drawIpeEdge(320, 16, 320 + dblLegentInt, 16) +
            //CIpeDraw.drawIpeEdge(320, 16, 320, 20) + CIpeDraw.drawIpeEdge(320 + dblLegentInt, 16, 320 + dblLegentInt, 20);
            var strData = GetScaleLegend(pFLayerEnv, pIpeEnv, CHelpFunc.GetUnits(ParameterInitialize.m_mapControl.MapUnits));


            //var tt = ParameterInitialize.m_mapControl.
            for (int i = 0; i < pFLayerLt.Count; i++)
            {
                var pFLayer = pFLayerLt[i] as IFeatureLayer;

                if (blnGroup == true)
                {
                    strData += "<group>\n";
                }

                strData += CToIpe.GetDataOfFeatureLayer(pFLayer, pFLayerEnv, pIpeEnv, strBoundWidth, true);

                if (blnGroup == true)
                {
                    strData += "</group>\n";
                }

                if (blnLayerToLeft == true)
                {
                    pIpeEnv.XMin -= pIpeEnv.Width;
                    pIpeEnv.XMax -= pIpeEnv.Width;
                }
            }

            string strFullName = ParameterInitialize.strSavePath + "\\" + CHelpFunc.GetTimeStamp() + ".ipe";

            using (var writer = new System.IO.StreamWriter(strFullName, true))
            {
                writer.Write(CIpeDraw.GenerateIpeContentByData(strData));
            }

            System.Diagnostics.Process.Start(@strFullName);
        }
Пример #6
0
        /// <summary>
        /// Save a feature layer of IPolyline to Ipe
        /// </summary>
        private static string TranIptToIpe(IFeature pFeature, IFeatureRenderer pRenderer, IEnvelope pFLayerEnv,
                                           CEnvelope pIpeEnv, string strBoundWidth = "normal")
        {
            var pMarkerSymbol         = pRenderer.SymbolByFeature[pFeature] as IMarkerSymbol;
            var pMarkerSymbolRgbColor = pMarkerSymbol.Color as IRgbColor;

            if (strBoundWidth == "")
            {
                strBoundWidth = pMarkerSymbol.Size.ToString();
            }

            var ipt = pFeature.Shape as IPoint;

            return(CIpeDraw.DrawIpt(ipt, pFLayerEnv, pIpeEnv, "disk", new CColor(pMarkerSymbolRgbColor), strBoundWidth));
        }
Пример #7
0
        public static string GetScaleLegend(IEnvelope pFLayerEnv, CEnvelope pIpeEnv, string strMapUnits)
        {
            double dblFactorIpeToLayer = pIpeEnv.Height / pFLayerEnv.Height;
            double dblLegend16         = 16 / dblFactorIpeToLayer;

            if (dblLegend16 < 1)
            {
                dblLegend16 = 1;
            }
            int    intLegendInt = CMath.GetNumberTidy(dblLegend16);
            double dblLegentInt = intLegendInt * dblFactorIpeToLayer;

            ////add legend (unit and a sample line), draw a line with length 16 in ipe
            return(CIpeDraw.writeIpeText("$" + intLegendInt + @"\,$" + strMapUnits, 320, 32) +
                   CIpeDraw.drawIpePath(new double[] { 320, 320, 320 + dblLegentInt, 320 + dblLegentInt },
                                        new double[] { 20, 16, 16, 20 }));
        }
Пример #8
0
        /// <summary>
        /// Save a feature layer of IPolyline to Ipe
        /// </summary>
        private static string TranIplToIpe(IFeature pFeature, IFeatureRenderer pRenderer, IEnvelope pFLayerEnv,
                                           CEnvelope pIpeEnv, string strBoundWidth = "normal")
        {
            var pLineSymbol         = pRenderer.SymbolByFeature[pFeature] as ILineSymbol;
            var pLineSymbolRgbColor = pLineSymbol.Color as IRgbColor;

            if (strBoundWidth == "")
            {
                strBoundWidth = pLineSymbol.Width.ToString();
            }

            //get the feature
            CPolyline cpl = new CPolyline(0, pFeature.Shape as IPolyline5);

            //append the string
            return(CIpeDraw.DrawCpl(cpl, pFLayerEnv, pIpeEnv,
                                    new CColor(pLineSymbolRgbColor), strBoundWidth));
        }
Пример #9
0
        public static string GetDataOfFeatureLayer(IFeatureLayer pFLayer, IEnvelope pFLayerEnv,
                                                   CEnvelope pIpeEnv, string strBoundWidth = "normal", bool blnDrawBound = false)
        {
            string str = "";

            if (blnDrawBound == true)
            {
                //add legend (unit and a sample line), draw a line with length 32 in ipe
                //so that we can easily compare shrinks with other figures
                //if the text of an object is above, then the object is under other objects
                //this bound line should be under all other objectss
                str += CIpeDraw.drawIpeEdge(pIpeEnv.XMin, pIpeEnv.YMin, pIpeEnv.XMin, pIpeEnv.YMax, "white");
            }
            string         strName         = pFLayer.Name;
            IFeatureClass  pFeatureClass   = pFLayer.FeatureClass;
            int            intFeatureCount = pFeatureClass.FeatureCount(null);
            IFeatureCursor pFeatureCursor  = pFeatureClass.Search(null, false);   //注意此处的参数(****,false)!!!
            var            pRenderer       = (pFLayer as IGeoFeatureLayer).Renderer;

            for (int i = 0; i < intFeatureCount; i++)
            {
                //at the last round of this loop, pFeatureCursor.NextFeature() will return null
                IFeature pFeature = pFeatureCursor.NextFeature();
                switch (pFeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    str += TranIptToIpe(pFeature, pRenderer, pFLayerEnv, pIpeEnv, strBoundWidth);
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    str += TranIplToIpe(pFeature, pRenderer, pFLayerEnv, pIpeEnv, strBoundWidth);
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    str += TranIpgToIpe(pFeature, pRenderer, pFLayerEnv, pIpeEnv, strBoundWidth);
                    break;

                default:
                    break;
                }
            }

            return(str);
        }
Пример #10
0
        private string strDataOfLayers(int intLayerNum, List <string> strLayerNameLt, IFeatureLayer pFLayer,
                                       IEnvelope pFLayerEnv, CEnvelope pIpeEnv, string strBoundWidth,
                                       string strSimplification, string strBufferStyle, double dblMiterLimit)
        {
            //for the first layer, we add all the patches
            string strDataAllLayers = CIpeDraw.SpecifyLayerByWritingText(strLayerNameLt[0], "removable", 320, 64);

            strDataAllLayers += CToIpe.GetScaleLegend(pFLayerEnv, pIpeEnv, CHelpFunc.GetUnits(_ParameterInitialize.m_mapControl.MapUnits));
            strDataAllLayers += CIpeDraw.writeIpeText(strLayerNameLt[0], 320, 128)
                                + "<group>\n" + CToIpe.GetDataOfFeatureLayer(pFLayer, pFLayerEnv, pIpeEnv, strBoundWidth, true) + "</group>\n";

            //for each of other layers, we only add the new patch
            for (int i = 1; i < strLayerNameLt.Count; i++)
            {
                strDataAllLayers += CIpeDraw.SpecifyLayerByWritingText(strLayerNameLt[i], "removable", 320, 64);

                //draw a rectangle to cover the patch number of the last layer
                strDataAllLayers += CIpeDraw.drawIpeBox(304, 112, 384, 160, "white");

                //add layer name and a text of patch numbers
                strDataAllLayers += CIpeDraw.writeIpeText(strLayerNameLt[i], 320, 128);

                strDataAllLayers += CToIpe.GetScaleLegend(pFLayerEnv, pIpeEnv,
                                                          CHelpFunc.GetUnits(_ParameterInitialize.m_mapControl.MapUnits));

                //add the Content of animations
                strDataAllLayers += "<group>\n";
                strDataAllLayers += CIpeDraw.drawIpeEdge(pIpeEnv.XMin, pIpeEnv.YMin, pIpeEnv.XMin, pIpeEnv.YMax, "white");
                foreach (var cpg in GetResultCpgEb(this.MergedCpgLt, Convert.ToDouble(strLayerNameLt[i]),
                                                   strSimplification, strBufferStyle, dblMiterLimit))
                {
                    strDataAllLayers += CIpeDraw.DrawCpg(cpg, pFLayerEnv, pIpeEnv,
                                                         new CUtility.CColor(0, 0, 0), new CUtility.CColor(230, 230, 230), strBoundWidth);
                }
                strDataAllLayers += "</group>\n";
                //strDataAllLayers += CToIpe.TranIpgToIpe(IpgLt[i - 1], pFillSymbolLt[i - 1], pFLayerEnv, pIpeEnv, strBoundWidth);
            }

            return(strDataAllLayers);
        }