Example #1
0
        private Point RotateVector(Point o, double angleRadian)
        {
            Point point = new Point();

            point.set_X((o.get_X() * Math.Cos(angleRadian)) - (o.get_Y() * Math.Sin(angleRadian)));
            point.set_Y((o.get_X() * Math.Sin(angleRadian)) + (o.get_Y() * Math.Cos(angleRadian)));
            point.set_X((double)((int)point.get_X()));
            point.set_Y((double)((int)point.get_Y()));
            return(point);
        }
Example #2
0
        public static Point GetPointRotatedByY(int width, Point point)
        {
            int num  = width - ((int)point.get_X());
            int num2 = (int)point.get_Y();

            return(new Point((double)num, (double)num2));
        }
Example #3
0
 public Point CalcNonStraightCenter(Point pTo)
 {
     Point point = new Point();
     point.set_X(base.PointCore.get_X() + (Math.Sign((double) (pTo.get_X() - base.PointCore.get_X())) * 6));
     point.set_Y(base.PointCore.get_Y() + (Math.Sign((double) (pTo.get_Y() - base.PointCore.get_Y())) * 6));
     return point;
 }
Example #4
0
        public void DrawOfflineTrains(List <TrainWebData> listTrains, LegendUILoader legendLoader)
        {
            MouseButtonEventHandler handler = null;

            foreach (TrainWebData data in listTrains)
            {
                Track peHead = base.GetElement(data.HeadElement) as Track;
                if (peHead != null)
                {
                    Point trainPoint = peHead.GetTrainPoint();
                    Track.GetOffsettedValue(peHead, (double)data.HeadOffset, data.HeadElementArrivedSource, ref trainPoint);
                    FrameworkElement control = legendLoader.GetControl();
                    control.set_Tag(data);
                    double num    = 0.0;
                    Point  point2 = new Point(0.5, 1.0);
                    if (peHead.PointPlus.get_X() == peHead.PointMinus.get_X())
                    {
                        point2 = new Point(1.0, 0.5);
                        num    = 90.0;
                    }
                    control.SetValue(Canvas.LeftProperty, trainPoint.get_X() - (point2.get_X() * 16.0));
                    control.SetValue(Canvas.TopProperty, trainPoint.get_Y() - (point2.get_Y() * 16.0));
                    this.g.get_Children().Add(control);
                    RotateTransform transform = new RotateTransform();
                    transform.set_Angle(-num);
                    control.set_RenderTransform(transform);
                    ToolTipService.SetToolTip(control, TrainControl.CreateTooltipControl(data.Tooltip));
                    if (handler == null)
                    {
                        handler = new MouseButtonEventHandler(this, (IntPtr)this.< DrawOfflineTrains > b__1);
                    }
                    control.add_MouseLeftButtonDown(handler);
                }
            }
        }
Example #5
0
        public static Point GetPointRotatedByX(int rY, Point point)
        {
            int num  = (int)point.get_X();
            int num2 = ((int)point.get_Y()) - rY;
            int num3 = rY - num2;

            return(new Point((double)num, (double)num3));
        }
Example #6
0
        public Point CalcCenter(Point pTo)
        {
            Point point = new Point();

            point.set_X(this.PointCore.get_X() + (((int)(pTo.get_X() - this.PointCore.get_X())) >> 1));
            point.set_Y(this.PointCore.get_Y() + (((int)(pTo.get_Y() - this.PointCore.get_Y())) >> 1));
            return(point);
        }
Example #7
0
        public Point CalcNonStraightCenter(Point pTo)
        {
            Point point = new Point();

            point.set_X(base.PointCore.get_X() + (Math.Sign((double)(pTo.get_X() - base.PointCore.get_X())) * 6));
            point.set_Y(base.PointCore.get_Y() + (Math.Sign((double)(pTo.get_Y() - base.PointCore.get_Y())) * 6));
            return(point);
        }
Example #8
0
        public static double GetRotationAngle(Point p1, Point p2)
        {
            double x    = Math.Abs((double)(p1.get_X() - p2.get_X()));
            double y    = Math.Abs((double)(p1.get_Y() - p2.get_Y()));
            double num3 = 0.0;

            if (x != 0.0)
            {
                if (y == 0.0)
                {
                    if (p1.get_X() > p2.get_X())
                    {
                        num3 = 3.1415926535897931;
                    }
                    else if (p1.get_X() < p2.get_X())
                    {
                        num3 = 0.0;
                    }
                }
                else if (((p2.get_X() > p1.get_X()) && (p2.get_Y() < p1.get_Y())) || ((p2.get_X() < p1.get_X()) && (p2.get_Y() > p1.get_Y())))
                {
                    num3 = Math.Atan2(y, x);
                }
                else
                {
                    num3 = -Math.Atan2(y, x);
                }
            }
            else if (p1.get_Y() > p2.get_Y())
            {
                num3 = 1.5707963267948966;
            }
            else if (p1.get_Y() < p2.get_Y())
            {
                num3 = -1.5707963267948966;
            }
            return((num3 * 180.0) / 3.1415926535897931);
        }
