/// <summary> /// ボタンの高さを決定します。 /// </summary> /// <param name="pintButtonHeight">ボタンの高さの種類</param> /// <param name="pstrHeightType">(OUT)ボタンの高さ別の記号。CSSクラス、背景画像に使用</param> /// <param name="pintHeight">(OUT)高さの数値</param> private void subGetHeight( emButtonHeight pintButtonHeight, out string pstrHeightType, out int pintHeight) { switch (pintButtonHeight) { case emButtonHeight.small: pintHeight = 22; pstrHeightType = "s"; break; case emButtonHeight.medium: pintHeight = 30; pstrHeightType = "m"; break; default: //デフォルトは小さいサイズ pintHeight = 22; pstrHeightType = "s"; break; } }
private void subSetStyle( emButtonWidth pintButtonWidth, emButtonHeight pintButtonHeight, emButtonIcon pintButtonIcon, bool pbolShowModalIcon, out string pstrClass, out string pstrStyle) { const string c_strIconLeft = "hrbutton_l"; const string c_strIconRight = "hrbutton_r"; const string c_strBasicClass = "hrbutton"; int intHeight = 0; int intWidth = 0; string strHeightType = ""; //ボタンの高さの種類 string strWidthType = ""; //ボタンの幅の種類 string strImageName = ""; //ボタンの背景画像名 string strImageUrl = ""; //ボタンのスタイル決定に使用 string strButtonDisabledClass = ""; //ボタンがDisabledのときのクラス string strIconPosClass = ""; //アイコンの位置を決定するCSSクラス string strBackgroundPosClass = ""; //背景の表示位置を決定するCSSクラス string strBalloonHintCss = ""; //バルーンヒントのCSSクラス var aryStyles = new List <string>(); //ボタンの高さを決定 subGetHeight(pintButtonHeight, out strHeightType, out intHeight); //ボタンの幅を決定 subGetWidth(pintButtonIcon, pbolShowModalIcon, pintButtonWidth, out strWidthType, out intWidth); //高さと幅をセット aryStyles.Add("height: " + intHeight.ToString() + "px"); aryStyles.Add("width: " + intWidth.ToString() + "px"); switch (pintButtonIcon) { case emButtonIcon.delete: strImageName = "hrbutton_del_" + strHeightType + "_" + strWidthType + ".png"; //アイコンは左 strIconPosClass = c_strIconLeft; break; case emButtonIcon.print: strImageName = "hrbutton_print_" + strHeightType + "_" + strWidthType + ".png"; //アイコンは左 strIconPosClass = c_strIconLeft; break; case emButtonIcon.preview: strImageName = "hrbutton_preview_" + strHeightType + "_" + strWidthType + ".png"; //アイコンは左 strIconPosClass = c_strIconLeft; break; case emButtonIcon.excel: strImageName = "hrbutton_excel_" + strHeightType + "_" + strWidthType + ".png"; //アイコンは左 strIconPosClass = c_strIconLeft; break; case emButtonIcon.csv: strImageName = "hrbutton_csv_" + strHeightType + "_" + strWidthType + ".png"; //アイコンは左 strIconPosClass = c_strIconLeft; break; case emButtonIcon.pdf: strImageName = "hrbutton_pdf_" + strHeightType + "_" + strWidthType + ".png"; //アイコンは左 strIconPosClass = c_strIconLeft; break; case emButtonIcon.none: default: //デフォルトはアイコンなし if (pbolShowModalIcon) { //ダイアログのアイコンを表示する場合 strImageName = "hrbutton_dialog_" + strHeightType + "_" + strWidthType + ".png"; //アイコンは右 strIconPosClass = c_strIconRight; } else { strImageName = "hrbutton_plain_" + strHeightType + "_" + strWidthType + ".png"; //アイコンなしのため、アイコン位置クラスはセットしない } break; } //アイコンの位置によって、背景描画位置を変える //----------- //背景クラス strBackgroundPosClass //----------- // クラス名は「高さ_状態」を表す。 //(例)hrbutton_s_n //高さsmall、使用可能状態を表す //(例)hrbutton_m_d //高さmedium、使用不可状態を表す //----------- strBackgroundPosClass = "hrbutton_" + strHeightType; if (this.Enabled) { strButtonDisabledClass = ""; strBackgroundPosClass += "_n"; } else { strButtonDisabledClass = "hrbutton_d"; strBackgroundPosClass += "_d"; } //バルーンヒントを表示するかどうか if (this.ToolTip.Trim() != "") { strBalloonHintCss = "balloonhint"; } //CSSを適用する var aryClasses = new string[] { c_strBasicClass, strIconPosClass, strBackgroundPosClass, strButtonDisabledClass, strBalloonHintCss }; //背景イメージを設定 strImageUrl = "../../images/" + strImageName; aryStyles.Add("background-image: url(" + strImageUrl + ")"); //OUT引数 pstrClass = string.Join(" ", aryClasses).Trim(); pstrStyle = string.Join("; ", aryStyles) + ";"; }