示例#1
0
		private void monthCalendarClone_DayQueryInfo(object sender, DayQueryInfoEventArgs e)
		{
			if (_sourceNote.StartDay <= e.Date && _sourceNote.FinishDay >= e.Date)
			{
				e.Info.BackColor1 = Color.Green;
				e.Info.TextColor = Color.Black;
				e.Info.DateColor = Color.Black;
				e.OwnerDraw = true;
			}
			if (_selectedRanges.Count(x => x.StartDate <= e.Date && x.FinishDate >= e.Date) > 0)
			{
				e.Info.BackColor1 = Color.Blue;
				e.Info.TextColor = Color.White;
				e.Info.DateColor = Color.White;
				e.OwnerDraw = true;
			}
			else if (_selectedDate.HasValue && e.Date.Equals(_selectedDate.Value))
			{
				e.Info.BackColor1 = Color.Orange;
				e.Info.TextColor = Color.White;
				e.Info.DateColor = Color.White;
				e.OwnerDraw = true;
			}
			else if (!(e.Date >= _flightDateStart && e.Date <= _flightDateEnd))
			{
				e.Info.TextColor = Color.Gray;
				e.Info.DateColor = Color.Gray;
				e.OwnerDraw = true;
				e.OwnerDraw = true;
			}
		}
