1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Text;
|
---|
4 | using System.Windows.Forms;
|
---|
5 | using System.Drawing;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Calendar
|
---|
8 | {
|
---|
9 | public class Office11Renderer : AbstractRenderer
|
---|
10 | {
|
---|
11 | protected override void Dispose(bool mainThread)
|
---|
12 | {
|
---|
13 | base.Dispose(mainThread);
|
---|
14 |
|
---|
15 | if (minuteFont != null)
|
---|
16 | minuteFont.Dispose();
|
---|
17 | }
|
---|
18 |
|
---|
19 | private Font minuteFont;
|
---|
20 |
|
---|
21 | public override Font MinuteFont
|
---|
22 | {
|
---|
23 | get
|
---|
24 | {
|
---|
25 | if (minuteFont == null)
|
---|
26 | minuteFont = new Font(BaseFont, FontStyle.Italic);
|
---|
27 |
|
---|
28 | return minuteFont;
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | public override void DrawHourLabel(System.Drawing.Graphics g, System.Drawing.Rectangle rect, int hour, bool ampm)
|
---|
33 | {
|
---|
34 | DrawHourLabel(g, rect, hour, ampm, false);
|
---|
35 | }
|
---|
36 |
|
---|
37 | public override void DrawHourLabel(Graphics g, Rectangle rect, int hour, bool ampm, bool timeindicator)
|
---|
38 | {
|
---|
39 | if (g == null)
|
---|
40 | throw new ArgumentNullException("g");
|
---|
41 |
|
---|
42 | Color m_Color = ControlPaint.LightLight(SystemColors.WindowFrame);
|
---|
43 | m_Color = ControlPaint.Light(m_Color);
|
---|
44 |
|
---|
45 | using (Pen m_Pen = new Pen(m_Color))
|
---|
46 | g.DrawLine(m_Pen, rect.Left, rect.Y, rect.Width, rect.Y);
|
---|
47 |
|
---|
48 | g.DrawString(hour.ToString("##00", System.Globalization.CultureInfo.InvariantCulture), HourFont, SystemBrushes.ControlText, rect);
|
---|
49 |
|
---|
50 | rect.X += 27;
|
---|
51 |
|
---|
52 | g.DrawString("00", MinuteFont, SystemBrushes.ControlText, rect);
|
---|
53 | }
|
---|
54 |
|
---|
55 | public override void DrawDayHeader(Graphics g, Rectangle rect, DateTime date)
|
---|
56 | {
|
---|
57 | if (g == null)
|
---|
58 | throw new ArgumentNullException("g");
|
---|
59 |
|
---|
60 | using (StringFormat format = new StringFormat())
|
---|
61 | {
|
---|
62 | format.Alignment = StringAlignment.Center;
|
---|
63 | format.FormatFlags = StringFormatFlags.NoWrap;
|
---|
64 | format.LineAlignment = StringAlignment.Center;
|
---|
65 |
|
---|
66 | ControlPaint.DrawButton(g, rect, ButtonState.Inactive);
|
---|
67 | ControlPaint.DrawBorder3D(g, rect, Border3DStyle.Etched);
|
---|
68 |
|
---|
69 | g.DrawString(
|
---|
70 | System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek),
|
---|
71 | BaseFont,
|
---|
72 | SystemBrushes.WindowText,
|
---|
73 | rect,
|
---|
74 | format
|
---|
75 | );
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | public override void DrawDayBackground(Graphics g, Rectangle rect)
|
---|
80 | {
|
---|
81 | if (g == null)
|
---|
82 | throw new ArgumentNullException("g");
|
---|
83 |
|
---|
84 | using (Brush m_Brush = new SolidBrush(this.HourColor))
|
---|
85 | g.FillRectangle(m_Brush, rect);
|
---|
86 | }
|
---|
87 |
|
---|
88 | public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect)
|
---|
89 | {
|
---|
90 | DrawAppointment(g, rect, appointment, isSelected, gripRect, true, false);
|
---|
91 | }
|
---|
92 |
|
---|
93 | public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect, bool enableShadows, bool useroundedCorners)
|
---|
94 | {
|
---|
95 | if (appointment == null)
|
---|
96 | throw new ArgumentNullException("appointment");
|
---|
97 |
|
---|
98 | if (g == null)
|
---|
99 | throw new ArgumentNullException("g");
|
---|
100 |
|
---|
101 | if (rect.Width != 0 && rect.Height != 0)
|
---|
102 | using (StringFormat format = new StringFormat())
|
---|
103 | {
|
---|
104 | format.Alignment = StringAlignment.Near;
|
---|
105 | format.LineAlignment = StringAlignment.Near;
|
---|
106 |
|
---|
107 | if ((appointment.Locked) && isSelected)
|
---|
108 | {
|
---|
109 | // Draw back
|
---|
110 | using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
|
---|
111 | g.FillRectangle(m_Brush, rect);
|
---|
112 | }
|
---|
113 | else
|
---|
114 | {
|
---|
115 | // Draw back
|
---|
116 | using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
|
---|
117 | g.FillRectangle(m_Brush, rect);
|
---|
118 | }
|
---|
119 |
|
---|
120 | if (isSelected)
|
---|
121 | {
|
---|
122 | using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
|
---|
123 | g.DrawRectangle(m_Pen, rect);
|
---|
124 |
|
---|
125 | Rectangle m_BorderRectangle = rect;
|
---|
126 |
|
---|
127 | m_BorderRectangle.Inflate(2, 2);
|
---|
128 |
|
---|
129 | using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
|
---|
130 | g.DrawRectangle(m_Pen, m_BorderRectangle);
|
---|
131 |
|
---|
132 | m_BorderRectangle.Inflate(-4, -4);
|
---|
133 |
|
---|
134 | using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
|
---|
135 | g.DrawRectangle(m_Pen, m_BorderRectangle);
|
---|
136 | }
|
---|
137 | else
|
---|
138 | {
|
---|
139 | // Draw gripper
|
---|
140 | gripRect.Width += 1;
|
---|
141 |
|
---|
142 | using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
|
---|
143 | g.FillRectangle(m_Brush, gripRect);
|
---|
144 |
|
---|
145 | using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
|
---|
146 | g.DrawRectangle(m_Pen, rect);
|
---|
147 | }
|
---|
148 |
|
---|
149 | rect.X += gripRect.Width;
|
---|
150 | g.DrawString(appointment.Subject, this.BaseFont, SystemBrushes.WindowText, rect, format);
|
---|
151 | }
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | }
|
---|