Exemplo n.º 1
0
 private void DrawStation(MarkerData s, Rectangle rc)
 {
     if (s.Visible)
     {
         Line l = new Line();
         l.set_X1((double)s.Position);
         l.set_X2((double)s.Position);
         l.set_Y1((double)rc.Y);
         l.set_Y2(this.CanvasRoot_ActualHeight - rc.Y);
         l.set_Width(1251.0);
         l.set_Height(this.CanvasRoot_ActualHeight);
         if (s.Style == PositionMarkerStyle.MarkerStation)
         {
             l.set_StrokeThickness(2.0);
         }
         else if (s.Style == PositionMarkerStyle.MarkerIntermediateStop)
         {
             l.get_StrokeDashArray().Add(2.0);
             l.get_StrokeDashArray().Add(2.0);
             l.set_StrokeThickness(2.0);
         }
         else if (s.Style == PositionMarkerStyle.MarkerSegmentBorder)
         {
             l.set_StrokeThickness(1.0);
         }
         else
         {
             l.set_StrokeThickness(2.0);
         }
         l.set_Stroke(new SolidColorBrush(SilverlightHelper.ConvertToColor(s.Color)));
         this.LineAdjust1PixelsWidth(l);
         this.CanvasRoot.get_Children().Add(l);
     }
 }
Exemplo n.º 2
0
 public void Draw()
 {
     this.Text.set_Text("");
     if (this.m_tl != null)
     {
         this.Text.set_Text((this.m_tl.Text.Length > 0) ? this.m_tl.Text : this.m_tl.ID);
         this.Text.set_Foreground(new SolidColorBrush(SilverlightHelper.ConvertToColor(this.m_tl.TextForeColor)));
         this.Text.set_FontFamily(new FontFamily(this.m_tl.FontName));
         this.Text.set_FontSize((double)(this.m_tl.FontSize + 3f));
         if ((this.m_tl.FontStyle & 1) == 1)
         {
             this.Text.set_FontWeight(FontWeights.get_Bold());
         }
         if ((this.m_tl.FontStyle & 2) == 2)
         {
             this.Text.set_FontStyle(FontStyles.get_Italic());
         }
         if ((this.m_tl.FontStyle & 4) == 4)
         {
             this.Text.set_TextDecorations(TextDecorations.get_Underline());
         }
         RotateTransform transform = new RotateTransform();
         transform.set_Angle((double)this.m_tl.Escapement);
         this.Text.set_RenderTransform(transform);
     }
 }
Exemplo n.º 3
0
        private double DrawCurveTitle(Rectangle rc, PointData dpt1, PointData dpt2, string title, bool draw)
        {
            Point     point3;
            Point     point4;
            PointData data;
            Point     point  = this.PointData2Point(dpt1, rc);
            Point     point2 = this.PointData2Point(dpt2, rc);

            if (point.get_X() < point2.get_X())
            {
                point3 = point;
                point4 = point2;
                data   = dpt1;
            }
            else
            {
                point3 = point2;
                point4 = point;
                data   = dpt2;
            }
            Color color = SilverlightHelper.ConvertToColor(dpt2.Color);

            if (dpt1.DateTime > dpt2.DateTime)
            {
                color = SilverlightHelper.ConvertToColor(dpt1.Color);
            }
            double    rotationAngle = SilverlightHelper.GetRotationAngle(point3, point4);
            TextBlock block         = new TextBlock();
            int       num2          = 100;
            double    num3          = 5.0;

            block.SetValue(Canvas.TopProperty, point3.get_Y() + num3);
            block.SetValue(Canvas.LeftProperty, point3.get_X() + num3);
            block.SetValue(FrameworkElement.WidthProperty, (double)num2);
            block.SetValue(FrameworkElement.HeightProperty, 50.0);
            block.set_Width((double)num2);
            block.set_Text(title);
            block.set_FontSize(12.0);
            block.set_FontFamily(new FontFamily("Arial"));
            block.set_Foreground(new SolidColorBrush(color));
            block.set_FontStyle(FontStyles.get_Normal());
            block.set_FontWeight(FontWeights.get_Bold());
            RotateTransform transform = new RotateTransform();

            transform.set_Angle(-rotationAngle);
            block.set_RenderTransform(transform);
            block.set_TextAlignment(1);
            if (draw)
            {
                this.CanvasRoot.get_Children().Add(block);
            }
            return(block.get_ActualWidth() + num3);
        }
