功能调整
This commit is contained in:
1 parent
42acf1b1cb
commit
772d9f4780
40 files changed
+4953
-389
No files matched your search
+148
-245
@@ -1,278 +1,181 @@
|
||||
using AllBase;
|
||||
using AllBase.Helper;
|
||||
using DevComponents.DotNetBar;
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Work.UserControls;
|
||||
|
||||
namespace Work.BaseForms
|
||||
{
|
||||
public partial class BaseForm : Form
|
||||
{
|
||||
const int WM_NCHITTEST = 0x0084;
|
||||
const int HTLEFT = 10; //左边界
|
||||
const int HTRIGHT = 11; //右边界
|
||||
const int HTTOP = 12; //上边界
|
||||
const int HTTOPLEFT = 13; //左上角
|
||||
const int HTTOPRIGHT = 14; //右上角
|
||||
const int HTBOTTOM = 15; //下边界
|
||||
const int HTBOTTOMLEFT = 0x10; //左下角
|
||||
const int HTBOTTOMRIGHT = 17; //右下角
|
||||
|
||||
protected bool Minimized { get { return this.pbMinBase.Visible; } set { this.pbMinBase.Visible = value; } }
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
switch (m.Msg)
|
||||
{
|
||||
case WM_NCHITTEST:
|
||||
base.WndProc(ref m);
|
||||
Point vPoint = new Point((int)m.LParam & 0xFFFF,
|
||||
(int)m.LParam >> 16 & 0xFFFF);
|
||||
vPoint = PointToClient(vPoint);
|
||||
if (vPoint.X <= 5)
|
||||
if (vPoint.Y <= 5)
|
||||
m.Result = (IntPtr)HTTOPLEFT;
|
||||
else if (vPoint.Y >= ClientSize.Height - 5)
|
||||
m.Result = (IntPtr)HTBOTTOMLEFT;
|
||||
else m.Result = (IntPtr)HTLEFT;
|
||||
else if (vPoint.X >= ClientSize.Width - 5)
|
||||
if (vPoint.Y <= 5)
|
||||
m.Result = (IntPtr)HTTOPRIGHT;
|
||||
else if (vPoint.Y >= ClientSize.Height - 5)
|
||||
m.Result = (IntPtr)HTBOTTOMRIGHT;
|
||||
else m.Result = (IntPtr)HTRIGHT;
|
||||
else if (vPoint.Y <= 5)
|
||||
m.Result = (IntPtr)HTTOP;
|
||||
else if (vPoint.Y >= ClientSize.Height - 5)
|
||||
m.Result = (IntPtr)HTBOTTOM;
|
||||
break;
|
||||
default:
|
||||
base.WndProc(ref m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public BaseForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
||||
if (FileBase.Exists(BaseClass.ProgromLogoIco))
|
||||
{
|
||||
Image img = Image.FromFile(BaseClass.ProgromLogoIco);
|
||||
pictureBox3.Image = img;
|
||||
}
|
||||
}
|
||||
|
||||
private void LcBaseForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (BaseClass.Ico != null)
|
||||
Iconx = Icon = BaseClass.Ico;
|
||||
else
|
||||
Iconx = Icon = BaseClass.Ico = ImageBuild.ConvertToIcon(Properties.Resources.icon);
|
||||
|
||||
|
||||
if (this.IsShowMax)
|
||||
{
|
||||
if (this.WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
this.pbMaxBase.Visible = false;
|
||||
this.pbNormalBase.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pbMaxBase.Visible = true;
|
||||
this.pbNormalBase.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PictureBox2_Click(object sender, EventArgs e)
|
||||
{
|
||||
WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
|
||||
public virtual void PictureBox1_Click(object sender, EventArgs e)
|
||||
{
|
||||
//pictureBox3.Image?.Dispose();
|
||||
Close();
|
||||
}
|
||||
|
||||
private Icon _iconx;
|
||||
public Icon Iconx
|
||||
{
|
||||
set
|
||||
{
|
||||
_iconx = value;
|
||||
if (_iconx == null) return;
|
||||
|
||||
using (MemoryStream mStream = new MemoryStream())
|
||||
{
|
||||
_iconx.Save(mStream);
|
||||
Image image = Image.FromStream(mStream);
|
||||
pictureBox3.Image = image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool isShowMax = false;
|
||||
public bool IsShowMax
|
||||
{
|
||||
get { return isShowMax; }
|
||||
set
|
||||
{
|
||||
isShowMax = value;
|
||||
if (isShowMax)
|
||||
{
|
||||
if (this.WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
this.pbMaxBase.Visible = false;
|
||||
this.pbNormalBase.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pbMaxBase.Visible = true;
|
||||
this.pbNormalBase.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pbMaxBase.Visible = false;
|
||||
this.pbNormalBase.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TitleText
|
||||
public bool IsSetFontScaleNone { get; set; } = true;
|
||||
public float FormDpi
|
||||
{
|
||||
get
|
||||
{
|
||||
return Text;
|
||||
return dpi;
|
||||
}
|
||||
set
|
||||
}
|
||||
private float dpi = 96;
|
||||
|
||||
public BaseForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void BaseForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
setSkinColor(this);
|
||||
|
||||
using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
|
||||
{
|
||||
Text = lbTitle.Text = value;
|
||||
}
|
||||
}
|
||||
private Point mouseOffset;//记录鼠标指针的坐标
|
||||
private bool isMouseDown;//记录鼠标左键是否按下
|
||||
private void Panel1_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (isMouseDown)
|
||||
{//获取鼠标的位置
|
||||
Point mousePos = MousePosition;
|
||||
mousePos.Offset(mouseOffset.X, mouseOffset.Y);
|
||||
Location = mousePos;
|
||||
dpi = graphics.DpiX;
|
||||
// 或者使用 graphics.DpiY 获取垂直方向的DPI
|
||||
// float dpi = graphics.DpiY;
|
||||
// Console.WriteLine("Screen DPI: " + dpi); // winform程序会闪退
|
||||
|
||||
if (IsSetFontScaleNone)
|
||||
SetFont(this, dpi);
|
||||
}
|
||||
}
|
||||
|
||||
private void Panel1_MouseDown(object sender, MouseEventArgs e)
|
||||
public void SetFont(Control control, float dpi)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
foreach (Control c in control.Controls)
|
||||
{
|
||||
mouseOffset = new Point(-e.X, -e.Y);
|
||||
isMouseDown = true;
|
||||
SetFont(c, dpi);
|
||||
|
||||
Font of = c.Font;
|
||||
Font nf = new Font(of.FontFamily, (of.Size * 96.0 / dpi).ParseToFloat(), of.Style, of.Unit, of.GdiCharSet, of.Bold);
|
||||
c.Font = nf;
|
||||
|
||||
if (c is DevComponents.DotNetBar.PanelEx)
|
||||
{
|
||||
var pEx = (c as DevComponents.DotNetBar.PanelEx);
|
||||
if (pEx.Style.Font != null)
|
||||
{
|
||||
Font osf = pEx.Style.Font;
|
||||
Font nsf = new Font(osf.FontFamily, (osf.Size * 96.0 / dpi).ParseToFloat(), osf.Style, osf.Unit, osf.GdiCharSet, osf.Bold);
|
||||
pEx.Style.Font = nsf;
|
||||
}
|
||||
|
||||
if (pEx.StyleMouseOver.Font != null)
|
||||
{
|
||||
Font oof = pEx.StyleMouseOver.Font;
|
||||
Font nof = new Font(oof.FontFamily, (oof.Size * 96.0 / dpi).ParseToFloat(), oof.Style, oof.Unit, oof.GdiCharSet, oof.Bold);
|
||||
pEx.StyleMouseOver.Font = nof;
|
||||
}
|
||||
|
||||
if (pEx.StyleMouseDown.Font != null)
|
||||
{
|
||||
Font odf = pEx.StyleMouseDown.Font;
|
||||
Font ndf = new Font(odf.FontFamily, (odf.Size * 96.0 / dpi).ParseToFloat(), odf.Style, odf.Unit, odf.GdiCharSet, odf.Bold);
|
||||
pEx.StyleMouseDown.Font = ndf;
|
||||
}
|
||||
}
|
||||
if (c is UserComponents.UcTreeView)
|
||||
{
|
||||
var tree = c as UserComponents.UcTreeView;
|
||||
Font ogf = tree.GroupFont;
|
||||
Font ngf = new Font(ogf.FontFamily, (ogf.Size * 96.0 / dpi).ParseToFloat(), ogf.Style, ogf.Unit, ogf.GdiCharSet, ogf.Bold);
|
||||
tree.GroupFont = ngf;
|
||||
}
|
||||
|
||||
if (c.Name == "pnlSA")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Panel1_MouseUp(object sender, MouseEventArgs e)
|
||||
public void setSkinColor(Control control)
|
||||
{
|
||||
isMouseDown = false;
|
||||
}
|
||||
|
||||
private void PictureBox1_MouseHover(object sender, EventArgs e)
|
||||
{
|
||||
this.pbCloseBase.Image = global::Work.Properties.Resources.close_hover;
|
||||
this.Cursor = Cursors.Hand;
|
||||
|
||||
}
|
||||
|
||||
private void PictureBox1_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
this.pbCloseBase.Image = global::Work.Properties.Resources.close;
|
||||
this.Cursor = Cursors.Default;
|
||||
|
||||
}
|
||||
|
||||
private void PictureBox2_MouseHover(object sender, EventArgs e)
|
||||
{
|
||||
this.pbMinBase.Image = global::Work.Properties.Resources.min_hover;
|
||||
this.Cursor = Cursors.Hand;
|
||||
|
||||
}
|
||||
|
||||
private void PictureBox2_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
this.pbMinBase.Image = global::Work.Properties.Resources.min;
|
||||
this.Cursor = Cursors.Default;
|
||||
|
||||
}
|
||||
|
||||
public virtual void HideTitle()
|
||||
{
|
||||
// this.panel1.Visible = false;
|
||||
}
|
||||
|
||||
#region 窗体提交数据完成事件
|
||||
public event Action<object> SaveComplete;
|
||||
protected virtual void OnSaveComplete(object param)
|
||||
{
|
||||
this.SaveComplete?.Invoke(param);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void pbNormalBase_Click(object sender, EventArgs e)
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
this.pbMaxBase.Visible = true;
|
||||
this.pbNormalBase.Visible = false;
|
||||
}
|
||||
|
||||
private void pbNormalBase_MouseHover(object sender, EventArgs e)
|
||||
{
|
||||
this.pbNormalBase.Image = global::Work.Properties.Resources.normal_hover;
|
||||
this.Cursor = Cursors.Hand;
|
||||
}
|
||||
|
||||
private void pbNormalBase_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
this.pbNormalBase.Image = global::Work.Properties.Resources.normal;
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
|
||||
private void pbMaxBase_Click(object sender, EventArgs e)
|
||||
{
|
||||
WindowState = FormWindowState.Maximized;
|
||||
this.pbMaxBase.Visible = false;
|
||||
this.pbNormalBase.Visible = true;
|
||||
}
|
||||
|
||||
private void pbMaxBase_MouseHover(object sender, EventArgs e)
|
||||
{
|
||||
this.pbMaxBase.Image = global::Work.Properties.Resources.max_hover;
|
||||
this.Cursor = Cursors.Hand;
|
||||
}
|
||||
|
||||
private void pbMaxBase_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
this.pbMaxBase.Image = global::Work.Properties.Resources.max;
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
private Point mPoint;
|
||||
private void panel2_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
mPoint = new Point(e.X, e.Y);
|
||||
}
|
||||
|
||||
private void panel2_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
foreach (Control c in control.Controls)
|
||||
{
|
||||
this.Location = new Point(this.Location.X + e.X - mPoint.X, this.Location.Y + e.Y - mPoint.Y);
|
||||
setSkinColor(c);
|
||||
|
||||
// pdd皮肤颜色
|
||||
if (BaseClass.MainPath == "29pdd" || BaseClass.MainPath == "29wx")
|
||||
{
|
||||
if (c is Panel && c.BackColor == GlobalConfig.DefaultMainColor)
|
||||
{
|
||||
c.BackColor = GlobalConfig.MainColor;
|
||||
}
|
||||
else if (c is PanelEx && c.Name.StartsWith("btn"))
|
||||
{
|
||||
var pnl = c as PanelEx;
|
||||
if (pnl.Style.BackColor1.Color == GlobalConfig.DefaultMainColor)
|
||||
{
|
||||
pnl.Style.BackColor1.Color = GlobalConfig.MainColor;
|
||||
pnl.Style.BackColor2.Color = GlobalConfig.MainColor;
|
||||
pnl.StyleMouseOver.BackColor1.Color = GlobalConfig.BorderColor;
|
||||
pnl.StyleMouseOver.BackColor2.Color = GlobalConfig.BorderColor;
|
||||
}
|
||||
else if (pnl.Style.BackColor1.Color == GlobalConfig.DefaultMainColorLight || pnl.Style.BorderColor.Color == GlobalConfig.DefaultMainColor)
|
||||
{
|
||||
pnl.Style.BorderColor.Color = GlobalConfig.MainColor;
|
||||
pnl.Style.BackColor1.Color = GlobalConfig.MainColorLight;
|
||||
pnl.Style.BackColor2.Color = GlobalConfig.MainColorLight;
|
||||
pnl.Style.ForeColor.Color = GlobalConfig.BorderColor;
|
||||
pnl.StyleMouseOver.BackColor1.Color = GlobalConfig.BorderColor;
|
||||
pnl.StyleMouseOver.BackColor2.Color = GlobalConfig.BorderColor;
|
||||
}
|
||||
}
|
||||
else if (c is ButtonEx)
|
||||
{
|
||||
c.BackColor = GlobalConfig.MainColor;
|
||||
}
|
||||
else if (c is SplitContainer && c.BackColor == GlobalConfig.DefaultMainColor)
|
||||
{
|
||||
c.BackColor = GlobalConfig.MainColor;
|
||||
}
|
||||
else if (c is UserComponents.UcTreeView)
|
||||
{
|
||||
var tv = c as UserComponents.UcTreeView;
|
||||
tv.ChildNodeSelectedBgColor = GlobalConfig.MainColor;
|
||||
}
|
||||
else if (c is UserComponents.UcGroupBoxEx && (c as UserComponents.UcGroupBoxEx).BorderColor == GlobalConfig.DefaultMainColor)
|
||||
{
|
||||
var gb = c as UserComponents.UcGroupBoxEx;
|
||||
gb.BorderColor = GlobalConfig.MainColor;
|
||||
}
|
||||
else if (c is UserComponents.DataGridViewEx)
|
||||
{
|
||||
var dgv = c as UserComponents.DataGridViewEx;
|
||||
dgv.BorderColor = GlobalConfig.MainColor;
|
||||
dgv.DefaultCellStyle.SelectionBackColor = GlobalConfig.MainColor;
|
||||
|
||||
dgv.CheckBoxRowBoxCheckColor = GlobalConfig.MainColor;
|
||||
dgv.CheckBoxRowBoxBorderColor = GlobalConfig.BorderColor;
|
||||
}
|
||||
else if (c is UserComponents.UcCheckBox)
|
||||
{
|
||||
var chk = c as UserComponents.UcCheckBox;
|
||||
chk.CheckBoxCheckColor = GlobalConfig.MainColor;
|
||||
chk.CheckBoxBorderColor = GlobalConfig.BorderColor;
|
||||
}
|
||||
else if (c is UserComponents.UcTabControl)
|
||||
{
|
||||
var tc = c as UserComponents.UcTabControl;
|
||||
tc.TabSelectColor = GlobalConfig.MainColor;
|
||||
tc.TabSelectTextColor = GlobalConfig.MainColor;
|
||||
}
|
||||
else if (c is UserComponents.UcTabControlMetro)
|
||||
{
|
||||
var tc = c as UserComponents.UcTabControlMetro;
|
||||
tc.BorderColor = GlobalConfig.BorderColor;
|
||||
tc.TabSelectColor = GlobalConfig.MainColor;
|
||||
tc.TabSelectTextColor = GlobalConfig.MainColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user