//──────────────────────────────────────── /// <summary> /// 情報表示。 /// </summary> /// <param name="g"></param> /// <param name="isOnWindow"></param> /// <param name="scale2"></param> public void Paint( Graphics g, bool isOnWindow, MemorySpritememoImpl memorySpritememo, float scale2, Spritememo_InfoDisplay infoDisplay ) { int ox; int oy; if (isOnWindow) { ox = 0; oy = 100; } else { ox = 0; oy = 0; } int row = 1; string sText; // // ベースx,y // sText = infoDisplay.E_sSpBaseLocationOnBg.ToString(); if ("" != sText) { // 影 g.DrawString( sText, infoDisplay.CoordinateFont, Brushes.Black, infoDisplay.TextLocationAA[row][2].X + ox, infoDisplay.TextLocationAA[row][2].Y + oy ); // 白抜き文字 g.DrawString( sText, infoDisplay.CoordinateFont, Brushes.White, infoDisplay.TextLocationAA[row][1].X + ox, infoDisplay.TextLocationAA[row][1].Y + oy ); row++; } // // 左上x,y // { string s = infoDisplay.E_sSpLtOnBg.ToString(); // 影 g.DrawString( s, infoDisplay.CoordinateFont, Brushes.Black, infoDisplay.TextLocationAA[row][2].X + ox, infoDisplay.TextLocationAA[row][2].Y + oy ); // 白抜き文字 g.DrawString( s, infoDisplay.CoordinateFont, Brushes.White, infoDisplay.TextLocationAA[row][1].X + ox, infoDisplay.TextLocationAA[row][1].Y + oy ); row++; } // // 中心x,y // { string s = infoDisplay.E_sSpCtOnBg.ToString(); // 影 g.DrawString( s, infoDisplay.CoordinateFont, Brushes.Black, infoDisplay.TextLocationAA[row][2].X + ox, infoDisplay.TextLocationAA[row][2].Y + oy ); // 白抜き文字 g.DrawString( s, infoDisplay.CoordinateFont, Brushes.White, infoDisplay.TextLocationAA[row][1].X + ox, infoDisplay.TextLocationAA[row][1].Y + oy ); row++; } // // 横幅、縦幅 // if ( (0 != memorySpritememo.DstSizeResult.Width || 0 != memorySpritememo.SrcSize.Width) && (0 != memorySpritememo.DstSizeResult.Height || 0 != memorySpritememo.SrcSize.Height) ) { string s = infoDisplay.E_sWH.ToString(); // 影 g.DrawString( s, infoDisplay.CoordinateFont, Brushes.Black, infoDisplay.TextLocationAA[row][2].X + ox, infoDisplay.TextLocationAA[row][2].Y + oy ); // 白抜き文字 g.DrawString( s, infoDisplay.CoordinateFont, Brushes.White, infoDisplay.TextLocationAA[row][1].X + ox, infoDisplay.TextLocationAA[row][1].Y + oy ); row++; } }
//──────────────────────────────────────── /// <summary> /// [乗せる画像]の描画 /// </summary> /// <param name="g"></param> /// <param name="bOnWindow"></param> /// <param name="scale2"></param> public void PaintSprite(Graphics g, bool bOnWindow, float scale2, PointF bgLocation, Spritememo_InfoDisplay infoDisplay) { if (null == this.MoSprite) { goto gt_ProcessEnd; } // // 表示する画像の、左上隅座標 // float x = scale2 * this.MoSprite.LtXOnBgOsz; float y = scale2 * this.MoSprite.LtYOnBgOsz; if (bOnWindow) { x += bgLocation.X; y += bgLocation.Y; } // // 表示する横幅、縦幅 // float width = this.MoSprite.DstSizeResult.Width; float height = this.MoSprite.DstSizeResult.Height; // 表示する位置と、横幅、縦幅 Rectangle dstRectScaled = new Rectangle((int)x, (int)y, (int)(scale2 * width), (int)(scale2 * height)); // 枠の太さ(影+本体= 2px) int borderWidth = 2; if (null == this.MoSprite.Bitmap) { // // ビットマップが指定されていなければ、緑色の四角を表示する。 // g.FillRectangle( this.MoSprite.AltBrush, dstRectScaled ); } else { // ビットマップ画像の不透明度を指定します。 System.Drawing.Imaging.ImageAttributes ia; { System.Drawing.Imaging.ColorMatrix cm = new System.Drawing.Imaging.ColorMatrix(); cm.Matrix00 = 1; cm.Matrix11 = 1; cm.Matrix22 = 1; cm.Matrix33 = this.MoSprite.NOpaque;//α値。0~1か? cm.Matrix44 = 1; //ImageAttributesオブジェクトの作成 ia = new System.Drawing.Imaging.ImageAttributes(); //ColorMatrixを設定する ia.SetColorMatrix(cm); } g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; //ドット絵のまま拡縮するように。しかし、この指定だと半ピクセル左上にずれるバグ。 g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; //半ピクセル左上にずれるバグに対応。 g.DrawImage( this.MoSprite.Bitmap, dstRectScaled, 0, 0, this.MoSprite.Bitmap.Width, this.MoSprite.Bitmap.Height, GraphicsUnit.Pixel, ia ); } // 十字線 if (this.MoSprite.BCross) { // 縦線 g.DrawLine( this.infoDisplay.GridPen,//Pens.Green, (int)(dstRectScaled.X + (double)dstRectScaled.Width / 2.0d), dstRectScaled.Y, (int)(dstRectScaled.X + (double)dstRectScaled.Width / 2.0d), dstRectScaled.Y + dstRectScaled.Height - 1 ); // 横線 g.DrawLine( this.infoDisplay.GridPen,//Pens.Green, dstRectScaled.X, (int)(dstRectScaled.Y + (double)dstRectScaled.Height / 2.0d), dstRectScaled.X + dstRectScaled.Width - 1, (int)(dstRectScaled.Y + (double)dstRectScaled.Height / 2.0d) ); } // 枠線 if (this.MoSprite.BBorder) { // // 枠線:影 // // X,Yを、1ドット右下にずらします。 dstRectScaled.Offset(1, 1); // 最初の状態だと、右辺、下辺が外に1px出ています。 // X,Yをずらした分と合わせて、縦幅、横幅を2ドット狭くします。 dstRectScaled.Width -= 2; dstRectScaled.Height -= 2; g.DrawRectangle(Pens.Black, dstRectScaled); // // dstRectScaled.Offset(-1, -1); // 元の位置に戻します。 dstRectScaled.Width += 2; // 元のサイズに戻します。 dstRectScaled.Height += 2; // // 枠線: // // 最初から1ドット出ている分と、X,Yをずらした分と合わせて、 // 縦幅、横幅を2ドット狭くします。 dstRectScaled.Width -= 2; dstRectScaled.Height -= 2; g.DrawRectangle( infoDisplay.GridPen,// Pens.Green, dstRectScaled); // 元に戻す。 dstRectScaled.Width += 2; dstRectScaled.Height += 2; } // // // // gt_ProcessEnd: return; }
//──────────────────────────────────────── /// <summary> /// コンストラクター。 /// </summary> public Usercontrol_XyMemo() { InitializeComponent(); this.mouseDragModeEnum = EnumMousedragmode.NONE; this.infoDisplay = new Spritememo_InfoDisplay(); this.pclstMouseDrag.Items.Add("なし"); this.pclstMouseDrag.Items.Add("背景画像移動"); this.pclstMouseDrag.Items.Add("乗せる画像移動"); this.pclstMouseDrag.SelectedIndex = 0; this.pcddlAlScale.Items.Add("x0.25"); this.pcddlAlScale.Items.Add("x0.5"); this.pcddlAlScale.Items.Add("x 1");//初期選択 this.pcddlAlScale.Items.Add("x 2"); this.pcddlAlScale.Items.Add("x 4"); this.pcddlAlScale.Items.Add("x 8"); this.pcddlAlScale.Items.Add("x 16"); this.pcddlAlScale.SelectedIndex = 2; this.pcddlBgOpaque.Items.Add("100"); this.pcddlBgOpaque.Items.Add(" 75"); this.pcddlBgOpaque.Items.Add(" 50");//初期選択 this.pcddlBgOpaque.Items.Add(" 25"); this.pcddlBgOpaque.SelectedIndex = 2; this.bgOpaque = 0.5F; // 格子枠の色 this.pcddlGridcolor.Items.Add("自動"); this.pcddlGridcolor.Items.Add("白"); this.pcddlGridcolor.Items.Add("灰色"); this.pcddlGridcolor.Items.Add("黒"); this.pcddlGridcolor.Items.Add("赤"); this.pcddlGridcolor.Items.Add("黄"); this.pcddlGridcolor.Items.Add("緑");//初期選択 this.pcddlGridcolor.Items.Add("青"); this.pcddlGridcolor.SelectedIndex = 6; this.bgLocation = new Point(); }
//──────────────────────────────────────── /// <summary> /// [乗せる画像]の描画 /// </summary> /// <param name="g"></param> /// <param name="bOnWindow"></param> /// <param name="scale2"></param> public void PaintSprite(Graphics g, bool bOnWindow, float scale2, PointF bgLocation, Spritememo_InfoDisplay infoDisplay) { if (null == this.MoSprite) { goto gt_ProcessEnd; } // // 表示する画像の、左上隅座標 // float x = scale2 * this.MoSprite.LtXOnBgOsz; float y = scale2 * this.MoSprite.LtYOnBgOsz; if (bOnWindow) { x += bgLocation.X; y += bgLocation.Y; } // // 表示する横幅、縦幅 // float width = this.MoSprite.DstSizeResult.Width; float height = this.MoSprite.DstSizeResult.Height; // 表示する位置と、横幅、縦幅 Rectangle dstRectScaled = new Rectangle((int)x, (int)y, (int)(scale2 * width), (int)(scale2 * height)); // 枠の太さ(影+本体= 2px) int borderWidth = 2; if (null == this.MoSprite.Bitmap) { // // ビットマップが指定されていなければ、緑色の四角を表示する。 // g.FillRectangle( this.MoSprite.AltBrush, dstRectScaled ); } else { // ビットマップ画像の不透明度を指定します。 System.Drawing.Imaging.ImageAttributes ia; { System.Drawing.Imaging.ColorMatrix cm = new System.Drawing.Imaging.ColorMatrix(); cm.Matrix00 = 1; cm.Matrix11 = 1; cm.Matrix22 = 1; cm.Matrix33 = this.MoSprite.NOpaque;//α値。0~1か? cm.Matrix44 = 1; //ImageAttributesオブジェクトの作成 ia = new System.Drawing.Imaging.ImageAttributes(); //ColorMatrixを設定する ia.SetColorMatrix(cm); } g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;//ドット絵のまま拡縮するように。しかし、この指定だと半ピクセル左上にずれるバグ。 g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;//半ピクセル左上にずれるバグに対応。 g.DrawImage( this.MoSprite.Bitmap, dstRectScaled, 0, 0, this.MoSprite.Bitmap.Width, this.MoSprite.Bitmap.Height, GraphicsUnit.Pixel, ia ); } // 十字線 if (this.MoSprite.BCross) { // 縦線 g.DrawLine( this.infoDisplay.GridPen,//Pens.Green, (int)(dstRectScaled.X + (double)dstRectScaled.Width / 2.0d), dstRectScaled.Y, (int)(dstRectScaled.X + (double)dstRectScaled.Width / 2.0d), dstRectScaled.Y + dstRectScaled.Height - 1 ); // 横線 g.DrawLine( this.infoDisplay.GridPen,//Pens.Green, dstRectScaled.X, (int)(dstRectScaled.Y + (double)dstRectScaled.Height / 2.0d), dstRectScaled.X + dstRectScaled.Width - 1, (int)(dstRectScaled.Y + (double)dstRectScaled.Height / 2.0d) ); } // 枠線 if (this.MoSprite.BBorder) { // // 枠線:影 // // X,Yを、1ドット右下にずらします。 dstRectScaled.Offset(1, 1); // 最初の状態だと、右辺、下辺が外に1px出ています。 // X,Yをずらした分と合わせて、縦幅、横幅を2ドット狭くします。 dstRectScaled.Width -= 2; dstRectScaled.Height -= 2; g.DrawRectangle(Pens.Black, dstRectScaled); // // dstRectScaled.Offset(-1, -1);// 元の位置に戻します。 dstRectScaled.Width += 2;// 元のサイズに戻します。 dstRectScaled.Height += 2; // // 枠線: // // 最初から1ドット出ている分と、X,Yをずらした分と合わせて、 // 縦幅、横幅を2ドット狭くします。 dstRectScaled.Width -= 2; dstRectScaled.Height -= 2; g.DrawRectangle( infoDisplay.GridPen,// Pens.Green, dstRectScaled); // 元に戻す。 dstRectScaled.Width += 2; dstRectScaled.Height += 2; } // // // // gt_ProcessEnd: return; }