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); } } }
private void DrawScales(Rectangle rc, List <MarkerData> s, double lastRightStationPosition, double firstLeftStationXPos) { DateTime timeStart = this.m_tgd.TimeStart; TimeSpan span = TimeSpan.FromMinutes(1.0); double num = 16.0; double num2 = 18.0; double num3 = 5.0; while (timeStart <= this.m_tgd.TimeStop) { double y = this.DateTime2PointY(timeStart, rc); if ((timeStart.Minute == 0) || ((timeStart.Minute % 10) == 0)) { this.DrawHorScaleLine(rc, y); this.DrawStationTimeScale(y, s, true); TextBlock block = new TextBlock(); block.SetValue(Canvas.TopProperty, y - (num2 / 2.0)); block.SetValue(Canvas.LeftProperty, ((firstLeftStationXPos - num) - num3) - 1.0); block.SetValue(FrameworkElement.WidthProperty, num); block.SetValue(FrameworkElement.HeightProperty, num2); block.set_TextAlignment(0); TextBlock block2 = new TextBlock(); block2.SetValue(Canvas.TopProperty, y - (num2 / 2.0)); block2.SetValue(Canvas.LeftProperty, (lastRightStationPosition + num3) + 2.0); block2.SetValue(FrameworkElement.WidthProperty, num); block2.SetValue(FrameworkElement.HeightProperty, num2); block2.set_TextAlignment(0); if (timeStart.Minute == 0) { block.set_Text(timeStart.Hour.ToString("00")); block.set_FontSize(15.0); block.set_FontFamily(new FontFamily("Arial")); block.set_Foreground(new SolidColorBrush(Colors.get_Black())); block.set_FontStyle(FontStyles.get_Normal()); block.set_FontWeight(FontWeights.get_Bold()); } else if ((timeStart.Minute % 10) == 0) { block.set_Text(timeStart.Minute.ToString()); block.set_FontSize(13.0); block.set_FontFamily(new FontFamily("Arial")); block.set_Foreground(new SolidColorBrush(Colors.get_Gray())); block.set_FontStyle(FontStyles.get_Normal()); block.set_FontWeight(FontWeights.get_Normal()); } block2.set_Text(block.get_Text()); block2.set_FontStyle(block.get_FontStyle()); block2.set_FontWeight(block.get_FontWeight()); block2.set_FontSize(block.get_FontSize()); block2.set_FontFamily(block.get_FontFamily()); block2.set_Foreground(block.get_Foreground()); this.CanvasRoot.get_Children().Add(block); this.CanvasRoot.get_Children().Add(block2); } else { this.DrawStationTimeScale(y, s, false); } timeStart = timeStart.Add(span); } }
public void Draw(bool bRotateText) { this.CanvasRoot.get_Children().Clear(); base.set_Height(this.HEIGHT_ACTUAL); base.set_Width(this.WIDTH_ACTUAL); this.CanvasRoot.SetValue(FrameworkElement.WidthProperty, this.WIDTH_ACTUAL); this.CanvasRoot.SetValue(FrameworkElement.HeightProperty, this.HEIGHT_ACTUAL); base.SetValue(FrameworkElement.WidthProperty, this.WIDTH_ACTUAL); base.SetValue(FrameworkElement.HeightProperty, this.HEIGHT_ACTUAL); Brush brush = CreateHatchBrush(this.BodyColorHi, this.BodyColorLo); Brush brush2 = CreateHatchBrush(this.BodyColorLo, this.BodyColorHi); Rectangle rectangle = new Rectangle(); rectangle.set_StrokeThickness(0.0); rectangle.set_Fill(brush); rectangle.SetValue(Canvas.LeftProperty, this.x0); rectangle.SetValue(Canvas.TopProperty, 0.0); rectangle.SetValue(FrameworkElement.HeightProperty, this.HEIGHT_ACTUAL / 2.0); rectangle.SetValue(FrameworkElement.WidthProperty, this.WIDTH_ACTUAL); Rectangle rectangle2 = new Rectangle(); rectangle2.set_StrokeThickness(0.0); rectangle2.set_Fill(brush2); rectangle2.SetValue(Canvas.LeftProperty, this.x0); rectangle2.SetValue(Canvas.TopProperty, 0.0 + (this.HEIGHT_ACTUAL / 2.0)); rectangle2.SetValue(FrameworkElement.HeightProperty, this.HEIGHT_ACTUAL / 2.0); rectangle2.SetValue(FrameworkElement.WidthProperty, this.WIDTH_ACTUAL); this.CanvasRoot.get_Children().Add(rectangle); this.CanvasRoot.get_Children().Add(rectangle2); if ((this.Direction == 1) || (this.Direction == -1)) { Polygon polygon = new Polygon(); polygon.set_Fill(brush); polygon.set_StrokeThickness(0.0); Polygon polygon2 = new Polygon(); polygon2.set_Fill(brush2); polygon2.set_StrokeThickness(0.0); if (this.Direction == 1) { polygon.get_Points().Add(new Point(this.x0 + this.WIDTH_ACTUAL, 0.0)); polygon.get_Points().Add(new Point(this.x0 + this.WIDTH_ACTUAL, 0.0 + (this.HEIGHT_ACTUAL / 2.0))); polygon.get_Points().Add(new Point((this.x0 + this.WIDTH_ACTUAL) + this.NOSE_LEN, 0.0 + (this.HEIGHT_ACTUAL / 2.0))); polygon2.get_Points().Add(new Point(this.x0 + this.WIDTH_ACTUAL, 0.0 + (this.HEIGHT_ACTUAL / 2.0))); polygon2.get_Points().Add(new Point(this.x0 + this.WIDTH_ACTUAL, 0.0 + this.HEIGHT_ACTUAL)); polygon2.get_Points().Add(new Point((this.x0 + this.WIDTH_ACTUAL) + this.NOSE_LEN, 0.0 + (this.HEIGHT_ACTUAL / 2.0))); } else if (this.Direction == -1) { polygon.get_Points().Add(new Point(this.x0, 0.0)); polygon.get_Points().Add(new Point(this.x0, 0.0 + (this.HEIGHT_ACTUAL / 2.0))); polygon.get_Points().Add(new Point(0.0, 0.0 + (this.HEIGHT_ACTUAL / 2.0))); polygon2.get_Points().Add(new Point(this.x0, 0.0 + this.HEIGHT_ACTUAL)); polygon2.get_Points().Add(new Point(0.0, 0.0 + (this.HEIGHT_ACTUAL / 2.0))); polygon2.get_Points().Add(new Point(this.x0, 0.0 + (this.HEIGHT_ACTUAL / 2.0))); } this.CanvasRoot.get_Children().Add(polygon); this.CanvasRoot.get_Children().Add(polygon2); } if (this.IDToDisplay.Length > 0) { TextBlock block = new TextBlock(); block.set_Text(this.IDToDisplay); double num = 16.5; block.set_FontFamily((this.IDToDisplay != "?") ? this.m_fntTrainBigImpact : this.m_fntTrainBigNormal); block.set_FontSize((this.IDToDisplay != "?") ? ((double)this.m_fntTrainBigImpactSize) : ((double)this.m_fntTrainBigNormalSize)); block.set_FontWeight((this.IDToDisplay != "?") ? this.m_fntTrainBigImpactStyle : this.m_fntTrainBigNormalStyle); block.set_FontStretch(FontStretches.get_Normal()); block.set_FontStyle(FontStyles.get_Normal()); if (this.m_Small) { block.set_FontFamily(this.m_fntTrainSmall); block.set_FontSize((double)this.m_fntTrainSmallSize); block.set_FontWeight(this.m_fntTrainSmallStyle); num = 12.0; } block.SetValue(Canvas.LeftProperty, this.x0); block.SetValue(Canvas.TopProperty, (0.0 + (this.HEIGHT_ACTUAL / 2.0)) - (num / 2.0)); block.SetValue(FrameworkElement.WidthProperty, this.WIDTH_ACTUAL); block.set_Foreground(new SolidColorBrush(Colors.get_Yellow())); block.set_TextAlignment(0); if (bRotateText) { RotateTransform transform = new RotateTransform(); transform.set_Angle(180.0); transform.set_CenterX(this.WIDTH_ACTUAL / 2.0); transform.set_CenterY(block.get_ActualHeight() / 2.0); block.set_RenderTransform(transform); } this.CanvasRoot.get_Children().Add(block); } foreach (FrameworkElement element in this.CanvasRoot.get_Children()) { double num2 = Convert.ToDouble(element.GetValue(Canvas.LeftProperty)); double num3 = Convert.ToDouble(element.GetValue(Canvas.TopProperty)); num2 = (num2 - (this.WIDTH_ACTUAL / 2.0)) - this.NOSE_LEN; num3 -= this.HEIGHT_ACTUAL / 2.0; element.SetValue(Canvas.LeftProperty, num2); element.SetValue(Canvas.TopProperty, num3); } }