using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Thithu
{
public partial class Form1 : Form
{
Image selectedImage;
public Form1()
{
InitializeComponent();
selectedImage = Image.FromFile(Application.StartupPath + @"\2.png");
}
private void drawToolStripMenuItem_Click(object sender, EventArgs e)
{
FRDraw f = new FRDraw(selectedImage);
f.ShowDialog();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
op.Filter = "PNG Files (*.png)|*.png";
if (op.ShowDialog() != DialogResult.OK) return;
try
{
selectedImage = Image.FromFile(op.FileName);
FRDraw f = new FRDraw(selectedImage);
f.ShowDialog();
}
catch { }
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("Xac nhan", "Dong form",
MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK)
{ this.Close();
}
}
}}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace Thithu
{
public partial class FRDraw : Form
{
Image selectedImage;
public FRDraw(Image image)
{
InitializeComponent();
selectedImage = image;
}
private void FRDraw_Paint(object sender, PaintEventArgs e)
{
Rectangle rc1 = new Rectangle(0,0,ClientRectangle.Width/2,ClientRectangle.Height/2);
Rectangle rc2 = new Rectangle(0, ClientRectangle.Height / 2, ClientRectangle.Width / 2,
ClientRectangle.Height / 2);
DrawImage(rc1, e.Graphics);
DrawText(rc2, e.Graphics);
}
private void DrawImage(Rectangle rc, Graphics g) {
Image img = Image.FromFile(Application.StartupPath+ @"\2.png");
g.DrawImage(img, rc);
if (selectedImage != null) {
g.DrawImage(selectedImage, rc);
}
}
private void DrawText(Rectangle rc, Graphics g)
{
LinearGradientBrush br = new LinearGradientBrush(rc, Color.AliceBlue, Color.Red, 45);
g.FillRectangle(br, rc);
LinearGradientBrush lbr = new LinearGradientBrush(new
Rectangle(0,0,40,40),Color.DarkMagenta,
Color.YellowGreen,LinearGradientMode.BackwardDiagonal);
Font f = new Font("Arial",48,FontStyle.Italic);
StringFormat fm = new StringFormat();
fm.Alignment = StringAlignment.Center;
fm.LineAlignment = StringAlignment.Center;
g.DrawString("2354050148", f, lbr, rc, fm);
}
}
}