zoukankan      html  css  js  c++  java
  • Chapter 3. WinForm(PictureBox控件)

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace 图片控件
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void pictureBox1_Click(object sender, EventArgs e)
            {
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                //设置图片显示方式:平铺
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                
                //获得指定一种图片的路径
                pictureBox1.Image = Image.FromFile(@"C:UsersAdministratorDesktop新建文件夹1.jpg");
            }
    
            int i = 0;
    
            //获得指定文件夹中的所有文件路径
            string[] path = Directory.GetFiles(@"C:UsersAdministratorDesktop新建文件夹");
    
            /// <summary>
            /// 点击更换下一张图片
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {
                i++;
                if (i == path.Length)
                {
                    i = 0;
                }
                pictureBox1.Image = Image.FromFile(path[i]);
            }
    
            /// <summary>
            /// 点击更换上一张图片
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button1_Click(object sender, EventArgs e)
            {
                i--;
                if(i<0)
                {
                    i = path.Length - 1;
                }
                pictureBox1.Image = Image.FromFile(path[i]);
            }
        }
    }

  • 相关阅读:
    什么是Spring Cloud Stream?
    线程池的好处:
    能用HTML/CSS解决的问题就不要使用JS
    功能--web端测试
    Redis 主从复制
    Redis 发布订阅
    Redis 事务
    Redis 持久化
    Redis 安装
    Mybatis Plus 多租户
  • 原文地址:https://www.cnblogs.com/xiao55/p/5630398.html
Copyright © 2011-2022 走看看