ArcEngine(4)パンの学習

7539 ワード

地図の平行移動は、最も重要な機能の一つと言えるが、多くの地図のデフォルトツールは平行移動である.AEは平行移動を実現し、比較的簡単で、コードは以下の通りである.
   1:    /// <summary>
   2:      ///   
   3:      /// </summary>
   4:      public class Pan : GISTools.Base.ToolBase
   5:      {
   6:         
   7:          private bool m_PanOperation;
   8:   
   9:          public Pan()
  10:              : base("Pan")
  11:          { }
  12:   
  13:          public Pan(AxMapControl mapCtl) 
  14:              : base(mapCtl, "Pan") 
  15:          {
  16:              if (m_cursor == null) m_cursor = getCursor(esriSystemMouseCursor.esriSystemMouseCursorPan);
  17:          }
  18:   
  19:          public Pan(AxPageLayoutControl plCtl)
  20:              : base(plCtl, "Pan")
  21:          {
  22:              if (m_cursor == null) m_cursor = getCursor(esriSystemMouseCursor.esriSystemMouseCursorPan);
  23:          }
  24:   
  25:          public override void OnMouseDown(int Button, int Shift, int X, int Y)
  26:          {
  27:              if (Button != 1) return;
  28:             IPoint point =m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
  29:             m_pActiveView.ScreenDisplay.PanStart(point);
  30:              m_PanOperation = true;
  31:          }
  32:   
  33:          public override void OnMouseMove(int Button, int Shift, int X, int Y)
  34:          {
  35:              if (Button != 1) return;
  36:   
  37:              if (!m_PanOperation) return;
  38:   
  39:              IPoint point = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
  40:              m_pActiveView.ScreenDisplay.PanMoveTo(point);
  41:          }
  42:   
  43:          public override void OnMouseUp(int Button, int Shift, int X, int Y)
  44:          {
  45:              if (Button != 1) return;
  46:   
  47:              if (!m_PanOperation) return;
  48:   
  49:              IEnvelope extent = m_pActiveView.ScreenDisplay.PanStop();
  50:   
  51:              if (extent != null)
  52:              {
  53:                  m_pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds = extent;
  54:                  m_pActiveView.ScreenDisplay.Invalidate(null, true, (short)esriScreenCache.esriAllScreenCaches);
  55:              }
  56:              m_PanOperation = false;
  57:          }
  58:      }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }