Engine地図移動動作を何とかしたい – 2 –


Engine地図移動動作を何とかしたい
ちらつきはダブルバッファ的に抑えられる。
次は全描画が長い際の対処を検討

public override void OnMouseMove(int button, int shift, int x, int y)
{
  if (this.m_Img == null || this.m_hookHelper == null)
    return;
  IScreenDisplay scDisplay = this.m_hookHelper.ActiveView.ScreenDisplay;
  var rect = scDisplay.DisplayTransformation.get_DeviceFrame();

  scDisplay.StartDrawing(scDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
  IntPtr screenGraphics = new IntPtr(scDisplay.hDC);

  using (Graphics screen = Graphics.FromHdc(screenGraphics))
  using (SolidBrush solid = new SolidBrush(Color.White))
  using (Bitmap bmp = new Bitmap(rect.right, rect.bottom))
  using (Graphics backBuffer = Graphics.FromImage(bmp))
  {
    backBuffer.FillRectangle(solid, new Rectangle(rect.left, rect.top, rect.right, rect.bottom));
    Point imgPt = new Point();
    imgPt.X = x - this.m_MouseDownPt.X;
    imgPt.Y = y - this.m_MouseDownPt.Y;

    backBuffer.DrawImageUnscaled(this.m_Img, imgPt);

    backBuffer.Dispose();

    screen.DrawImageUnscaled(bmp, new Point(0, 0));

    //screen.DrawImageUnscaled(this.m_Img, imgPt);
  }
  scDisplay.FinishDrawing();
}
カテゴリー: 開発 タグ: パーマリンク