Ejemplo n.º 1
0
        public static Pile getSectionPos(string sp)
        {
            if ((sp == null) || (!sp.Contains("K")))
            {
                return(null);
            }
            Pile   _pile       = new Pile();
            string _tunnelpart = sp.Split('K')[0];

            switch (_tunnelpart)
            {
            case "Y":
                _pile.tunnelpart = Tunnelpart.right;
                break;

            case "Z":
                _pile.tunnelpart = Tunnelpart.left;
                break;

            case "LX":
                _pile.tunnelpart = Tunnelpart.s3inclinedshaft;
                break;

            case "BX":
                _pile.tunnelpart = Tunnelpart.s2inclinedshaft;
                break;

            default:
                break;
            }
            string st1, st2, t1, t2, t3;

            string[] str;
            decimal  m1, m2, restemp;

            if (sp.Contains("-"))
            {
                _pile.piletype = Piletype.interval;
                //计算起始桩号
                str             = sp.Split('-');
                st1             = str[0];
                st2             = str[1];
                str             = st1.Split('+');
                t1              = str[0];
                t2              = str[1];
                str             = t1.Split('K');
                t3              = str[1];
                m1              = Convert.ToDecimal(t3);
                m2              = Convert.ToDecimal(t2);
                restemp         = m1 * 1000 + m2;
                _pile.startpile = restemp;

                //计算终止桩号
                str           = st2.Split('+');
                t1            = str[0];
                t2            = str[1];
                str           = t1.Split('K');
                t3            = str[1];
                m1            = Convert.ToDecimal(t3);
                m2            = Convert.ToDecimal(t2);
                restemp       = m1 * 1000 + m2;
                _pile.endpile = restemp;
            }
            else
            {
                _pile.piletype  = Piletype.point;
                str             = sp.Split('+');
                t1              = str[0];
                t2              = str[1];
                str             = t1.Split('K');
                t3              = str[1];
                m1              = Convert.ToDecimal(t3);
                m2              = Convert.ToDecimal(t2);
                restemp         = m1 * 1000 + m2;
                _pile.pilepoint = restemp;
            }

            return(_pile);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Participates in rendering operations.
        /// </summary>
        /// <param name="drawingContext">The drawing instructions for a specific element. This context is provided to the layout system.</param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            try
            {
                base.OnRender(drawingContext);
                double xDest = (Unit == Unit.Cm ? DipHelper.CmToDip(Length) : DipHelper.InchToDip(Length)) * this.Zoom;
                drawingContext.DrawRectangle(null, BorderPen, new Rect(new Point(0.0, 0.0), new Point(xDest, Height)));
                //桩号
                if (Marks == "Horizontal")
                {
                    double startpile = DipHelper.GetRulerMileage(RulerExtent.XMin);
                    double endpile   = DipHelper.GetRulerMileage(RulerExtent.XMax);
                    double fontwidth = DipHelper.PtToDip(6) * 3;

                    double chip = (Chip - startpile) / (endpile - startpile) * xDest;
                    drawingContext.DrawLine(RedPen, new Point(chip, 0), new Point(chip, Height));

                    int s1 = (int)Math.Truncate(startpile) + 1;
                    int s2 = (int)Math.Truncate(endpile);
                    for (int i = s1; i <= s2; i++)
                    {
                        if ((i < 1000) || (i > 13500))
                        {
                            continue;
                        }
                        string st  = i.ToString();
                        string st1 = st.Substring(0, st.Length - 3);
                        if ((st1 == null) || (st1 == ""))
                        {
                            st1 = "0";
                        }
                        string st2 = st.Substring(st.Length - 3);
                        st = "K" + st1 + "+" + st2;
                        double d      = (Convert.ToDouble(i) - startpile) / (endpile - startpile) * xDest;
                        double deltad = (100.0) / (endpile - startpile) * xDest;
                        if (i % 1000 == 0)
                        {
                            drawingContext.DrawLine(p, new Point(d, 0), new Point(d, SegmentHeight));
                            FormattedText ft = new FormattedText(
                                st, CultureInfo.CurrentCulture,
                                FlowDirection.LeftToRight,
                                new Typeface("Arial"),
                                DipHelper.PtToDip(6),
                                Brushes.DimGray);
                            ft.SetFontWeight(FontWeights.Regular);
                            ft.TextAlignment = TextAlignment.Center;
                            drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            continue;
                        }
                        if (i % 500 == 0)
                        {
                            drawingContext.DrawLine(p, new Point(d, 0), new Point(d, SegmentHeight * 2.0 / 3.0));
                            FormattedText ft = new FormattedText(st2, CultureInfo.CurrentCulture,
                                                                 FlowDirection.LeftToRight,
                                                                 new Typeface("Arial"),
                                                                 DipHelper.PtToDip(6),
                                                                 Brushes.DimGray);
                            ft.SetFontWeight(FontWeights.Regular);
                            ft.TextAlignment = TextAlignment.Center;
                            drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            continue;
                        }
                        if (i % 100 == 0)
                        {
                            drawingContext.DrawLine(ThinPen, new Point(d, 0), new Point(d, SegmentHeight / 3.0));
                            if (deltad >= fontwidth)
                            {
                                FormattedText ft = new FormattedText(st2, CultureInfo.CurrentCulture,
                                                                     FlowDirection.LeftToRight,
                                                                     new Typeface("Arial"),
                                                                     DipHelper.PtToDip(6),
                                                                     Brushes.DimGray);
                                ft.SetFontWeight(FontWeights.Regular);
                                ft.TextAlignment = TextAlignment.Center;
                                drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            }
                            continue;
                        }
                    }
                }
                if (Marks == "MILI")
                {
                    double startpile = DipHelper.GetRulerMileage(RulerExtent.XMin);
                    double endpile   = DipHelper.GetRulerMileage(RulerExtent.XMax);
                    double fontwidth = DipHelper.PtToDip(6) * 3;

                    double chip = (Chip - startpile) / (endpile - startpile) * xDest;
                    drawingContext.DrawLine(RedPen, new Point(chip, 0), new Point(chip, Height));
                    show_number = mileage_start.Count;
                    for (int i = 0; i <= show_number - 1; i++)
                    {
                        Pile   p_a = DipHelper.getSectionPos(mileage_start[i]);
                        Pile   p_b = DipHelper.getSectionPos(mileage_end[i]);
                        string st  = show_content[i];
                        double p1  = Convert.ToDouble(p_a.pilepoint);
                        double p2  = Convert.ToDouble(p_b.pilepoint);
                        if (p1 < startpile)
                        {
                            p1 = startpile;
                        }
                        if (p2 > endpile)
                        {
                            p2 = endpile;
                        }
                        double d1 = (p1 - startpile) / (endpile - startpile) * xDest;
                        double d2 = (p2 - startpile) / (endpile - startpile) * xDest;
                        if ((d1 < 0) || (d2 < 0))
                        {
                            continue;
                        }
                        if ((d1 > xDest) || (d2 > xDest))
                        {
                            continue;
                        }
                        double deltad = Math.Abs(p2 - p1) / (endpile - startpile) * xDest;
                        drawingContext.DrawLine(p, new Point(d1, 0), new Point(d1, SegmentHeight / 2));
                        drawingContext.DrawLine(p, new Point(d2, 0), new Point(d2, SegmentHeight / 2));
                        if (deltad >= fontwidth)
                        {
                            FormattedText ft = new FormattedText(
                                st, CultureInfo.CurrentCulture,
                                FlowDirection.LeftToRight,
                                new Typeface("Arial"),
                                DipHelper.PtToDip(6),
                                Brushes.DimGray);
                            ft.SetFontWeight(FontWeights.Regular);
                            ft.TextAlignment = TextAlignment.Center;
                            drawingContext.DrawText(ft, new Point((d1 + d2) / 2, Height - ft.Height));
                        }
                    }
                }

                if (Marks == "Vertical")
                {
                    double startheight = DipHelper.GetRulerAltitude(RulerExtent.XMin);
                    double endheight   = DipHelper.GetRulerAltitude(RulerExtent.XMax);
                    double fontwidth   = DipHelper.PtToDip(6) * 3;

                    double chip = (Chip - startheight) / (endheight - startheight) * xDest;
                    drawingContext.DrawLine(RedPen, new Point(chip, 0), new Point(chip, Height));

                    int s1 = (int)Math.Truncate(startheight) + 1;
                    int s2 = (int)Math.Truncate(endheight);
                    for (int i = s1; i <= s2; i++)
                    {
                        if ((i < 1300) || (i > 5000))
                        {
                            continue;
                        }
                        string st     = i.ToString();
                        double d      = (Convert.ToDouble(i) - startheight) / (endheight - startheight) * xDest;
                        double deltad = (100.0) / (endheight - startheight) * xDest;
                        if (i % 1000 == 0)
                        {
                            drawingContext.DrawLine(p, new Point(d, 0), new Point(d, SegmentHeight));
                            FormattedText ft = new FormattedText(
                                st, CultureInfo.CurrentCulture,
                                FlowDirection.LeftToRight,
                                new Typeface("Arial"),
                                DipHelper.PtToDip(6),
                                Brushes.DimGray);
                            ft.SetFontWeight(FontWeights.Regular);
                            ft.TextAlignment = TextAlignment.Center;
                            drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            continue;
                        }
                        if (i % 500 == 0)
                        {
                            drawingContext.DrawLine(p, new Point(d, 0), new Point(d, SegmentHeight * 2.0 / 3.0));
                            FormattedText ft = new FormattedText(st, CultureInfo.CurrentCulture,
                                                                 FlowDirection.LeftToRight,
                                                                 new Typeface("Arial"),
                                                                 DipHelper.PtToDip(6),
                                                                 Brushes.DimGray);
                            ft.SetFontWeight(FontWeights.Regular);
                            ft.TextAlignment = TextAlignment.Center;
                            drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            continue;
                        }
                        if (i % 100 == 0)
                        {
                            drawingContext.DrawLine(ThinPen, new Point(d, 0), new Point(d, SegmentHeight / 3.0));
                            if (deltad >= fontwidth)
                            {
                                FormattedText ft = new FormattedText(st, CultureInfo.CurrentCulture,
                                                                     FlowDirection.LeftToRight,
                                                                     new Typeface("Arial"),
                                                                     DipHelper.PtToDip(6),
                                                                     Brushes.DimGray);
                                ft.SetFontWeight(FontWeights.Regular);
                                ft.TextAlignment = TextAlignment.Center;
                                drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            }
                            continue;
                        }
                    }
                }
                if (Marks == "XJ")
                {
                    double startheight = RulerExtent.XMin;
                    double endheight   = RulerExtent.XMax;
                    double fontwidth   = DipHelper.PtToDip(6) * 3;

                    double chip = (Chip - startheight) / (endheight - startheight) * xDest;
                    drawingContext.DrawLine(RedPen, new Point(chip, 0), new Point(chip, Height));

                    int s1 = (int)Math.Truncate(startheight) + 1;
                    int s2 = (int)Math.Truncate(endheight);
                    for (int i = s1; i <= s2; i++)
                    {
                        int pile = DipHelper.GetRulerXJMileage(i);
                        if (pile < 0)
                        {
                            continue;
                        }
                        string st  = pile.ToString().PadLeft(4, '0');
                        string st2 = st.Substring(st.Length - 3);
                        st = "K" + st[0] + "+" + st2;
                        double d      = (Convert.ToDouble(i) - startheight) / (endheight - startheight) * xDest;
                        double deltad = (10.0) / (endheight - startheight) * xDest;
                        if ((pile % 1000 == 0) || (pile == 1900))
                        {
                            drawingContext.DrawLine(p, new Point(d, 0), new Point(d, SegmentHeight));
                            FormattedText ft = new FormattedText(
                                st, CultureInfo.CurrentCulture,
                                FlowDirection.LeftToRight,
                                new Typeface("Arial"),
                                DipHelper.PtToDip(6),
                                Brushes.DimGray);
                            ft.SetFontWeight(FontWeights.Regular);
                            ft.TextAlignment = TextAlignment.Center;
                            drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            continue;
                        }
                        if (pile % 500 == 0)
                        {
                            drawingContext.DrawLine(p, new Point(d, 0), new Point(d, SegmentHeight * 2.0 / 3.0));
                            FormattedText ft = new FormattedText(st2, CultureInfo.CurrentCulture,
                                                                 FlowDirection.LeftToRight,
                                                                 new Typeface("Arial"),
                                                                 DipHelper.PtToDip(6),
                                                                 Brushes.DimGray);
                            ft.SetFontWeight(FontWeights.Regular);
                            ft.TextAlignment = TextAlignment.Center;
                            drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            continue;
                        }
                        if (pile % 100 == 0)
                        {
                            drawingContext.DrawLine(ThinPen, new Point(d, 0), new Point(d, SegmentHeight / 3.0));
                            if (deltad >= fontwidth)
                            {
                                FormattedText ft = new FormattedText(st2, CultureInfo.CurrentCulture,
                                                                     FlowDirection.LeftToRight,
                                                                     new Typeface("Arial"),
                                                                     DipHelper.PtToDip(6),
                                                                     Brushes.DimGray);
                                ft.SetFontWeight(FontWeights.Regular);
                                ft.TextAlignment = TextAlignment.Center;
                                drawingContext.DrawText(ft, new Point(d, Height - ft.Height));
                            }
                            continue;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }