namespace System.Windows.Forms
{
-#if NET_2_0
- public
-#endif
- enum TextImageRelation
+ public enum TextImageRelation
{
Overlay = 0,
ImageAboveText = 1,
namespace System.Windows.Forms
{
-#if NET_2_0
- public sealed
-#endif
- class TextRenderer
+ public sealed class TextRenderer
{
private TextRenderer ()
{
}
#region Public Methods
-#if NET_2_0
public static void DrawText (IDeviceContext dc, string text, Font font, Point pt, Color foreColor)
{
DrawTextInternal (dc, text, font, pt, foreColor, Color.Transparent, TextFormatFlags.Default, false);
{
DrawTextInternal (dc, text, font, pt, foreColor, backColor, TextFormatFlags.Default, false);
}
-#endif
-#if NET_2_0
- public
-#else
- internal
-#endif
- static void DrawText (IDeviceContext dc, string text, Font font, Point pt, Color foreColor, TextFormatFlags flags)
+ public static void DrawText (IDeviceContext dc, string text, Font font, Point pt, Color foreColor, TextFormatFlags flags)
{
DrawTextInternal (dc, text, font, pt, foreColor, Color.Transparent, flags, false);
}
-#if NET_2_0
public static void DrawText (IDeviceContext dc, string text, Font font, Rectangle bounds, Color foreColor, Color backColor)
{
DrawTextInternal (dc, text, font, bounds, foreColor, backColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter, false);
}
-#endif
public static void DrawText (IDeviceContext dc, string text, Font font, Rectangle bounds, Color foreColor, TextFormatFlags flags)
{
DrawTextInternal (dc, text, font, bounds, foreColor, Color.Transparent, flags, false);
}
-#if NET_2_0
public static void DrawText (IDeviceContext dc, string text, Font font, Point pt, Color foreColor, Color backColor, TextFormatFlags flags)
{
DrawTextInternal (dc, text, font, pt, foreColor, backColor, flags, false);
{
DrawTextInternal (dc, text, font, bounds, foreColor, backColor, flags, false);
}
-#endif
-#if NET_2_0
- public
-#else
- internal
-#endif
- static Size MeasureText (string text, Font font)
+ public static Size MeasureText (string text, Font font)
{
return MeasureTextInternal (Hwnd.GraphicsContext, text, font, Size.Empty, TextFormatFlags.Default, false);
}
-#if NET_2_0
public static Size MeasureText (IDeviceContext dc, string text, Font font)
{
return MeasureTextInternal (dc, text, font, Size.Empty, TextFormatFlags.Default, false);
{
return MeasureTextInternal (dc, text, font, proposedSize, flags, false);
}
-#endif
#endregion
#region Internal Methods That Do Stuff
-#if NET_2_0
internal static void DrawTextInternal (IDeviceContext dc, string text, Font font, Rectangle bounds, Color foreColor, Color backColor, TextFormatFlags flags, bool useDrawString)
-#else
- internal static void DrawTextInternal (Graphics dc, string text, Font font, Rectangle bounds, Color foreColor, Color backColor, TextFormatFlags flags, bool useDrawString)
-#endif
{
if (dc == null)
throw new ArgumentNullException ("dc");
if (clear_clip_region)
SelectClipRgn (hdc, IntPtr.Zero);
-#if NET_2_0
dc.ReleaseHdc ();
-#else
- dc.ReleaseHdc (hdc);
-#endif
}
// Use Graphics.DrawString as a fallback method
else {
if (!(dc is Graphics)) {
g.Dispose ();
-#if NET_2_0
dc.ReleaseHdc ();
-#else
- if (hdc != IntPtr.Zero) dc.ReleaseHdc (hdc);
-#endif
}
}
}
-#if NET_2_0
internal static Size MeasureTextInternal (IDeviceContext dc, string text, Font font, Size proposedSize, TextFormatFlags flags, bool useMeasureString)
-#else
- internal static Size MeasureTextInternal (Graphics dc, string text, Font font, Size proposedSize, TextFormatFlags flags, bool useMeasureString)
-#endif
{
if (!useMeasureString && !XplatUI.RunningOnUnix) {
// Tell DrawText to calculate size instead of draw
Win32DrawText (hdc, text, text.Length, ref r, (int)flags);
}
-#if NET_2_0
dc.ReleaseHdc ();
-#else
- dc.ReleaseHdc (hdc);
-#endif
// Really, I am just making something up here, which as far as I can tell, MS
// just makes something up as well. This will require lots of tweaking to match MS. :(
#endregion
#region Internal Methods That Are Just Overloads
-#if NET_2_0
internal static void DrawTextInternal (IDeviceContext dc, string text, Font font, Point pt, Color foreColor, bool useDrawString)
{
DrawTextInternal (dc, text, font, pt, foreColor, Color.Transparent, TextFormatFlags.Default, useDrawString);
}
internal static void DrawTextInternal (IDeviceContext dc, string text, Font font, Rectangle bounds, Color foreColor, TextFormatFlags flags, bool useDrawString)
-#else
- internal static void DrawTextInternal (Graphics dc, string text, Font font, Rectangle bounds, Color foreColor, TextFormatFlags flags, bool useDrawString)
-#endif
{
DrawTextInternal (dc, text, font, bounds, foreColor, Color.Transparent, flags, useDrawString);
}
return MeasureTextInternal (dc, text, font, Size.Empty, TextFormatFlags.Default, useMeasureString);
}
-#if NET_2_0
internal static Size MeasureTextInternal (string text, Font font, Size proposedSize, bool useMeasureString)
{
return MeasureTextInternal (Hwnd.GraphicsContext, text, font, proposedSize, TextFormatFlags.Default, useMeasureString);
return MeasureTextInternal (dc, text, font, proposedSize, TextFormatFlags.Default, useMeasureString);
}
-#endif
internal static Size MeasureTextInternal (string text, Font font, Size proposedSize, TextFormatFlags flags, bool useMeasureString)
{
return MeasureTextInternal (Hwnd.GraphicsContext, text, font, proposedSize, flags, useMeasureString);
protected Theme ()
{
-#if NET_2_0
default_font = SystemFonts.DefaultFont;
-#else
- default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
-#endif
syscolors = null;
}
#endregion // OwnerDraw Support
#region Button
-#if NET_2_0
public abstract Size CalculateButtonAutoSize (Button button);
-#endif
public abstract void CalculateButtonTextAndImageLayout (ButtonBase b, out Rectangle textRectangle, out Rectangle imageRectangle);
public abstract void DrawButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
public abstract void DrawFlatButton (Graphics g, ButtonBase b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
#endregion // ButtonBase
#region CheckBox
-#if NET_2_0
public abstract Size CalculateCheckBoxAutoSize (CheckBox checkBox);
public abstract void CalculateCheckBoxTextAndImageLayout (ButtonBase b, Point offset, out Rectangle glyphArea, out Rectangle textRectangle, out Rectangle imageRectangle);
public abstract void DrawCheckBox (Graphics g, CheckBox cb, Rectangle glyphArea, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
-#endif
public abstract void DrawCheckBox (Graphics dc, Rectangle clip_area, CheckBox checkbox);
#endregion // CheckBox
#endregion // Datagrid
-#if NET_2_0
#region DataGridView
#region DataGridViewHeaderCell
#region DataGridViewRowHeaderCell
public abstract bool DataGridViewHeaderCellHasHotStyle (DataGridView dataGridView);
#endregion
#endregion
-#endif
#region DateTimePicker
public abstract void DrawDateTimePicker(Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp);
#region RadioButton
// Drawing
-#if NET_2_0
public abstract Size CalculateRadioButtonAutoSize (RadioButton rb);
public abstract void CalculateRadioButtonTextAndImageLayout (ButtonBase b, Point offset, out Rectangle glyphArea, out Rectangle textRectangle, out Rectangle imageRectangle);
public abstract void DrawRadioButton (Graphics g, RadioButton rb, Rectangle glyphArea, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
-#endif
public abstract void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button);
// Sizing
#endregion // ToolTip
#region BalloonWindow
-#if NET_2_0
public abstract void ShowBalloonWindow (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon);
public abstract void HideBalloonWindow (IntPtr handle);
public abstract void DrawBalloonWindow (Graphics dc, Rectangle clip, NotifyIcon.BalloonWindow control);
public abstract Rectangle BalloonWindowRect (NotifyIcon.BalloonWindow control);
-#endif
#endregion // BalloonWindow
#region TrackBar
public abstract void CPDrawSizeGrip (Graphics graphics, Color backColor, Rectangle bounds);
public abstract void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
StringFormat format);
-#if NET_2_0
public abstract void CPDrawStringDisabled (IDeviceContext dc, string s, Font font, Color color, Rectangle layoutRectangle, TextFormatFlags format);
public abstract void CPDrawVisualStyleBorder (Graphics graphics, Rectangle bounds);
-#endif
public abstract void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style);
#endregion // ControlPaint Methods
}
}
static readonly Color info_border_color = Color.FromArgb (218, 178, 85);
-#if NET_2_0
static readonly Color info_second_color = Color.FromArgb (220, 220, 160);
-#endif
+
public override Image Images(UIIcon index, int size) {
switch (index) {
case UIIcon.PlacesRecentDocuments:
#endregion // ToolTip
#region BalloonWindow
-#if NET_2_0
NotifyIcon.BalloonWindow balloon_window;
public override void ShowBalloonWindow (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon)
return rect;
}
-#endif
#endregion // BalloonWindow
} //class
return PushButtonState.Normal;
}
#endregion
-#if NET_2_0
+
#region Button 2.0
public override void DrawButtonBackground (Graphics g, Button button, Rectangle clipArea)
{
ButtonRenderer.GetPushButtonRenderer (GetPushButtonState (button)).DrawBackground (g, new Rectangle (Point.Empty, button.Size));
}
#endregion
-#endif
+
#region CheckBox
protected override void CheckBox_DrawCheckBox (Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle)
{
{
if (!RenderClientAreas)
return base.ComboBoxDropDownButtonHasHotElementStyle (comboBox);
-#if NET_2_0
switch (comboBox.FlatStyle) {
case FlatStyle.Flat:
case FlatStyle.Popup:
return base.ComboBoxDropDownButtonHasHotElementStyle (comboBox);
}
-#endif
return true;
}
static bool ComboBoxShouldPaintBackground (ComboBox comboBox)
{
if (comboBox.DropDownStyle == ComboBoxStyle.Simple)
return false;
-#if NET_2_0
switch (comboBox.FlatStyle) {
case FlatStyle.Flat:
case FlatStyle.Popup:
return false;
}
-#endif
return true;
}
public override void ComboBoxDrawBackground (ComboBox comboBox, Graphics g, Rectangle clippingArea, FlatStyle style)
}
#endregion
#endregion
-#if NET_2_0
+
#region DataGridView
#region DataGridViewHeaderCell
#region DataGridViewRowHeaderCell
}
#endregion
#endregion
-#endif
+
#region DateTimePicker
#region Border
protected override void DateTimePickerDrawBorder (DateTimePicker dateTimePicker, Graphics g, Rectangle clippingArea)
int draw_mode = 0;
int max_blocks = int.MaxValue;
int start_pixel = client_area.X;
-#if NET_2_0
draw_mode = (int)ctrl.Style;
-#endif
switch (draw_mode) {
-#if NET_2_0
case 1: // Continuous
client_area.Width = (int)(client_area.Width * ((double)(ctrl.Value - ctrl.Minimum) / (double)(Math.Max (ctrl.Maximum - ctrl.Minimum, 1))));
renderer.DrawBackground (dc, client_area, clip_rect);
max_blocks = 5;
start_pixel = client_area.X + (int)(client_area.Width * percent_done);
goto default;
-#endif
default: // Blocks
int block_width = renderer.GetInteger (IntegerProperty.ProgressChunkSize);
block_width = Math.Max (block_width, 0); // block_width is used to break out the loop below, it must be >= 0!
#endregion
#endregion
-#if NET_2_0
static bool AreEqual (VisualStyleElement value1, VisualStyleElement value2)
{
return
value1.Part == value2.Part &&
value1.State == value2.State;
}
-#endif
+
#region Measurement device context
static Control control;
static IDeviceContext GetMeasurementDeviceContext ()
#endregion
#region Button Layout Calculations
-#if NET_2_0
public override Size CalculateButtonAutoSize (Button button)
{
Size ret_size = Size.Empty;
return ret_size;
}
-#endif
public override void CalculateButtonTextAndImageLayout (ButtonBase button, out Rectangle textRectangle, out Rectangle imageRectangle)
{
#endregion // ButtonBase
#region CheckBox
-#if NET_2_0
public override void DrawCheckBox (Graphics g, CheckBox cb, Rectangle glyphArea, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle)
{
// Draw Button Background
return ret_size;
}
-#endif
public override void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox) {
StringFormat text_format;
#endregion // Datagrid
-#if NET_2_0
#region DataGridView
#region DataGridViewHeaderCell
#region DataGridViewRowHeaderCell
}
#endregion
#endregion
-#endif
#region DateTimePicker
protected virtual void DateTimePickerDrawBorder (DateTimePicker dateTimePicker, Graphics g, Rectangle clippingArea)
int first = control.FirstVisibleIndex;
int lastvisibleindex = control.LastVisibleIndex;
-#if NET_2_0
if (control.VirtualMode)
control.OnCacheVirtualItems (new CacheVirtualItemsEventArgs (first, lastvisibleindex));
-#endif
for (int i = first; i <= lastvisibleindex; i++) {
ListViewItem item = control.GetItemAtDisplayIndex (i);
if (clip.IntersectsWith (item.Bounds)) {
-#if NET_2_0
bool owner_draw = false;
if (control.OwnerDraw)
owner_draw = DrawListViewItemOwnerDraw (dc, item, i);
if (!owner_draw)
-#endif
{
DrawListViewItem (dc, control, item);
if (control.View == View.Details)
}
}
-#if NET_2_0
if (control.UsingGroups) {
// Use InternalCount instead of Count to take into account Default Group as needed
for (int i = 0; i < control.Groups.InternalCount; i++) {
dc.FillPolygon (brush, insertion_mark.TopTriangle);
dc.FillPolygon (brush, insertion_mark.BottomTriangle);
}
-#endif
// draw the gridlines
-#if NET_2_0
if (details && control.GridLines && !control.UsingGroups) {
-#else
- if (details && control.GridLines) {
-#endif
Size control_size = control.ClientSize;
int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
0 : control.header_control.Height;
Rectangle rect = col.Rect;
rect.X -= control.h_marker;
-#if NET_2_0
bool owner_draw = false;
if (control.OwnerDraw)
owner_draw = DrawListViewColumnHeaderOwnerDraw (dc, control, col, rect);
if (owner_draw)
continue;
-#endif
ListViewDrawColumnHeaderBackground (control, col, dc, rect, clip);
rect.X += 5;
if (rect.Width <= 0)
continue;
-#if NET_2_0
int image_index;
if (control.SmallImageList == null)
image_index = -1;
rect.X += image_width;
rect.Width -= image_width;
}
-#endif
dc.DrawString (col.Text, control.Font, SystemBrushes.ControlText, rect, col.Format);
}
dc.DrawLine (ResPool.GetSizedPen (ColorHighlight, 2), target_x, 0, target_x, col.Rect.Height);
}
-#if NET_2_0
protected virtual bool DrawListViewColumnHeaderOwnerDraw (Graphics dc, ListView control, ColumnHeader column, Rectangle bounds)
{
ListViewItemStates state = ListViewItemStates.ShowKeyboardCues;
return true;
}
-#endif
protected virtual void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
{
Rectangle full_rect = item.GetBounds (ItemBoundsPortion.Entire);
Rectangle text_rect = item.GetBounds (ItemBoundsPortion.Label);
-#if NET_2_0
// Tile view doesn't support CheckBoxes
if (control.CheckBoxes && control.View != View.Tile) {
-#else
- if (control.CheckBoxes) {
-#endif
if (control.StateImageList == null) {
// Make sure we've got at least a line width of 1
int check_wd = Math.Max (3, rect_checkrect.Width / 6);
else {
int simage_idx;
if (item.Checked)
-#if NET_2_0
simage_idx = control.StateImageList.Images.Count > 1 ? 1 : -1;
-#else
- simage_idx = control.StateImageList.Images.Count > 1 ? 1 : 0;
-#endif
else
simage_idx = control.StateImageList.Images.Count > 0 ? 0 : -1;
}
}
- ImageList image_list = control.View == View.LargeIcon
-#if NET_2_0
- || control.View == View.Tile
-#endif
- ? control.LargeImageList : control.SmallImageList;
+ ImageList image_list = control.View == View.LargeIcon || control.View == View.Tile ? control.LargeImageList : control.SmallImageList;
if (image_list != null) {
int idx;
-#if NET_2_0
if (item.ImageKey != String.Empty)
idx = image_list.Images.IndexOfKey (item.ImageKey);
else
-#endif
idx = item.ImageIndex;
if (idx > -1 && idx < image_list.Images.Count)
else
format.Alignment = StringAlignment.Near;
-#if NET_2_0
if (control.LabelWrap && control.View != View.Details && control.View != View.Tile)
-#else
- if (control.LabelWrap && control.View != View.Details)
-#endif
format.FormatFlags = StringFormatFlags.LineLimit;
else
format.FormatFlags = StringFormatFlags.NoWrap;
- if ((control.View == View.LargeIcon && !item.Focused)
- || control.View == View.Details
-#if NET_2_0
- || control.View == View.Tile
-#endif
- )
+ if ((control.View == View.LargeIcon && !item.Focused) || control.View == View.Details || control.View == View.Tile)
format.Trimming = StringTrimming.EllipsisCharacter;
Rectangle highlight_rect = text_rect;
(item.Selected && control.Focused) ? SystemBrushes.HighlightText :
this.ResPool.GetSolidBrush (item.ForeColor);
-#if NET_2_0
// Tile view renders its Text in a different fashion
if (control.View == View.Tile && Application.VisualStylesEnabled) {
// Item.Text is drawn using its first subitem's bounds
dc.DrawString (sub_item.Text, sub_item.Font, itemBrush, sub_item.Bounds, format);
}
} else
-#endif
if (item.Text != null && item.Text.Length > 0) {
Font font = item.Font;
-#if NET_2_0
+
if (control.HotTracking && item.Hot)
font = item.HotFont;
-#endif
if (item.Selected && control.Focused)
dc.DrawString (item.Text, font, textBrush, highlight_rect, format);
if (item.UseItemStyleForSubItems) {
sub_item_back_br = ResPool.GetSolidBrush (item.BackColor);
sub_item_fore_br = ResPool.GetSolidBrush (item.ForeColor);
-#if NET_2_0
+
// Hot tracking for subitems only applies when UseStyle is true
if (control.HotTracking && item.Hot)
sub_item_font = item.HotFont;
else
-#endif
sub_item_font = item.Font;
} else {
sub_item_back_br = ResPool.GetSolidBrush (subItem.BackColor);
format.Dispose ();
}
-#if NET_2_0
protected virtual bool DrawListViewSubItemOwnerDraw (Graphics dc, ListViewItem item, ListViewItemStates state, int index)
{
ListView control = item.ListView;
pen.Dispose ();
brush.Dispose ();
}
-#endif
public override bool ListViewHasHotHeaderStyle {
get {
public override void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb) {
Rectangle client = pb.ClientRectangle;
-#if NET_2_0
client = new Rectangle (client.Left + pb.Padding.Left, client.Top + pb.Padding.Top, client.Width - pb.Padding.Horizontal, client.Height - pb.Padding.Vertical);
-#endif
// FIXME - instead of drawing the whole picturebox every time
// intersect the clip rectangle with the drawn picture and only draw what's needed,
case PictureBoxSizeMode.CenterImage:
dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
break;
-#if NET_2_0
+
case PictureBoxSizeMode.Zoom:
Size image_size;
dc.DrawImage (pb.Image, (client.Width / 2) - (image_size.Width / 2), (client.Height / 2) - (image_size.Height / 2), image_size.Width, image_size.Height);
break;
-#endif
+
default:
// Normal, AutoSize
dc.DrawImage (pb.Image, client.Left, client.Top, pb.Image.Width, pb.Image.Height);
int draw_mode = 0;
int max_blocks = int.MaxValue;
int start_pixel = client_area.X;
-#if NET_2_0
draw_mode = (int) ctrl.Style;
-#endif
+
switch (draw_mode) {
-#if NET_2_0
case 1: { // Continuous
int pixels_to_draw;
pixels_to_draw = (int)(client_area.Width * ((double)(ctrl.Value - ctrl.Minimum) / (double)(Math.Max(ctrl.Maximum - ctrl.Minimum, 1))));
}
goto case 0;
-#endif
case 0:
default: // Blocks
Rectangle block_rect;
}
}
-#if NET_2_0
public override void DrawRadioButton (Graphics g, RadioButton rb, Rectangle glyphArea, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle)
{
// Draw Button Background
{
CalculateCheckBoxTextAndImageLayout (b, offset, out glyphArea, out textRectangle, out imageRectangle);
}
-#endif
#endregion // RadioButton
#region ScrollBar
format.Alignment = StringAlignment.Center;
else
format.Alignment = StringAlignment.Near;
-#if !NET_2_0
- if (control is PropertyGrid.PropertyToolBar) {
- dc.FillRectangle (ResPool.GetSolidBrush(control.BackColor), clip_rectangle);
-
- if (clip_rectangle.X == 0) {
- dc.DrawLine (SystemPens.ControlLightLight, clip_rectangle.X, 1, clip_rectangle.X, control.Bottom);
- }
-
- if (clip_rectangle.Y < 2) {
- dc.DrawLine (SystemPens.ControlLightLight, clip_rectangle.X, 1, clip_rectangle.Right, 1);
- }
- if (clip_rectangle.Bottom == control.Bottom) {
- dc.DrawLine (SystemPens.ControlDark, clip_rectangle.X, clip_rectangle.Bottom - 1, clip_rectangle.Right, clip_rectangle.Bottom - 1);
- }
-
- if (clip_rectangle.Right == control.Right) {
- dc.DrawLine (SystemPens.ControlDark, clip_rectangle.Right - 1, 1, clip_rectangle.Right - 1, control.Bottom - 1);
- }
- } else {
-#endif
- if (control.Appearance != ToolBarAppearance.Flat || control.Parent == null) {
- dc.FillRectangle (SystemBrushes.Control, clip_rectangle);
- }
+ if (control.Appearance != ToolBarAppearance.Flat || control.Parent == null) {
+ dc.FillRectangle (SystemBrushes.Control, clip_rectangle);
+ }
- if (control.Divider && clip_rectangle.Y < 2) {
- if (clip_rectangle.Y < 1) {
- dc.DrawLine (SystemPens.ControlDark, clip_rectangle.X, 0, clip_rectangle.Right, 0);
- }
- dc.DrawLine (SystemPens.ControlLightLight, clip_rectangle.X, 1, clip_rectangle.Right, 1);
+ if (control.Divider && clip_rectangle.Y < 2) {
+ if (clip_rectangle.Y < 1) {
+ dc.DrawLine (SystemPens.ControlDark, clip_rectangle.X, 0, clip_rectangle.Right, 0);
}
-#if !NET_2_0
+ dc.DrawLine (SystemPens.ControlLightLight, clip_rectangle.X, 1, clip_rectangle.Right, 1);
}
-#endif
foreach (ToolBarItem item in control.items)
if (item.Button.Visible && clip_rectangle.IntersectsWith (item.Rectangle))
ToolTipDrawBackground (dc, clip_rectangle, control);
TextFormatFlags flags = TextFormatFlags.HidePrefix;
-#if NET_2_0
+
Color foreground = control.ForeColor;
if (control.title.Length > 0) {
Font bold_font = new Font (control.Font, control.Font.Style | FontStyle.Bold);
if (control.icon != null)
dc.DrawIcon (control.icon, control.icon_rect);
-#else
- Color foreground = this.ColorInfoText;
-#endif
TextRenderer.DrawTextInternal (dc, control.Text, control.Font, control.text_rect, foreground, flags, false);
}
protected virtual void ToolTipDrawBackground (Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control)
{
-#if NET_2_0
- Brush back_brush = ResPool.GetSolidBrush (control.BackColor);;
-#else
- Brush back_brush = SystemBrushes.Info;
-#endif
+ Brush back_brush = ResPool.GetSolidBrush (control.BackColor);
dc.FillRectangle (back_brush, control.ClientRectangle);
dc.DrawRectangle (SystemPens.WindowFrame, 0, 0, control.Width - 1, control.Height - 1);
}
Rectangle text_rect = new Rectangle (Point.Empty, size);
text_rect.Inflate (-2, -1);
tt.text_rect = text_rect;
-#if NET_2_0
tt.icon_rect = tt.title_rect = Rectangle.Empty;
Size title_size = Size.Empty;
size.Width += padding * 2;
size.Height += padding * 2;
}
-#endif
return size;
}
#endregion // ToolTip
#region BalloonWindow
-#if NET_2_0
NotifyIcon.BalloonWindow balloon_window;
public override void ShowBalloonWindow (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon)
return rect;
}
-#endif
#endregion // BalloonWindow
#region TrackBar
dc.DrawString (s, font, ResPool.GetSolidBrush (cpcolor.Dark), layoutRectangle, format);
}
-#if NET_2_0
public override void CPDrawStringDisabled (IDeviceContext dc, string s, Font font, Color color, Rectangle layoutRectangle, TextFormatFlags format)
{
CPColor cpcolor = ResPool.GetCPColor (color);
{
graphics.DrawRectangle (SystemPens.ControlDarkDark, bounds);
}
-#endif
private static void DrawBorderInternal (Graphics graphics, int startX, int startY, int endX, int endY,
int width, Color color, ButtonBorderStyle style, Border3DSide side)
namespace System.Windows.Forms
{
-#if NET_2_0
[ComVisible (true)]
[ClassInterface (ClassInterfaceType.AutoDispatch)]
-#endif
public class ThreadExceptionDialog: Form
{
Exception e;
g.DrawIcon (SystemIcons.Error, 15, 10);
}
-#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
add { base.AutoSizeChanged += value; }
remove { base.AutoSizeChanged -= value; }
}
-#endif
}
}
internal Thread thread;
internal bool Busy;
internal IntPtr window;
-
-#if NET_2_0
object control_tag;
-#endif
+
internal static readonly int Minimum = 15;
public Timer ()
}
set {
if (value <= 0)
-#if NET_2_0
throw new ArgumentOutOfRangeException ("Interval", string.Format ("'{0}' is not a valid value for Interval. Interval must be greater than 0.", value));
-#else
- throw new ArgumentException (string.Format("'{0}' is not a valid value for Interval. Interval must be greater than 0.", value));
-#endif
if (interval == value) {
return;
}
}
-#if NET_2_0
[Localizable(false)]
[Bindable(true)]
[TypeConverter(typeof(StringConverter))]
control_tag = value;
}
}
-#endif
public void Start ()
{
namespace System.Windows.Forms
{
-#if NET_2_0
[ComVisible (true)]
[ClassInterface (ClassInterfaceType.AutoDispatch)]
-#endif
[DefaultEvent ("ButtonClick")]
[DefaultProperty ("Buttons")]
[Designer ("System.Windows.Forms.Design.ToolBarDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
static object ButtonClickEvent = new object ();
static object ButtonDropDownEvent = new object ();
-#if NET_2_0
[Browsable (true)]
[EditorBrowsable (EditorBrowsableState.Always)]
public new event EventHandler AutoSizeChanged {
add { base.AutoSizeChanged += value; }
remove { base.AutoSizeChanged -= value; }
}
-#endif
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
remove { base.BackgroundImageChanged -= value; }
}
-#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
public new event EventHandler BackgroundImageLayoutChanged {
add { base.BackgroundImageLayoutChanged += value; }
remove { base.BackgroundImageLayoutChanged -= value; }
}
-#endif
public event ToolBarButtonClickEventHandler ButtonClick {
add { Events.AddHandler (ButtonClickEvent, value); }
get { return ThemeEngine.Current.ToolBarDefaultSize; }
}
-#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Never)]
protected override bool DoubleBuffered {
get { return base.DoubleBuffered; }
set { base.DoubleBuffered = value; }
}
-#endif
#endregion
ToolBarAppearance appearance = ToolBarAppearance.Normal;
bool autosize = true;
-#if NET_2_0
[Browsable (true)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Visible)]
[EditorBrowsable (EditorBrowsableState.Always)]
-#endif
[DefaultValue (true)]
[Localizable (true)]
- public
-#if NET_2_0
- override
-#endif
- bool AutoSize {
+ public override bool AutoSize {
get { return autosize; }
set {
if (value == autosize)
set { base.BackgroundImage = value; }
}
-#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
public override ImageLayout BackgroundImageLayout {
get { return base.BackgroundImageLayout; }
set { base.BackgroundImageLayout = value; }
}
-#endif
[DefaultValue (BorderStyle.None)]
[DispIdAttribute (-504)]
base.Dispose (disposing);
}
-#if NET_2_0
private ToolBarButton button_for_focus = null;
internal void UIAPerformClick (ToolBarButton button)
current_item = previous_item;
}
}
-#endif
void PerformButtonClick (ToolBarButtonClickEventArgs e)
{
current_item.Pressed = false;
current_item.Invalidate ();
-#if NET_2_0
button_for_focus = current_item.Button;
button_for_focus.UIAHasFocus = true;
-#endif
+
OnButtonClick (e);
}
LayoutToolBar ();
}
-#if NET_2_0
protected override void ScaleControl (SizeF factor, BoundsSpecified specified)
{
specified &= ~BoundsSpecified.Height;
base.ScaleCore (dx, dy);
}
-#endif
private int requested_size = -1;
private void FocusChanged (object sender, EventArgs args)
{
-#if NET_2_0
if (!Focused && button_for_focus != null)
button_for_focus.UIAHasFocus = false;
button_for_focus = null;
-#endif
if (Appearance != ToolBarAppearance.Flat || Buttons.Count == 0)
return;
#endregion
#region UIA Framework Events
-#if NET_2_0
static object UIACollectionChangedEvent = new object ();
internal event CollectionChangeEventHandler UIACollectionChanged {
if (eh != null)
eh (owner, e);
}
-#endif
#endregion
#region constructors
public virtual ToolBarButton this [int index] {
get { return (ToolBarButton) list [index]; }
set {
-#if NET_2_0
// UIA Framework Event: Button Removed
OnUIACollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, index));
-#endif
value.SetParent (owner);
list [index] = value;
owner.Redraw (true);
-#if NET_2_0
-
// UIA Framework Event: Button Added
OnUIACollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, index));
-#endif
}
}
-#if NET_2_0
public virtual ToolBarButton this[string key] {
get {
if (string.IsNullOrEmpty (key))
return null;
}
}
-#endif
bool ICollection.IsSynchronized {
get { return list.IsSynchronized; }
if (redraw)
owner.Redraw (true);
-#if NET_2_0
// UIA Framework Event: Button Added
OnUIACollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, result));
-#endif
return result;
}
list.Clear ();
owner.Redraw (false);
-#if NET_2_0
// UIA Framework Event: Button Cleared
OnUIACollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh, -1));
-#endif
}
public bool Contains (ToolBarButton button)
return list.Contains (button);
}
-#if NET_2_0
public virtual bool ContainsKey (string key)
{
return !(this[key] == null);
}
-#endif
public IEnumerator GetEnumerator ()
{
return list.IndexOf (button);
}
-#if NET_2_0
public virtual int IndexOfKey (string key)
{
return IndexOf (this[key]);
}
-#endif
public void Insert (int index, ToolBarButton button)
{
list.Insert (index, button);
owner.Redraw (true);
-#if NET_2_0
// UIA Framework Event: Button Added
OnUIACollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, index));
-#endif
}
public void Remove (ToolBarButton button)
list.RemoveAt (index);
owner.Redraw (true);
-#if NET_2_0
// UIA Framework Event: Button Removed
OnUIACollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, index));
-#endif
}
-#if NET_2_0
public virtual void RemoveByKey (string key)
{
Remove (this[key]);
}
-#endif
#endregion methods
}
namespace System.Windows.Forms
{
-#if !NET_2_0
- [Serializable]
-#endif
public enum ToolBarAppearance
{
Normal = 0,
private string text = "";
private string tooltip = "";
private bool visible = true;
-#if NET_2_0
private string image_key = string.Empty;
private string name;
-#endif
#endregion
#region constructors
if (ImageIndex > -1 && ImageIndex < list.Images.Count)
return list.Images [ImageIndex];
-#if NET_2_0
if (!string.IsNullOrEmpty (image_key))
return list.Images [image_key];
-#endif
return null;
}
menu = (ContextMenu) value;
else
throw new ArgumentException ("DropDownMenu must be of type ContextMenu.");
-#if NET_2_0
+
OnUIADropDownMenuChanged (EventArgs.Empty);
-#endif
}
}
enabled = value;
Invalidate ();
-#if NET_2_0
OnUIAEnabledChanged (EventArgs.Empty);
-#endif
}
}
-#if NET_2_0
[RefreshProperties (RefreshProperties.Repaint)]
-#endif
[DefaultValue (-1)]
[Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
[Localizable (true)]
bool layout = (Parent != null) && ((value == -1) || (image_index == -1));
image_index = value;
-#if NET_2_0
image_key = string.Empty;
-#endif
if (layout)
Parent.Redraw (true);
}
}
-#if NET_2_0
[Localizable (true)]
[DefaultValue ("")]
[Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
name = value;
}
}
-#endif
[Browsable (false)]
public ToolBar Parent {
if (parent != null)
parent.Redraw (true);
-#if NET_2_0
OnUIAStyleChanged (EventArgs.Empty);
-#endif
}
}
text = value;
-#if NET_2_0
OnUIATextChanged (EventArgs.Empty);
-#endif
if (Parent != null)
Parent.Redraw (true);
Parent.Invalidate (Rectangle);
}
-#if NET_2_0
bool uiaHasFocus = false;
internal bool UIAHasFocus {
get { return uiaHasFocus; }
if (eh != null)
eh (this, e);
}
-#endif
#endregion Internal Methods
// COMPLETE
namespace System.Windows.Forms {
-#if !NET_2_0
- [Serializable]
-#endif
public delegate void ToolBarButtonClickEventHandler (object sender, ToolBarButtonClickEventArgs e);
}
namespace System.Windows.Forms
{
-#if !NET_2_0
- [Serializable]
-#endif
public enum ToolBarButtonStyle
{
PushButton = 1,
namespace System.Windows.Forms
{
-#if !NET_2_0
- [Serializable]
-#endif
public enum ToolBarTextAlign
{
Underneath = 0,
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
#endregion
}
}
-#endif
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System.Drawing;
namespace System.Windows.Forms
#endregion // Public Instance Properties
}
}
-#endif
\ No newline at end of file
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
namespace System.Windows.Forms
{
public delegate void ToolStripArrowRenderEventHandler (object sender, ToolStripArrowRenderEventArgs e);
}
-#endif
\ No newline at end of file
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System;
using System.Drawing;
using System.ComponentModel;
#endregion
}
}
-#endif
// Authors:
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
+
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms.Design;
}
}
}
-#endif
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System;
using System.Drawing;
using System.ComponentModel;
#endregion
}
}
-#endif
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms.Layout;
#endregion
}
}
-#endif
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System.Drawing;
namespace System.Windows.Forms
#endregion
}
}
-#endif
\ No newline at end of file
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
namespace System.Windows.Forms
{
public delegate void ToolStripContentPanelRenderEventHandler (object sender, ToolStripContentPanelRenderEventArgs e);
}
-#endif
\ No newline at end of file
// Authors:
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
+
using System.Drawing;
using System.ComponentModel;
#endregion
}
}
-#endif
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System.Drawing;
using System.Runtime.InteropServices;
using System.ComponentModel;
#endregion
}
}
-#endif
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms.Design;
#endregion
}
}
-#endif
//
-#if NET_2_0
namespace System.Windows.Forms
{
public enum ToolStripDropDownCloseReason
CloseCalled = 4
}
}
-#endif
\ No newline at end of file
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
namespace System.Windows.Forms
{
public class ToolStripDropDownClosedEventArgs : EventArgs
#endregion // Public Instance Properties
}
}
-#endif
\ No newline at end of file
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
namespace System.Windows.Forms
{
public delegate void ToolStripDropDownClosedEventHandler (object sender, ToolStripDropDownClosedEventArgs e);
}
-#endif
\ No newline at end of file
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System.ComponentModel;
namespace System.Windows.Forms
#endregion // Public Instance Properties
}
}
-#endif
\ No newline at end of file