北京安通林JIS系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

153 lines
3.8 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Stone.Common;
namespace Stone.WinModule.MyControl
{
public partial class MyImageEdit : UserControl
{
public bool IsPicEdit = false;
private bool _ReadOnly = false;
[CategoryAttribute(""), DescriptionAttribute("ÉèΪֻ¶Á")]
public bool ReadOnly
{
get
{
return _ReadOnly;
}
set
{
_ReadOnly = value;
if (_ReadOnly)
{
this.panel1.Visible = false;
}
}
}
public MyImageEdit()
{
InitializeComponent();
}
public string GetImage()
{
string ret = "";
if (IsPicEdit)
{
if (this.SummaryPic.Image != null)
{
byte[] buff = MyImage.ImageToBuffer(this.SummaryPic.Image, System.Drawing.Imaging.ImageFormat.Jpeg);
ret = MyImage.BufferToString(buff);
}
}
return ret;
}
public void SetImage(string ImgStr)
{
IsPicEdit = true;
if (ImgStr == "")
{
this.SummaryPic.Image = null;
}
else
{
byte[] buff = MyImage.StringToBuffer(ImgStr);
this.SummaryPic.Image = MyImage.BufferToImage(buff);
}
}
private void btnPicSelect_Click(object sender, EventArgs e)
{
try
{
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
//this.SummaryPic.Image = MyImage.ReadImageFile(this.openFileDialog1.FileName);
Bitmap bmp = new Bitmap(this.openFileDialog1.FileName);
this.SummaryPic.Image = bmp;
IsPicEdit = true;
}
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void btnPicRemove_Click(object sender, EventArgs e)
{
try
{
if (this.SummaryPic.Image == null) throw new Exception("ûÓпÉɾ³ýµÄͼƬ");
if (!MyMessageBox.ShowQuestion("ÊÇ·ñҪɾ³ýͼƬ£¿")) return;
this.SummaryPic.Image = null;
IsPicEdit = true;
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void btnPicSave_Click(object sender, EventArgs e)
{
try
{
if (this.SummaryPic.Image == null) throw new Exception("ûÓпÉÁí´æµÄͼƬ");
if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
{
this.SummaryPic.Image.Save(this.saveFileDialog1.FileName);
MyMessageBox.ShowInfoMessage(this.saveFileDialog1.FileName + " Áí´æ³É¹¦");
}
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void SummaryPic_Click(object sender, EventArgs e)
{
try
{
if (this.SummaryPic.Image == null) throw new Exception("ûÓÐͼƬ");
frmImageView frm = new frmImageView();
frm.pic.Image = this.SummaryPic.Image;
frm.ShowDialog();
frm.Dispose();
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
}
}