广告位联系
返回顶部
分享到

C#实现窗体换肤的教程方法

C#教程 来源:互联网 作者:佚名 发布时间:2024-01-23 23:33:44 人浏览
摘要

实践过程 效果 代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

实践过程

效果

代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

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));

    }

}


版权声明 : 本文内容来源于互联网或用户自行发布贡献,该文观点仅代表原作者本人。本站仅提供信息存储空间服务和不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权, 违法违规的内容, 请发送邮件至2530232025#qq.cn(#换@)举报,一经查实,本站将立刻删除。
原文链接 :
相关文章
  • QT升级6.0以上版本遇到问题以及解决方法
    最近重装QT的时候发现QT已经升级到了6.0以上的新版本。既然是重装,那就跟进新的更新。更新新的QT后以前的旧版本建立的工程,自然会出
  • C#实现窗体换肤的教程方法

    C#实现窗体换肤的教程方法
    实践过程 效果 代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 5
  • C#递归应用之实现JS文件的自动引用介绍

    C#递归应用之实现JS文件的自动引用介绍
    两张表,分别是 :sys_tbl,和 sys_field,其中:sys_tbl 是系统所有表的信息,包含两个字段 :code(表名),name(表描述信息);sys_fld 是记录第张
  • C#纯技术之Class写入Json介绍

    C#纯技术之Class写入Json介绍
    C# Class写入Json 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 /// summary /// 写入json文件 /// /summary /// param name=obj/param /// param name=save
  • C#实体类转换的两种方式总结
    C#实体类转换方式 将一个实体类的数据赋值到另一个实体类中(亦或者实现深拷贝)。 以下提供两种方式 一种是序列化 一种是泛型+反射
  • C#中的时间显示格式(12小时制VS24小时制)介绍
    C#时间显示格式 一起看下: 24小时制 1 this.toolStripStatusLabel1.Text = 您好,欢迎来到XXXX控制系统! + 当前时间: + DateTime.Now.ToString(yyyy-MM-dd HH
  • C#中使用Spire.doc对word的操作方式介绍

    C#中使用Spire.doc对word的操作方式介绍
    使用Spire.doc对word的操作 在最近的工程中我们要处理一些word文档。通过在网上的大量搜索,我发现大多数软件功能不是不完整就是有重复。
  • C#纯技术之Class写入Json介绍

    C#纯技术之Class写入Json介绍
    C# Class写入Json 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 /// summary /// 写入json文件 /// /summary /// param name=obj/param /// param name=save
  • C#实体类转换的两种方式介绍
    C#实体类转换方式 将一个实体类的数据赋值到另一个实体类中(亦或者实现深拷贝)。 以下提供两种方式 一种是序列化 一种是泛型+反射
  • 在C#中构造自定义属性的详细介绍
    属性用于向程序添加元数据,例如编译器指令和其他信息,例如注释、描述、方法和类。 .Net Framework 允许创建可用于存储声明性信息并可在
  • 本站所有内容来源于互联网或用户自行发布,本站仅提供信息存储空间服务,不拥有版权,不承担法律责任。如有侵犯您的权益,请您联系站长处理!
  • Copyright © 2017-2022 F11.CN All Rights Reserved. F11站长开发者网 版权所有 | 苏ICP备2022031554号-1 | 51LA统计