//* -----------------------------------------------------------------------* /// <summary>解像度列挙体に対応する解説を取得します。</summary> /// /// <param name="resolution">解像度列挙体</param> /// <returns>解説</returns> public static string ToString(this EResolution resolution) { string strRes = resolution.ToString().Replace("plus", "+").Replace("43", string.Empty); Rectangle rect = resolution.toRect(); return(strRes + string.Format( "({0}x{1})", rect.Width.ToString(), rect.Height.ToString())); }
//* -----------------------------------------------------------------------* /// <summary>解像度間の誤差を取得します。</summary> /// /// <param name="res1">解像度列挙体1。</param> /// <param name="res2">解像度列挙体2。</param> /// <returns>解像度。</returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// 予約値を設定しようとした場合。 /// </exception> public static Vector2 getScaleGap(EResolution res1, EResolution res2) { Rectangle rectRes1 = res1.toRect(); Rectangle rectRes2 = res2.toRect(); return(new Vector2( (float)(rectRes1.Width) / (float)(rectRes2.Width), (float)(rectRes1.Height) / (float)(rectRes2.Height))); }
//* -----------------------------------------------------------------------* /// <summary> /// <para>解像度を自動で検索し、設定します。</para> /// <para>Windowsでは最小に、XBOX360では最大に設定します。</para> /// </summary> /// /// <param name="gdm">グラフィック デバイスの構成・管理クラス。</param> /// <param name="bWide">ワイド画面を優先して検索するかどうか。</param> /// <param name="bFullScreen">全画面モードにするかどうか。</param> /// <returns> /// 自動設定の結果が現在の設定と異なり、かつ設定完了した場合、<c>true</c>。 /// </returns> public static bool applyScreenChange(GraphicsDeviceManager gdm, bool bWide, bool bFullScreen) { bool bResult = false; EResolution resolution = CResolution.getMinResolution(bWide); if (bFullScreen) { resolution = CResolution.getPrev(CResolution.getMaxResolution(bWide)); } Rectangle screenRect = resolution.toRect(); bResult = (gdm.IsFullScreen != bFullScreen) || (gdm.PreferredBackBufferWidth != screenRect.Width) || (gdm.PreferredBackBufferHeight != screenRect.Height); if (bResult) { gdm.IsFullScreen = bFullScreen; gdm.PreferredBackBufferWidth = screenRect.Width; gdm.PreferredBackBufferHeight = screenRect.Height; gdm.ApplyChanges(); } return(bResult); }
//* -----------------------------------------------------------------------* /// <summary>コンストラクタ。</summary> /// /// <param name="source">変換元の解像度。</param> /// <param name="destination">変換先の解像度。</param> public CResolutionSqueeze(EResolution source, EResolution destination) : this(source.toRect(), destination.toRect()) { }
//* -----------------------------------------------------------------------* /// <summary>コンストラクタ。</summary> /// /// <param name="source">変換元の解像度。</param> /// <param name="destination">変換先の解像度。</param> /// <param name="alignHorizontal">水平位置揃え情報。</param> /// <param name="alignVertical">垂直位置揃え情報。</param> /// <param name="cut"> /// アスペクト比が異り、かつこの値が<c>true</c>である場合、拡大してはみ出した /// 分をカットします。一方<c>false</c>の場合、縮小して余白を表示します。 /// アスペクト比が一致する場合、この引数によって何も変化しません。 /// </param> public CResolutionLetterBox(EResolution source, EResolution destination, EAlign alignHorizontal, EAlign alignVertical, bool cut) : this(source.toRect(), destination.toRect(), alignHorizontal, alignVertical, cut) { }