zoukankan      html  css  js  c++  java
  • C#

    运行效果:

    项目目录结构:

    主窗体代码:

      1 using System;
      2 using System.Collections.Generic;
      3 using System.ComponentModel;
      4 using System.Data;
      5 using System.Drawing;
      6 using System.Linq;
      7 using System.Text;
      8 using System.Threading.Tasks;
      9 using System.Windows.Forms;
     10 using Skin.command;
     11 
     12 namespace Skin
     13 {
     14     public partial class Print : Form
     15     {
     16         public Print()
     17         {
     18             InitializeComponent();
     19         }
     20 
     21         /// <summary>
     22         /// 实例化一个操作类对象
     23         /// </summary>
     24         Command Command = new Command();
     25 
     26         #region 加载事件
     27         /// <summary>
     28         /// 加载事件
     29         /// </summary>
     30         /// <param name="sender"></param>
     31         /// <param name="e"></param>
     32         private void Print_Load(object sender, EventArgs e)
     33         {
     34             Command.BindSkin("DiamondBlue.ssk");
     35         }
     36         #endregion
     37 
     38         #region 皮肤
     39 
     40         /// <summary>
     41         /// deepGreen皮肤
     42         /// </summary>
     43         private void deepGreenToolStripMenuItem_Click(object sender, EventArgs e)
     44         {
     45             Command.BindSkin("DeepGreen.ssk");
     46         }
     47 
     48         /// <summary>
     49         /// deepOrange皮肤
     50         /// </summary>
     51         private void deepOrangeToolStripMenuItem_Click(object sender, EventArgs e)
     52         {
     53             Command.BindSkin("DeepOrange.ssk");
     54         }
     55 
     56         /// <summary>
     57         /// WaveColor2皮肤
     58         /// </summary>
     59         private void waveColor2sskToolStripMenuItem_Click(object sender, EventArgs e)
     60         {
     61             Command.BindSkin("WaveColor2.ssk");
     62         }
     63 
     64         /// <summary>
     65         /// WaveColor1皮肤
     66         /// </summary>
     67         private void waveToolStripMenuItem_Click(object sender, EventArgs e)
     68         {
     69             Command.BindSkin("WaveColor1.ssk");
     70         }
     71 
     72         /// <summary>
     73         /// Wave皮肤
     74         /// </summary>
     75         private void waveToolStripMenuItem1_Click(object sender, EventArgs e)
     76         {
     77             Command.BindSkin("Wave.ssk");
     78         }
     79 
     80         /// <summary>
     81         /// DiamondBlue皮肤
     82         /// </summary>
     83         private void diamondBlueToolStripMenuItem_Click(object sender, EventArgs e)
     84         {
     85             Command.BindSkin("DiamondBlue.ssk");
     86         }
     87 
     88         /// <summary>
     89         /// DiamondGreen皮肤
     90         /// </summary>
     91         private void diamondGreenToolStripMenuItem_Click(object sender, EventArgs e)
     92         {
     93             Command.BindSkin("DiamondGreen.ssk");
     94         }
     95 
     96         #endregion
     97 
     98         #region 退出事件
     99         /// <summary>
    100         /// 退出事件
    101         /// </summary>
    102         /// <param name="sender"></param>
    103         /// <param name="e"></param>
    104         private void 退出EToolStripMenuItem_Click(object sender, EventArgs e)
    105         {
    106             Application.Exit();
    107         }
    108         #endregion 
    109     }
    110 }

    command文件夹下的Command.cs代码:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 using System.IO;
     7 using System.Windows.Forms;
     8 using Skin;
     9 
    10 namespace Skin.command
    11 {
    12     public class Command
    13     {
    14 
    15         /// <summary>
    16         /// 实例化一个Skin对象
    17         /// </summary>
    18         Sunisoft.IrisSkin.SkinEngine se = new Sunisoft.IrisSkin.SkinEngine();
    19 
    20         #region 操作路径
    21         /// <summary>
    22         /// 操作路径
    23         /// </summary>
    24         /// <param name="skinfile"></param>
    25         /// <returns></returns>
    26         public static string skinPath(string skinfile)
    27         {
    28             string newSkinPath = string.Empty;
    29 
    30             newSkinPath = skinfile.Replace(@"binDebug", "");
    31 
    32             return newSkinPath;
    33         }
    34         #endregion
    35 
    36         #region 绑定皮肤
    37         /// <summary>
    38         /// 绑定皮肤
    39         /// </summary>
    40         /// <param name="skinname"></param>
    41         public void BindSkin(string skinname)
    42         {
    43             //获取执行根目录
    44             string rootPath = Path.GetDirectoryName(Application.ExecutablePath).ToString();
    45 
    46             //获取存储皮肤文件夹的根目录
    47             string skinFolderPath = Command.skinPath(rootPath);
    48 
    49             //获取皮肤文件的绝对路径
    50             string skinPath = skinFolderPath + "skin\" + skinname;
    51 
    52             //赋值路径信息
    53             se.SkinFile = skinPath;
    54         }
    55         #endregion
    56     }
    57 }

    完成。

  • 相关阅读:
    Java线程面试题 Top 50
    抽象类
    this和super的区别
    引用传递
    【代码】递归调用
    java异常
    抽象类 final
    sublime使用技巧
    zabbix表达式
    tcpdump
  • 原文地址:https://www.cnblogs.com/KTblog/p/4521383.html
Copyright © 2011-2022 走看看