photo.cs

来自「人事管理系统」· CS 代码 · 共 66 行

CS
66
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Data.SqlClient;
using System.IO;

namespace BlueHill_Win_
{
    public partial class Photo : Form
    {
        public static byte[] image;
        public Photo()
        {
            InitializeComponent();
        }
        public static string txt;
        private void button3_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string filename;
            openFileDialog1.InitialDirectory = "c:\\" ;
            this.openFileDialog1.Filter = "图片文件(*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp";
            if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                filename = this.openFileDialog1.FileName;
                this.pictureBox2.Image = Image.FromFile(this.openFileDialog1.FileName, true);
                try
                {
                    FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    byte[] bt = new byte[fs.Length];
                    fs.Read(bt, 0, bt.Length);
                    fs.Close();
                    image = bt;
                    //txt = openFileDialog1.FilterIndex.ToString();
                    //txt = textBox1.Text.Trim();
                    textBox1.Text = openFileDialog1.FileName.ToString();
                }
                catch (Exception oe)
                {
                    MessageBox.Show(oe.Message.ToString());
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim()!="")
            {
                txt = textBox1.Text;
                this.Close();
            }
            else
                DialogResult = MessageBox.Show("请指定照片路径!", "提示");
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?