/// <summary> /// インデクサー /// </summary> /// <param name="type"></param> /// <returns></returns> public Size this[ScreeanSizeType type] { get { // 画面サイズリスト返却 return(this.m_List[type]); } }
/// <summary> /// 画面サイズ取得 /// </summary> /// <param name="defaultValue"></param> /// <param name="Width"></param> /// <param name="Height"></param> /// <returns></returns> public ScreeanSizeType Get(ScreeanSizeType defaultValue, int Width, int Height) { Debug.WriteLine("■{0} = Width:{1},Height:{2}", defaultValue.ToString(), Width, Height); // 結果を初期化 ScreeanSizeType result = defaultValue; int differenceValueWidthMin = int.MaxValue; int differenceValueHeightMin = int.MaxValue; // 画面サイズリストを繰り返し foreach (ScreeanSizeType s in this.m_List.Keys) { Debug.WriteLine("□{0} = Width:{1}<>{3},Height:{2}<>{4}", s.ToString(), this.m_List[s].Width, this.m_List[s].Height, Width, Height); // どちらも超えているので対象外 if ((this.m_List[s].Width > Width) || (this.m_List[s].Height > Height)) { Debug.WriteLine(" ⇒ 超過"); continue; } // 幅、高さともに同じなら返却する if ((this.m_List[s].Width == Width) && (this.m_List[s].Height == Height)) { // 結果設定 result = s; Debug.WriteLine(" ⇒ 決定"); break; } // 候補値と差を計算 Console.WriteLine(" ⇒ 比較"); int differenceValueWidth = Width - this.m_List[s].Width; int differenceValueHeight = Height - this.m_List[s].Height; Debug.WriteLine(" └{0} = = Width:{1},Height:{2}", s.ToString(), differenceValueWidth, differenceValueHeight); if ((differenceValueWidthMin >= differenceValueWidth) && (differenceValueHeightMin >= differenceValueHeight)) { result = s; differenceValueWidthMin = differenceValueWidth; differenceValueHeightMin = differenceValueHeight; Debug.WriteLine(" └{0}(更新) = = Width:{1},Height:{2}", result.ToString(), differenceValueWidthMin, differenceValueHeightMin); } } // 結果を返却 Debug.WriteLine("画面種別:" + result.ToString()); return(result); }