示例#1
0
        public CalendarConvertorViewModel()
        {
            DurationHeader = "Calendar Convertor";

            #region Initialize

            _gregorDays          = new ObservableCollection <ListDataItem>();
            _gregorMonths        = new ObservableCollection <ListDataItem>();
            _gregorYears         = new ObservableCollection <ListDataItem>();
            _selectedGregorDay   = new ListDataItem();
            _selectedGregorMonth = new ListDataItem();
            _selectedGregorYear  = new ListDataItem();
            _ethioDays           = new ObservableCollection <ListDataItem>();
            _ethioMonths         = new ObservableCollection <ListDataItem>();
            _ethioYears          = new ObservableCollection <ListDataItem>();
            _selectedEthioDay    = new ListDataItem();
            _selectedEthioMonth  = new ListDataItem();
            _selectedEthioYear   = new ListDataItem();

            #endregion

            #region Load Properties

            for (var i = 1; i <= 30; i++)
            {
                GregorDays.Add(new ListDataItem {
                    Display = i.ToString(), Value = i
                });
                EthioDays.Add(new ListDataItem {
                    Display = i.ToString(), Value = i
                });
            }
            GregorDays.Add(new ListDataItem {
                Display = "31", Value = 31
            });

            for (var i = 1; i <= 12; i++)
            {
                string monthNo = " (" + i + ")"; //"";
                GregorMonths.Add(new ListDataItem {
                    Display = ReportUtility.GetEngMonth(i - 1) + monthNo, Value = i
                });
                EthioMonths.Add(new ListDataItem {
                    Display = ReportUtility.GetAmhMonth(i - 1) + monthNo, Value = i
                });
            }
            EthioMonths.Add(new ListDataItem {
                Display = ReportUtility.GetAmhMonth(12) + " (13)", Value = 13
            });

            for (var i = 1900; i <= 2020; i++)
            {
                GregorYears.Add(new ListDataItem {
                    Display = i.ToString(), Value = i
                });
            }
            for (var i = 1900; i <= 2020; i++)
            {
                EthioYears.Add(new ListDataItem {
                    Display = i.ToString(), Value = i
                });
            }


            //try
            //{
            //    SelectedGregorDay = GregorDays[DateTime.Now.Day - 1];
            //    SelectedGregorMonth = GregorMonths[DateTime.Now.Month - 1];
            //    SelectedGregorYear = GregorYears[DateTime.Now.Year - 1900];

            //    SetEthioValues();
            //}
            //catch
            //{
            //}

            #endregion

            Messenger.Default.Register <DateTime>(this, (message) =>
            {
                SelectedDateParam = message;
            });
            //SetGregor();
        }
示例#2
0
        public CalendarConvertorViewModel()
        {
            DurationHeader = "Calendar Convertor";

            #region Initialize
            _gregorDays          = new ObservableCollection <ListDataItem>();
            _gregorMonths        = new ObservableCollection <ListDataItem>();
            _gregorYears         = new ObservableCollection <ListDataItem>();
            _selectedGregorDay   = new ListDataItem();
            _selectedGregorMonth = new ListDataItem();
            _selectedGregorYear  = new ListDataItem();
            _ethioDays           = new ObservableCollection <ListDataItem>();
            _ethioMonths         = new ObservableCollection <ListDataItem>();
            _ethioYears          = new ObservableCollection <ListDataItem>();
            _selectedEthioDay    = new ListDataItem();
            _selectedEthioMonth  = new ListDataItem();
            _selectedEthioYear   = new ListDataItem();
            #endregion

            #region Load Properties
            for (var i = 1; i <= 30; i++)
            {
                GregorDays.Add(new ListDataItem {
                    Display = i.ToString(), Value = i
                });
                EthioDays.Add(new ListDataItem {
                    Display = i.ToString(), Value = i
                });
            }
            GregorDays.Add(new ListDataItem {
                Display = "31", Value = 31
            });

            for (var i = 1; i <= 12; i++)
            {
                var monthNo = " (" + i + ")";
                GregorMonths.Add(new ListDataItem {
                    Display = ReportUtility.getEngMonth(i - 1) + monthNo, Value = i
                });
                EthioMonths.Add(new ListDataItem {
                    Display = ReportUtility.getAmhMonth(i - 1) + monthNo, Value = i
                });
            }
            EthioMonths.Add(new ListDataItem {
                Display = ReportUtility.getAmhMonth(12), Value = 13
            });

            for (var i = 2010; i <= 2020; i++)
            {
                GregorYears.Add(new ListDataItem {
                    Display = i.ToString(), Value = i
                });
            }
            for (var i = 2000; i <= 2010; i++)
            {
                EthioYears.Add(new ListDataItem {
                    Display = i.ToString(), Value = i
                });
            }
            try
            {
                SelectedGregorDay   = GregorDays[DateTime.Now.Day - 1];
                SelectedGregorMonth = GregorMonths[DateTime.Now.Month - 1];
                SelectedGregorYear  = GregorYears[DateTime.Now.Year - 2010];

                SetEthioValues();

                //var ethioDay = ReportUtility.getEthCalendar(DateTime.Now, false);
                //SelectedEthioDay = EthioDays.FirstOrDefault();
                //SelectedEthioMonth = EthioMonths.FirstOrDefault();
                //SelectedEthioYear = EthioYears[Convert.ToInt32(ethioDay.Substring(4, 4)) - 2000];
            }
            catch { }

            #endregion
        }