예제 #1
0
 public void PinchUp(CPointF Point_, Single Scale_)
 {
     PinchMove(Point_, Scale_);
     _Scale    = GetScale();
     BaseScale = 1.0f;
     CurScale  = 1.0f;
 }
예제 #2
0
        private Bitmap prepareTrackBmp(Rectangle trackRect, Gps2PixelProjection trackProj, TrackParser td)
        {
            // We need at least a lap to draw something
            if (!td.HasSamples || trackProj == null)
            {
                return(null);
            }

            // We'll draw one of the laps. Just get the first lap.
            TrackParser.Lap currLap = td.Laps[0];

            int    w   = trackRect.Width;
            int    h   = trackRect.Height;
            Bitmap bmp = new Bitmap(w, h);

            using (Graphics g = Graphics.FromImage(bmp)) {
                using (Brush bgColor = new SolidBrush(Color.Gray),
                       trackColor = new SolidBrush(Color.Yellow)) {
                    using (Pen trackPen = new Pen(trackColor, kTrackWidth)) {
                        g.FillRectangle(bgColor, 0, 0, w, h);

                        List <TrackParser.Sample> samples = td.Samples;
                        TrackParser.Sample        s       = samples[0];
                        CPointF last = new CPointF();
                        CPointF next = new CPointF();

                        transformGpsCoord(s.mLongtiude, s.mLatitude, trackProj, last);

                        float px = (float)trackProj.mPixelOffsetX;
                        float py = (float)trackProj.mPixelOffsetY;

                        last.mX -= px;
                        last.mY -= py;

                        for (int i = 1, n = samples.Count; i < n; i++)
                        {
                            s = samples[i];
                            if (s.mLap != currLap)
                            {
                                continue;
                            }

                            transformGpsCoord(s.mLongtiude, s.mLatitude, trackProj, next);
                            next.mX -= px;
                            next.mY -= py;

                            g.DrawLine(trackPen, last.mX, last.mY, next.mX, next.mY);

                            last.mX = next.mX;
                            last.mY = next.mY;
                        }
                    }
                }
            }

            return(bmp);
        }
예제 #3
0
        private void transformGpsCoord(double longitude, double latitude,
                                       Gps2PixelProjection proj,
                                       CPointF outPoint)
        {
            double px = (longitude - proj.mGpsOffsetX) * proj.mGpsScaleX + proj.mPixelOffsetX;
            double py = (latitude - proj.mGpsOffsetY) * proj.mGpsScaleY + proj.mPixelOffsetY;

            outPoint.mX = (float)px;
            outPoint.mY = (float)py;
        }
예제 #4
0
            public void Move(CPointF Point_)
            {
                var Scale = GetScale();

                ScaledBitmapRect.Left   = (Int32)(Point_.X - BitmapBasePoint.X * Scale);
                ScaledBitmapRect.Top    = (Int32)(Point_.Y - BitmapBasePoint.Y * Scale);
                ScaledBitmapRect.Right  = (Int32)(ScaledBitmapRect.Left + (BitmapWidth * Scale));
                ScaledBitmapRect.Bottom = (Int32)(ScaledBitmapRect.Top + (BitmapHeight * Scale));

                if (LayoutWidth > ScaledBitmapRect.Width())
                {
                    var ScaledBitmapRectWidth = ScaledBitmapRect.Width();
                    var NewLeft = (LayoutWidth - ScaledBitmapRect.Width()) * 0.5f;
                    BitmapBasePoint.X -= (Int32)((NewLeft - ScaledBitmapRect.Left) / Scale);
                    ScaledBitmapRect.Offset((Int32)NewLeft - ScaledBitmapRect.Left, 0);
                }
                else
                {
                    // SrcRect가 Bitmap을 벗어나지 않도록
                    if (ScaledBitmapRect.Left > 0.0f)
                    {
                        BitmapBasePoint.X += (Int32)(ScaledBitmapRect.Left / Scale);
                        ScaledBitmapRect.Offset(-ScaledBitmapRect.Left, 0);
                    }
                    else if (ScaledBitmapRect.Right < LayoutWidth)
                    {
                        BitmapBasePoint.X -= (Int32)((LayoutWidth - ScaledBitmapRect.Right) / Scale);
                        ScaledBitmapRect.Offset(LayoutWidth - ScaledBitmapRect.Right, 0);
                    }
                }

                if (LayoutHeight > ScaledBitmapRect.Height())
                {
                    var ScaledBitmapRectHeight = ScaledBitmapRect.Height();
                    var NewTop = (LayoutHeight - ScaledBitmapRect.Height()) * 0.5f;
                    BitmapBasePoint.Y -= (Int32)((NewTop - ScaledBitmapRect.Top) / Scale);
                    ScaledBitmapRect.Offset(0, (Int32)NewTop - ScaledBitmapRect.Top);
                }
                else
                {
                    // SrcRect가 Bitmap을 벗어나지 않도록
                    if (ScaledBitmapRect.Top > 0.0f)
                    {
                        BitmapBasePoint.Y += (Int32)(ScaledBitmapRect.Top / Scale);
                        ScaledBitmapRect.Offset(0, -ScaledBitmapRect.Top);
                    }
                    else if (ScaledBitmapRect.Bottom < LayoutHeight)
                    {
                        BitmapBasePoint.Y -= (Int32)((LayoutHeight - ScaledBitmapRect.Bottom) / Scale);
                        ScaledBitmapRect.Offset(0, LayoutHeight - ScaledBitmapRect.Bottom);
                    }
                }

                RefreshSrcRect();
            }
