コード例 #1
0
 /// <summary>
 /// 选中结束日期
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void calendar2_CalendarDateSelect(object sender, CalendarDateSelectEventArge e)
 {
     if (_Mode == DateMode.Month)
     {
         this.DateTo = string.Format("{0}-{1}", e._Year, e._Month.ToString().PadLeft(2, '0'));
     }
     else
     {
         this.DateTo = string.Format("{0}-{1}-{2}", e._Year, e._Month.ToString().PadLeft(2, '0'), e._Day.ToString().PadLeft(2, '0'));
     }
     SetDateDisp();
 }
コード例 #2
0
        /// <summary>
        /// 选中月份
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMonth_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var cell = sender as CalendarCell;

            this.Year       = cell.Year;
            this.Month      = cell.Month;
            this.Year_Month = cell.Year;
            this.Year_Year  = cell.Year;
            foreach (var row in pnlMonth.Children)
            {
                var pnl = row as StackPanel;
                foreach (var cel in pnl.Children)
                {
                    var lbl = cel as Label;
                    lbl.Background = CommonUtil.ToBrush("#FFFFFF");
                    lbl.Foreground = CommonUtil.ToBrush("#3b3b3b");
                }
            }

            var col = sender as Label;

            col.Background = CommonUtil.ToBrush("#FF4169E1");
            col.Foreground = CommonUtil.ToBrush("#FFFFFF");

            var arge = new CalendarDateSelectEventArge(CalendarMonthSelectRoutedEvent, this);

            arge._Year  = cell.Year;
            arge._Month = cell.Month;
            arge._Day   = 0;
            RaiseEvent(arge);

            if (_Mode == DateMode.Month)
            {
                if (this.SelectDateClose)
                {
                    FormCommon.CloseForm(this);
                }
                return;
            }
            this.Mode = 1;
            SetByMode();
        }
コード例 #3
0
        /// <summary>
        /// 选中日期
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDay_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var cell = sender as CalendarCell;

            this.Date.Year  = cell.Year;
            this.Date.Month = cell.Month;
            this.Date.Day   = cell.Day;
            foreach (var row in pnlDate.Children)
            {
                var pnl = row as StackPanel;
                foreach (var cel in pnl.Children)
                {
                    var lbl = cel as CalendarCell;
                    lbl.Background = CommonUtil.ToBrush("#FFFFFF");
                    if (lbl.Year == this.Year && lbl.Month == this.Month)
                    {
                        lbl.Foreground = CommonUtil.ToBrush("#3b3b3b");
                    }
                    else
                    {
                        lbl.Foreground = CommonUtil.ToBrush("#CCC");
                    }
                }
            }

            var col = sender as Label;

            col.Background = CommonUtil.ToBrush("#FF4169E1");
            col.Foreground = CommonUtil.ToBrush("#FFFFFF");

            var arge = new CalendarDateSelectEventArge(CalendarDateSelectRoutedEvent, this);

            arge._Year  = this.Date.Year;
            arge._Month = this.Date.Month;
            arge._Day   = this.Date.Day;
            RaiseEvent(arge);

            if (this.SelectDateClose)
            {
                FormCommon.CloseForm(this);
            }
        }