Example #9
0
 public static double GetRotationAngle(Point p1, Point p2)
 {
     double x = Math.Abs((double) (p1.get_X() - p2.get_X()));
     double y = Math.Abs((double) (p1.get_Y() - p2.get_Y()));
     double num3 = 0.0;
     if (x != 0.0)
     {
         if (y == 0.0)
         {
             if (p1.get_X() > p2.get_X())
             {
                 num3 = 3.1415926535897931;
             }
             else if (p1.get_X() < p2.get_X())
             {
                 num3 = 0.0;
             }
         }
         else if (((p2.get_X() > p1.get_X()) && (p2.get_Y() < p1.get_Y())) || ((p2.get_X() < p1.get_X()) && (p2.get_Y() > p1.get_Y())))
         {
             num3 = Math.Atan2(y, x);
         }
         else
         {
             num3 = -Math.Atan2(y, x);
         }
     }
     else if (p1.get_Y() > p2.get_Y())
     {
         num3 = 1.5707963267948966;
     }
     else if (p1.get_Y() < p2.get_Y())
     {
         num3 = -1.5707963267948966;
     }
     return ((num3 * 180.0) / 3.1415926535897931);
 }
Example #10
0
 public static Point GetPointRotatedByX(int rY, Point point)
 {
     int num = (int) point.get_X();
     int num2 = ((int) point.get_Y()) - rY;
     int num3 = rY - num2;
     return new Point((double) num, (double) num3);
 }
Example #11
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);
         }
     }
 }
Example #12
0
 public Point CalcCenter(Point pTo)
 {
     Point point = new Point();
     point.set_X(this.PointCore.get_X() + (((int) (pTo.get_X() - this.PointCore.get_X())) >> 1));
     point.set_Y(this.PointCore.get_Y() + (((int) (pTo.get_Y() - this.PointCore.get_Y())) >> 1));
     return point;
 }
Example #13
0
 private void CalculateLineIntersection(Point point, Point NextPoint, ref double yLeft, ref double xTop, ref double yRight, ref double xBottom, double Left, double Top, double Right, double Bottom)
 {
     double num = 0.0;
     double num2 = 0.0;
     if (point.get_X() == NextPoint.get_X())
     {
         xTop = xBottom = point.get_X();
         yLeft = yRight = double.NaN;
     }
     else
     {
         num = (point.get_Y() - NextPoint.get_Y()) / (point.get_X() - NextPoint.get_X());
         if (num == 0.0)
         {
             xTop = xBottom = double.NaN;
             yLeft = yRight = point.get_Y();
         }
         else
         {
             num2 = point.get_Y() - (num * point.get_X());
             yLeft = (num * Left) + num2;
             yRight = (num * Right) + num2;
             xTop = (Top - num2) / num;
             xBottom = (Bottom - num2) / num;
         }
     }
 }