Exemplo n.º 4
0
        private int FindBetterPointForCurveTitleDrawing(TrainCurveData c, int startIndex, int endIndex, Rectangle rc)
        {
            Point point = this.PointData2Point(c.Points[endIndex], rc);

            for (int i = startIndex; (i < c.Points.Count) && (i <= endIndex); i++)
            {
                if (Math.Abs(SilverlightHelper.GetRotationAngle(this.PointData2Point(c.Points[i], rc), point)) < 30.0)
                {
                    return(i);
                }
            }
            return(startIndex);
        }
Exemplo n.º 5
0
        public void Draw(bool full)
        {
            Rectangle rectangle;

            SilverlightHelper.Debug(">>> Draw");
            if (full)
            {
                this.UpdateHeight();
            }
            if (this.m_tgd.Markers.Count > 0)
            {
                this.m_stations.Clear();
                this.m_tgd.Markers.Sort(new Comparison <MarkerData>(this.MySortFunction));
                this.m_stations.AddRange(this.m_tgd.Markers);
            }
            this.DrawGetRectangle(this.m_stations, out rectangle);
            this.DrawActualTime(rectangle);
            if (((this.m_tgd != null) && (this.m_tgd.Markers != null)) && (this.m_tgd.Curves != null))
            {
                if (full)
                {
                    double num;
                    double num2;
                    this.CanvasRoot.get_Children().Clear();
                    this.DrawStations(this.m_stations, rectangle, out num, out num2);
                    this.DrawScales(rectangle, this.m_stations, num, num2);
                    this.DrawCurves(rectangle, full);
                    this.DrawActualTime(rectangle);
                }
                else
                {
                    this.DrawCurves(rectangle, full);
                }
                if (this.m_bAllowToUpdateScroll || full)
                {
                    double num3 = this.DateTime2PointY(this.m_actualTime, rectangle) - (this.scrollViewer.get_ActualHeight() / 2.0);
                    this.scrollViewer.UpdateLayout();
                    this.scrollViewer.ScrollToVerticalOffset(num3);
                }
                SilverlightHelper.Debug("<<< Draw");
            }
        }
Exemplo n.º 6
0
        private void DrawStationTimeScale(double y, List <MarkerData> ls, bool big)
        {
            double num = big ? 4.5 : 2.0;

            foreach (MarkerData data in ls)
            {
                if (data.Style == PositionMarkerStyle.MarkerStation)
                {
                    Line l = new Line();
                    l.set_X1(data.Position - num);
                    l.set_Y1(y);
                    l.set_X2(data.Position + num);
                    l.set_Y2(y);
                    this.LineAdjust1PixelsWidth(l);
                    l.set_Width(1251.0);
                    l.set_Height(this.CanvasRoot_ActualHeight);
                    l.set_StrokeThickness(1.0);
                    l.set_Stroke(new SolidColorBrush(SilverlightHelper.ConvertToColor(data.Color)));
                    this.CanvasRoot.get_Children().Add(l);
                }
            }
        }
Exemplo n.º 7
0
        private void DrawCurves(Rectangle rc, bool full)
        {
            SilverlightHelper.Debug("DrawCurves started");
            List <TrainCurveData> list  = new List <TrainCurveData>();
            List <TrainCurveData> list2 = new List <TrainCurveData>();

            foreach (CurveData data in this.m_tgd.Curves)
            {
                TrainCurveData item = new TrainCurveData {
                    CaptionHasDrawn = false,
                    Caption         = data.Caption,
                    Name            = data.Name,
                    Points          = data.Points,
                    Regular         = data.Regular
                };
                if (item.Regular)
                {
                    list.Add(item);
                }
                else
                {
                    list2.Add(item);
                }
            }
            if (full)
            {
                SilverlightHelper.Debug("Regular curves draw started");
                if (list.Count > 0)
                {
                    this.m_regularCurves = list;
                }
                List <Line> rectangles = new List <Line>();
                foreach (TrainCurveData data2 in this.m_regularCurves)
                {
                    this.DrawCurve(data2, rc, rectangles, 0);
                }
                SilverlightHelper.Debug("Regular curves draw finished");
            }
            SilverlightHelper.Debug("Realtime curves draw started");
            Dictionary <string, int> dictionary = new Dictionary <string, int>();

            foreach (TrainCurveData data2 in list2)
            {
                if (!this.m_name2RealtimeCurve.ContainsKey(data2.Name))
                {
                    this.m_name2RealtimeCurve[data2.Name] = new TrainCurveData();
                }
                this.m_name2RealtimeCurve[data2.Name].Caption = data2.Caption;
                this.m_name2RealtimeCurve[data2.Name].Name    = data2.Name;
                this.m_name2RealtimeCurve[data2.Name].Regular = data2.Regular;
                dictionary[data2.Name] = (this.m_name2RealtimeCurve[data2.Name].Points.Count > 0) ? (this.m_name2RealtimeCurve[data2.Name].Points.Count - 1) : 0;
                this.m_name2RealtimeCurve[data2.Name].Points.AddRange(data2.Points);
            }
            foreach (string str in dictionary.Keys)
            {
                int startIndex = dictionary[str];
                this.DrawCurve(this.m_name2RealtimeCurve[str], rc, null, startIndex);
            }
            SilverlightHelper.Debug("Realtime curves draw finished");
            SilverlightHelper.Debug("DrawCurves finished");
        }
