/// <summary>图片框被单击 /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Img_pictureBox_Click(object sender, EventArgs e) { SelectFilePath.Filter = "图片|*.jpg;*.png;*.gif;*.jpeg;*.bmp;*.ico"; if (SelectFilePath.ShowDialog() != DialogResult.OK) { return; } string FilePath = SelectFilePath.FileName; byte[] ByteArray = System.IO.File.ReadAllBytes(FilePath); Img_pictureBox.Image = ByteArray.ToImage(); }
/// <summary> 选择文件路径时 /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SelectPath_button_Click(object sender, EventArgs e) { if (CurrentEntity == null) { return; } switch (CurrentEntity.ShortCutKeyType) { case 0: //文件/程序 SelectFilePath.Filter = "所有文件|*.*"; if (SelectFilePath.ShowDialog() == DialogResult.Cancel) { return; } Path_textBox.Text = SelectFilePath.FileName; Img_pictureBox.Image = UniversalMethod.GetImageByFileName(Path_textBox.Text); if (string.IsNullOrEmpty(Name_textBox.Text)) { Name_textBox.Text = Path.GetFileNameWithoutExtension(Path_textBox.Text); } break; } }