Example #14
0
        private void SetPopupOffset(Point point, string District, double PopupWidth, double PopupHeight, ref FloatPopup floatPopup)
        {
            Dictionary<string, Point> dictionary = new Dictionary<string, Point>();
            switch (District)
            {
                case "西北部":
                    this.PopupHOriginOffset = 80.0;
                    this.PopupVOriginOffset = -40.0;
                    floatPopup.ArrowPlacement = Dock.Right;
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    break;

                case "东北部":
                    this.PopupHOriginOffset = 180.0;
                    this.PopupVOriginOffset = 0.0;
                    floatPopup.ArrowPlacement = Dock.Left;
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    break;

                case "城六区":
                    this.PopupHOriginOffset = 230.0;
                    this.PopupVOriginOffset = 230.0;
                    floatPopup.ArrowPlacement = Dock.Left;
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    break;

                case "西南部":
                    this.PopupHOriginOffset = 160.0;
                    this.PopupVOriginOffset = 60.0;
                    floatPopup.ArrowPlacement = Dock.Right;
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    break;

                case "东南部":
                    this.PopupHOriginOffset = 170.0;
                    this.PopupVOriginOffset = 120.0;
                    floatPopup.ArrowPlacement = Dock.Left;
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    break;

                case "延庆县":
                    this.PopupHOriginOffset = 60.0;
                    this.PopupVOriginOffset = -60.0;
                    floatPopup.ArrowPlacement = Dock.Right;
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    break;

                case "昌平区":
                    this.PopupHOriginOffset = 150.0;
                    this.PopupVOriginOffset = 0.0;
                    floatPopup.ArrowPlacement = Dock.Right;
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    break;

                case "怀柔区":
                case "密云县":
                    this.PopupHOriginOffset = 200.0;
                    this.PopupVOriginOffset = 100.0;
                    floatPopup.ArrowPlacement = Dock.Left;
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    break;

                case "顺义区":
                    this.PopupHOriginOffset = 200.0;
                    this.PopupVOriginOffset = 100.0;
                    floatPopup.ArrowPlacement = Dock.Left;
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    break;

                case "平谷区":
                    this.PopupHOriginOffset = 200.0;
                    this.PopupVOriginOffset = 100.0;
                    floatPopup.ArrowPlacement = Dock.Left;
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    break;

                case "东城区":
                case "西城区":
                case "朝阳区":
                    this.PopupHOriginOffset = 200.0;
                    this.PopupVOriginOffset = 100.0;
                    floatPopup.ArrowPlacement = Dock.Left;
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    break;

                case "海淀区":
                    this.PopupHOriginOffset = 200.0;
                    this.PopupVOriginOffset = 100.0;
                    floatPopup.ArrowPlacement = Dock.Right;
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    break;

                case "石景山区":
                case "丰台区":
                    this.PopupHOriginOffset = 200.0;
                    this.PopupVOriginOffset = 100.0;
                    floatPopup.ArrowPlacement = Dock.Right;
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    break;

                case "门头沟区":
                case "房山区":
                    this.PopupHOriginOffset = 200.0;
                    this.PopupVOriginOffset = 100.0;
                    floatPopup.ArrowPlacement = Dock.Right;
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    break;

                case "通州区":
                case "大兴区":
                    this.PopupHOriginOffset = 200.0;
                    this.PopupVOriginOffset = 100.0;
                    floatPopup.ArrowPlacement = Dock.Left;
                    dictionary.Add("SouthEast1", this.map.LocationToViewportPoint(this.PopSouthEast1));
                    dictionary.Add("SouthEast2", this.map.LocationToViewportPoint(this.PopSouthEast2));
                    dictionary.Add("SouthWest", this.map.LocationToViewportPoint(this.PopSouthWest));
                    dictionary.Add("NorthWest2", this.map.LocationToViewportPoint(this.PopNorthWest2));
                    dictionary.Add("NorthEast1", this.map.LocationToViewportPoint(this.PopNorthEast1));
                    dictionary.Add("NorthWest1", this.map.LocationToViewportPoint(this.PopNorthWest1));
                    dictionary.Add("NorthEast2", this.map.LocationToViewportPoint(this.PopNorthEast2));
                    break;
            }
            double num = 0.0;
            double num2 = 0.0;
            if (this.DayForecastPanel.get_Visibility() == null)
            {
                num = this.DayForecastPanel.get_ActualWidth();
                num2 = this.DayForecastPanel.get_ActualHeight();
            }
            else if (this.ActuallyFrame.get_Visibility() == null)
            {
                num = this.ActuallyFrame.get_ActualWidth();
                num2 = this.ActuallyFrame.get_ActualHeight();
            }
            foreach (KeyValuePair<string, Point> pair in dictionary)
            {
                Point point2 = pair.Value;
                point2.set_X(point2.get_X() * this.mapScale);
                point2.set_Y(point2.get_Y() * this.mapScale);
                double num3 = point2.get_X();
                bool flag = false;
                switch (pair.Key)
                {
                    case "NorthWest1":
                    {
                        if (point2.get_Y() < (num2 + PopupHeight))
                        {
                            num3 = point2.get_X() - num;
                        }
                        double num4 = 1.0;
                        if (num2 == 0.0)
                        {
                            num4 = 0.6;
                        }
                        if ((num3 >= (PopupWidth * num4)) && (point2.get_Y() >= PopupHeight))
                        {
                            this.PopupHOriginOffset = point.get_X() - point2.get_X();
                            this.PopupVOriginOffset = point2.get_Y() - point.get_Y();
                            floatPopup.ArrowPlacement = Dock.Right;
                            flag = true;
                        }
                        break;
                    }
                    case "NorthWest2":
                    {
                        if (point2.get_Y() < (num2 + PopupHeight))
                        {
                            num3 = point2.get_X() - num;
                        }
                        double num5 = 1.0;
                        if (num2 == 0.0)
                        {
                            num5 = 0.9;
                        }
                        if ((num3 >= (PopupWidth * num5)) && (point2.get_Y() >= PopupHeight))
                        {
                            this.PopupHOriginOffset = point.get_X() - point2.get_X();
                            this.PopupVOriginOffset = point2.get_Y() - point.get_Y();
                            floatPopup.ArrowPlacement = Dock.Right;
                            flag = true;
                        }
                        break;
                    }
                    case "SouthWest":
                        if (((this.map.get_ActualHeight() - num2) - 10.0) < PopupHeight)
                        {
                            num3 = point2.get_X() - num;
                        }
                        if (num3 >= PopupWidth)
                        {
                            this.PopupHOriginOffset = point.get_X() - point2.get_X();
                            if (point2.get_Y() < num2)
                            {
                                this.PopupVOriginOffset = ((num2 + 10.0) + PopupHeight) - point.get_Y();
                            }
                            else
                            {
                                this.PopupVOriginOffset = (point2.get_Y() + PopupHeight) - point.get_Y();
                            }
                            floatPopup.ArrowPlacement = Dock.Right;
                            flag = true;
                        }
                        break;

                    case "NorthEast1":
                        if ((this.map.get_ActualWidth() - point2.get_X()) >= (PopupWidth * 0.9))
                        {
                            this.PopupHOriginOffset = point2.get_X() - point.get_X();
                            this.PopupVOriginOffset = point2.get_Y() - point.get_Y();
                            floatPopup.ArrowPlacement = Dock.Left;
                            flag = true;
                        }
                        break;

                    case "NorthEast2":
                        if (((this.map.get_ActualWidth() - point2.get_X()) >= (PopupWidth * 0.9)) && (point2.get_Y() > (PopupHeight * 0.7)))
                        {
                            this.PopupHOriginOffset = point2.get_X() - point.get_X();
                            this.PopupVOriginOffset = point2.get_Y() - point.get_Y();
                            floatPopup.ArrowPlacement = Dock.Left;
                            flag = true;
                        }
                        break;

                    case "SouthEast1":
                        if (((this.map.get_ActualWidth() - point2.get_X()) >= (PopupWidth * 0.9)) && ((this.map.get_ActualHeight() - point2.get_Y()) > (PopupHeight * 0.8)))
                        {
                            this.PopupHOriginOffset = point2.get_X() - point.get_X();
                            this.PopupVOriginOffset = (point2.get_Y() + PopupHeight) - point.get_Y();
                            floatPopup.ArrowPlacement = Dock.Left;
                            flag = true;
                        }
                        break;

                    case "SouthEast2":
                        if ((this.map.get_ActualWidth() - point2.get_X()) >= (PopupWidth * 0.9))
                        {
                            this.PopupHOriginOffset = point2.get_X() - point.get_X();
                            this.PopupVOriginOffset = (point2.get_Y() + PopupHeight) - point.get_Y();
                            floatPopup.ArrowPlacement = Dock.Left;
                            flag = true;
                        }
                        break;
                }
                if (flag)
                {
                    break;
                }
            }
            floatPopup.HOriginOffset = this.PopupHOriginOffset;
            floatPopup.VOriginOffset = this.PopupVOriginOffset;
        }
