1
lu
2025-04-03 6935dde2d36bf5717115c825b31d28d7a2f22951
DevApp/Gs.DevApp/UserControl/Toast.cs
@@ -1,4 +1,5 @@
using DevExpress.XtraEditors;
using Gs.DevApp.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -15,26 +16,29 @@
    {
        private System.Windows.Forms.Timer tmr;
        private System.Windows.Forms.Timer tmr2;
        /// <summary>
        /// Shows a message windows. 3 sec is the suggested time
        ///
        /// </summary>
        /// <param name="messageText">Message</param>
        /// <param name="vanishingSeconds">Showing time</param>
        public Toast(System.Drawing.Color bgColor,string messageText, int vanishingSeconds = 2)
        /// <param name="it">1成功,-1失败</param>
        /// <param name="messageText"></param>
        /// <param name="vanishingSeconds"></param>
        public Toast(int it, string messageText, int vanishingSeconds = 2)
        {
            InitializeComponent();
            this.Appearance.BackColor = bgColor;
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Toast));
            if (it > 0)
                this.panel1.BackgroundImage = global::Gs.DevApp.Properties.Resources.ok123;
            else
                this.panel1.BackgroundImage = global::Gs.DevApp.Properties.Resources.error123;
            double elapsedTime = 0;
            testo.Text = messageText;
            double vanishingMilliSeconds = vanishingSeconds * 1000;
            // message dimensions
            //this.Width = testo.Width + 50;
            //this.Height = testo.Height + 50;
            //text position
           // testo.Location = new Point((this.Width / 2) - (testo.Width / 2), (this.Height / 2) - (testo.Height / 2));
            // testo.Location = new Point((this.Width / 2) - (testo.Width / 2), (this.Height / 2) - (testo.Height / 2));
            //first timer
            tmr = new System.Windows.Forms.Timer();
            tmr.Tick += delegate