Exemplo n.º 8
0
 private void DrawCurve(TrainCurveData c, Rectangle rc, List <Line> rectangles, int startIndex)
 {
     if ((c != null) && (c.Points != null))
     {
         PointData data;
         PointData data2;
         int       num           = 0;
         int       num2          = -1;
         Line      item          = new Line();
         Color     color         = Colors.get_Black();
         double    widthRequires = 0.0;
         if (c.Points.Count > 0)
         {
             widthRequires = this.DrawCurveTitle(rc, c.Points[0], c.Points[0], c.Caption, false);
         }
         for (int i = startIndex; i < (c.Points.Count - 1); i++)
         {
             data  = c.Points[i];
             data2 = c.Points[i + 1];
             if (!c.Regular)
             {
                 TimeSpan span = (TimeSpan)(data.DateTime - data2.DateTime);
                 if (this.IsGap((double)(data.Position - data2.Position), span.TotalMinutes))
                 {
                     c.CaptionHasDrawn   = false;
                     c.CaptionStartIndex = i + 1;
                     continue;
                 }
             }
             color = SilverlightHelper.ConvertToColor(data2.Color);
             Line line2 = new Line();
             line2.set_X1(this.Position2PointX(data.Position, rc));
             line2.set_Y1(this.DateTime2PointY(data.DateTime, rc));
             line2.set_X2(this.Position2PointX(data2.Position, rc));
             line2.set_Y2(this.DateTime2PointY(data2.DateTime, rc));
             line2.set_Width(1251.0);
             line2.set_Height(this.CanvasRoot_ActualHeight);
             line2.set_StrokeThickness(2.0);
             line2.set_Stroke(new SolidColorBrush(color));
             this.CanvasRoot.get_Children().Add(line2);
             if (c.Regular && (c.Caption.Length > 0))
             {
                 if (!this.HasInsersection(rectangles, line2))
                 {
                     int num5 = data2.Position - data.Position;
                     if (num5 > num)
                     {
                         num  = num5;
                         num2 = i;
                         item = this.LineClone(line2);
                     }
                 }
             }
             else if (!c.CaptionHasDrawn)
             {
                 int  num6;
                 int  num7;
                 int  num8;
                 bool flag;
                 if (this.GetGoodPointsForTitle(c, c.CaptionStartIndex, rc, widthRequires, out num6, out num7, out num8, out flag))
                 {
                     c.CaptionHasDrawn = true;
                     this.DrawCurveTitle(rc, c.Points[num6], c.Points[num7], c.Caption, true);
                 }
                 else if (flag)
                 {
                     c.CaptionStartIndex = num8;
                 }
             }
         }
         if ((c.Regular && (c.Caption.Length > 0)) && (num2 != -1))
         {
             data  = c.Points[num2];
             data2 = c.Points[num2 + 1];
             color = SilverlightHelper.ConvertToColor(data2.Color);
             if (rectangles != null)
             {
                 rectangles.Add(item);
             }
             Point point  = new Point();
             Point point2 = new Point();
             point.set_X(this.Position2PointX(data.Position, rc));
             point.set_Y(this.DateTime2PointY(data.DateTime, rc));
             point2.set_X(this.Position2PointX(data2.Position, rc));
             point2.set_Y(this.DateTime2PointY(data2.DateTime, rc));
             double    rotationAngle = SilverlightHelper.GetRotationAngle(point, point2);
             double    num10         = point2.get_X() - point.get_X();
             TextBlock block         = new TextBlock();
             block.SetValue(Canvas.TopProperty, point.get_Y() + 5.0);
             block.SetValue(Canvas.LeftProperty, point.get_X());
             block.SetValue(FrameworkElement.WidthProperty, num10);
             block.SetValue(FrameworkElement.HeightProperty, 50.0);
             block.set_Width(num10);
             block.set_Text(c.Caption);
             block.set_FontSize(17.0);
             block.set_FontFamily(new FontFamily("Arial"));
             block.set_Foreground(new SolidColorBrush(color));
             block.set_FontStyle(FontStyles.get_Normal());
             block.set_FontWeight(FontWeights.get_Bold());
             RotateTransform transform = new RotateTransform();
             transform.set_Angle(-rotationAngle);
             block.set_RenderTransform(transform);
             block.set_TextAlignment(0);
             this.CanvasRoot.get_Children().Add(block);
         }
     }
 }
