C # implement Toast similar to Android

Source: Internet
Author: User
Public partial class ToastForm: Form {// <summary> // display millisecond // </summary> private int _ wait_ms = 1000; public ToastForm (double seconds, string text, Form parent): this (seconds, text, parent, Color. blue, 15, ContentAlignment. topCenter) {} public ToastForm (double seconds, string text, Form parent, int font_size): this (seconds, text, parent, Color. blue, font_size, ContentAlignment. topCenter ){} Public ToastForm (double seconds, string text, Form parent, Color text_color, int font_size, ContentAlignment textAlignment) {InitializeComponent (); _ wait_ms = (int) (seconds * 1000 ); if (font_size! = LbShow. font. size) lbShow. font = new Font (lbShow. font. name, font_size, lbShow. font. style); lbShow. text = text; if (lbShow. textAlign! = TextAlignment) lbShow. textAlign = textAlignment; this. lbShow. foreColor = text_color; this. left = parent. left + (parent. width-this. width)/2; this. top = parent. top + (parent. height-this. height)/2;} private void ToastForm_Load (object sender, EventArgs e) {Thread t = new Thread (ThreadStart) delegate {Thread. sleep (_ wait_ms); try {this. invoke (new EventHandler (s1, e1) => this. close ();} catch {}}); t. isBackground = true; t. start ();}}

 

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.