⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datetimeselectcontrol.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
            this.label3.TabIndex = 0x1f;
            this.label3.Text = "日";
            base.set_AutoScaleDimensions(new SizeF(6f, 12f));
            base.set_AutoScaleMode(1);
            this.set_AutoSize(true);
            base.set_AutoSizeMode(0);
            this.BackColor = Color.Transparent;
            base.Controls.Add(this.label3);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.cboDay);
            base.Controls.Add(this.txtYear);
            base.Controls.Add(this.cboMonth);
            base.Name = "DateTimeSelectControl";
            base.Size = new Size(0xec, 0x18);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void InnerSetDateTime(DateTime? value, bool updateChilds)
        {
            this.InnerSetDateTime(value, updateChilds, false);
        }

        private void InnerSetDateTime(DateTime? value, bool updateChilds, bool forceFireEvent)
        {
            DateTime? nullable = this._datetime;
            DateTime? nullable2 = value;
            if (((nullable.get_HasValue() != nullable2.get_HasValue()) || (nullable.get_HasValue() && (nullable.GetValueOrDefault() != nullable2.GetValueOrDefault()))) || forceFireEvent)
            {
                this._datetime = value;
                if (updateChilds)
                {
                    if (value.get_HasValue())
                    {
                        DateTime time = value.get_Value();
                        this.txtYear.Text = time.Year.ToString();
                        this.SelectedMonth = time.Month;
                        this.SelectedDay = time.Day;
                    }
                    else
                    {
                        this.txtYear.Text = string.Empty;
                        this.SelectedMonth = 1;
                        this.SelectedDay = 1;
                    }
                }
                this.OnDateTimeChange();
            }
        }

        private void OnDateTimeChange()
        {
            EventHandler selectedDateTimeChange = this.SelectedDateTimeChange;
            if (selectedDateTimeChange != null)
            {
                selectedDateTimeChange(this, EventArgs.Empty);
            }
        }

        protected override void OnGotFocus(EventArgs e)
        {
            base.OnGotFocus(e);
            if (this.txtYear != null)
            {
                this.txtYear.SelectAll();
                this.txtYear.Focus();
            }
        }

        private void OnYearTextChange()
        {
            EventHandler yearTextChange = this.YearTextChange;
            if (yearTextChange != null)
            {
                yearTextChange(this, EventArgs.Empty);
            }
        }

        private bool TryGetSelectedYear(out int year)
        {
            year = 0;
            string text = this.txtYear.Text;
            if (text.Length <= 0)
            {
                year = this.NullYear;
                return true;
            }
            if (text.Length == 4)
            {
                bool flag = int.TryParse(text, ref year);
                if (!flag || ((year >= this.MinDateTime.Year) && (year <= this.MaxDateTime.Year)))
                {
                    return flag;
                }
            }
            return false;
        }

        private void txtYear_TextChanged(object sender, EventArgs e)
        {
            int year;
            if (this.TryGetSelectedYear(out year))
            {
                this.FillDaysOnYearMonthChanged();
            }
            this.InnerSetDateTime(this.GetSelectedDateTime(), false);
            this.OnYearTextChange();
        }

        public Imps.Common.Horoscope Horoscope
        {
            get
            {
                string sHoroscope;
                if (this.SelectedDay == 0)
                {
                    return Imps.Common.Horoscope.Unknown;
                }
                if (!this.SelectedDateTime.get_HasValue() || !this.SelectedDateTime.get_HasValue())
                {
                    return Imps.Common.Horoscope.Unknown;
                }
                ChineseCalendar calendar = new ChineseCalendar(this.SelectedDateTime.get_Value());
                return (Imps.Common.Horoscope) calendar.FormatHoroscope(out sHoroscope);
            }
        }

        public string LunalAnimal
        {
            get
            {
                if (((this.SelectedDay != 0) && this.SelectedDateTime.get_HasValue()) && (this.SelectedDateTime.get_HasValue() && (this.SelectedDateTime.get_Value().Year != this.NullYear)))
                {
                    ChineseCalendar calendar = new ChineseCalendar(this.SelectedDateTime.get_Value());
                    DateTime? selectedDateTime = this.SelectedDateTime;
                    DateTime minSupportedDateTime = calendar.MinSupportedDateTime;
                    if (!(selectedDateTime.get_HasValue() ? (selectedDateTime.GetValueOrDefault() < minSupportedDateTime) : false))
                    {
                        DateTime? nullable6 = this.SelectedDateTime;
                        DateTime maxSupportedDateTime = calendar.MaxSupportedDateTime;
                        if (!(nullable6.get_HasValue() ? (nullable6.GetValueOrDefault() > maxSupportedDateTime) : false))
                        {
                            return calendar.LunarAnimal;
                        }
                    }
                }
                return IMPSEnums.GetEnumDescription<LunarAnimal>(LunarAnimal.Unknown);
            }
        }

        public DateTime MaxDateTime
        {
            get
            {
                return this._maxDate;
            }
            set
            {
                this._maxDate = value;
            }
        }

        public DateTime MinDateTime
        {
            get
            {
                return this._minDate;
            }
            set
            {
                this._minDate = value;
            }
        }

        public int NullYear
        {
            get
            {
                return this._nullYear;
            }
            set
            {
                this._nullYear = value;
            }
        }

        public DateTime? SelectedDateTime
        {
            get
            {
                return this._datetime;
            }
            set
            {
                this.InnerSetDateTime(value, true);
            }
        }

        public int SelectedDay
        {
            get
            {
                return this.cboDay.SelectedIndex;
            }
            set
            {
                this.cboDay.SelectedIndex = value;
            }
        }

        public int SelectedMonth
        {
            get
            {
                return this.cboMonth.SelectedIndex;
            }
            set
            {
                this.cboMonth.SelectedIndex = value;
            }
        }

        public string SelectedYearText
        {
            get
            {
                return this.txtYear.Text;
            }
            set
            {
                this.txtYear.Text = value;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -