Form1.cs

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

namespace BarterSkin
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

public static int var_bar = 1;

private void barter(int n)
        {
            switch (n)
            {
                case 1:
                    {
                        this.Width = Properties.Resources.sy1_01.Width;
                        this.Height = Properties.Resources.sy1_01.Height + Properties.Resources.sy1_02.Height - 5;
                        panel_Title.BackgroundImage = Properties.Resources.sy1_01;
                        panel_ALL.BackgroundImage = Properties.Resources.sy1_02;
                        pictureBox_Min.Image = null;
                        pictureBox_Min.Image = Properties.Resources.sy1_04;
                        pictureBox_Max.Image = null;
                        pictureBox_Max.Image = Properties.Resources.sy1_05;
                        pictureBox_Close.Image = null;
                        pictureBox_Close.Image = Properties.Resources.sy1_03;
                        var_bar = 1;
                        break;
                    }
                case 2:
                    {
                        this.Width = Properties.Resources.sy2_01.Width;
                        this.Height = Properties.Resources.sy2_01.Height + Properties.Resources.sy2_02.Height - 5;
                        panel_Title.BackgroundImage = Properties.Resources.sy2_01;
                        panel_ALL.BackgroundImage = Properties.Resources.sy2_02;
                        pictureBox_Min.Image = null;
                        pictureBox_Min.Image = Properties.Resources.sy2_04;
                        pictureBox_Max.Image = null;
                        pictureBox_Max.Image = Properties.Resources.sy2_05;
                        pictureBox_Close.Image = null;
                        pictureBox_Close.Image = Properties.Resources.sy2_03;
                        var_bar = 2;
                        break;
                    }
                case 3:
                    {
                        this.Width = Properties.Resources.sy3_01.Width;
                        this.Height = Properties.Resources.sy3_01.Height + Properties.Resources.sy3_02.Height - 5;
                        panel_Title.BackgroundImage = Properties.Resources.sy3_01;
                        panel_ALL.BackgroundImage = Properties.Resources.sy3_02;
                        pictureBox_Min.Image = null;
                        pictureBox_Min.Image = Properties.Resources.sy3_04;
                        pictureBox_Max.Image = null;
                        pictureBox_Max.Image = Properties.Resources.sy3_05;
                        pictureBox_Close.Image = null;
                        pictureBox_Close.Image = Properties.Resources.sy3_03;
                        var_bar = 3;
                        break;
                    }
            }
            barterShow(n);
        }

private void barterShow(int n)
        {
            ToolS_1.Checked = false;
            ToolS_2.Checked = false;
            ToolS_3.Checked = false;
            switch (n)
            {
                case 1: ToolS_1.Checked = true; break;
                case 2: ToolS_2.Checked = true; break;
                case 3: ToolS_3.Checked = true; break;
            }

}

private void Form1_Load(object sender, EventArgs e)
        {
            barter(1);
        }

#region  设置窗体的最大化、最小化和关闭按钮的单击事件
        /// <summary>
        /// 设置窗体的最大化、最小化和关闭按钮的单击事件
        /// </summary>
        /// <param Frm_Tem="Form">窗体</param>
        /// <param n="int">标识</param>
        public void FrmClickMeans(Form Frm_Tem, int n)
        {
            switch (n)
            {
                case 0:
                    Frm_Tem.WindowState = FormWindowState.Minimized;
                    break;
                case 1:
                    {
                        if (Frm_Tem.WindowState == FormWindowState.Maximized)
                            Frm_Tem.WindowState = FormWindowState.Normal;
                        else
                            Frm_Tem.WindowState = FormWindowState.Maximized;
                        break;
                    }
                case 2:
                    Frm_Tem.Close();
                    break;
            }
        }
        #endregion

#region  控制图片的切换状态
        /// <summary>
        /// 控制图片的切换状态
        /// </summary>
        /// <param Frm_Tem="Form">要改变图片的对象</param>
        /// <param n="int">标识</param>
        /// <param ns="int">移出移入标识</param>
        public static PictureBox Tem_PictB = new PictureBox();
        public void ImageSwitch(object sender, int n, int ns)
        {
            Tem_PictB = (PictureBox)sender;

switch (n)
            {
                case 0:
                    {
                        Tem_PictB.Image = null;
                        if (ns == 0)
                        {
                            switch (var_bar)
                            {
                                case 1: Tem_PictB.Image = Properties.Resources.sy1_04_1; break;
                                case 2: Tem_PictB.Image = Properties.Resources.sy2_04_1; break;
                                case 3: Tem_PictB.Image = Properties.Resources.sy3_04_1; break;
                            }
                        }
                        if (ns == 1)
                        {
                            switch (var_bar)
                            {
                                case 1: Tem_PictB.Image = Properties.Resources.sy1_04; break;
                                case 2: Tem_PictB.Image = Properties.Resources.sy2_04; break;
                                case 3: Tem_PictB.Image = Properties.Resources.sy3_04; break;
                            }
                        }
                        break;
                    }
                case 1:
                    {
                        Tem_PictB.Image = null;
                        if (ns == 0)
                        {
                            switch (var_bar)
                            {
                                case 1: Tem_PictB.Image = Properties.Resources.sy1_05_1; break;
                                case 2: Tem_PictB.Image = Properties.Resources.sy2_05_1; break;
                                case 3: Tem_PictB.Image = Properties.Resources.sy3_05_1; break;
                            }
                        }
                        if (ns == 1)
                        {
                            switch (var_bar)
                            {
                                case 1: Tem_PictB.Image = Properties.Resources.sy1_05; break;
                                case 2: Tem_PictB.Image = Properties.Resources.sy2_05; break;
                                case 3: Tem_PictB.Image = Properties.Resources.sy3_05; break;
                            }
                        }
                        break;
                    }
                case 2:
                    {
                        Tem_PictB.Image = null;
                        if (ns == 0)
                        {
                            switch (var_bar)
                            {
                                case 1: Tem_PictB.Image = Properties.Resources.sy1_03_1; break;
                                case 2: Tem_PictB.Image = Properties.Resources.sy2_03_1; break;
                                case 3: Tem_PictB.Image = Properties.Resources.sy3_03_1; break;
                            }
                        }
                        if (ns == 1)
                        {
                            switch (var_bar)
                            {
                                case 1: Tem_PictB.Image = Properties.Resources.sy1_03; break;
                                case 2: Tem_PictB.Image = Properties.Resources.sy2_03; break;
                                case 3: Tem_PictB.Image = Properties.Resources.sy3_03; break;
                            }
                        }
                        break;
                    }
            }
        }
        #endregion

private void pictureBox_Close_Click(object sender, EventArgs e)
        {
            FrmClickMeans(this, Convert.ToInt16(((PictureBox)sender).Tag.ToString()));
        }

private void pictureBox_Close_MouseEnter(object sender, EventArgs e)
        {
            ImageSwitch(sender, Convert.ToInt16(((PictureBox)sender).Tag.ToString()), 0);
        }

private void pictureBox_Close_MouseLeave(object sender, EventArgs e)
        {
            ImageSwitch(sender, Convert.ToInt16(((PictureBox)sender).Tag.ToString()), 1);
        }

private void ToolS_1_Click(object sender, EventArgs e)
        {
            barter(Convert.ToInt32(((ToolStripMenuItem)sender).Tag));
        }

}
}

Form1.designer.cs

namespace BarterSkin
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

/// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

#region Windows 窗体设计器生成的代码

/// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.pictureBox_Close = new System.Windows.Forms.PictureBox();
            this.panel_Title = new System.Windows.Forms.Panel();
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.ToolS_1 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolS_2 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolS_3 = new System.Windows.Forms.ToolStripMenuItem();
            this.pictureBox_Min = new System.Windows.Forms.PictureBox();
            this.pictureBox_Max = new System.Windows.Forms.PictureBox();
            this.panel_ALL = new System.Windows.Forms.Panel();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_Close)).BeginInit();
            this.panel_Title.SuspendLayout();
            this.contextMenuStrip1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_Min)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_Max)).BeginInit();
            this.SuspendLayout();
            //
            // pictureBox_Close
            //
            this.pictureBox_Close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.pictureBox_Close.Location = new System.Drawing.Point(269, 11);
            this.pictureBox_Close.Name = "pictureBox_Close";
            this.pictureBox_Close.Size = new System.Drawing.Size(20, 20);
            this.pictureBox_Close.TabIndex = 3;
            this.pictureBox_Close.TabStop = false;
            this.pictureBox_Close.Tag = "2";
            this.pictureBox_Close.MouseLeave += new System.EventHandler(this.pictureBox_Close_MouseLeave);
            this.pictureBox_Close.Click += new System.EventHandler(this.pictureBox_Close_Click);
            this.pictureBox_Close.MouseEnter += new System.EventHandler(this.pictureBox_Close_MouseEnter);
            //
            // panel_Title
            //
            this.panel_Title.ContextMenuStrip = this.contextMenuStrip1;
            this.panel_Title.Controls.Add(this.pictureBox_Close);
            this.panel_Title.Controls.Add(this.pictureBox_Min);
            this.panel_Title.Controls.Add(this.pictureBox_Max);
            this.panel_Title.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel_Title.Location = new System.Drawing.Point(0, 0);
            this.panel_Title.Name = "panel_Title";
            this.panel_Title.Size = new System.Drawing.Size(298, 37);
            this.panel_Title.TabIndex = 2;
            //
            // contextMenuStrip1
            //
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolS_1,
            this.ToolS_2,
            this.ToolS_3});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(101, 70);
            //
            // ToolS_1
            //
            this.ToolS_1.Name = "ToolS_1";
            this.ToolS_1.Size = new System.Drawing.Size(100, 22);
            this.ToolS_1.Tag = "1";
            this.ToolS_1.Text = "换肤1";
            this.ToolS_1.Click += new System.EventHandler(this.ToolS_1_Click);
            //
            // ToolS_2
            //
            this.ToolS_2.Name = "ToolS_2";
            this.ToolS_2.Size = new System.Drawing.Size(100, 22);
            this.ToolS_2.Tag = "2";
            this.ToolS_2.Text = "换肤2";
            this.ToolS_2.Click += new System.EventHandler(this.ToolS_1_Click);
            //
            // ToolS_3
            //
            this.ToolS_3.Name = "ToolS_3";
            this.ToolS_3.Size = new System.Drawing.Size(100, 22);
            this.ToolS_3.Tag = "3";
            this.ToolS_3.Text = "换肤3";
            this.ToolS_3.Click += new System.EventHandler(this.ToolS_1_Click);
            //
            // pictureBox_Min
            //
            this.pictureBox_Min.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.pictureBox_Min.Location = new System.Drawing.Point(217, 11);
            this.pictureBox_Min.Name = "pictureBox_Min";
            this.pictureBox_Min.Size = new System.Drawing.Size(20, 20);
            this.pictureBox_Min.TabIndex = 2;
            this.pictureBox_Min.TabStop = false;
            this.pictureBox_Min.Tag = "0";
            this.pictureBox_Min.MouseLeave += new System.EventHandler(this.pictureBox_Close_MouseLeave);
            this.pictureBox_Min.Click += new System.EventHandler(this.pictureBox_Close_Click);
            this.pictureBox_Min.MouseEnter += new System.EventHandler(this.pictureBox_Close_MouseEnter);
            //
            // pictureBox_Max
            //
            this.pictureBox_Max.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.pictureBox_Max.Location = new System.Drawing.Point(243, 11);
            this.pictureBox_Max.Name = "pictureBox_Max";
            this.pictureBox_Max.Size = new System.Drawing.Size(20, 20);
            this.pictureBox_Max.TabIndex = 0;
            this.pictureBox_Max.TabStop = false;
            this.pictureBox_Max.Tag = "1";
            this.pictureBox_Max.MouseLeave += new System.EventHandler(this.pictureBox_Close_MouseLeave);
            this.pictureBox_Max.Click += new System.EventHandler(this.pictureBox_Close_Click);
            this.pictureBox_Max.MouseEnter += new System.EventHandler(this.pictureBox_Close_MouseEnter);
            //
            // panel_ALL
            //
            this.panel_ALL.ContextMenuStrip = this.contextMenuStrip1;
            this.panel_ALL.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel_ALL.Location = new System.Drawing.Point(0, 37);
            this.panel_ALL.Name = "panel_ALL";
            this.panel_ALL.Size = new System.Drawing.Size(298, 157);
            this.panel_ALL.TabIndex = 3;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(298, 194);
            this.Controls.Add(this.panel_ALL);
            this.Controls.Add(this.panel_Title);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_Close)).EndInit();
            this.panel_Title.ResumeLayout(false);
            this.contextMenuStrip1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_Min)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_Max)).EndInit();
            this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.PictureBox pictureBox_Close;
        private System.Windows.Forms.Panel panel_Title;
        private System.Windows.Forms.PictureBox pictureBox_Min;
        private System.Windows.Forms.PictureBox pictureBox_Max;
        private System.Windows.Forms.Panel panel_ALL;
        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
        private System.Windows.Forms.ToolStripMenuItem ToolS_1;
        private System.Windows.Forms.ToolStripMenuItem ToolS_2;
        private System.Windows.Forms.ToolStripMenuItem ToolS_3;
    }
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace BarterSkin
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

C#窗体换肤的更多相关文章

  1. .NET vs2010中使用IrisSkin2.dll轻松实现winForm窗体换肤功能

    IrisSkin2.dll是一款很不错的免费皮肤控件,利用它可以轻松的实现winForm窗体换肤! 网上很多朋友说在VS2010中不能使用IrisSkin2.dll,我这里提供一个取巧的办法. Iri ...

  2. C#.NET vs2010中使用IrisSkin4.dll轻松实现WinForm窗体换肤功能

    IrisSkin2.dll是一款很不错的免费皮肤控件,利用它可以轻松的实现WinForm窗体换肤 然而IrisSkin2.dll只能在.NET Faremwork 4.0以及之前的版本使用,所以要在V ...

  3. Winform- IrisSkin.dll轻松实现窗体换肤功能

    IrisSkin2.dll是一款很不错的免费皮肤控件,利用它可以轻松的实现winForm窗体换肤 然而IrisSkin2.dll只能在.NET Faremwork 4.0以及之前的版本使用,所以要在V ...

  4. VS窗体换肤

    1.首先我们要下载一个皮肤 vs窗体皮肤下载官网:http://irisskin.software.informer.com/download/ 2.创建一个lib文件夹 把下载好的引用放到里面 3. ...

  5. C# 实现对窗体(Form)换肤

    http://www.csharpwin.com/csharpresource/2992.shtml 一直想写一个比较完整的.容易扩展的窗体换肤的方案,由于时间问题,都没去实现这个想法.现在有朋友提出 ...

  6. WPF换肤之五:创建漂亮的窗体

    原文:WPF换肤之五:创建漂亮的窗体 换肤效果 经过了前面四章的讲解,我们终于知道了如何拖拉窗体使之改变大小,也知道了如何处理鼠标事件,同时,也知道了如何利用更好的编写方式来编写一个方便实用和维护的换 ...

  7. C# 轻松实现对窗体(Form)换肤[转]

    一直想写一个比较完整的.容易扩展的窗体换肤的方案,由于时间问题,都没去实现这个想法.现在有朋友提出需要,就把以前写的重新拿出来看了一篇,花了些时间,做出了现在的这个换肤的方案.实现的过程中遇到了不少问 ...

  8. C# Winform中窗体的美化—— 用IrisSkin轻松实现换肤功能

    今天经前辈提醒才知道winform窗体还有美化工具,呵呵,不得不说,孤陋寡闻了.下面总结一下irisskin2的使用步骤和遇到的问题及解决办法. 1.网址:http://www.pc6.com/sof ...

  9. C# Winform 换肤

    本来计划接着上篇 C# Winform模仿百度日历,发现一时半会写不完,只写了一小半还不全,暂且搁置下.现在计划下班后每天至少写一篇博客,未能完成的等周末(不加班都情况)补充完整. 本篇博客窗体换肤, ...

随机推荐

  1. MySQL事务(三)

    一.事务(Innodb锁)的隔离级别概述 并发事务带来的问题: 更新丢失(lost update):当两个或多个事务选择同一行,然后基于最初选定的值更新该行时,由于每个事务都不知道其他事务的存在,就会 ...

  2. CentOS下yum命令详解

    CentOS下yum命令详解 Yum: 即Yellowdog Update Modifier,是一种基于rpm的包管理工具 yum命令使用示例 显示yum仓库 显示所有仓库 yum repolist ...

  3. jquery选择器和基本操作

    定义:jQuery 对象就是通过jQuery包装DOM对象后产生的对象.jQuery 对象是 jQuery 独有的. 如果一个对象是 jQuery 对象, 那么它就可以使用 jQuery 里的方法: ...

  4. day32 通道 数据共享 进程池

    1.管道 格式: conn1,conn2 = Pipe() 管道的两端可以进行全双工通信   如图 进程2创建了管道,它就拥有管道两端的信息,每个端点都能收发信息,它把端点信息传给进程1和进程3 ,它 ...

  5. 『算法设计_伪代码』贪心算法_最短路径Dijkstra算法

    Dijkstra算法实际上是一个贪婪算法(Greedy algorithm).因为该算法总是试图优先访问每一步循环中距离起始点最近的下一个结点.Dijkstra算法的过程如下图所示. 初始化 给定图中 ...

  6. 漏洞复现——bash远程解析命令执行漏洞

    漏洞描述:Bash脚本在解析某些特殊字符串时出现逻辑错误导致可以执行后面的命令,在一些cgi脚本中,数据是通过环境变量来传递的,这样就会形成该漏洞 漏洞原理:bash通过以函数名作为环境变量名,以“( ...

  7. 【Java】【6】JDK8 Stream操作整理

    摘要: 1,List<EntityOld>转换为List<EntityNew> List<EntityOld> list = oldList; List<En ...

  8. Oracle 用户,角色,权限等

    权限管理是 Oracle 系统的精华,不同用户登录到同一数据库中,可能看到不同数量的表,拥有不同的权限.Oracle 的权限分为系统权限和数据对象权限,共一百多种,如果单独对用户授权,很囧,有一些用户 ...

  9. js中用来操作数组的相关的方法

    push向数组的的末尾添加新的内容 unshift向数组的开头增加新的内容 slice(n,m)从索引n开始(包含n),找到索引m处(不包含m),然后把找到的内容作为一个新的数组返回,原有的数组不改变 ...

  10. web服务器-----Tomcat 7.0安装

    下载地址:http://tomcat.apache.org/ 1.下载 2.解压缩---c盘 3.运行bin\startup.bat 启动Tomcat服务器 运行bin\shutdown.bat关闭T ...