中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

C#怎么實現窗體換膚

發布時間:2023-01-03 10:38:05 來源:億速云 閱讀:108 作者:iii 欄目:開發技術

這篇“C#怎么實現窗體換膚”文章的知識點大部分人都不太理解,所以小編給大家總結了以下內容,內容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“C#怎么實現窗體換膚”文章吧。

效果

C#怎么實現窗體換膚

代碼

C#怎么實現窗體換膚

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

以上就是關于“C#怎么實現窗體換膚”這篇文章的內容,相信大家都有了一定的了解,希望小編分享的內容對大家有幫助,若想了解更多相關的知識內容,請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

清原| 株洲市| 太仆寺旗| 永泰县| 昭通市| 女性| 清远市| 平果县| 高唐县| 青田县| 苏尼特右旗| 黄梅县| 土默特左旗| 北川| 济源市| 彝良县| 奉新县| 称多县| 牟定县| 石林| 天祝| 通城县| 始兴县| 新河县| 湘潭县| 丰城市| 周口市| 青阳县| 漳平市| 龙井市| 绥江县| 西峡县| 沛县| 晋州市| 卓尼县| 个旧市| 射洪县| 即墨市| 白银市| 武鸣县| 噶尔县|