コード例 #1
0
        public static DatePickerValue Parse(string s)
        {
            s = s.ToPersianStandardAlphabet();
            DatePickerValue dv = new DatePickerValue();

            if (!string.IsNullOrEmpty(s))
            {
                foreach (DateConcept dc in SMAH1.EnumInfoBase <DateConcept> .GetFields())
                {
                    if (string.Compare(
                            s.RemoveDiacritics().Replace("" + SPACE, "").Replace("" + SEMI_SPACE, ""),
                            SMAH1.EnumInfoBase <DateConcept> .GetFieldDescription(dc, 0).RemoveDiacritics().Replace("" + SPACE, "").Replace("" + SEMI_SPACE, "")
                            ) == 0)
                    {
                        dv = SetConcept(dc);
                        break;
                    }
                }

                if (dv.IsEmpty)
                {
                    SMAH1.Persian.Date dt = new SMAH1.Persian.Date(s);
                    if (dt.DayOfMonth == 0)
                    {
                        throw new Exception("Format Invalid");
                    }
                    dv = DatePickerValue.FromDate(dt);
                }
            }

            return(dv);
        }
コード例 #2
0
ファイル: DatePicker.cs プロジェクト: sasiit23/smah1
 private void TsmPaste_Click(object sender, EventArgs e)
 {
     if (DatePickerValue.TryParse(Clipboard.GetText(), out DatePickerValue dv))
     {
         this.Value = dv;
     }
 }
コード例 #3
0
ファイル: DatePicker.cs プロジェクト: sasiit23/smah1
        void DatePickerPopup_ChangeDate(object sender, EventArgs e)
        {
            if (datePickerPopup.IsEmpty())
            {
                txtShowDate.Text = string.Empty;
                dv = DatePickerValue.Empty;
            }
            else if (datePickerPopup.DateConceptStatus == DateConcept.None)
            {
                txtShowDate.Text = datePickerPopup.Result.ToString();
                dv = DatePickerValue.FromDate(datePickerPopup.Result);
            }
            else
            {
                txtShowDate.Text = SMAH1.EnumInfoBase <DateConcept> .GetFieldDescription(datePickerPopup.DateConceptStatus, 0);

                switch (datePickerPopup.DateConceptStatus)
                {
                case DateConcept.FutureYear:
                    dv = DatePickerValue.FutureYear;
                    break;

                case DateConcept.FutureMonth:
                    dv = DatePickerValue.FutureMonth;
                    break;

                case DateConcept.FutureWeek:
                    dv = DatePickerValue.FutureWeek;
                    break;

                case DateConcept.Tomorrow:
                    dv = DatePickerValue.Tomorrow;
                    break;

                case DateConcept.Today:
                    dv = DatePickerValue.Today;
                    break;

                case DateConcept.Yesterday:
                    dv = DatePickerValue.Yesterday;
                    break;

                case DateConcept.LastWeek:
                    dv = DatePickerValue.LastWeek;
                    break;

                case DateConcept.LastMonth:
                    dv = DatePickerValue.LastMonth;
                    break;

                case DateConcept.LastYear:
                    dv = DatePickerValue.LastYear;
                    break;
                }
            }
            OnSelectDate();
        }
コード例 #4
0
        public static DatePickerValue FromDate(SMAH1.Persian.Date date)
        {
            DatePickerValue dv = new DatePickerValue
            {
                DateSelection = date,
                NotEmpty      = true,
                IsConcept     = false
            };

            return(dv);
        }
コード例 #5
0
ファイル: DatePicker.cs プロジェクト: sasiit23/smah1
 private void Cms_Opening(object sender, CancelEventArgs e)
 {
     tsmEmpty.Enabled = tsmCopy.Enabled = !this.Value.IsEmpty;
     tsmPaste.Enabled = false;
     if (Clipboard.ContainsText())
     {
         if (DatePickerValue.TryParse(Clipboard.GetText(), out DatePickerValue dv))
         {
             tsmPaste.Enabled = true;
         }
     }
 }