示例#2
0
		internal void Draw(Graphics e)
		{
			
			int today = -1;
			string[] selectedDays;

            Brush bgBrush = new SolidBrush(Colors.BackColor1);    
			Brush selBrush = new SolidBrush(Color.FromArgb(125,Colors.Selected.BackColor));   
			Brush focusBrush = new SolidBrush(Color.FromArgb(125,Colors.Focus.BackColor));
			Pen todayPen = new Pen(Color.FromArgb(150,Calendar.TodayColor),2);
			
			try
			{
                if (BackgroundImage != null)
                    e.DrawImage(BackgroundImage, Rect);
                else
                {
                    if (Colors.GradientMode != mcGradientMode.None)
                        m_calendar.DrawGradient(e, m_rect, Colors.BackColor1, Colors.BackColor2, Colors.GradientMode);
                    else
                        e.FillRectangle(bgBrush, m_rect);
                }
				// Draw days
				
                for (int i = 0;i<42;i++)
				{
					
                    // only draw days that are visible...
                    if ((m_days[i].Rectangle.Height > 0) && (m_days[i].Rectangle.Width > 0))
                    {
                        // Create new graphics object
                        Graphics d = m_calendar.CreateGraphics();
                        // Create bitmap..
                    
                        Bitmap bmp = new Bitmap(m_days[i].Rectangle.Width, m_days[i].Rectangle.Height, d);
                        // link graphics object to bitmap
                        d = Graphics.FromImage(bmp);
                        DayRenderEventArgs args = new DayRenderEventArgs(d, m_days[i].Rectangle, m_days[i].Date, m_days[i].State);
                        DayRender(this, args);
                        if (!args.OwnerDraw)
                        {
                            // day is not user drawn
                            m_days[i].UserDrawn = false;
                            DateItem dayInfo = new DateItem();
                            dayInfo.Calendar = m_calendar;
                            DayQueryInfoEventArgs info = new DayQueryInfoEventArgs(dayInfo, m_days[i].Date, m_days[i].State);
                            DayQueryInfo(this, info);
                            if (!info.OwnerDraw)
                                dayInfo = null;
                            m_days[i].Draw(e, dayInfo);
                            if (dayInfo != null)
                                dayInfo.Dispose();
                        }
                        else
                        {
                            // Draw user rendered day
                            m_days[i].UserDrawn = true;
                            e.DrawImage(bmp, m_days[i].Rectangle);
                        }

                        // Check if day has focus and if focus should be drawn
                        if ((m_days[i].State == mcDayState.Focus) && (m_calendar.ShowFocus))
                        {
                            e.FillRectangle(focusBrush, m_days[i].Rectangle);
                            ControlPaint.DrawBorder(e, m_days[i].Rectangle, Colors.Focus.Border, BorderStyles.Focus);
                        }

                        if ((m_days[i].Date == DateTime.Today) && (!args.OwnerDraw))
                            today = i;

                        d.Dispose();
                        bmp.Dispose();
                    }
				}
			
				// check if date is "today" and if it should be marked..
				if ( (m_calendar.ShowToday) && (today !=-1) && 
					((m_calendar.ShowTrailingDates) || (m_days[today].Date.Month == m_calendar.ActiveMonth.Month)) )  
				{

                    RectangleF dateRect = m_days[today].DateRegion[0].GetBounds(e);

                    dateRect.Inflate(5, 5);
                    e.DrawEllipse(todayPen, dateRect); 
	  
                    
                }

				// Check if a selection exist
			
				selectedDays = DaysInSelection(NO_AREA);
				if (selectedDays.Length>0)
				{
					// Check how many selection areas there are
					if (m_selArea.Count<=1) 
					{
						for (int i = 0;i<m_selArea.Count;i++)
						{
							SelectionArea area = (SelectionArea)m_selArea[i];
							if ((area.Begin!=-1) && (area.End !=-1))
							{
								// Get Coordinates for selection rectangle
						
								m_selRight = System.Math.Max(m_days[area.End].Rectangle.Right,m_days[area.Begin].Rectangle.Right); 
								m_selLeft = System.Math.Min(m_days[area.End].Rectangle.Left,m_days[area.Begin].Rectangle.Left);
								m_selTop = System.Math.Min(m_days[area.End].Rectangle.Top,m_days[area.Begin].Rectangle.Top); 
								m_selBottom = System.Math.Max(m_days[area.End].Rectangle.Bottom,m_days[area.Begin].Rectangle.Bottom); 	
				
								// Draw selection
								Rectangle selRect = new Rectangle(m_selLeft,m_selTop,m_selRight-m_selLeft,m_selBottom-m_selTop);
								e.FillRectangle(selBrush,selRect); 
								ControlPaint.DrawBorder(e,selRect,Colors.Selected.Border,BorderStyles.Selected);  	
							}
						
						}
					}
						// Multiple selection areas, we dont use border so we 
						// draw each day individually to not overlap regions
					else
					{
						for (int i =0;i<42;i++)
						{
							if ((m_days[i].State==mcDayState.Selected) && (m_days[i].SelectionArea!=-1))
							{
								e.FillRectangle(selBrush,m_days[i].Rectangle);
							}
						}
					}
			
				}
			}
			catch (Exception)
			{

			}
		
			bgBrush.Dispose();
			selBrush.Dispose();
			todayPen.Dispose();
			focusBrush.Dispose();
		}
		private void monthCalendarClone_DayQueryInfo(object sender, DayQueryInfoEventArgs e)
		{
			if (_selectedDates.Select(x => x.Date).Contains(e.Date))
			{
				e.Info.BackColor1 = Color.Blue;
				e.Info.TextColor = Color.White;
				e.Info.DateColor = Color.White;
				e.OwnerDraw = true;
			}
			else if (e.Date == _originalInsert.Date)
			{
				e.Info.BackColor1 = Color.Green;
				e.Info.TextColor = Color.White;
				e.Info.DateColor = Color.White;
				e.OwnerDraw = true;
			}
			else if (_originalInsert.Date.HasValue && e.Date.DayOfWeek == _originalInsert.Date.Value.DayOfWeek && checkEditHighlightWeekdays.Checked && (e.Date >= _originalInsert.Parent.Parent.FlightDateStart && e.Date <= _originalInsert.Parent.Parent.FlightDateEnd))
			{
				e.Info.BoldedDate = true;
				e.OwnerDraw = true;
			}
			else if (!_originalInsert.Parent.AvailableDays.Contains(e.Date) || !(e.Date >= _originalInsert.Parent.Parent.FlightDateStart && e.Date <= _originalInsert.Parent.Parent.FlightDateEnd))
			{
				e.Info.TextColor = Color.Gray;
				e.Info.DateColor = Color.Gray;
				e.OwnerDraw = true;
				e.OwnerDraw = true;
			}
		}
示例#4
0
 private void m_month_DayQueryInfo(object sender, DayQueryInfoEventArgs e)
 {
     if (this.DayQueryInfo != null)
         this.DayQueryInfo(this, e);
 }
示例#5
0
 /// <summary>
 /// Handles the DayQueryInfo event of the monthCalendar control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="DayQueryInfoEventArgs"/> instance containing the event data.</param>
 private void MonthCalendar_DayQueryInfo(object sender, DayQueryInfoEventArgs e)
 {
     e.Info.BoldedDate = this.Entries.Values.Any(x => x.LocalTime.Date == e.Date);
     e.OwnerDraw = true;
 }