调整优化代码文件组织结构
This commit is contained in:
1 parent
025c213435
commit
840636d5c9
130 files changed
+5936
-228
No files matched your search
@@ -0,0 +1,87 @@
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TemuKJD.BaseForms
|
||||
{
|
||||
public partial class BaseForm : Form
|
||||
{
|
||||
public BaseForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void BaseForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
|
||||
{
|
||||
float dpi = graphics.DpiX;
|
||||
// 或者使用 graphics.DpiY 获取垂直方向的DPI
|
||||
// float dpi = graphics.DpiY;
|
||||
// Console.WriteLine("Screen DPI: " + dpi); // winform程序会闪退
|
||||
|
||||
SetFont(this, dpi);
|
||||
}
|
||||
}
|
||||
|
||||
void SetFont(Control control, float dpi)
|
||||
{
|
||||
foreach (Control c in control.Controls)
|
||||
{
|
||||
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 UserComponent.UcTreeView)
|
||||
{
|
||||
var tree = c as UserComponent.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 is DataGridView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (c.Name == "pnlSA")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user