/// <summary> /// ボタンの幅を決定します。 /// </summary> /// <param name="pintButtonIcon">ボタンに表示するアイコンの種類</param> /// <param name="pbolShowModalIcon">モーダルアイコンを表示するかどうか</param> /// <param name="pintButtonWidth">ボタンの幅の種類</param> /// <param name="pstrWidthType">(OUT)ボタンの幅別の記号。CSSクラス、背景画像に適用</param> /// <param name="pintWidth">(OUT)幅の数値</param> private void subGetWidth( emButtonIcon pintButtonIcon, bool pbolShowModalIcon, emButtonWidth pintButtonWidth, out string pstrWidthType, out int pintWidth) { bool bolNoIcon = false; switch (pintButtonIcon) { case emButtonIcon.delete: case emButtonIcon.print: case emButtonIcon.preview: case emButtonIcon.excel: case emButtonIcon.csv: case emButtonIcon.pdf: break; case emButtonIcon.none: default: if (!pbolShowModalIcon) { //アイコンは表示しない bolNoIcon = true; } break; } if (bolNoIcon) { //通常のボタン switch (pintButtonWidth) { case emButtonWidth.xSmall: pstrWidthType = "xs"; pintWidth = 60; break; case emButtonWidth.middle: pstrWidthType = "m"; pintWidth = 130; break; case emButtonWidth.large: pstrWidthType = "l"; pintWidth = 170; break; case emButtonWidth.xLarge: pstrWidthType = "xl"; pintWidth = 222; break; case emButtonWidth.small: default: //デフォルトはsmallサイズ pstrWidthType = "s"; pintWidth = 90; break; } } else { //アイコンを表示する switch (pintButtonWidth) { case emButtonWidth.xSmall: pstrWidthType = "xs"; pintWidth = 85; break; case emButtonWidth.middle: pstrWidthType = "m"; pintWidth = 155; break; case emButtonWidth.large: pstrWidthType = "l"; pintWidth = 195; break; case emButtonWidth.xLarge: pstrWidthType = "xl"; pintWidth = 252; break; case emButtonWidth.small: default: //デフォルトはsmallサイズ pstrWidthType = "s"; pintWidth = 112; 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) + ";"; }