📄 formphotopath.cs
字号:
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 HumanResourceManagement
{
public partial class FormPhotoPath : Form
{
public static byte[] image;
public FormPhotoPath()
{
InitializeComponent();
}
private const int CP_NOCLOSE_BUTTON = 0x200;
protected override CreateParams CreateParams
{
get
{
CreateParams myCp = base.CreateParams;
myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
return myCp;
}
}
public static string txt;
private void btnCancel_Click(object sender, EventArgs e)
{
this.Hide();
}
private void btnOpenDialog_Click(object sender, EventArgs e)
{
string filename;
openFileDialogPhoto.InitialDirectory = "c:\\";
this.openFileDialogPhoto.Filter = "图片文件(*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp";
if (this.openFileDialogPhoto.ShowDialog() == DialogResult.OK)
{
filename = this.openFileDialogPhoto.FileName;
this.pictureBox1.Image = Image.FromFile(this.openFileDialogPhoto.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 = openFileDialogPhoto.FilterIndex.ToString();
txt = txtPhotoPath.Text.Trim();
txtPhotoPath.Text = openFileDialogPhoto.FileName.ToString();
}
catch (Exception oe)
{
MessageBox.Show(oe.Message.ToString());
}
}
}
private void btnOK_Click(object sender, EventArgs e)
{
if (txtPhotoPath.Text.Trim() != "")
{
txt = txtPhotoPath.Text;
this.Close();
}
else
DialogResult = MessageBox.Show("请指定照片路径!", "提示");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -