模仿 msn 写的一个界面程序(源码),希望大家能够喜欢

这是一个使用C#编写的模仿MSN界面的程序,实现了窗口无边框、圆角效果,包含最大化、最小化和关闭按钮。程序中包含了自定义控件如按钮、组合框、标签、文本框等,并且对窗口进行了布局调整和鼠标事件处理,允许用户进行窗口拖动和大小调整操作。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.Resources;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Drawing.Drawing2D;

namespace CSystem
{
    
public partial class frmStart : Form
    
{       

        
private clsFun.DrawOnPint DrawPint = new clsFun.DrawOnPint();
        
private clsFun.GraphicsPathArc PathArc = new clsFun.GraphicsPathArc();
        
private clsFun.CursorType MouseSize = new clsFun.CursorType(00);
        
private Point mouseOffset;
        
private Boolean isMouseDown = false;
        
////任务栏右键菜单
        //----------------------------------------------------------------------------------------------------
        [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
        
public static extern int GetWindowLong(HandleRef hWnd, int nIndex);
        [DllImport(
"user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
        
public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);       
        
void NoneBorder()
        
{
            
int WS_SYSMENU = 0x00080000// 系统菜单
            int WS_MINIMIZEBOX = 0x20000// 最大最小化按钮 0x40000禁止返原按钮,0x10000禁止最小化按钮
            int windowLong = (GetWindowLong(new HandleRef(thisthis.Handle), -16));
            SetWindowLong(
new HandleRef(thisthis.Handle), -16, windowLong | WS_SYSMENU | WS_MINIMIZEBOX);
        }

        
//------------------------------------------------------------------------------------------------------


        
/// <summary>
        
/// 构造
        
/// </summary>

        public frmStart()
        
{
            InitializeComponent();
            SetWindowsForm();
        }


        
private void SetWindowsForm()
        
{
            
////设置窗体标题和位置大小
            base.FormBorderStyle = FormBorderStyle.None;
            
base.BackColor = Color.FromArgb(236246249);
            
base.Text = "Imitation msn";//Center System
            base.Width = 350;
            
base.Height = 660;           
            
base.AutoScroll = false;
            MouseSize.Action 
= null;
            clsFun.DrawOnPint.UFontType mFontType 
= new clsFun.DrawOnPint.UFontType();
            mFontType.mFont 
= new Font("Arial"10, FontStyle.Bold);//Arial, Arial Black, Arial Narrow
            mFontType.mColor = Color.FromArgb(255255255);
            mFontType.mTitle 
= "IIM";
            mFontType.mPen 
= new Pen(Color.FromArgb(112112112), 1);
            DrawPint.SetFontType(mFontType);
            DrawPint.SetDrawPint(
this.Width, this.Height);
            
//绘制圆弧
            PathArc.SetArcParameter(11, DrawPint.Height, DrawPint.Width);
            
this.Region = PathArc.GetGraphicArcValue();
            
//事件
            this.Resize += new EventHandler(frmStart_Resize);
            
//
            CreateComponent();
            NoneBorder();
        }

       
        
private void CreateComponent()
        
{
            UButton[] mBut 
= new UButton[5];
            
for (int i = 0; i < mBut.Length; i++)
            
{
                mBut[i] 
= new UButton();
                mBut[i].Tag 
= i;
                mBut[i].Text 
= i.ToString();
                mBut[i].Click 
+= new EventHandler(frmStart_Max_Min_Close_Click);
                
this.Controls.Add(mBut[i]);
            }

            mBut[
0].SetBmp(Properties.Resources.SysButtonMin,
                Properties.Resources.SysButtonMinHover,
                Properties.Resources.SysButtonMinClick,
                Properties.Resources.SysButtonMin.Width,
                Properties.Resources.SysButtonMin.Height);
            mBut[
1].SetBmp(Properties.Resources.SysButtonMax,
                Properties.Resources.SysButtonMaxHover,
                Properties.Resources.SysButtonMaxClick,
                Properties.Resources.SysButtonMax.Width,
                Properties.Resources.SysButtonMax.Height);
            mBut[
2].SetBmp(Properties.Resources.SysButtonClose,
               Properties.Resources.SysButtonCloseHover,
               Properties.Resources.SysButtonCloseClick,
               Properties.Resources.SysButtonClose.Width,
               Properties.Resources.SysButtonClose.Height);
            mBut[
3].SetBmp(Properties.Resources.log,
               Properties.Resources.log,
               Properties.Resources.log,
               Properties.Resources.log.Width,
               Properties.Resources.log.Height);

            mBut[
4].SetBmp(Properties.Resources.Syslogin,
               Properties.Resources.SysloginHover,
               Properties.Resources.SysloginClick,
               Properties.Resources.Syslogin.Width,
               Properties.Resources.Syslogin.Height);

            ComboBox[] mCB 
= new ComboBox[1];
            
for (int i = 0; i < mCB.Length; i++)
            
{
                mCB[i] 
= new ComboBox();
                mCB[i].Tag 
= i;
                mCB[i].BackColor 
= Color.FromArgb(236246249);
                mCB[i].FlatStyle 
= FlatStyle.Popup;
                mCB[i].Text 
= "nicepaintoem@163.com";              
                
this.Controls.Add(mCB[i]);
            }


            Label[] mLab 
= new Label[7];
            
for (int i = 0; i < mLab.Length; i++)
            
{
                mLab[i] 
= new Label();
                mLab[i].Tag 
= i;
                mLab[i].AutoSize 
= true;
                
if (i <= 2{ mLab[i].ForeColor = Color.FromArgb(696969); }
                
else
                
{ mLab[i].ForeColor = Color.FromArgb(0136228); }
                
this.Controls.Add(mLab[i]);
            }

            mLab[
0].Text = "电子邮件地址(&E):";
            mLab[
1].Text = "密码(&W):";
            mLab[
2].Text = "登陆状态:";
            mLab[
3].Text = "说明:模仿MSN界面制作";
            mLab[
4].Text = "开发平台:Microsoft Visual Studio .net C#";
            mLab[
5].Text = "模仿者:小李";
            mLab[
6].Text = "MSN:nicepaintoem@hotmail.com";           

            UTextBox[] mTebox 
= new UTextBox[1];          
            
for (int i = 0; i < mTebox.Length; i++)
            
{
                mTebox[i] 
= new UTextBox();
                mTebox[i].Tag 
= i;
                mTebox[i].BackColor 
= Color.FromArgb(236246249);
                mTebox[i].ForeColor 
= Color.FromArgb(60198221);
                mTebox[i].BorderStyle 
= BorderStyle.FixedSingle;
                
this.Controls.Add(mTebox[i]);
            }

            mTebox[
0].PasswordChar = (char)'*';
            mTebox[
0].Text = "123456789";
           
            UCheckBox[] mRadioButt 
= new UCheckBox[3];
            
for (int i = 0; i < mRadioButt.Length; i++)
            
{
                mRadioButt[i] 
= new UCheckBox();
                mRadioButt[i].Tag 
= i;
                mRadioButt[i].BackColor 
= Color.FromArgb(236246249);
                mRadioButt[i].ForeColor 
= Color.FromArgb(696969);
                mRadioButt[i].AutoSize 
= true;
                mRadioButt[i].FlatStyle 
= FlatStyle.Flat;
                mRadioButt[i].SetBmp(Properties.Resources.Checkbox_CheckState_false,
                Properties.Resources.Checkbox_CheckState_false_Hover,
                Properties.Resources.Checkbox_CheckState_false_Click,
                Properties.Resources.Checkbox_CheckState_true,
                Properties.Resources.Checkbox_CheckState_true_Hover,
                Properties.Resources.Checkbox_CheckState_true_Click,
                Properties.Resources.Checkbox_CheckState_true.Width,
                Properties.Resources.Checkbox_CheckState_true.Height);
                
this.Controls.Add(mRadioButt[i]);
            }

            mRadioButt[
0].Text = "保存我的信息(&B)";
            mRadioButt[
0].Checked = true;
            mRadioButt[
1].Text = "记住我的密码(&R)";
            mRadioButt[
2].Text = "自动为我登陆(&N)";
           


        }


        
private void frmStart_Max_Min_Close_Click(object sender, EventArgs e)
        
{
            
switch ((int)((UButton)sender).Tag)
            
{
                
case 0:
                    
base.WindowState = FormWindowState.Minimized;
                    
break;
                
case 1:
                    
if (base.WindowState == FormWindowState.Normal)                   
                    
{
                        
this.WindowState = FormWindowState.Maximized;
                        DrawPint.SetDrawPint(
this.Width, this.Height);
                        PathArc.SetArcParameter(
11, DrawPint.Height, DrawPint.Width);
                        
this.Region = PathArc.GetGraphicArcValue();
                        
this.Invalidate();
                    }

                    
else
                    
{
                        
this.WindowState = FormWindowState.Normal;
                        DrawPint.SetDrawPint(
this.Width, this.Height);
                        PathArc.SetArcParameter(
11, DrawPint.Height, DrawPint.Width);
                        
this.Region = PathArc.GetGraphicArcValue();
                        
this.Invalidate();
                    }

                    
break;
                
case 2:
                    
this.Close();
                    
break;
                
default:
                    
break;
            }

        }


        
private void FindingComponent(Control pCTL, ComboBox[] pCB,UButton[] pBut,Label[] pLab,
            UTextBox[] pTebox, UCheckBox[] pRadioButt)
        
{
            
foreach (Control ctl in pCTL.Controls)
            
{
                
if (ctl is ComboBox)
                
{
                    
int i = int.Parse(Convert.ToString(ctl.Tag));
                    pCB[i] 
= (ComboBox)ctl;
                }

                
if (ctl is UButton)
                
{
                    
int i = int.Parse(Convert.ToString(ctl.Tag));
                    pBut[i] 
= (UButton)ctl;
                }

                
if (ctl is Label)
                
{
                    
int i = int.Parse(Convert.ToString(ctl.Tag));
                    pLab[i] 
= (Label)ctl;
                }

                
if (ctl is UTextBox)
                
{
                    
int i = int.Parse(Convert.ToString(ctl.Tag));
                    pTebox[i] 
= (UTextBox)ctl;
                }

                
if (ctl is UCheckBox)
                
{
                    
int i = int.Parse(Convert.ToString(ctl.Tag));
                    pRadioButt[i] 
= (UCheckBox)ctl;
                }

                
if (ctl.Controls.Count > 0)
                
{
                    FindingComponent(ctl, pCB, pBut, pLab, pTebox, pRadioButt);
                }

            }

        }


        
private void frmStart_Resize(object sender, EventArgs e)
        
{
            
//最小化,则不出理
            if (this.WindowState == FormWindowState.Minimized)
            
{
                
return;
            }

            
//正常模式,则限制其大小
            if (this.WindowState == FormWindowState.Normal)
            
{
                
//窗口的宽度和高度750, 450
                if (this.Width < 250this.Width = 250;
                
if (this.Height < 400this.Height = 400;
            }

            
if (this.Width < 1000 || this.Height < 600)
                
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width - 10,
                    Screen.PrimaryScreen.Bounds.Top 
+ 30);

            UTextBox[] fTebox 
= new UTextBox[1];
            ComboBox[] fCB 
= new ComboBox[1];
            UButton[] fBut 
= new UButton[5];
            Label[] fLab 
= new Label[7];
            UCheckBox[] fRadioButt 
= new UCheckBox[3];
            FindingComponent(
this, fCB, fBut, fLab, fTebox, fRadioButt);

            fBut[
0].Location = new Point(this.Width - (fBut[0].Width + fBut[1].Width + fBut[2].Width + 10), 0);
            fBut[
1].Location = new Point(fBut[0].Right, 0);
            fBut[
2].Location = new Point(fBut[1].Right, 0);
            fBut[
3].Location = new Point(this.Width / 2 - Properties.Resources.log.Width / 2,
                Properties.Resources.Topleft.Height 
+ (Properties.Resources.log.Height / 2));

            fLab[
0].Location = new Point(fBut[3].Left - fBut[3].Width / 2, fBut[3].Bottom + 30);
            fLab[
0].AutoSize = true;
            fCB[
0].Location = new Point(fLab[0].Left, fLab[0].Bottom + 2);
            fCB[
0].Size = new Size(fBut[3].Width * 2, fCB[0].Height);

            fLab[
1].Location = new Point(fLab[0].Left, fCB[0].Bottom + 10);
            fLab[
1].AutoSize = true;
            fTebox[
0].Location = new Point(fLab[1].Left, fLab[1].Bottom + 2);
            fTebox[
0].Size = new Size(fCB[0].Width, fTebox[0].Height);

            fLab[
2].Location = new Point(fTebox[0].Left, fTebox[0].Bottom + 10);
            
//

            fRadioButt[
0].Location = new Point(fLab[2].Left, fLab[2].Bottom + 15);
            fRadioButt[
1].Location = new Point(fRadioButt[0].Left, fRadioButt[0].Bottom + 10);
            fRadioButt[
2].Location = new Point(fRadioButt[1].Left, fRadioButt[1].Bottom + 10);

            fBut[
4].Location = new Point(this.Width / 2 - fBut[4].Width / 2, fRadioButt[2].Bottom + 30);
            
//
            fLab[3].Location = new Point(fRadioButt[2].Left, this.Height - 100);
            fLab[
4].Location = new Point(fRadioButt[2].Left, fLab[3].Bottom + 5);
            fLab[
5].Location = new Point(fRadioButt[2].Left, fLab[4].Bottom + 5);
            fLab[
6].Location = new Point(fRadioButt[2].Left, fLab[5].Bottom + 5);
        }



        
重载事件


    }

}
【电力系统】单机无穷大电力系统短路故障暂态稳定Simulink仿真(带说明文档)内容概要:本文档围绕“单机无穷大电力系统短路故障暂态稳定Simulink仿真”展开,提供了完整的仿真模型与说明文档,重点研究电力系统在发生短路故障后的暂态稳定性问题。通过Simulink搭建单机无穷大系统模型,模拟不同类型的短路故障(如三相短路),分析系统在故障期间及切除后的动态响应,包括发电机转子角度、转速、电压和功率等关键参数的变化,进而评估系统的暂态稳定能力。该仿真有助于理解电力系统稳定性机理,掌握暂态过程分析方法。; 适合人群:电气工程及相关专业的本科生、研究生,以及从事电力系统分析、运行与控制工作的科研人员和工程师。; 使用场景及目标:①学习电力系统暂态稳定的基本概念与分析方法;②掌握利用Simulink进行电力系统建模与仿真的技能;③研究短路故障对系统稳定性的影响及提高稳定性的措施(如故障清除时间优化);④辅助课程设计、毕业设计或科研项目中的系统仿真验证。; 阅读建议:建议结合电力系统稳定性理论知识进行学习,先理解仿真模型各模块的功能与参数设置,再运行仿真并仔细分析输出结果,尝试改变故障类型或系统参数以观察其对稳定性的影响,从而深化对暂态稳定问题的理解。
本研究聚焦于运用MATLAB平台,将支持向量机(SVM)应用于数据预测任务,并引入粒子群优化(PSO)算法对模型的关键参数进行自动调优。该研究属于机器学习领域的典型实践,其核心在于利用SVM构建分类模型,同时借助PSO的全局搜索能力,高效确定SVM的最优超参数配置,从而显著增强模型的整体预测效能。 支持向量机作为一种经典的监督学习方法,其基本原理是通过在高维特征空间中构造一个具有最大间隔的决策边界,以实现对样本数据的分类或回归分析。该算法擅长处理小规模样本集、非线性关系以及高维度特征识别问题,其有效性源于通过核函数将原始数据映射至更高维的空间,使得原本复杂的分类问题变得线性可分。 粒子群优化算法是一种模拟鸟群社会行为的群体智能优化技术。在该算法框架下,每个潜在解被视作一个“粒子”,粒子群在解空间中协同搜索,通过不断迭代更新自身速度与位置,并参考个体历史最优解和群体全局最优解的信息,逐步逼近问题的最优解。在本应用中,PSO被专门用于搜寻SVM中影响模型性能的两个关键参数——正则化参数C与核函数参数γ的最优组合。 项目所提供的实现代码涵盖了从数据加载、预处理(如标准化处理)、基础SVM模型构建到PSO优化流程的完整步骤。优化过程会针对不同的核函数(例如线性核、多项式核及径向基函数核等)进行参数寻优,并系统评估优化前后模型性能的差异。性能对比通常基于准确率、精确率、召回率及F1分数等多项分类指标展开,从而定量验证PSO算法在提升SVM模型分类能力方面的实际效果。 本研究通过一个具体的MATLAB实现案例,旨在演示如何将全局优化算法与机器学习模型相结合,以解决模型参数选择这一关键问题。通过此实践,研究者不仅能够深入理解SVM的工作原理,还能掌握利用智能优化技术提升模型泛化性能的有效方法,这对于机器学习在实际问题中的应用具有重要的参考价值。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值