Example #15
0
 private void OpenForecastFloatPopup()
 {
     Point point = new Point(0.0, 0.0);
     if (this.forecastGrid.SelectedItem != null)
     {
         this.airDataContext.CurrentZoneForecast = this.forecastGrid.SelectedItem as BEPB.Forecast;
         this.forecastMsg.set_Visibility(0);
         string zone = this.airDataContext.CurrentZoneForecast.Zone;
         if (zone != null)
         {
             if (!(zone == "城六区"))
             {
                 if (zone == "西北部")
                 {
                     if (this.LastSelectedFive != this.NorthWest)
                     {
                         if (this.LastSelectedFive != null)
                         {
                             this.LastSelectedFive.Fill = this.LastSelectedFiveBrush;
                         }
                         this.LastSelectedFive = this.NorthWest;
                         this.LastSelectedFiveBrush = this.brFive;
                     }
                     this.NorthWest.Fill = new SolidColorBrush(Colors.get_Red());
                     point = this.map.LocationToViewportPoint(this.NorthWestText.Location);
                 }
                 else if (zone == "东北部")
                 {
                     if (this.LastSelectedFive != this.NorthEast)
                     {
                         if (this.LastSelectedFive != null)
                         {
                             this.LastSelectedFive.Fill = this.LastSelectedFiveBrush;
                         }
                         this.LastSelectedFive = this.NorthEast;
                         this.LastSelectedFiveBrush = this.brFive;
                     }
                     this.NorthEast.Fill = new SolidColorBrush(Colors.get_Red());
                     point = this.map.LocationToViewportPoint(this.NorthEastText.Location);
                 }
                 else if (zone == "东南部")
                 {
                     if (this.LastSelectedFive != this.SouthEast)
                     {
                         if (this.LastSelectedFive != null)
                         {
                             this.LastSelectedFive.Fill = this.LastSelectedFiveBrush;
                         }
                         this.LastSelectedFive = this.SouthEast;
                         this.LastSelectedFiveBrush = this.brFive;
                     }
                     this.SouthEast.Fill = new SolidColorBrush(Colors.get_Red());
                     point = this.map.LocationToViewportPoint(this.SouthEastText.Location);
                 }
                 else if (zone == "西南部")
                 {
                     if (this.LastSelectedFive != this.SouthWest)
                     {
                         if (this.LastSelectedFive != null)
                         {
                             this.LastSelectedFive.Fill = this.LastSelectedFiveBrush;
                         }
                         this.LastSelectedFive = this.SouthWest;
                         this.LastSelectedFiveBrush = this.brFive;
                     }
                     this.SouthWest.Fill = new SolidColorBrush(Colors.get_Red());
                     point = this.map.LocationToViewportPoint(this.SouthWestText.Location);
                 }
             }
             else
             {
                 if (this.LastSelectedFive != this.CityCenter)
                 {
                     if (this.LastSelectedFive != null)
                     {
                         this.LastSelectedFive.Fill = this.LastSelectedFiveBrush;
                     }
                     this.LastSelectedFive = this.CityCenter;
                     this.LastSelectedFiveBrush = this.brFive;
                 }
                 this.CityCenter.Fill = new SolidColorBrush(Colors.get_Red());
                 point = this.map.LocationToViewportPoint(this.CityCenterText.Location);
             }
         }
     }
     this.ForecastBorder.set_DataContext(this.airDataContext.CurrentZoneForecast);
     double popupWidth = 315.0;
     double popupHeight = 254.0;
     string isNight = this.airDataContext.CurrentZoneForecast.IsNight;
     if (isNight != null)
     {
         if (!(isNight == "0"))
         {
             if (isNight == "1")
             {
                 popupHeight = 462.0;
             }
         }
         else
         {
             popupHeight = 254.0;
         }
     }
     this.FloatForecastPopup.set_Width(popupWidth);
     this.FloatForecastPopup.set_Height(popupHeight);
     point.set_X(point.get_X() * this.mapScale);
     point.set_Y(point.get_Y() * this.mapScale);
     this.SetPopupOffset(point, this.airDataContext.CurrentZoneForecast.Zone, popupWidth, popupHeight, ref this.FloatForecastPopup);
     this.FloatForecastPopup.Open(point, new Rect(10.0, 10.0, this.map.get_ActualWidth() - 10.0, this.map.get_ActualHeight() - 10.0));
 }
