<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[恶魔界]]></title>
<link><![CDATA[https://www.dk-x.com/]]></link>
<description><![CDATA[卑微的80后,活着:等明天的太阳,闭眼:明天的太阳等我````]]></description>
<language><![CDATA[]]></language>
<copyright><![CDATA[Copyright 恶魔界]]></copyright>
<webMaster><![CDATA[]]></webMaster>
<generator><![CDATA[EM.CMS v1.0.0.0]]></generator>
<image>
	<title><![CDATA[恶魔界]]></title>
	<url><![CDATA[https://www.dk-x.com/UI/Images/Logo.png]]></url>
	<link><![CDATA[https://www.dk-x.com/]]></link>
	<description><![CDATA[卑微的80后,活着:等明天的太阳,闭眼:明天的太阳等我````]]></description>
</image>
<item>
	<link><![CDATA[https://www.dk-x.com/Article/103924AF-C302-40C5-A34A-0584D0387301.htm]]></link>
	<title><![CDATA[仿QQ窗体自动收缩]]></title>
	<author><![CDATA[XEM]]></author>
	<category><![CDATA[C#]]></category>
	<pubDate>2023/5/31 1:05:21</pubDate>
	<guid><![CDATA[https://www.dk-x.com/Article/103924AF-C302-40C5-A34A-0584D0387301.htm]]></guid>
	<description><![CDATA[<p>模仿QQ主窗体自动收缩的功能，展示部分功能。</p>

<pre>
<code class="language-cs">        private void Timer1_Tick(object sender, EventArgs e)
        {
            if (Top &lt; 3 &amp;&amp; Tem_place == 0)//如果窗体被移到屏幕的顶部
            {
                if (Handle == FormNameAt(Cursor.Position.X, Cursor.Position.Y))//当鼠标移致到该窗体上
                {
                    panel_Title.Tag = 1;//设置标识，用于判断窗体在屏幕顶部
                    timer2.Enabled = false;//不对窗体进行拉伸操作
                    Top = 0;//使窗体致顶
                }
                else
                {
                    panel_Title.Tag = 1;//设置标识，用于判断窗体在屏幕顶部
                    timer2.Enabled = true;//将窗体在顶部进行隐藏
                }
            }
            else
            {
                if (Left &lt; 3 || Right &gt; GetSystemMetrics(0) - 3)//如果窗体被移到屏幕的左端或右端
                {
                    if (Left &lt; 3)//如果窗体被移到屏幕的左端
                    {
                        if (Handle == FormNameAt(Cursor.Position.X, Cursor.Position.Y))//当鼠标移致到该窗体上
                        {
                            panel_Title.Tag = 2;//设置标识，用于判断窗体在屏幕左端
                            timer2.Enabled = false;
                            Frm_Height = Height;
                            Left = 0;//使窗体致左
                            Top = 0;
                            Height = Screen.AllScreens[0].Bounds.Height;
                            Tem_place = 1;
                        }
                        else
                        {
                            panel_Title.Tag = 2;
                            timer2.Enabled = true;//将窗体在左端进行隐藏
                        }
                    }
                    if (Right &gt; GetSystemMetrics(0) - 3)//如果窗体被移到屏幕的右端
                    {
                        if (Handle == FormNameAt(Cursor.Position.X, Cursor.Position.Y))//当鼠标移致到该窗体上
                        {
                            panel_Title.Tag = 3;//设置标识，用于判断窗体在屏幕右端
                            timer2.Enabled = false;
                            Frm_Height = Height;
                            Left = GetSystemMetrics(0) - Width;//使窗体致右
                            Top = 0;
                            Height = Screen.AllScreens[0].Bounds.Height;
                            Tem_place = 1;
                        }
                        else
                        {
                            panel_Title.Tag = 3;
                            timer2.Enabled = true;//将窗体在右端进行隐藏
                        }
                    }
                }
            }
        }</code></pre>

<p>&nbsp;</p>]]></description>
</item>
<item>
	<link><![CDATA[https://www.dk-x.com/Article/453152E1-294A-4212-B7CB-DB565EB585D9.htm]]></link>
	<title><![CDATA[C#在 DataGridView 中遍历 查找相同的数据并定位]]></title>
	<author><![CDATA[XEM]]></author>
	<category><![CDATA[C#]]></category>
	<pubDate>2023/5/6 22:05:53</pubDate>
	<guid><![CDATA[https://www.dk-x.com/Article/453152E1-294A-4212-B7CB-DB565EB585D9.htm]]></guid>
	<description><![CDATA[<p>经常用到的东西，记录下来，然后用的时候想不起来。</p>

<p>1.遍历整个&nbsp;dataGridView1 控件</p>

<pre>
<code class="language-cs">for (int i = 0; i &lt; dataGridView1.RowCount; i++)
{
    for (int j = 0; j &lt; dataGridView1.ColumnCount; j++)
    {
        //打印第i行第j列数据
        Console.WriteLine(Convert.ToString(dataGridView1[j, i].Value));
        // 注意dataGridView1[j,i]代表的是第i行第j列
    }
}</code></pre>

<p>2.模糊查找数据并定位并加入是否还要继续查找</p>

<pre>
<code class="language-cs">int row = dataGridView1.Rows.Count;//得到总行数
int cell = dataGridView1.Rows[1].Cells.Count;//得到总列数
string strTxt = txtFind.Text;//得到输入的字符串，并付值给变量
Regex r = new Regex(strTxt); // 定义一个Regex对象实例 
for (int i = 0; i &lt; row; i++)//得到总行数并在之内循环
{
    for (int j = 0; j &lt; cell; j++)//得到总列数并在之内循环
    {
        Match m = r.Match(dataGridView1.Rows[i].Cells[j].Value.ToString()); // 在字符串中模糊匹配 
        if (m.Success)
        {   //对比TexBox中的值是否与dataGridView中的值相同（上面这句）
            dataGridView1.CurrentCell = dataGridView1[j, i];//定位到相同的单元格
            if (MessageBox.Show("是否需要继续查找？", "", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                //如果选择了取消就会返回,如果选择了确定,就会继续查找匹配的.
                return;//返回
            }
        }
    }
}</code></pre>

<p>&nbsp;</p>]]></description>
</item>
<item>
	<link><![CDATA[https://www.dk-x.com/Article/9261FE6E-BF5A-4774-A2D8-14F0FC9DB1DB.htm]]></link>
	<title><![CDATA[开源 EM.Controls 带示例Demo 自定义控件库]]></title>
	<author><![CDATA[XEM]]></author>
	<category><![CDATA[C#]]></category>
	<pubDate>2023/4/11 1:10:37</pubDate>
	<guid><![CDATA[https://www.dk-x.com/Article/9261FE6E-BF5A-4774-A2D8-14F0FC9DB1DB.htm]]></guid>
	<description><![CDATA[<p>自己网上Ctrl + C 、Ctrl + V 收集，并自己开发的，自用 简单窗体控件库，如有喜欢的朋友可以下载去探索下。</p>

<p>目前有 10个重写控件，分别是：Button、CheckBox、Form、GlassButton、ImageButton、ListView、MessageBox、RadioButtom</p>

<p>SplashScreen、TextBox。不会写的很复杂，适合新手，一看就明白。源码注释明确。</p>

<p>控件演示窗口：</p>

<p style="text-align:center"><img alt="EM.Controls" height="469" src="/Attach/202304/11012029-EM.Controls_2.png" width="790" /></p>

<p>&nbsp;消息窗口展示：</p>

<p style="text-align:center"><img alt="EM.Controls" height="154" src="/Attach/202304/11012032-EM.Controls_3.png" width="334" /></p>

<p>文件目录展示：</p>

<p style="text-align:center"><img alt="EM.Controls" height="588" src="/Attach/202304/11012023-EM.Controls_1.png" width="330" /></p>

<p>&nbsp;展示部分窗体代码：</p>

<pre>
<code class="language-cs">using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace EM.Controls
{
    /// &lt;summary&gt;
    /// 自定义扩展窗体Form
    /// &lt;/summary&gt;
    public class Form : System.Windows.Forms.Form
    {
        #region 私有变量
        //系统按钮管理器
        private SystemButtonManager _systemButtonManager;
        #endregion

        #region 构造函数

        public Form()
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;
            _systemButtonManager = new SystemButtonManager(this);
            FormIni();
        }
        #endregion

        #region 属性
        [Description("确定窗体标题栏的右上角是否有关闭框。")]
        public bool CloseBox { get; set; } = true;

        [Description("窗体圆角的半径。")]
        public int Radius { get; set; } = 5;

        [Description("是否允许窗体改变大小。")]
        public bool CanResize { get; set; } = true;

        [Description("窗体背景图片。")]
        public override Image BackgroundImage { get; set; }

        [Description("绘制窗体标题的字体。")]
        public Font TextFont { get; set; } = new Font("宋体", 9.0f, FontStyle.Bold);

        [Description("绘制窗体标题的颜色。")]
        public Color TextForeColor { get; set; } = Color.FromArgb(250, Color.White);

        [Description("绘制带有阴影的窗体标题。")]
        public bool TextWithShadow { get; set; } = true;

        [Description("使窗体绘制阴影。")]
        public Color TextShadowColor { get; set; } = Color.FromArgb(2, Color.Black);

        [Description("窗体阴影的宽度。默认值：3")]
        public int TextShadowWidth { get; set; } = 3;

        [Description("最小窗体宽大小。")]
        public int MinFormSizeWidth { get; set; } = 50;

        [Description("最小窗体高大小。")]
        public int MinFormSizeHeight { get; set; } = 30;

        [Browsable(false)]
        [Description("返回窗体关闭系统按钮所在的坐标矩形")]
        public Rectangle CloseBoxRect
        {
            get { return SystemButtonManager.SystemButtonArray[0].LocationRect; }
        } 
        [Browsable(false)]
        [Description("返回窗体最大化或者还原系统按钮所在的坐标矩形")]
        public Rectangle MaximiziBoxRect
        {
            get { return SystemButtonManager.SystemButtonArray[1].LocationRect; }
        }

        [Browsable(false)]
        [Description("返回窗体最小化系统按钮所在的坐标矩形")]
        public Rectangle MinimiziBoxRect
        {
            get { return SystemButtonManager.SystemButtonArray[2].LocationRect; }
        }
        /// &lt;summary&gt;
        /// 窗体 Icon 矩形
        /// &lt;/summary&gt;
        internal Rectangle IconRect
        {
            get
            {
                if (base.ShowIcon &amp;&amp; base.Icon != null)
                {
                    return new Rectangle(8, 8, SystemInformation.SmallIconSize.Width, SystemInformation.SmallIconSize.Width);
                }
                return Rectangle.Empty;
            }
        }
        /// &lt;summary&gt;
        /// 窗体标题矩形
        /// &lt;/summary&gt;
        internal Rectangle TextRect
        {
            get
            {
                if (base.Text.Length != 0)
                {
                    return new Rectangle(IconRect.Right + 5, 8, Width - (8 + IconRect.Width + 2), TextFont.Height);
                }
                return Rectangle.Empty;
            }
        } 
        internal SystemButtonManager SystemButtonManager
        {
            get
            {
                if (_systemButtonManager == null)
                {
                    _systemButtonManager = new SystemButtonManager(this);
                }
                return _systemButtonManager;
            }
        } 
        #endregion 
        #region 继承

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                if (!DesignMode)
                {
                    if (MaximizeBox) { cp.Style |= (int)WindowStyle.WS_MAXIMIZEBOX; }
                    if (MinimizeBox) { cp.Style |= (int)WindowStyle.WS_MINIMIZEBOX; }
                    cp.ExStyle |= (int)WindowStyle.WS_CLIPCHILDREN;  //防止因窗体控件太多出现闪烁
                    cp.ClassStyle |= (int)ClassStyle.CS_DropSHADOW;  //实现窗体边框阴影效果
                }
                return cp;
            }
        } 
        protected override void OnCreateControl()
        {
            base.OnCreateControl();
            RenderHelper.SetFormRoundRectRgn(this, Radius);
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            UpdateSystemButtonRect();
        } 
        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            if (this.Width &lt;= MinFormSizeWidth) { this.Width = MinFormSizeWidth; }
            if (this.Height &lt;= MinFormSizeHeight) { this.Height = MinFormSizeHeight; }

            RenderHelper.SetFormRoundRectRgn(this, Radius);

            //更新 最大化 按钮 图标
            UpdateMaxButton();
            // 更新  按钮的位置
            UpdateSystemButtonRect();
        }
        /// &lt;summary&gt;
        /// 处理Win 系统消息
        /// &lt;/summary&gt;
        /// &lt;param name="m"&gt;&lt;/param&gt;
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case Win32.WM_ERASEBKGND:
                    m.Result = IntPtr.Zero;
                    break;
                case Win32.WM_NCHITTEST://这个消息是当鼠标移动或者有鼠标键按下时候发出的
                    WmNcHitTest(ref m);
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        } 
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            SystemButtonManager.ProcessMouseOperate(e.Location, MouseOperate.Move);
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button == MouseButtons.Left)
            {
                SystemButtonManager.ProcessMouseOperate(e.Location, MouseOperate.Down);
            }
        } 
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (e.Button == MouseButtons.Left)
            {
                SystemButtonManager.ProcessMouseOperate(e.Location, MouseOperate.Up);
            }
        } 
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            SystemButtonManager.ProcessMouseOperate(Point.Empty, MouseOperate.Leave);
        }
        /// &lt;summary&gt;
        /// 重写控件的 OnPaint 事件
        /// &lt;/summary&gt;
        /// &lt;param name="e"&gt;&lt;/param&gt;
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.CompositingQuality = CompositingQuality.Default;
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

            //绘制 背景图片
            if (BackgroundImage != null)
            {
                switch (BackgroundImageLayout)
                {
                    case ImageLayout.Stretch:
                    case ImageLayout.Zoom:
                        e.Graphics.DrawImage(BackgroundImage, ClientRectangle, new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);
                        break;
                    case ImageLayout.Center:
                    case ImageLayout.None:
                    case ImageLayout.Tile:
                        e.Graphics.DrawImage(BackgroundImage, ClientRectangle, ClientRectangle, GraphicsUnit.Pixel);
                        break;
                }
            }

            //绘制窗体主体部分白色透明层
            RenderHelper.DrawFromAlphaMainPart(this, e.Graphics);

            //绘制 边缘
            RenderHelper.DrawFormFringe(this, e.Graphics, RenderHelper.GetImageFormResourceStream("Control.Form.Res.fringe_bkg.png"), Radius);

            //绘制 系统按钮
            SystemButtonManager.DrawSystemButtons(e.Graphics);

            //绘制 icon
            if (Icon != null &amp;&amp; ShowIcon) { e.Graphics.DrawIcon(Icon, IconRect); }

            //绘制文本
            if (Text.Length != 0)
            {
                if (TextWithShadow)
                {
                    using (Image textImg = RenderHelper.GetStringImgWithShadowEffect(Text, TextFont, TextForeColor, TextShadowColor, TextShadowWidth))
                    {
                        e.Graphics.DrawImage(textImg, TextRect.Location);
                    }
                }
                else
                {
                    TextRenderer.DrawText(e.Graphics, Text, TextFont, TextRect, TextForeColor, TextFormatFlags.SingleLine | TextFormatFlags.EndEllipsis);
                }
            }
        } 
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                _systemButtonManager?.Dispose();
                TextFont?.Dispose();
                BackgroundImage?.Dispose();
            }
        } 
        #endregion 
        #region 私有方法

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // Form
            // 
            this.ClientSize = new System.Drawing.Size(528, 385);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "Form";
            this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
            this.ResumeLayout(false); 
        }

        private void FormIni()
        {
            this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;
            this.DoubleBuffered = true;  //设置本窗体双缓冲
            SetStyles();
        }  
        private void SetStyles()
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            UpdateStyles();
        }
        /// &lt;summary&gt;
        /// 通过获取系统消息，调整窗体大小。
        /// &lt;/summary&gt;
        /// &lt;param name="m"&gt;&lt;/param&gt;
        private void WmNcHitTest(ref Message m)
        {
            if (CanResize == true &amp;&amp; WindowState != FormWindowState.Maximized)
            {
                Point mouseLocation = PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y)); //获取鼠标在屏幕的坐标点
                                                                                                      //左上斜角
                if (mouseLocation.X &lt; 5 &amp;&amp; mouseLocation.Y &lt; 5)
                {
                    m.Result = new IntPtr(Win32.HTTOPLEFT);
                    return;
                }
                //右上斜角
                if (mouseLocation.X &gt; Width - 5 &amp;&amp; mouseLocation.Y &lt; 5)
                {
                    m.Result = new IntPtr(Win32.HTTOPRIGHT);
                    return;
                }
                //左下斜角
                if (mouseLocation.X &lt; 5 &amp;&amp; mouseLocation.Y &gt; Height - 5)
                {
                    m.Result = new IntPtr(Win32.HTBOTTOMLEFT);
                    return;
                }
                //右下斜角
                if (mouseLocation.X &gt; Width - 5 &amp;&amp; mouseLocation.Y &gt; Height - 5)
                {
                    m.Result = new IntPtr(Win32.HTBOTTOMRIGHT);
                    return;
                }
                //上
                if (mouseLocation.Y &lt; 5)
                {
                    m.Result = new IntPtr(Win32.HTTOP);
                    return;
                }
                //下
                if (mouseLocation.Y &gt; Height - 5)
                {
                    m.Result = new IntPtr(Win32.HTBOTTOM);
                    return;
                }
                //左
                if (mouseLocation.X &lt; 5)
                {
                    m.Result = new IntPtr(Win32.HTLEFT);
                    return;
                }
                //右
                if (mouseLocation.X &gt; Width - 5)
                {
                    m.Result = new IntPtr(Win32.HTRIGHT);
                    return;
                }
            } 
            m.Result = new IntPtr(Win32.HTCLIENT);
        }

        private void UpdateMaxButton()
        {
            //获取窗体 最大化 状态。
            bool isMax = WindowState == FormWindowState.Maximized;

            if (isMax) //最大化状态，变换按钮图标、提示
            {
                SystemButtonManager.SystemButtonArray[1].NormalImg = RenderHelper.GetImageFormResourceStream("Control.Form.Res.SystemButtons.restore_normal.png");
                SystemButtonManager.SystemButtonArray[1].HighLightImg = RenderHelper.GetImageFormResourceStream("Control.Form.Res.SystemButtons.restore_highlight.png");
                SystemButtonManager.SystemButtonArray[1].DownImg = RenderHelper.GetImageFormResourceStream("Control.Form.Res.SystemButtons.restore_down.png");
                SystemButtonManager.SystemButtonArray[1].ToolTip = "还原";
            }
            else //非最大化状态，变换按钮图标、提示
            {
                SystemButtonManager.SystemButtonArray[1].NormalImg = RenderHelper.GetImageFormResourceStream("Control.Form.Res.SystemButtons.max_normal.png");
                SystemButtonManager.SystemButtonArray[1].HighLightImg = RenderHelper.GetImageFormResourceStream("Control.Form.Res.SystemButtons.max_highlight.png");
                SystemButtonManager.SystemButtonArray[1].DownImg = RenderHelper.GetImageFormResourceStream("Control.Form.Res.SystemButtons.max_down.png");
                SystemButtonManager.SystemButtonArray[1].ToolTip = "最大化";
            }
        }

        protected void UpdateSystemButtonRect()
        {
            //更新关闭按钮位置矩形。
            Rectangle closeRect = new Rectangle(Width - SystemButtonManager.SystemButtonArray[0].NormalImg.Width,
                -1,
                SystemButtonManager.SystemButtonArray[0].NormalImg.Width,
                SystemButtonManager.SystemButtonArray[0].NormalImg.Height);
            SystemButtonManager.SystemButtonArray[0].LocationRect = CloseBox ? closeRect : Rectangle.Empty;

            //Max
            Rectangle MaxButtonRect = new Rectangle(closeRect.X - SystemButtonManager.SystemButtonArray[1].NormalImg.Width,
                -1,
                SystemButtonManager.SystemButtonArray[1].NormalImg.Width,
                SystemButtonManager.SystemButtonArray[1].NormalImg.Height);
            SystemButtonManager.SystemButtonArray[1].LocationRect = MaximizeBox ? MaxButtonRect : Rectangle.Empty;

            //Min
            //如果没有最小化按钮，则画空白矩形，
            if (!MinimizeBox)
            {
                SystemButtonManager.SystemButtonArray[2].LocationRect = Rectangle.Empty;
                return;
            }
            //如果没有最大化按钮，最小化按钮，就画在关闭按钮旁，
            int MinLocation = MaximizeBox ?
                MaxButtonRect.X - SystemButtonManager.SystemButtonArray[2].NormalImg.Width :
                closeRect.X - SystemButtonManager.SystemButtonArray[2].NormalImg.Width;
            Rectangle MinButtonRect = new Rectangle(MinLocation,
                -1,
                SystemButtonManager.SystemButtonArray[2].NormalImg.Width,
                SystemButtonManager.SystemButtonArray[2].NormalImg.Height);
            SystemButtonManager.SystemButtonArray[2].LocationRect = MinButtonRect;
        } 
        #endregion
    }
}
</code></pre>

<p>&nbsp;</p>

<p>代码，目前还有比较多的功能BUG。有能力，有兴趣的朋友，可以一起完善，可以加我们的QQ群：<strong>7261922</strong></p>

<p>&nbsp;</p>]]></description>
</item>
</channel>
</rss>