首页/技术开发/内容

一个Xp风格的表单类(一)

技术开发2024-06-10 阅读()
Sys_Res_Visible==true ))
{
if(this.WindowState==FormWindowState.Maximized)
{
this.WindowState=FormWindowState.Normal;
}
else
{
this.WindowState=FormWindowState.Maximized;
}
this.Cursor=Cursors.Default;
}
}

protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
ni.Visible=false;
ni.Dispose();
}

protected override void OnTextChanged(System.EventArgs e)
{this.RePaint(false);}

//protected override void OnLayout(System.Windows.Forms.LayoutEventArgs e)
//{
//mmd,在这里一加事件,居然从TRAY里恢复窗口的时候,不从画子控件了..郁闷
//this.XpPanel.Location=new Point(4,30);
//this.XpPanel.Size=new Size(this.Width-8,this.Height-34);
//this.XpPanel.SendToBack();
//foreach(Control c in this.Controls)
//{
//c.Parent=this.XpPanel;
//}
//}

//protected override void OnControlAdded(System.Windows.Forms.ControlEventArgs ce)
//{
/* 这也不是什么根本的办法,,,,,自己用还中....
try
{
if(ce.Control.Parent==this && ce.Control.Name!=this.Name && ce.Control.Name!=this.XpPanel.Name)
{
ce.Control.Parent=this.XpPanel;
}
}
catch{}
*/
//}

/*
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0x0084 && CurPoint2.Y<=30 ) //WM_NCHITTEST
{
m.Result= (IntPtr)2; // HTCLIENT
this.Text=this.CurPoint2.Y.ToString();
return;
}

}*/
//protected override void OnActivated(System.EventArgs e)
//{

//}
//####################################################################
#endregion









#region 自 定 义 属 性
//####################### 自 定 义 属 性 #############################
[
Category("XpForm属性"),
Description("获取或设置窗体的关闭按钮是否可见.")
]
public bool Sys_Close_IsVisible
{
get{return Sys_Close_Visible;}
set
{
Sys_Close_Visible=value;
InitSysCmd();
int SysIndex=0;
for(int i=0;i<=6;i++)
{
if(SysCmd[i,0]==1)
{
SysIndex+=1;
}
}
this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
}
}
[
Category("XpForm属性"),
Description("获取或设置窗体的最大化按钮是否可见.")
]
public bool Sys_Max_IsVisible
{
get{return Sys_Max_Visible;}
set
{
Sys_Max_Visible=value;
InitSysCmd();
int SysIndex=0;
for(int i=0;i<=6;i++)
{
if(SysCmd[i,0]==1)
{
SysIndex+=1;
}
}
this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
}
}
[
Category("XpForm属性"),
Description("获取或设置窗体的最小化按钮是否可见.")
]
public bool Sys_Min_IsVisible
{
get{return Sys_Min_Visible;}
set
{
Sys_Min_Visible=value;
InitSysCmd();
int SysIndex=0;
for(int i=0;i<=6;i++)
{
if(SysCmd[i,0]==1)
{
SysIndex+=1;
}
}
this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
}
}
[
Category("XpForm属性"),
Description("获取或设置窗体的收起(向上)按钮是否可见.")
]
public bool Sys_Up_IsVisible
{
get{return Sys_Up_Visible;}
set
{
Sys_Up_Visible=value;
InitSysCmd();
int SysIndex=0;
for(int i=0;i<=6;i++)
{
if(SysCmd[i,0]==1)
{
SysIndex+=1;
}
}
this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
}
}
[
Category("XpForm属性"),
Description("获取或设置窗体的缩入托盘按钮是否可见.")
]
public bool Sys_Tray_IsVisible
{
get{return Sys_Tray_Visible;}
set
{
Sys_Tray_Visible=value;
InitSysCmd();
int SysIndex=0;
for(int i=0;i<=6;i++)
{
if(SysCmd[i,0]==1)
{
SysIndex+=1;
}
}
this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
}
}
[
Category("XpForm属性"),
Description("获取或设置窗体在托盘区显示的图标.")
]
public Icon Sys_Icon
{
get{return TrayIcon;}
set{TrayIcon=value;ni.Icon=TrayIcon;}
}
[
Category("XpForm属性"),
Description("获取或设置窗体在托盘区的上下文菜单.")
]
public ContextMenu Sys_ContextMenu
{
get{return TrayContextMenu;}
set{TrayContextMenu=value;ni.ContextMenu=TrayContextMenu;}
}
[
Category("XpForm属性"),
Description("获取或设置当鼠标停留在托盘区图标上时的提示文字.")
]
public string Sys_ToolTip
{
get{return TempTrayToolTip;}
set{TempTrayToolTip=value;TrayToolTip=TempTrayToolTip.Split("\n".ToCharArray(),0);ni.Text=value;}
}
[
Category("XpForm属性"),
Description("多行编辑控件中的文本行,作为字符串值的数组.(用于设置多行ToolTip)")
]
public string[] Sys_ToolTip_Lines
{
get{return TrayToolTip;}
set
{
string[] a=value;
//TrayToolTip=value[0];
TempTrayToolTip="";
for(int i=0;i<=a.Length-1;i++)
{
TempTrayToolTip=TempTrayToolTip+a.GetValue(i).ToString();
if(i<a.Length-1)
{
TempTrayToolTip=TempTrayToolTip+"\n";
}
}
ni.Text=TempTrayToolTip;
TrayToolTip=value;
}
}
[
Category("XpForm属性"),
Description("获取或设置窗体刚启动时是否在托盘区显示.(需要先设置Sys_Icon属性.)")
]
public bool ShowInTray
{
get{return IsShowInTray;}
set
{
IsShowInTray=value;
if(!this.DesignMode)
{
ni.Icon=TrayIcon;
ni.ContextMenu=TrayContextMenu;
ni.Text=TempTrayToolTip;
ni.Visible=value;
}
}
}
[
Category("XpForm属性"),
Description("窗体图标的宽.)")
]
public int FormIcon_Width
{
get{return FormIconWidth;}
set
{
if(value>=FormIconWidth)
{
FormIconWidth=value;
this.Invalidate(new Rectangle(8,6,value,FormIconHeight));
}
else
{
int temp=FormIconWidth;
FormIconWidth=value;
this.Invalidate(new Rectangle(8,6,value,temp));
}
}
}
[
Category("XpForm属性"),
Description("窗体图标的高.)")
]
public int FormIcon_Height
{
get{return FormIconHeight;}
set
{
if(value>=FormIconHeight)
{
FormIconHeight=value;
this.Invalidate(new Rectangle(8,6,FormIconWidth,value));
}
else
{
int temp=FormIconHeight;
FormIconHeight=value;
this.Invalidate(new Rectangle(8,6,temp,value));
}
}
}
//####################################################################
#endregion
}
}



第1页  第2页  第3页  第4页  第5页  第6页  第7页  第8页  第9页 

……

相关阅读