Example #16
0
 private void ClipLine(Point point, Point NextPoint, double yLeft, double xTop, double yRight, double xBottom, double Left, double Top, double Right, double Bottom, ref PointCollection ClippedPolygon)
 {
     if ((xTop == Left) && (yLeft == Top))
     {
         if (((ClippedPolygon.get_Count() == 0) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_X() != Left)) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_Y() != Top))
         {
             ClippedPolygon.Add(new Point(Left, Top));
         }
     }
     else if ((xTop == Right) && (yRight == Top))
     {
         if (((ClippedPolygon.get_Count() == 0) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_X() != Right)) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_Y() != Top))
         {
             ClippedPolygon.Add(new Point(Right, Top));
         }
     }
     else if ((xBottom == Right) && (yRight == Bottom))
     {
         if (((ClippedPolygon.get_Count() == 0) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_X() != Right)) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_Y() != Bottom))
         {
             ClippedPolygon.Add(new Point(Right, Bottom));
         }
     }
     else if ((xBottom == Left) && (yLeft == Bottom))
     {
         if (((ClippedPolygon.get_Count() == 0) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_X() != Left)) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_Y() != Bottom))
         {
             ClippedPolygon.Add(new Point(Left, Bottom));
         }
     }
     else if (((Top <= yLeft) && (yLeft <= Bottom)) && ((Left <= xTop) && (xTop <= Right)))
     {
         if (((point.get_X() < Left) && (point.get_Y() > Top)) && ((NextPoint.get_X() > Left) && (NextPoint.get_Y() < Top)))
         {
             ClippedPolygon.Add(new Point(Left, yLeft));
             ClippedPolygon.Add(new Point(xTop, Top));
         }
         else if (((point.get_X() > Left) && (point.get_Y() < Top)) && ((NextPoint.get_Y() > Top) && (NextPoint.get_X() < Left)))
         {
             ClippedPolygon.Add(new Point(xTop, Top));
             ClippedPolygon.Add(new Point(Left, yLeft));
         }
     }
     else if (((Left <= xTop) && (xTop <= Right)) && ((Top <= yRight) && (yRight <= Bottom)))
     {
         if (((point.get_X() > Right) && (point.get_Y() > Top)) && ((NextPoint.get_X() < Right) && (NextPoint.get_Y() < Top)))
         {
             ClippedPolygon.Add(new Point(Right, yRight));
             ClippedPolygon.Add(new Point(xTop, Top));
         }
         else if (((point.get_X() < Right) && (point.get_Y() < Top)) && ((NextPoint.get_X() > Right) && (NextPoint.get_Y() > Top)))
         {
             ClippedPolygon.Add(new Point(xTop, Top));
             ClippedPolygon.Add(new Point(Right, yRight));
         }
     }
     else if (((Left <= xBottom) && (xBottom <= Right)) && ((Top <= yRight) && (yRight <= Bottom)))
     {
         if (((point.get_X() > Right) && (point.get_Y() < Bottom)) && ((NextPoint.get_X() < Right) && (NextPoint.get_Y() > Bottom)))
         {
             ClippedPolygon.Add(new Point(Right, yRight));
             ClippedPolygon.Add(new Point(xBottom, Bottom));
         }
         else if (((point.get_X() < Right) && (point.get_Y() > Bottom)) && ((NextPoint.get_X() > Right) && (NextPoint.get_Y() < Bottom)))
         {
             ClippedPolygon.Add(new Point(xBottom, Bottom));
             ClippedPolygon.Add(new Point(Right, yRight));
         }
     }
     else if (((Left <= xBottom) && (xBottom <= Right)) && ((Top <= yLeft) && (yLeft <= Bottom)))
     {
         if (((point.get_X() < Left) && (point.get_Y() < Bottom)) && ((NextPoint.get_X() > Left) && (NextPoint.get_Y() > Bottom)))
         {
             ClippedPolygon.Add(new Point(Left, yLeft));
             ClippedPolygon.Add(new Point(xBottom, Bottom));
         }
         else if (((point.get_X() > Left) && (point.get_Y() > Bottom)) && ((NextPoint.get_X() < Left) && (NextPoint.get_Y() < Bottom)))
         {
             ClippedPolygon.Add(new Point(xBottom, Bottom));
             ClippedPolygon.Add(new Point(Left, yLeft));
         }
     }
     else if (((Left <= xTop) && (xTop <= Right)) && ((Left <= xBottom) && (xBottom <= Right)))
     {
         if ((point.get_Y() < Top) && (NextPoint.get_Y() > Bottom))
         {
             ClippedPolygon.Add(new Point(xTop, Top));
             ClippedPolygon.Add(new Point(xBottom, Bottom));
         }
         else if ((point.get_Y() > Bottom) && (NextPoint.get_Y() < Top))
         {
             ClippedPolygon.Add(new Point(xBottom, Bottom));
             ClippedPolygon.Add(new Point(xTop, Top));
         }
     }
     else if (((Top <= yLeft) && (yLeft <= Bottom)) && ((Top <= yRight) && (yRight <= Bottom)))
     {
         if ((point.get_X() < Left) && (NextPoint.get_X() > Right))
         {
             ClippedPolygon.Add(new Point(Left, yLeft));
             ClippedPolygon.Add(new Point(Right, yRight));
         }
         else if ((point.get_X() > Right) && (NextPoint.get_X() < Left))
         {
             ClippedPolygon.Add(new Point(Right, yRight));
             ClippedPolygon.Add(new Point(Left, yLeft));
         }
     }
 }