コード例 #6
0
        private void DatePickerCompleteChangeDate()
        {
            if (IsEmpty())
            {
                dv = DatePickerValue.Empty;
            }
            else if (DateConceptStatus == DateConcept.None)
            {
                dv = DatePickerValue.FromDate(Result);
            }
            else
            {
                switch (DateConceptStatus)
                {
                case DateConcept.FutureYear:
                    dv = DatePickerValue.FutureYear;
                    break;

                case DateConcept.FutureMonth:
                    dv = DatePickerValue.FutureMonth;
                    break;

                case DateConcept.FutureWeek:
                    dv = DatePickerValue.FutureWeek;
                    break;

                case DateConcept.Tomorrow:
                    dv = DatePickerValue.Tomorrow;
                    break;

                case DateConcept.Today:
                    dv = DatePickerValue.Today;
                    break;

                case DateConcept.Yesterday:
                    dv = DatePickerValue.Yesterday;
                    break;

                case DateConcept.LastWeek:
                    dv = DatePickerValue.LastWeek;
                    break;

                case DateConcept.LastMonth:
                    dv = DatePickerValue.LastMonth;
                    break;

                case DateConcept.LastYear:
                    dv = DatePickerValue.LastYear;
                    break;
                }
            }
        }
コード例 #7
0
        public static bool TryParse(string s, out DatePickerValue dv)
        {
            bool ret = false;

            s  = s.ToPersianStandardAlphabet();
            dv = new DatePickerValue();
            if (string.IsNullOrEmpty(s))
            {
                ret = true;
            }
            else
            {
                foreach (DateConcept dc in SMAH1.EnumInfoBase <DateConcept> .GetFields())
                {
                    if (string.Compare(
                            s.RemoveDiacritics().Replace("" + SPACE, "").Replace("" + SEMI_SPACE, ""),
                            SMAH1.EnumInfoBase <DateConcept> .GetFieldDescription(dc, 0).RemoveDiacritics().Replace("" + SPACE, "").Replace("" + SEMI_SPACE, "")
                            ) == 0)
                    {
                        dv  = SetConcept(dc);
                        ret = true;
                        break;
                    }
                }

                if (dv.IsEmpty)
                {
                    SMAH1.Persian.Date dt = new SMAH1.Persian.Date(s);
                    if (dt.DayOfMonth == 0)
                    {
                        ret = false;
                    }
                    else
                    {
                        ret = true;
                        dv  = DatePickerValue.FromDate(dt);
                    }
                }
            }

            return(ret);
        }
コード例 #8
0
        private static DatePickerValue SetConcept(DateConcept dc)
        {
            DatePickerValue dv = new DatePickerValue();

            if (dc != DateConcept.None)
            {
                dv.NotEmpty      = true;
                dv.IsConcept     = true;
                dv.Concept       = dc;
                dv.DateSelection = SMAH1.Persian.Date.Empty;
            }
            else
            {
                dv.NotEmpty      = false;
                dv.IsConcept     = false;
                dv.Concept       = dc;
                dv.DateSelection = SMAH1.Persian.Date.Empty;
            }

            return(dv);
        }
コード例 #9
0
ファイル: DatePicker.cs プロジェクト: sasiit23/smah1
 private void TxtShowDate_KeyDown(object sender, KeyEventArgs e)
 {
     e.SuppressKeyPress = true;
     if (e.KeyData == (Keys.Control | Keys.V))
     {
         if (Clipboard.ContainsText())
         {
             if (DatePickerValue.TryParse(Clipboard.GetText(), out DatePickerValue dv))
             {
                 this.Value = dv;
             }
         }
     }
     else if (e.KeyData == (Keys.Control | Keys.C) && txtShowDate.SelectionLength > 0)
     {
         Clipboard.SetText(txtShowDate.Text);
     }
     else if (e.KeyCode == Keys.Delete)
     {
         this.Value = new DatePickerValue();
     }
 }
コード例 #10
0
        public bool Equals(DatePickerValue p)
        {
            if (p == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, p))
            {
                return(true);
            }

            if (this.GetType() != p.GetType())
            {
                return(false);
            }

            if (this.IsEmpty == p.IsEmpty && this.IsEmpty)
            {
                return(true);
            }

            if (this.IsConcept == p.IsConcept)
            {
                if (this.IsConcept)
                {
                    if (this.Concept == p.Concept)
                    {
                        return(true);
                    }
                }
                else
                {
                    return(this.DateSelection == p.DateSelection);
                }
            }

            return(false);
        }