Exemplo n.º 9
0
        private void DrawTrain(Canvas g, Train train, Point pt, bool small, bool allowToDraw, out Rectangle rectangle)
        {
            Color color;
            Color color2;

            rectangle = new Rectangle();
            TrainControl control = new TrainControl(train);

            control.OnTrainProperties += new TrainControl.TrainPropertiesHandler(this.TrainControl_OnTrainProperties);
            Train.GetTrainColors(train, out color, out color2);
            control.BodyColorHi = color2;
            control.BodyColorLo = color;
            Point       connectionSourcePoint = new Point(0.0, 0.0);
            Point       point2      = new Point(0.0, 0.0);
            PathElement headElement = train.HeadElement;

            if ((train.NextElement != null) && (train.NextElement != headElement))
            {
                connectionSourcePoint = train.NextElement.GetConnectionSourcePoint(train.m_nNextElementSource);
                point2 = train.HeadElement.GetConnectionSourcePoint(train.m_nHeadElementArrivedSource);
            }
            else if (train.m_nHeadElementArrivedSource != -1)
            {
                connectionSourcePoint = headElement.GetConnectionSourcePoint(headElement.GetOppositeSource(train.m_nHeadElementArrivedSource));
                point2 = headElement.GetConnectionSourcePoint(train.m_nHeadElementArrivedSource);
            }
            double rotationAngle = 0.0;

            if ((((connectionSourcePoint.get_X() != 0.0) || (connectionSourcePoint.get_Y() != 0.0)) && ((point2.get_X() != 0.0) || (point2.get_Y() != 0.0))) && (point2 != connectionSourcePoint))
            {
                rotationAngle = SilverlightHelper.GetRotationAngle(point2, connectionSourcePoint);
            }
            else if (train.HeadElement != null)
            {
                int[] sources = train.HeadElement.GetSources();
                if ((sources != null) && (sources.Length > 1))
                {
                    point2 = train.HeadElement.GetConnectionSourcePoint(sources[0]);
                    connectionSourcePoint = train.HeadElement.GetConnectionSourcePoint(sources[1]);
                    rotationAngle         = SilverlightHelper.GetRotationAngle(point2, connectionSourcePoint);
                }
            }
            control.ID          = train.ID;
            control.Tooltip     = train.GetToolTipText();
            control.IDToDisplay = train.IDToDisplay;
            control.Small       = small;
            control.Direction   = 1;
            rectangle           = new Rectangle();
            rectangle.X         = (int)pt.get_X();
            rectangle.Y         = (int)pt.get_Y();
            rectangle.Width     = (int)control.WIDTH_ACTUAL;
            rectangle.Height    = (int)control.HEIGHT_ACTUAL;
            if (allowToDraw)
            {
                control.SetValue(Canvas.LeftProperty, (double)rectangle.X);
                control.SetValue(Canvas.TopProperty, (double)rectangle.Y);
                control.SetValue(FrameworkElement.WidthProperty, (double)rectangle.Width);
                control.SetValue(FrameworkElement.HeightProperty, (double)rectangle.Height);
                double num2 = point2.get_X() - connectionSourcePoint.get_X();
                double num3 = point2.get_Y() - connectionSourcePoint.get_Y();
                int[]  textOrientationVectorHor = TextOrientationVectorHor;
                if (train.HeadElement is Track)
                {
                    Track track = train.HeadElement as Track;
                    if (track.PointMinus.get_Y() == track.PointPlus.get_Y())
                    {
                        textOrientationVectorHor = TextOrientationVectorVer;
                    }
                }
                double num4 = SilverlightHelper.GetAngleBetweenVercors((double)textOrientationVectorHor[0], (double)textOrientationVectorHor[1], num2, num3);
                control.Draw(num4 >= 90.0);
                RotateTransform transform = new RotateTransform();
                transform.set_Angle(-rotationAngle);
                control.set_RenderTransform(transform);
                g.get_Children().Add(control);
            }
            rectangle.Width += (int)(2.0 * control.NOSE_LEN);
            rectangle.Height = rectangle.Width = Math.Max(rectangle.Width, rectangle.Height);
        }