예제 #5
0
            public void PinchMove(CPointF Point_, Single Scale_)
            {
                CurScale = Scale_;
                var scale = GetScale();

                if (scale > MaxScale)
                {
                    BaseScale = _Scale * CurScale / MaxScale;
                }
                else if (scale < MinScale)
                {
                    BaseScale = _Scale * CurScale / MinScale;
                }

                Move(Point_);
            }
예제 #6
0
            public Boolean OnTouchEvent(MotionEvent e)
            {
                switch (e.Action)
                {
                case MotionEventActions.Down:
                case MotionEventActions.Pointer1Down:
                case MotionEventActions.Pointer2Down:
                case MotionEventActions.Pointer3Down:
                {
                    if (_Points.Count == 2)
                    {
                        return(false);
                    }

                    CPointF point = new CPointF(e.GetX(e.ActionIndex), e.GetY(e.ActionIndex));

                    switch (_Points.Count)
                    {
                    case 0:
                        _Points.Add(e.GetPointerId(e.ActionIndex), point);
                        _CallbackDown(point);
                        break;

                    case 1:
                        var i = _Points.GetEnumerator();
                        i.MoveNext();
                        _CallbackUp(i.Current.Value);

                        _Points.Add(e.GetPointerId(e.ActionIndex), point);
                        _BaseDistance = Distance;
                        _CallbackPinchDown(Center);
                        break;
                    }
                }
                break;

                case MotionEventActions.Up:
                case MotionEventActions.Pointer1Up:
                case MotionEventActions.Pointer2Up:
                case MotionEventActions.Pointer3Up:
                {
                    CPointF point;
                    if (!_Points.TryGetValue(e.GetPointerId(e.ActionIndex), out point))
                    {
                        return(false);
                    }

                    point.X = e.GetX(e.ActionIndex);
                    point.Y = e.GetY(e.ActionIndex);

                    switch (_Points.Count)
                    {
                    case 1:
                    {
                        _CallbackUp(point);
                        _Points.Remove(e.GetPointerId(e.ActionIndex));
                    }
                    break;

                    case 2:
                    {
                        _CallbackPinchUp(Center, Scale);
                        _Points.Remove(e.GetPointerId(e.ActionIndex));

                        var i = _Points.GetEnumerator();
                        i.MoveNext();
                        _CallbackDown(i.Current.Value);
                    }
                    break;
                    }
                }
                break;

                case MotionEventActions.Move:
                {
                    for (Int32 i = 0; i < e.PointerCount; ++i)
                    {
                        CPointF TouchedPoint;
                        if (!_Points.TryGetValue(e.GetPointerId(i), out TouchedPoint))
                        {
                            continue;
                        }

                        TouchedPoint.X = e.GetX(i);
                        TouchedPoint.Y = e.GetY(i);
                    }

                    var center = Center;
                    switch (_Points.Count)
                    {
                    case 1:
                        _CallbackMove(center);
                        break;

                    case 2:
                        _CallbackPinchMove(center, Scale);
                        break;
                    }
                }
                break;

                case MotionEventActions.Cancel:
                    if (_Points.Count == 0)
                    {
                        return(false);
                    }

                    switch (_Points.Count)
                    {
                    case 1:
                        var i = _Points.GetEnumerator();
                        i.MoveNext();
                        _CallbackUp(i.Current.Value);
                        break;

                    case 2:
                        _CallbackPinchUp(Center, Scale);
                        break;
                    }
                    _Points.Clear();
                    break;

                case MotionEventActions.Outside: break;

                case MotionEventActions.HoverMove: break;

                case MotionEventActions.Scroll: break;

                case MotionEventActions.HoverEnter: break;

                case MotionEventActions.HoverExit: break;

                case MotionEventActions.Mask: break;

                case MotionEventActions.PointerIdMask: break;
                }

                return(true);
            }
예제 #7
0
 public void Up(CPointF Point_)
 {
     Move(Point_);
 }
예제 #8
0
 public void Down(CPointF Point_)
 {
     BitmapBasePoint.X = (Int32)((Point_.X - ScaledBitmapRect.Left) / _Scale);
     BitmapBasePoint.Y = (Int32)((Point_.Y - ScaledBitmapRect.Top) / _Scale);
 }
예제 #9
0
 public void PinchDown(CPointF Point_)
 {
     Down(Point_);
 }