📄 lc_button.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace LC_DataIO
{
public class LC_Button:Button
{
private string objname = "";
private bool mousedonw = false;
private ContextMenuStrip cm = new ContextMenuStrip();
public ToolStripMenuItem mi = new ToolStripMenuItem("选择");
private bool selectIf = false;
public bool SelectIf
{
get { return selectIf; }
set
{
selectIf = value;
if (selectIf)
{
setbkcolor(Color.Red);
mousedonw = false;
}
else
Mousedonw = Mousedonw;
}
}
public bool Mousedonw
{
get { return mousedonw; }
set
{
mousedonw = value;
if (!mousedonw)
setbkcolor(Color.Gray);
else
this.setbkcolor(Color.BurlyWood);
}
}
public LC_Button(string obj)
{
this.BackgroundImageLayout = ImageLayout.Stretch;
this.Size = new System.Drawing.Size(81, 79);
this.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.UseVisualStyleBackColor = true;
this.Text = obj;
enableDrag();
this.setbkcolor(Color.Gray);
}
public LC_Button(Point p,string obj)
{
this.BackgroundImageLayout = ImageLayout.Stretch;
this.Size = new System.Drawing.Size(81, 79);
this.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.UseVisualStyleBackColor = true;
this.objname = obj;
this.Text = obj;
setPos(p);
enableDrag();
this.setbkcolor(Color.Gray);
}
public void setPos(Point p)
{
this.Location = new Point(p.X-this.Width/2,p.Y-this.Height/2);
}
public void setbkimg(Image bkimg)
{
this.BackgroundImage = bkimg;
this.BackgroundImageLayout = ImageLayout.Stretch;
}
public void setbkcolor(Color c)
{
this.BackColor = c;
}
public void enableDrag()
{
if (this.Text != "XML")
{
cm.Items.Add(mi);
this.ContextMenuStrip = cm;
mi.Click += new EventHandler(mi_Click);
this.MouseDown += new MouseEventHandler(LC_Button_MouseDown);
}
}
void mi_Click(object sender, EventArgs e)
{
if (mi.Text == "选择")
{
mi.Text = "取消选择";
SelectIf = true;
if (this.Text != "XML")
{
HeadPage.hp.selectConverter(this.Text, this.Text, 0);
}
}
else
{
mi.Text = "选择";
SelectIf = false;
if (this.Text != "XML")
{
HeadPage.hp.selectConverter(this.Text, this.Text, 1);
}
}
}
void LC_Button_MouseMove(object sender, MouseEventArgs e)
{
if (mousedonw&&this.Text!="XML")
{
}
}
void LC_Button_MouseDown(object sender, MouseEventArgs e)
{
if (!this.selectIf&&this.Text!="XML")
{
if (e.Button == MouseButtons.Left && e.Clicks == 2)
{
HeadPage.hp.initallobj();
Mousedonw = true;
}
if (e.Button == MouseButtons.Left && e.Clicks == 1)
{
Mousedonw = false;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -