首页 > 编程语言 >WinCE5.0下实现透明背景按钮(.net C#) 个人实验

WinCE5.0下实现透明背景按钮(.net C#) 个人实验

时间:2023-04-06 18:03:53浏览次数:39  
标签:C# Image WinCE5.0 System pictureBox1 pictureBox3 new net Drawing


参考了WinCE5.0下实现透明背景按钮(.net C#)这篇文章后,本着不模仿的态度去做,结果发现还是原先作者的思路比较好,自己的做法

虽然比较简单当时图片得做很多张,效果其实也差不多,而且可维护性并不强,先把我自己做的贴出来。

希望自己多敲敲,能找出更简单的方案来

目录试图:

WinCE5.0下实现透明背景按钮(.net C#) 个人实验_object

效果:

WinCE5.0下实现透明背景按钮(.net C#) 个人实验_wince_02

 

直接贴代码:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
 
namespace whiteButton2
{
    public partial class Form1 : Form
    {
        private string currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);//获取PDA路径
        private Bitmap bg, title;//
 
        public Form1()
        {
            this.WindowState = FormWindowState.Maximized;
            this.FormBorderStyle = FormBorderStyle.None;
            this.ControlBox = false;
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {

 
            bg = new Bitmap(currentPath + @"\Resources\bg293.jpg");
            title = new Bitmap(currentPath + @"\Resources\title.jpg");
        }
 
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphics;
            graphics = e.Graphics;
            graphics.DrawImage(bg,0,0);
            graphics.DrawImage(title,0,0);
        }
 
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
            //各类事件及方法
        }
 
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
        }
 
        private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
        }
 
        private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
        }
 
    }
}


 

Form1.Designer.cs界面代码:


namespace whiteButton2
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        private System.Windows.Forms.MainMenu mainMenu1;
 
        /// <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()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.pictureBox2 = new System.Windows.Forms.PictureBox();
            this.pictureBox3 = new System.Windows.Forms.PictureBox();
            this.pictureBox4 = new System.Windows.Forms.PictureBox();
            this.SuspendLayout();
            // 
            // pictureBox1
            // 
            this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
            this.pictureBox1.Location = new System.Drawing.Point(3, 46);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(111, 40);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
            this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
            this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);
            // 
            // pictureBox2
            // 
            this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
            this.pictureBox2.Location = new System.Drawing.Point(3, 49);
            this.pictureBox2.Name = "pictureBox2";
            this.pictureBox2.Size = new System.Drawing.Size(112, 39);
            this.pictureBox2.Visible = false;
            // 
            // pictureBox3
            // 
            this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
            this.pictureBox3.Location = new System.Drawing.Point(121, 46);
            this.pictureBox3.Name = "pictureBox3";
            this.pictureBox3.Size = new System.Drawing.Size(110, 40);
            this.pictureBox3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox3_MouseDown);
            this.pictureBox3.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox3_MouseUp);
            // 
            // pictureBox4
            // 
            this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
            this.pictureBox4.Location = new System.Drawing.Point(121, 46);
            this.pictureBox4.Name = "pictureBox4";
            this.pictureBox4.Size = new System.Drawing.Size(110, 40);
            this.pictureBox4.Visible = false;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.AutoScroll = true;
            this.ClientSize = new System.Drawing.Size(240, 268);
            this.Controls.Add(this.pictureBox3);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.pictureBox2);
            this.Controls.Add(this.pictureBox4);
            this.Menu = this.mainMenu1;
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
            this.ResumeLayout(false);
 
        }
 
        #endregion
 
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.PictureBox pictureBox2;
        private System.Windows.Forms.PictureBox pictureBox3;
        private System.Windows.Forms.PictureBox pictureBox4;
    }
}

PDA目录下如果没有图片会报(指的是PDA端 不是项目根目录下):

WinCE5.0下实现透明背景按钮(.net C#) 个人实验_c#_03

 

解决方法:

通过同步软件把图片目录拷过去

WinCE5.0下实现透明背景按钮(.net C#) 个人实验_.net_04

找到 我的WINDOWS移动设备

WinCE5.0下实现透明背景按钮(.net C#) 个人实验_resources_05

粘贴进去就好了

WinCE5.0下实现透明背景按钮(.net C#) 个人实验_wince_06

 


 

 

标签:C#,Image,WinCE5.0,System,pictureBox1,pictureBox3,new,net,Drawing
From: https://blog.51cto.com/u_15999672/6173929

相关文章

  • winCE 页面绘制 例子一则
     效果如下:   usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingSystem.Reflection;usingSystem.Drawing.Imaging;n......
  • canvas基础1
    canvas基础1一、canvas是HTML5提供的画画本//创建<canvas>元素时至少要设置其width和height属性,这样才能告诉浏览器在大面积上绘图。//出现在开始和结束标签之间的内容是后备数据,会在浏览器不支持<canvas>元素时显示。<canvasid="drawing"width="200"height=......
  • C++,OpenCV-颜色模型转换(4)
    HSV颜色模型HSV模型HSV(Hue,Saturation,Value)根据颜色直观特性创建的一种颜色空间,也称六角锥体模型(HexconeModel),参数分别为色调(H),饱和度(S),明度(V)色调H用角度度量,取值范围为0°~360°,从红色开始按逆时针方向计算,红色为0°,绿色为120°,蓝色为240°。它们的补色是:黄色为60°,青色为180°......
  • 威纶通与三菱PLC条码枪解码程序本程序是威纶通触摸屏USB接头直接插条形码扫码枪,得到的
    威纶通与三菱PLC条码枪解码程序本程序是威纶通触摸屏USB接头直接插条形码扫码枪,得到的数据传送到PLC中进行解码,转化成为PLC能识别的十进制,用于需要使用扫码枪设定数据是非常实用,当然带485通信的扫码枪直接与PLC通信不需要这一步,到时带485枪比较贵,普通的USB就100左右,带串口的通常上......
  • 【庖丁解牛】图像处理库: 解决WeCenter至少需要有GD图像处理库才能正常运行
    错误复现以下是安装wecenter时候的报错信息:zmedu致码高胜寒解决方案一[root@xinsz08install]#yuminstallphp-mysqlnd解决方案二如果方案一不管用,建议重新编译php,亲测有效:在从新编译之前先安装依赖包:yum-yinstallcurl-develyum-yinstallpostgresql-develyuminstall......
  • 灰狼优化算法GWO优化SVM支持向量机惩罚参数c和核函数参数g
    灰狼优化算法GWO优化SVM支持向量机惩罚参数c和核函数参数g,有例子,易上手,简单粗暴,替换数据即可,分类问题。仅适应于windows系统YID:6999630206572076......
  • 【庖丁解牛】configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd
    问题复现configure:WARNING:unrecognizedoptions:--with-mcrypt,--enable-gd-native-ttf问题分析php7.2以后不支持–with-mcrypt,--enable-gd-native-ttf这两个参数,需要去掉问题解决php编译我一开始用的源码:[[email protected]]#'./configure''--prefix=/app/php''-......
  • 2009年NOIP提高组真题-HanKson的趣味题(GCD&LCM优化)
    2009年NOIP提高组真题-HanKson的趣味题(GCD&LCM优化)本题的编码是用Python实现的,C++的思路也是相同的。希望本文能够帮助到你!题目:暴力法:直接根据题目的要求写:frommathimportgcddeflcm(a,b):returna*b//gcd(a,b)n=int(input())for_inrange(n):cnt=......
  • 【Linux】apache服务相关概念及安装
    文章目录web服务概述什么是apachehttpd工作模型apache的安装及应用1.apache的安装2.启动:3.设置开机启动:4.查看httpd的进程及端口号httpd的程序环境查看运行情况方法1:浏览器输入IP,可以查看到已经运行方法2:elinks命令测试总结web服务概述WEB服务器也称为WWW(WORLDWIDEWEB,万......
  • 【C#】Npoi.Mapper 具体操作方法
    前言    我们在日常开发中对Excel的操作可能会比较频繁,好多功能都会涉及到Excel的操作。在.NetCore中大家可能使用Npoi比较多,这款软件功能也十分强大,而且接近原始编程。但是直接使用Npoi大部分时候我们可能都会自己封装一下,毕竟根据二八原则,我们百分之八十的场景可能都是进......