//ネイティブ位置からコントロール位置を再計算して設定
        private void UpdateControlLocation()
        {
            Point pixelLocation = EtCourseScaler.NativeToPixelInvY(nativeLocation);

            pixelLocation.Offset(-pixelLocationOffset.X, -pixelLocationOffset.Y);
            this.Location = pixelLocation;
        }
        //コントロール位置からネイティブ位置を計算
        private void RecalculateNativePosition()
        {
            Point pixelLocation = this.Location;

            pixelLocation.Offset(pixelLocationOffset.X, pixelLocationOffset.Y);

            this.NativeX = EtCourseScaler.PixelToNativeInvY(pixelLocation).X;
            this.NativeY = EtCourseScaler.PixelToNativeInvY(pixelLocation).Y;
        }
Beispiel #3
0
        //イベント ハンドラ
        //制御点を追加
        private void addControlPointMenu_Click(object sender, EventArgs e)
        {
            //制御点を追加する座標を算出して作成
            Point addLocation = EtCourseScaler.PixelToNativeInvY(coursePicture.PointToClient(new Point(mapMenu.Left, mapMenu.Top)));

            ControlPoint point = AddControlPoint(addLocation);

            //選択する
            this.ControlPointSelected(point);

            //線を再描画
            UpdateView();
        }
Beispiel #4
0
 /**
  * コースのドラッグスクロール中?
  */
 private void coursePicture_MouseMove(object sender, MouseEventArgs e)
 {
     if (bScrolling)
     {             //ドラッグスクロール中
         Point scrollPoint = coursePicture.PointToScreen(new Point(e.X, e.Y));
         int   x           = scrollPoint.X - scrollOrigin.X;
         int   y           = scrollPoint.Y - scrollOrigin.Y;
         this.AutoScrollPosition = new Point(x * -1, y * -1);
     }
     else
     {
         //座標を通知
         NoticeMousePos(EtCourseScaler.PixelToNativeInvY(new Point(e.X, e.Y)));
     }
 }