Example #17
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);
         }
     }
 }
Example #18
0
 public static Point GetPointRotatedByY(int width, Point point)
 {
     int num = width - ((int) point.get_X());
     int num2 = (int) point.get_Y();
     return new Point((double) num, (double) num2);
 }
Example #19
0
        public void Open(Point point, Rect rect)
        {
            this.rect = rect;
            switch (this.ArrowPlacement)
            {
                case Dock.Left:
                    this.PathPoint3.set_Size(new Size(this.CornerRadius.get_TopLeft(), this.CornerRadius.get_TopLeft()));
                    this.PathPoint5.set_Size(new Size(this.CornerRadius.get_TopRight(), this.CornerRadius.get_TopRight()));
                    this.PathPoint7.set_Size(new Size(this.CornerRadius.get_BottomRight(), this.CornerRadius.get_BottomRight()));
                    this.PathPoint9.set_Size(new Size(this.CornerRadius.get_BottomLeft(), this.CornerRadius.get_BottomLeft()));
                    this.RootPopup.set_HorizontalOffset(point.get_X() + this.HOriginOffset);
                    if ((this.RootPopup.get_HorizontalOffset() + base.get_Width()) <= rect.get_Width())
                    {
                        if (this.RootPopup.get_HorizontalOffset() < rect.get_Left())
                        {
                            this.RootPopup.set_HorizontalOffset(rect.get_Left());
                        }
                        break;
                    }
                    this.RootPopup.set_HorizontalOffset(rect.get_Width() - base.get_Width());
                    break;

                case Dock.Right:
                    this.PathPoint3.set_Size(new Size(this.CornerRadius.get_BottomRight(), this.CornerRadius.get_BottomRight()));
                    this.PathPoint5.set_Size(new Size(this.CornerRadius.get_BottomLeft(), this.CornerRadius.get_BottomLeft()));
                    this.PathPoint7.set_Size(new Size(this.CornerRadius.get_TopLeft(), this.CornerRadius.get_TopLeft()));
                    this.PathPoint9.set_Size(new Size(this.CornerRadius.get_TopRight(), this.CornerRadius.get_TopRight()));
                    this.RootPopup.set_HorizontalOffset((point.get_X() - this.HOriginOffset) - base.get_Width());
                    if ((this.RootPopup.get_HorizontalOffset() + base.get_Width()) <= rect.get_Width())
                    {
                        if (this.RootPopup.get_HorizontalOffset() < rect.get_Left())
                        {
                            this.RootPopup.set_HorizontalOffset(rect.get_Left());
                        }
                    }
                    else
                    {
                        this.RootPopup.set_HorizontalOffset(rect.get_Width() - base.get_Width());
                    }
                    this.RootPopup.set_VerticalOffset((point.get_Y() - base.get_Height()) + this.VOriginOffset);
                    if ((this.RootPopup.get_VerticalOffset() + base.get_Height()) > rect.get_Height())
                    {
                        this.RootPopup.set_VerticalOffset(rect.get_Height() - base.get_Height());
                    }
                    else if (this.RootPopup.get_VerticalOffset() < rect.get_Top())
                    {
                        this.RootPopup.set_VerticalOffset(rect.get_Top());
                    }
                    this.HOffsetAnimation.set_From(new double?(point.get_X()));
                    this.HOffsetAnimation.set_To(new double?(this.RootPopup.get_HorizontalOffset()));
                    this.VOffsetAnimation.set_From(new double?(point.get_Y()));
                    this.VOffsetAnimation.set_To(new double?(this.RootPopup.get_VerticalOffset()));
                    this.WidthAnimation.set_From(0.0);
                    this.WidthAnimation.set_To(new double?(base.get_Width()));
                    this.HeightAnimation.set_From(0.0);
                    this.HeightAnimation.set_To(new double?(base.get_Height()));
                    this.StartPointAnimation.set_From(new Point(0.0, 0.0));
                    this.StartPointAnimation.set_To(new Point(point.get_X() - this.RootPopup.get_HorizontalOffset(), point.get_Y() - this.RootPopup.get_VerticalOffset()));
                    this.PathPoint1Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint1Animation.set_To(new Point(base.get_Width() + this.BorderWidth, (base.get_Height() / 2.0) + this.HalfArrowWidth));
                    this.PathPoint2Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint2Animation.set_To(new Point(base.get_Width() + this.BorderWidth, (base.get_Height() + this.BorderWidth) - this.CornerRadius.get_BottomRight()));
                    this.PathPoint3Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint3Animation.set_To(new Point((base.get_Width() + this.BorderWidth) - this.CornerRadius.get_BottomRight(), base.get_Height() + this.BorderWidth));
                    this.PathPoint4Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint4Animation.set_To(new Point((-1.0 * this.BorderWidth) + this.CornerRadius.get_BottomLeft(), base.get_Height() + this.BorderWidth));
                    this.PathPoint5Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint5Animation.set_To(new Point(-1.0 * this.BorderWidth, (base.get_Height() + this.BorderWidth) - this.CornerRadius.get_BottomLeft()));
                    this.PathPoint6Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint6Animation.set_To(new Point(-1.0 * this.BorderWidth, (-1.0 * this.BorderWidth) + this.CornerRadius.get_TopLeft()));
                    this.PathPoint7Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint7Animation.set_To(new Point((-1.0 * this.BorderWidth) + this.CornerRadius.get_TopLeft(), -1.0 * this.BorderWidth));
                    this.PathPoint8Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint8Animation.set_To(new Point((base.get_Width() + this.BorderWidth) - this.CornerRadius.get_TopRight(), -1.0 * this.BorderWidth));
                    this.PathPoint9Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint9Animation.set_To(new Point(base.get_Width() + this.BorderWidth, (-1.0 * this.BorderWidth) + this.CornerRadius.get_TopRight()));
                    this.PathPoint10Animation.set_From(new Point(0.0, 0.0));
                    this.PathPoint10Animation.set_To(new Point(base.get_Width() + this.BorderWidth, (base.get_Height() / 2.0) - this.HalfArrowWidth));
                    goto Label_0DE2;

                default:
                    goto Label_0DE2;
            }
            this.RootPopup.set_VerticalOffset((point.get_Y() - base.get_Height()) + this.VOriginOffset);
            if ((this.RootPopup.get_VerticalOffset() + base.get_Height()) > rect.get_Height())
            {
                this.RootPopup.set_VerticalOffset(rect.get_Height() - base.get_Height());
            }
            else if (this.RootPopup.get_VerticalOffset() < rect.get_Top())
            {
                this.RootPopup.set_VerticalOffset(rect.get_Top());
            }
            this.HOffsetAnimation.set_From(new double?(point.get_X()));
            this.HOffsetAnimation.set_To(new double?(this.RootPopup.get_HorizontalOffset()));
            this.VOffsetAnimation.set_From(new double?(point.get_Y()));
            this.VOffsetAnimation.set_To(new double?(this.RootPopup.get_VerticalOffset()));
            this.WidthAnimation.set_From(0.0);
            this.WidthAnimation.set_To(new double?(base.get_Width()));
            this.HeightAnimation.set_From(0.0);
            this.HeightAnimation.set_To(new double?(base.get_Height()));
            this.StartPointAnimation.set_From(new Point(0.0, 0.0));
            this.StartPointAnimation.set_To(new Point(point.get_X() - this.RootPopup.get_HorizontalOffset(), point.get_Y() - this.RootPopup.get_VerticalOffset()));
            this.PathPoint1Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint1Animation.set_To(new Point(-1.0 * this.BorderWidth, (base.get_Height() / 2.0) - this.HalfArrowWidth));
            this.PathPoint2Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint2Animation.set_To(new Point(-1.0 * this.BorderWidth, (-1.0 * this.BorderWidth) + this.CornerRadius.get_TopLeft()));
            this.PathPoint3Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint3Animation.set_To(new Point((-1.0 * this.BorderWidth) + this.CornerRadius.get_TopLeft(), -1.0 * this.BorderWidth));
            this.PathPoint4Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint4Animation.set_To(new Point((base.get_Width() + this.BorderWidth) - this.CornerRadius.get_TopRight(), -1.0 * this.BorderWidth));
            this.PathPoint5Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint5Animation.set_To(new Point(base.get_Width() + this.BorderWidth, (-1.0 * this.BorderWidth) + this.CornerRadius.get_TopRight()));
            this.PathPoint6Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint6Animation.set_To(new Point(base.get_Width() + this.BorderWidth, (base.get_Height() + this.BorderWidth) - this.CornerRadius.get_BottomRight()));
            this.PathPoint7Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint7Animation.set_To(new Point((base.get_Width() + this.BorderWidth) - this.CornerRadius.get_BottomRight(), base.get_Height() + this.BorderWidth));
            this.PathPoint8Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint8Animation.set_To(new Point((-1.0 * this.BorderWidth) + this.CornerRadius.get_BottomLeft(), base.get_Height() + this.BorderWidth));
            this.PathPoint9Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint9Animation.set_To(new Point(-1.0 * this.BorderWidth, (base.get_Height() + this.BorderWidth) - this.CornerRadius.get_BottomLeft()));
            this.PathPoint10Animation.set_From(new Point(0.0, 0.0));
            this.PathPoint10Animation.set_To(new Point(-1.0 * this.BorderWidth, (base.get_Height() / 2.0) + this.HalfArrowWidth));
            Label_0DE2:
            base.set_Width(0.0);
            base.set_Height(0.0);
            this.IsOpen = true;
            this.PopupStoryboard.Begin();
        }
