Files
mirror-processhacker/1.x/trunk/ProcessHacker/Components/MessageLabel.cs
T
dmex 056f4c0914 PH1.x: Code Cleanup/Fixes
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4784 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2011-10-30 02:47:41 +00:00

76 lines
1.7 KiB
C#

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using ProcessHacker.Common;
using ProcessHacker.Native.Api;
namespace ProcessHacker.Components
{
public partial class MessageLabel : UserControl
{
private MessageLabelIcon _icon = MessageLabelIcon.None;
public MessageLabel()
{
InitializeComponent();
}
public bool AutoEllipsis
{
get { return labelText.AutoEllipsis; }
set { labelText.AutoEllipsis = value; }
}
public MessageLabelIcon Icon
{
get { return _icon; }
set
{
_icon = value;
Image oldImage = this.pictureIcon.Image;
pictureIcon.Image = this.GetBitmap(_icon);
if (oldImage != null)
oldImage.Dispose();
}
}
[Browsable(true)]
public override string Text
{
get { return labelText.Text; }
set { labelText.Text = value; }
}
private Bitmap GetBitmap(MessageLabelIcon icon)
{
if (icon == MessageLabelIcon.None)
return null;
IntPtr iconHandle;
Win32.LoadIconMetric(IntPtr.Zero, new IntPtr((int)icon), 0, out iconHandle);
try
{
return Utils.ToBitmap(iconHandle, 16, 16);
}
finally
{
Win32.DestroyIcon(iconHandle);
}
}
}
public enum MessageLabelIcon
{
None = 0,
Information = 32516,
Warning = 32515,
Error = 32513
}
}