/// <summary> /// ConvertTo(プロパティグリッド表示値への変換)を実行する。 /// </summary> /// <param name="context">コンテキスト</param> /// <param name="culture">カルチャと</param> /// <param name="value">EditPaddingオブジェクト</param> /// <param name="destinationType">変換後の型</param> /// <returns>文字列</returns> public override object ConvertTo( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { // 型をチェック if (destinationType == typeof(string)) { // 文字列へ変換 if (value is EditPadding) { EditPadding ep = (EditPadding)value; if (ep.PadChar == null) { return(ep.PadDir.ToString() + " : -"); } else { return(ep.PadDir.ToString() + " : " + ep.PadChar); } } } // 上記以外の場合、ベースへ。 return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary>Equals</summary> /// <param name="ep">EditPadding</param> /// <returns> /// true:等しい /// false:等しくない /// </returns> /// <remarks>全メンバの==のAND</remarks> public bool Equals(EditPadding ep) { // null対応 if (ep == null) { return(false); } return ((this.PadDir == ep.PadDir) && (this.PadChar == ep.PadChar)); }
/// <summary> /// ConvertFrom(プロパティグリッドからの変換)を実行する。 /// </summary> /// <param name="context">コンテキスト</param> /// <param name="culture">カルチャ</param> /// <param name="value">文字列</param> /// <returns>EditPaddingオブジェクト</returns> public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object value) { // 文字列型の場合 if (value is string) { string[] s = value.ToString().Split(':'); EditPadding ep = new EditPadding(); string padDir = s[0].Trim(); if (padDir == PadDirection.Left.ToString()) { ep.PadDir = PadDirection.Left; } else if (padDir == PadDirection.Right.ToString()) { ep.PadDir = PadDirection.Right; } else { ep.PadDir = PadDirection.None; } if (s.Length <= 1 || s[1].Trim() == "") { ep.PadChar = '-'; } else { ep.PadChar = char.Parse(s[1].Trim()); } return(ep); } // 上記以外の場合、ベースへ。 return(base.ConvertFrom(context, culture, value)); }
/// <summary>Equals</summary> /// <param name="ep">EditPadding</param> /// <returns> /// true:等しい /// false:等しくない /// </returns> /// <remarks>全メンバの==のAND</remarks> public bool Equals(EditPadding ep) { // null対応 if (ep == null) { return false; } return (this.PadDir == ep.PadDir) && (this.PadChar == ep.PadChar); }
/// <summary> /// ConvertFrom(プロパティグリッドからの変換)を実行する。 /// </summary> /// <param name="context">コンテキスト</param> /// <param name="culture">カルチャ</param> /// <param name="value">文字列</param> /// <returns>EditPaddingオブジェクト</returns> public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object value) { // 文字列型の場合 if (value is string) { string[] s = value.ToString().Split(':'); EditPadding ep = new EditPadding(); string padDir = s[0].Trim(); if (padDir == PadDirection.Left.ToString()) { ep.PadDir = PadDirection.Left; } else if (padDir == PadDirection.Right.ToString()) { ep.PadDir = PadDirection.Right; } else { ep.PadDir = PadDirection.None; } if (s.Length <= 1 || s[1].Trim() == "") { ep.PadChar = '-'; } else { ep.PadChar = char.Parse(s[1].Trim()); } return ep; } // 上記以外の場合、ベースへ。 return base.ConvertFrom(context, culture, value); }