给个mail地址我,给你那儿发个demo.
解决方案 »
- assembly.loadFrom() 能否随便加载一个DLL?
- 求助一个蜂鸣器蜂鸣的问题
- AI算法求教
- “/”应用程序中的服务器错误。找不到指定的模块。 (异常来自 HRESULT:0x8007007E)
- WINFORM调用JAVA写的web service需要注意些什么问题?
- C#连接数据库问题
- 50分求一个richtextbox问题解答,得到解决马上加分.
- 执行一个存储过程。没有参数。想把SELECT查询的记录集放在DATASET里。。怎么做啊。。谢
- 有人做过移动网关CMPP 2.0 开发吗/
- 高分求助啊 C# WebBrowser组件 本窗口打开
- 那里有C#数据库和.net类库方面的书!!!!
- 那儿不对????
[email protected]
Thanks lots!!!
[email protected]
[email protected]
Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!
email: [email protected]
[email protected]
谢谢!
[email protected] you!!
[email protected]
// Copyright (c) 2001 Mike Krueger
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAusing System;
using System.Drawing;
using System.Diagnostics;
using System.Drawing.Text;
using System.Drawing.Imaging;
using System.Windows.Forms;//using SharpDevelop.Gui.Window;
//using Core.Properties;
//using SharpDevelop.Internal.ExternalTool;
//using Internal.Text;
public enum IconMenuStyle {
Standard,
Office2000,
VSNet
};
public interface MenuItemStyleDrawer
{
void DrawCheck(Graphics g, Rectangle bounds, bool selected);
void DrawIcon(Graphics g, Image icon, Rectangle bounds, bool selected, bool enabled, bool ischecked);
void DrawSeparator(Graphics g, Rectangle bounds);
void DrawBackground(Graphics g, Rectangle bounds, DrawItemState state, bool toplevel, bool hasicon);
void DrawMenuText(Graphics g, Rectangle bounds, string text, string shortcut, bool enabled, bool toplevel, DrawItemState state);
}
public class Office2000Style : MenuItemStyleDrawer
{
static int TEXTSTART = 20;
public void DrawCheck(Graphics g, Rectangle bounds, bool selected)
{
ControlPaint.DrawMenuGlyph(g, new Rectangle(bounds.X + 2, bounds.Y + 2, 14, 14), MenuGlyph.Check);
}
public void DrawIcon(Graphics g, Image icon, Rectangle bounds, bool selected, bool enabled, bool ischecked)
{
if (enabled) {
g.DrawImage(icon, bounds.Left + 2, bounds.Top + 2);
} else
ControlPaint.DrawImageDisabled(g, icon, bounds.Left + 2, bounds.Top + 2, SystemColors.Control);
if (selected)
ControlPaint.DrawBorder3D(g, bounds.Left, bounds.Top, icon.Width + 3, icon.Height + 3, Border3DStyle.RaisedInner);
}
public void DrawSeparator(Graphics g, Rectangle bounds)
{
ControlPaint.DrawBorder3D(g, bounds.X, bounds.Y + 2, bounds.Width, 3, Border3DStyle.Etched, Border3DSide.Top);
}
public void DrawBackground(Graphics g, Rectangle bounds, DrawItemState state, bool toplevel, bool hasicon)
{
bool selected = (state & DrawItemState.Selected) > 0;
if (selected ||((state & DrawItemState.HotLight) > 0)) {
if (toplevel) {
// g.FillRectangle(SystemBrushes.Highlight, bounds);
ControlPaint.DrawBorder3D(g, bounds.Left, bounds.Top, bounds.Width, bounds.Height, selected ? Border3DStyle.SunkenOuter : Border3DStyle.RaisedInner, Border3DSide.All);
} else {
if (hasicon) {
g.FillRectangle(SystemBrushes.Menu, new Rectangle(bounds.X, bounds.Y, bounds.X + SystemInformation.SmallIconSize.Width + 5, bounds.Height));
bounds.X += SystemInformation.SmallIconSize.Width + 5;
bounds.Width -= SystemInformation.SmallIconSize.Width + 5;
}
g.FillRectangle(SystemBrushes.Highlight, bounds);
}
} else {
if (toplevel) {
g.FillRectangle(SystemBrushes.Control, bounds);
} else {
g.FillRectangle(SystemBrushes.Menu, bounds);
}
}
}
public void DrawMenuText(Graphics g, Rectangle bounds, string text, string shortcut, bool enabled, bool toplevel, DrawItemState state)
{
bool selected = (state & DrawItemState.Selected) > 0;
StringFormat stringformat = new StringFormat();
stringformat.HotkeyPrefix = ((state & DrawItemState.NoAccelerator) > 0) ? HotkeyPrefix.Hide : HotkeyPrefix.Show;
int shortcutwidth = (int)(g.MeasureString(shortcut, SystemInformation.MenuFont).Width);
int textwidth = (int)(g.MeasureString(text, SystemInformation.MenuFont).Width);
int x = toplevel ? bounds.Left + (bounds.Width - textwidth) / 2: bounds.Left + TEXTSTART;
int y = bounds.Top + 2;
if (enabled) {
// normal draw
Color color = (selected && !toplevel) ? Color.White : SystemColors.MenuText;
g.DrawString(text, SystemInformation.MenuFont, new SolidBrush(color), x, y, stringformat);
g.DrawString(shortcut, SystemInformation.MenuFont, new SolidBrush(color), bounds.Left + 130, bounds.Top + 2, stringformat);
} else {
// disabled menuitem draw
if (!selected) {
g.DrawString(text, SystemInformation.MenuFont, SystemBrushes.ControlLightLight, x + 1, y + 1, stringformat);
g.DrawString(shortcut, SystemInformation.MenuFont, SystemBrushes.ControlLightLight, bounds.Right - shortcutwidth - 10 + 1, bounds.Top + 2 + 1, stringformat);
}
g.DrawString(text, SystemInformation.MenuFont, new SolidBrush(SystemColors.GrayText), x, y, stringformat);
g.DrawString(shortcut, SystemInformation.MenuFont, new SolidBrush(SystemColors.GrayText), bounds.Right - shortcutwidth - 10, bounds.Top + 2, stringformat);
}
}
}
{
static Color bgcolor = SystemColors.ControlLightLight; //Color.FromArgb(246, 246, 246);
static Color ibgcolor = SystemColors.ControlLight; //Color.FromArgb(202, 202, 202);
static Color sbcolor = Color.FromArgb(173, 173, 209);
static Color sbbcolor = Color.FromArgb( 0, 0, 128);
static int TEXTSTART = 20;
public void DrawCheck(Graphics g, Rectangle bounds, bool selected)
{
ControlPaint.DrawMenuGlyph(g, new Rectangle(bounds.X + 2, bounds.Y + 2, 14, 14), MenuGlyph.Check);
g.DrawRectangle(new Pen(sbbcolor), bounds.X + 1, bounds.Y + 1, 14 + 1, 14 + 1);
}
public void DrawIcon(Graphics g, Image icon, Rectangle bounds, bool selected, bool enabled, bool ischecked)
{
if (enabled) {
if (selected) {
ControlPaint.DrawImageDisabled(g, icon, bounds.Left + 2, bounds.Top + 2, Color.Black);
g.DrawImage(icon, bounds.Left + 1, bounds.Top + 1);
} else {
g.DrawImage(icon, bounds.Left + 2, bounds.Top + 2);
}
} else
ControlPaint.DrawImageDisabled(g, icon, bounds.Left + 2, bounds.Top + 2, SystemColors.HighlightText);
}
public void DrawSeparator(Graphics g, Rectangle bounds)
{
int y = bounds.Y + bounds.Height / 2;
g.DrawLine(new Pen(SystemColors.ControlDark), bounds.X + SystemInformation.SmallIconSize.Width + 7, y, bounds.X + bounds.Width - 2, y);
}
public void DrawBackground(Graphics g, Rectangle bounds, DrawItemState state, bool toplevel, bool hasicon)
{
bool selected = (state & DrawItemState.Selected) > 0;
if (selected || ((state & DrawItemState.HotLight) > 0)) {
if (toplevel && selected) { // draw toplevel, selected menuitem
g.FillRectangle(new SolidBrush(ibgcolor), bounds);
ControlPaint.DrawBorder3D(g, bounds.Left, bounds.Top, bounds.Width, bounds.Height, Border3DStyle.Flat, Border3DSide.Top | Border3DSide.Left | Border3DSide.Right);
} else { // draw menuitem, selected OR toplevel, hotlighted
g.FillRectangle(new SolidBrush(sbcolor), bounds);
g.DrawRectangle(new Pen(sbbcolor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
}
} else {
if (!toplevel) { // draw menuitem, unselected
g.FillRectangle(new SolidBrush(ibgcolor), bounds);
bounds.X += 16 + 5;
bounds.Width -= 16 + 5;
g.FillRectangle(new SolidBrush(bgcolor), bounds);
} else {
// draw toplevel, unselected menuitem
g.FillRectangle(SystemBrushes.Control, bounds);
}
}
}
public void DrawMenuText(Graphics g, Rectangle bounds, string text, string shortcut, bool enabled, bool toplevel, DrawItemState state)
{
StringFormat stringformat = new StringFormat();
stringformat.HotkeyPrefix = ((state & DrawItemState.NoAccelerator) > 0) ? HotkeyPrefix.Hide : HotkeyPrefix.Show;
int textwidth = (int)(g.MeasureString(text, SystemInformation.MenuFont).Width);
int shortcutwidth = (int)(g.MeasureString(shortcut, SystemInformation.MenuFont).Width);
int x = toplevel ? bounds.Left + (bounds.Width - textwidth) / 2: bounds.Left + TEXTSTART;
int y = bounds.Top + 2;
Brush brush = null;
if (!enabled)
brush = new SolidBrush(Color.FromArgb(120, SystemColors.MenuText));
else
brush = new SolidBrush(SystemColors.MenuText);
g.DrawString(text, SystemInformation.MenuFont, brush, x, y, stringformat);
g.DrawString(shortcut, SystemInformation.MenuFont, brush, bounds.Right - shortcutwidth - 10, bounds.Top + 2, stringformat);
}
}