Example #20
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);
        }
Example #21
0
        public static bool GetOffsettedValue(PathElement peHead, double HeadOffset, int HeadElementArrivedSource, ref Point ptOut)
        {
            Point point = new Point();

            int[] sources = peHead.GetSources();
            Debug.Assert(sources.Length == 2);
            Point connectionSourcePoint = peHead.GetConnectionSourcePoint(sources[0]);
            Point point3 = peHead.GetConnectionSourcePoint(sources[1]);

            if (sources.Length != 2)
            {
                return(false);
            }
            double introduced12 = Math.Pow(connectionSourcePoint.get_X() - point3.get_X(), 2.0);
            double num          = Math.Sqrt(introduced12 + Math.Pow(connectionSourcePoint.get_Y() - point3.get_Y(), 2.0));
            double num2         = (num * HeadOffset) / ((peHead.Length == 0) ? ((double)1) : ((double)peHead.Length));
            double num3         = 1.0;
            double num4         = 0.0;

            if (!(connectionSourcePoint.get_Y() == point3.get_Y()))
            {
                num3 = Math.Abs((double)(point3.get_X() - connectionSourcePoint.get_X())) / num;
                num4 = Math.Abs((double)(point3.get_Y() - connectionSourcePoint.get_Y())) / num;
            }
            double num5 = num2 * num3;
            double num6 = num2 * num4;

            if (HeadElementArrivedSource == sources[0])
            {
                if (connectionSourcePoint.get_X() <= point3.get_X())
                {
                    connectionSourcePoint.set_X(connectionSourcePoint.get_X() + ((int)num5));
                }
                else
                {
                    connectionSourcePoint.set_X(connectionSourcePoint.get_X() - ((int)num5));
                }
                if (connectionSourcePoint.get_Y() <= point3.get_Y())
                {
                    connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + ((int)num6));
                }
                else
                {
                    connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - ((int)num6));
                }
                point = connectionSourcePoint;
            }
            else
            {
                if (point3.get_X() <= connectionSourcePoint.get_X())
                {
                    point3.set_X(point3.get_X() + ((int)num5));
                }
                else
                {
                    point3.set_X(point3.get_X() - ((int)num5));
                }
                if (point3.get_Y() <= connectionSourcePoint.get_Y())
                {
                    point3.set_Y(point3.get_Y() + ((int)num6));
                }
                else
                {
                    point3.set_Y(point3.get_Y() - ((int)num6));
                }
                point = point3;
            }
            ptOut = point;
            return(true);
        }
