GcShapeButtonをズームする時、コントロールの位置が固定になる

文書番号 : 39004     文書種別 : 不具合     登録日 : 2015/07/09     最終更新日 : 2015/11/27
文書を印刷する
対象製品
MultiTouch for Windows Forms 1.0J
状況
修正済み
詳細
GcZoomまたはGcApplicationZoomコンポーネントを使用してズームを行う場合、GcShapeButtonZoomPolicyを使用してもGcShapeButtonコントロールのサイズが変更されず元の位置に固定されます。この動作によって元のレイアウトが崩れることがあります。
回避方法
Service Pack 3(v1.0.2015.1127)では、PlusPak for Windows Forms 8.0JのGcShapeButtonコントロールで提供しているSizeModeプロパティの値を使用して、表示を最適化するズームポリシーを提供しています。
最新のサービスパックは、アップデートページ からダウンロードできます。

PlusPak for Windows Forms 7.0Jでは、GcShapeButtonコントロールはSizeModeプロパティを提供していないため、Service Pack 3で提供しているGcShapeButtonZoomPolicyを適用するとエラーが発生します。
PlusPak for Windows Forms 7.0JのGcShapeButtonコントロールでは、以下の回避方法をご検討ください。

ズーム後のレイアウトでもGcShapeButtonの位置を保持するには、GcShapeButtonZoomPolicyのコードを下記のように置き換えます。

[Visual Basic]
Public Class GcShapeButtonZoomPolicy
  Inherits NoZoomFontZoomPolicy
  Public Overrides ReadOnly Property TargetType() As Type
    Get
      Return GetType(GcShapeButton)
    End Get
  End Property

  Public Overrides Sub ZoomBounds(control As Control, infos As ZoomBoundsInfo)
    control.Bounds = Align(infos.Zoom(infos.CurrentBounds), New Rectangle(Point.Empty, control.Size), ContentAlignment.MiddleCenter)
  End Sub
  Private Shared Function Align(outer As Rectangle, inner As Rectangle, alignment As ContentAlignment) As Rectangle
    Dim offsetX As Integer = outer.X - inner.X, offsetY As Integer = outer.Y - inner.Y

    Select Case alignment
      Case ContentAlignment.BottomCenter, ContentAlignment.MiddleCenter, ContentAlignment.TopCenter
        offsetX += (outer.Width - inner.Width) / 2
        Exit Select
      Case ContentAlignment.BottomRight, ContentAlignment.MiddleRight, ContentAlignment.TopRight
        offsetX += outer.Width - inner.Width
        Exit Select
    End Select

    Select Case alignment
      Case ContentAlignment.MiddleCenter, ContentAlignment.MiddleLeft, ContentAlignment.MiddleRight
        offsetY += (outer.Height - inner.Height) / 2
        Exit Select
      Case ContentAlignment.BottomCenter, ContentAlignment.BottomLeft, ContentAlignment.BottomRight
        offsetY += outer.Height - inner.Height
        Exit Select
    End Select

    inner.Offset(offsetX, offsetY)

    Return inner
  End Function
End Class

[C#]
  public class GcShapeButtonZoomPolicy : NoZoomFontZoomPolicy
  {
    public override Type TargetType
    {
      get { return typeof(GcShapeButton); }
    }

    public override void ZoomBounds(Control control, ZoomBoundsInfo infos)
    {
      control.Bounds = Align(infos.Zoom(infos.CurrentBounds), new Rectangle(Point.Empty, control.Size), ContentAlignment.MiddleCenter);
    }
    static Rectangle Align(Rectangle outer, Rectangle inner, ContentAlignment alignment)
    {
      int offsetX = outer.X - inner.X, offsetY = outer.Y - inner.Y;

      switch (alignment)
      {
        case ContentAlignment.BottomCenter:
        case ContentAlignment.MiddleCenter:
        case ContentAlignment.TopCenter:
          offsetX += (outer.Width - inner.Width) / 2;
          break;
        case ContentAlignment.BottomRight:
        case ContentAlignment.MiddleRight:
        case ContentAlignment.TopRight:
          offsetX += outer.Width - inner.Width;
          break;
      }

      switch (alignment)
      {
        case ContentAlignment.MiddleCenter:
        case ContentAlignment.MiddleLeft:
        case ContentAlignment.MiddleRight:
          offsetY += (outer.Height - inner.Height) / 2;
          break;
        case ContentAlignment.BottomCenter:
        case ContentAlignment.BottomLeft:
        case ContentAlignment.BottomRight:
          offsetY += outer.Height - inner.Height;
          break;
      }

      inner.Offset(offsetX, offsetY);

      return inner;
    }
  }
キーワード
MTTK11183