Private lab with transparent background button (. net C #) under WinCE5.0

Source: Internet
Author: User

After referring to the article "implement transparent background button (. net C #)" under WinCE5.0, I did it in a non-imitation manner. The results showed that the author had better ideas and practice.

Although it was relatively simple, I had to make a lot of images at that time, and the effect was actually similar, and the maintainability was not strong. I posted my own images first.

I hope I can find a simpler solution

Directory attempt:

 

Effect:

 

 

Directly paste the Code:

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); // obtain the PDA Path
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 picturebox#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 ")));
// Events and Methods
}
Private void picturebox#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 interface code:

Namespace whiteButton2
{
Partial class Form1
{
/// <Summary>
/// Required designer variables.
/// </Summary>
Private System. ComponentModel. IContainer components = null;
Private System. Windows. Forms. MainMenu mainMenu1;
/// <Summary>
/// Clear all resources in use.
/// </Summary>
/// <Param name = "disposing"> If the managed resource should be released, the value is true; otherwise, the value is false. </Param>
Protected override void Dispose (bool disposing)
{
If (disposing & (components! = Null ))
{
Components. Dispose ();
}
Base. Dispose (disposing );
}
# Region code generated by Windows Form Designer
/// <Summary>
/// The designer supports the required methods-do not
/// Use the code editor to modify the content of this method.
/// </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. picturebox#mousedown );
This. pictureBox1.MouseUp + = new System. Windows. Forms. MouseEventHandler (this. picturebox#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. form#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;
}
}
 
 

If there is no image in the PDA directory, it will be reported (that is, the PDA end is not under the project root directory ):

 

 

Solution:

Copy the image directory through synchronization software

 

Find my WINDOWS mobile device

 

Paste it in.

 
Author: sat472291519

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.