Beispiel #5
0
        /**
         * すべての軌跡を描画し、画像として保存する。
         */
        public void SaveAllTrack(string fileName)
        {
            //ファイルが閉じている
            if (playStatus == PlayStatus.Close)
            {
                throw new NxtLogFileNotOpenedException("ログファイルが開かれていません。");
            }

            //ログの最後
            int last = nxtTrackLog.Length - 1;

            //保存対象のBitmapを生成
            Size   courseImageSize = EtCourseScaler.GetPixelCourseSize();
            Bitmap trackImage      = new Bitmap(courseImageSize.Width, courseImageSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            Graphics g = Graphics.FromImage(trackImage);

            //ベース(コース)描画
            g.DrawImage(courseImage, 0, 0);

            //軌跡描画---------
            Point startPoint = EtCourseScaler.NativeToPixelInvY(nxtTrackLog.getLog(last).point);

            //最初の一点は必ず描画するため、開始座標を+1する
            startPoint.Offset(new Point(1, 1));

            Point endPoint;

            //色作成
            Pen linePen = new Pen(TRACK_LINE_COLOR, TRACK_LINE_WIDTH);

            for (int i = last; i >= 0; i--)
            {
                endPoint = EtCourseScaler.NativeToPixelInvY(nxtTrackLog.getLog(i).point);

                //描画
                g.DrawLine(linePen, startPoint, endPoint);

                startPoint = endPoint;
            }

            //保存
            trackImage.Save(fileName, ImageFormat.Png);
        }
 //制御点がコース外に飛び出てたらもどす
 private void CheckRegion()
 {
     if (this.nativeLocation.X < 0)
     {
         this.nativeLocation.X = 0;
     }
     if (-this.nativeLocation.Y < 0)
     {
         this.nativeLocation.Y = 0;
     }
     if (this.nativeLocation.X > EtCourseScaler.GetNativeCourseSize().Width)
     {
         this.nativeLocation.X = EtCourseScaler.GetNativeCourseSize().Width;
     }
     if (-this.nativeLocation.Y > EtCourseScaler.GetNativeCourseSize().Height)
     {
         this.nativeLocation.Y = -EtCourseScaler.GetNativeCourseSize().Height;
     }
 }
Beispiel #7
0
        /**
         * コース画像を読み込んでリサイズし保持する。
         * 読込みに失敗した場合は同サイズの白い画像を作成して保持する。
         */
        private void InitializeImages()
        {
            Size courseImageSize = EtCourseScaler.GetPixelCourseSize();

            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                courseImage = new Bitmap(new Bitmap(assembly.GetManifestResourceStream(COURSE_IMAGE)), courseImageSize.Width, courseImageSize.Height);
            }
            catch (Exception)
            {
                courseImage = new Bitmap(courseImageSize.Width, courseImageSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                Graphics g = Graphics.FromImage(courseImage);
                g.Clear(Color.White);
                g.DrawString("コース画像を読み込めませんでした。起動は続行されますが、コース画像は表示されません。", DefaultFont, new SolidBrush(GRID_TEXT_COLOR), new Point(0, 0));
            }

            DrawGrid(courseImage, EtCourseScaler.NativeToPixel(GRID_PITCH));

            //renderTargetを同サイズに
            renderTarget = new Bitmap(courseImageSize.Width, courseImageSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        }
Beispiel #8
0
        /**
         * コースビューの表示を更新する。
         */
        public void UpdateView()
        {
            Debug.WriteLine("UpdateView()");

            Graphics g = Graphics.FromImage(renderTarget);

            //ファイルが閉じている
            if (playStatus == PlayStatus.Close)
            {
                //ベース(コース)のみ描画
                g.DrawImage(courseImage, 0, 0);
            }
            else
            {
                //ベース(コース)描画
                g.DrawImage(courseImage, 0, 0);

                //軌跡を描画-------------------------------------------------------
                Point startPoint = EtCourseScaler.NativeToPixelInvY(nxtTrackLog.getLog(playPosition).point);

                //最初の一点は必ず描画するため、開始座標を+1する
                startPoint.Offset(new Point(1, 1));

                Point endPoint;

                int trackCount = 0;                 //何ログ分まで描いたかをカウント
                for (int i = playPosition; i >= 0; i--)
                {
                    //規定数分描いたらやめる
                    if (trackCount >= TRACK_COUNT)
                    {
                        break;
                    }

                    endPoint = EtCourseScaler.NativeToPixelInvY(nxtTrackLog.getLog(i).point);

                    //色作成
                    Pen gpsLinePen = new Pen(Color.FromArgb((int)(255 - (trackCount * (255 / (double)TRACK_COUNT))), TRACK_LINE_COLOR), TRACK_LINE_WIDTH);
                    //描画
                    g.DrawLine(gpsLinePen, startPoint, endPoint);

                    startPoint = endPoint;
                    trackCount++;
                }
            }

            //制御線を描画----------------------------------------------------------
            int pointCount     = controlPointList.Count;
            Pen controlLinePen = new Pen(CONTROL_LINE_COLOR, CONTROL_LINE_WIDTH);

            //制御点が一つ以上あれば開始点・終了点に丸をつける
            if (pointCount > 0)
            {
                //終了点
                g.FillEllipse(new SolidBrush(Color.White), controlPointList[pointCount - 1].ScaledLocation.X - 11, controlPointList[pointCount - 1].ScaledLocation.Y - 11, 20, 20);
                g.DrawEllipse(new Pen(Color.Red, 2), controlPointList[pointCount - 1].ScaledLocation.X - 11, controlPointList[pointCount - 1].ScaledLocation.Y - 11, 20, 20);

                //開始点
                g.FillEllipse(new SolidBrush(Color.White), controlPointList[0].ScaledLocation.X - 9, controlPointList[0].ScaledLocation.Y - 9, 16, 16);
                g.DrawEllipse(new Pen(Color.Blue, 2), controlPointList[0].ScaledLocation.X - 9, controlPointList[0].ScaledLocation.Y - 9, 16, 16);
            }

            //制御点が2個以上なら線を描く
            if (pointCount > 1)
            {
                //二制御点間に線を引く
                for (int i = 0; i < (pointCount - 1); i++)
                {
                    g.DrawLine(
                        controlLinePen,
                        controlPointList[i].ScaledLocation,
                        controlPointList[i + 1].ScaledLocation);
                }
            }

            //表示更新
            if (coursePicture.Image == null)
            {
                coursePicture.Image = renderTarget;
            }
            coursePicture.Refresh();
        }