■ CultureInfo 클래스 : 지역 정보 사용하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


MainForm.cs

 

 

using System;

using System.Drawing;

using System.Globalization;

using System.Windows.Forms;

 

namespace TestProject

{

    /// <summary>

    /// 메인 폼

    /// </summary>

    public partial class MainForm : Form

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainForm()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainForm()

        {

            InitializeComponent();

 

            #region 이벤트를 설정한다.

 

            Load += Form_Load;

 

            #endregion

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Private

        //////////////////////////////////////////////////////////////////////////////// Event

 

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

 

        /// <summary>

        /// 폼 로드시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void Form_Load(object sender, EventArgs e)

        {

            CultureInfo info = CultureInfo.InstalledUICulture;

 

            AddHeader("Day/Month :");

 

            AddItem("Day"         , info.DateTimeFormat.DayNames             );

            AddItem("Abbrev Day"  , info.DateTimeFormat.AbbreviatedDayNames  );

            AddItem("Short Days"  , info.DateTimeFormat.ShortestDayNames     );

            AddItem("Month"       , info.DateTimeFormat.MonthNames           );

            AddItem("Abbrev Month", info.DateTimeFormat.AbbreviatedMonthNames);

 

            AddHeader("Date/Time Format :");

 

            AddItem("AMDesignator"           , info.DateTimeFormat.AMDesignator             );

            AddItem("DateSeparator"          , info.DateTimeFormat.DateSeparator            );

            AddItem("FirstDayOfWeek"         , info.DateTimeFormat.FirstDayOfWeek.ToString());

            AddItem("FullDateTimePattern"    , info.DateTimeFormat.FullDateTimePattern      );

            AddItem("LongDatePattern"        , info.DateTimeFormat.LongDatePattern          );

            AddItem("LongTimePattern"        , info.DateTimeFormat.LongTimePattern          );

            AddItem("MonthDayPattern"        , info.DateTimeFormat.MonthDayPattern          );

            AddItem("NativeCalendarName"     , info.DateTimeFormat.NativeCalendarName       );

            AddItem("PMDesignator"           , info.DateTimeFormat.PMDesignator             );

            AddItem("RFC1123Pattern"         , info.DateTimeFormat.RFC1123Pattern           );

            AddItem("ShortDatePattern"       , info.DateTimeFormat.ShortDatePattern         );

            AddItem("ShortTimePattern"       , info.DateTimeFormat.ShortTimePattern         );

            AddItem("SortableDateTimePattern", info.DateTimeFormat.SortableDateTimePattern  );

            AddItem("TimeSeparator"          , info.DateTimeFormat.TimeSeparator            );

 

            AddHeader("Culture :");

 

            AddItem("Culture Name"        , info.Name                       );

            AddItem("Culture Native Name" , info.NativeName                 );

            AddItem("Culture Display Name", info.DisplayName                );

            AddItem("Culture English Name", info.EnglishName                );

            AddItem("IetfLanguageTag"     , info.IetfLanguageTag            );

            AddItem("IsNeutralCulture"    , info.IsNeutralCulture.ToString());

 

            AddHeader("Currency Format :");

 

            AddItem("Decimal Digits"   , info.NumberFormat.CurrencyDecimalDigits.ToString()  );

            AddItem("Decimal Separator", info.NumberFormat.CurrencyDecimalSeparator          );

            AddItem("Group Separator"  , info.NumberFormat.CurrencyGroupSeparator            );

            AddItem("Group Size"       , info.NumberFormat.CurrencyGroupSizes                );

            AddItem("Negative Pattern" , info.NumberFormat.CurrencyNegativePattern.ToString());

            AddItem("Positive Pattern" , info.NumberFormat.CurrencyPositivePattern.ToString());

            AddItem("Currency Symbol " , info.NumberFormat.CurrencySymbol                    );

 

            AddHeader("Number Format :");

 

            AddItem("NaN"                     , info.NumberFormat.NaNSymbol                       );

            AddItem("Native Digits"           , info.NumberFormat.NativeDigits                    );

            AddItem("Infinity Symbol"         , info.NumberFormat.NegativeInfinitySymbol          );

            AddItem("Negative Sign"           , info.NumberFormat.NegativeSign                    );

            AddItem("Decimal Separator"       , info.NumberFormat.NumberDecimalSeparator          );

            AddItem("Group Separator"         , info.NumberFormat.NumberGroupSeparator            );

            AddItem("Group Size"              , info.NumberFormat.PercentGroupSizes               );

            AddItem("Negative Pattern"        , info.NumberFormat.NumberNegativePattern.ToString());

            AddItem("Positive Infinity Symbol", info.NumberFormat.PositiveInfinitySymbol          );

            AddItem("Positive Sign"           , info.NumberFormat.PositiveSign                    );

 

            AddHeader("Percent Format :");

 

            AddItem("Decimal Digits"   , info.NumberFormat.PercentDecimalDigits.ToString()  );

            AddItem("Decimal Separator", info.NumberFormat.PercentDecimalSeparator          );

            AddItem("Group Separator"  , info.NumberFormat.PercentGroupSeparator            );

            AddItem("Group Size"       , info.NumberFormat.PercentGroupSizes                );

            AddItem("Negative Pattern" , info.NumberFormat.PercentNegativePattern.ToString());

            AddItem("Positive Pattern" , info.NumberFormat.PercentPositivePattern.ToString());

            AddItem("Percent Symbol"   , info.NumberFormat.PercentSymbol                    );

            AddItem("PerMilleSymbol"   , info.NumberFormat.PerMilleSymbol                   );

 

            this.listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////// Function

 

        #region 헤더 추가하기 - AddHeader(name)

 

        /// <summary>

        /// 헤더 추가하기

        /// </summary>

        /// <param name="name">명칭</param>

        private void AddHeader(string name)

        {

            ListViewItem item = this.listView.Items.Add(name);

 

            item.BackColor = Color.Pink;

        }

 

        #endregion

        #region 항목 추가하기 - AddItem(name, value)

 

        /// <summary>

        /// 항목 추가하기

        /// </summary>

        /// <param name="name">명칭</param>

        /// <param name="value"></param>

        private void AddItem(string name, string value)

        {

            ListViewItem item = this.listView.Items.Add(name);

 

            item.SubItems.Add(value);

        }

 

        #endregion

        #region 항목 추가하기 - AddItem(name, valueArray)

 

        /// <summary>

        /// 항목 추가하기

        /// </summary>

        /// <param name="name">명칭</param>

        /// <param name="valueArray">값 배열</param>

        private void AddItem(string name, string[] valueArray)

        {

            for(int i = 0; i < valueArray.Length; i++)

            {

                AddItem(name + "[" + i + "]", valueArray[i]);

            }

        }

 

        #endregion

        #region 항목 추가하기 - AddItem(name, valueArray)

 

        /// <summary>

        /// 항목 추가하기

        /// </summary>

        /// <param name="name">명칭</param>

        /// <param name="valueArray">값 배열</param>

        private void AddItem(string name, int[] valueArray)

        {

            for(int i = 0; i < valueArray.Length; i++)

            {

                AddItem(name + "[" + i + "]", valueArray[i].ToString());

            }

        }

 

        #endregion

    }

}

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요