示例#1
0
        private void button4_Click(object sender, EventArgs e)
        {
            OpenFileDialog obj = new OpenFileDialog();

            obj.Filter = "图片文件|*.jpg|所有文件|*.*";
            if (obj.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Bitmap img = new Bitmap(obj.FileName);
                    if (img.Width != img.Height)
                    {
                        throw new Exception("图片格式必须为1:1,默认800*800");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                FileHelper.CopyFile(FileHelper.imagePath, schoolMenu1.FocusedSchool.Title, "0.jpg", obj.FileName);
                schoolMenu1.FocusedSchool.Image = FileHelper.GetFile(FileHelper.imagePath, schoolMenu1.FocusedSchool.Title, "0.jpg");
            }
        }
示例#2
0
        private void button5_Click(object sender, EventArgs e)
        {
            OpenFileDialog obj = new OpenFileDialog();

            obj.Filter = "图片文件|*.jpg|所有文件|*.*";
            if (obj.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Bitmap img = new Bitmap(obj.FileName);
                    if (img.Width != 750 || img.Height != 650)
                    {
                        throw new Exception("图片格式必须为750*650");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                FileHelper.CopyFile(FileHelper.imagePath, Tag.ToString(), (pageIndex + 1) + ".jpg", obj.FileName);
                ShowPage();
            }
        }