2013年11月26日火曜日

FillAccessor

using Microsoft.Office.Core;
using OfficeExcel = Microsoft.Office.Interop.Excel;

namespace Core.File.Excel
{
    /// <summary>
    /// ExcelのFillアクセサー
    /// </summary>
    public class FillAccessor : BaseExcelAccessor
    {
        #region 構築・破棄

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="fill"></param>
        private FillAccessor(OfficeExcel.FillFormat fill, ExcelAccessor application)
            :base(application)
        {
            Fill = fill;
        }

        /// <summary>
        /// 構成子
        /// </summary>
        /// <param name="fill"></param>
        /// <returns></returns>
        internal static FillAccessor GetAccessor(OfficeExcel.FillFormat fill, ExcelAccessor application)
        {
            return new FillAccessor(fill, application);
        }

        #endregion

        #region プロパティ

        /// <summary>border</summary>
        private OfficeExcel.FillFormat Fill { get; set; }

        /// <summary>ForeColor</summary>
        private OfficeExcel.ColorFormat foreColor;
        /// <summary>ForeColor</summary>
        private OfficeExcel.ColorFormat ForeColor
        {
            get
            {
                if (this.foreColor == null)
                {
                    this.foreColor = Fill.ForeColor;
                    ReleaseComObjects.Add(this.foreColor);
                }
                return this.foreColor;
            }
        }

        /// <summary>塗りつぶし色</summary>
        public int ForeColorRGB
        {
            get
            {
                return ForeColor.RGB;
            }
            set
            {
                ForeColor.RGB = value;
            }
        }

        /// <summary>透明度</summary>
        public float Transparency
        {
            get
            {
                return Fill.Transparency;
            }
            set
            {
                Fill.Transparency = value;
            }
        }

        /// <summary>Visible</summary>
        public bool Visible
        {
            set
            {
                if (value)
                {
                    Fill.Visible = MsoTriState.msoTrue;
                }
                else
                {
                    Fill.Visible = MsoTriState.msoFalse;
                }
            }
        }

        #endregion
    }
}

0 件のコメント:

コメントを投稿