Example #22
0
        public virtual Point GetTrainPoint(ArrayList alTrains, TrainBase t)
        {
            int index = -1;

            if (alTrains.Count > 1)
            {
                index = alTrains.IndexOf(t);
            }
            Point       trainPoint = this.GetTrainPoint();
            PathElement element    = this;
            Point       point2     = new Point();

            if (t.HeadElementArrivedSource != -1)
            {
                int[] sources = element.GetSources();
                Debug.Assert(sources.Length == 2);
                Point connectionSourcePoint = element.GetConnectionSourcePoint(sources[0]);
                Point point4 = element.GetConnectionSourcePoint(sources[1]);
                if (sources.Length != 2)
                {
                    return(trainPoint);
                }
                double introduced15 = Math.Pow(connectionSourcePoint.get_X() - point4.get_X(), 2.0);
                double num2         = Math.Sqrt(introduced15 + Math.Pow(connectionSourcePoint.get_Y() - point4.get_Y(), 2.0));
                double num3         = (num2 * t.HeadOffset) / ((element.Length == 0) ? ((double)1) : ((double)element.Length));
                double num4         = 1.0;
                double num5         = 0.0;
                if (!(connectionSourcePoint.get_Y() == point4.get_Y()))
                {
                    num4 = Math.Abs((double)(point4.get_X() - connectionSourcePoint.get_X())) / num2;
                    num5 = Math.Abs((double)(point4.get_Y() - connectionSourcePoint.get_Y())) / num2;
                }
                double num6 = num3 * num4;
                double num7 = num3 * num5;
                if (t.HeadElementArrivedSource == sources[0])
                {
                    if (connectionSourcePoint.get_X() <= point4.get_X())
                    {
                        connectionSourcePoint.set_X(connectionSourcePoint.get_X() + num6);
                    }
                    else
                    {
                        connectionSourcePoint.set_X(connectionSourcePoint.get_X() - num6);
                    }
                    if (connectionSourcePoint.get_Y() <= point4.get_Y())
                    {
                        connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + num7);
                    }
                    else
                    {
                        connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - num7);
                    }
                    point2 = connectionSourcePoint;
                }
                else
                {
                    if (point4.get_X() <= connectionSourcePoint.get_X())
                    {
                        point4.set_X(point4.get_X() + num6);
                    }
                    else
                    {
                        point4.set_X(point4.get_X() - num6);
                    }
                    if (point4.get_Y() <= connectionSourcePoint.get_Y())
                    {
                        point4.set_Y(point4.get_Y() + num7);
                    }
                    else
                    {
                        point4.set_Y(point4.get_Y() - num7);
                    }
                    point2 = point4;
                }
                trainPoint = point2;
                if (index != -1)
                {
                    if (connectionSourcePoint.get_Y() == point4.get_Y())
                    {
                        trainPoint.set_Y(trainPoint.get_Y() - 6.0);
                        trainPoint.set_Y(trainPoint.get_Y() + (13 * index));
                    }
                    else
                    {
                        trainPoint.set_X(trainPoint.get_X() - 6.0);
                        trainPoint.set_X(trainPoint.get_X() + (13 * index));
                    }
                }
            }
            return(trainPoint);
        }