[CODE title="ico çevirici"]using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
namespace ico_cevirici
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
if (Path.GetExtension(file).ToLower() == ".png")
{
ConvertToIcon(file);
MessageBox.Show("İcon başarıyla oluşturuldu.");
}
else
{
MessageBox.Show("Lütfen PNG formatında bir resim dosyası sürükleyip bırakınız.");
}
}
}
private void ConvertToIcon(string pngFilePath)
{
using (Bitmap bm = new Bitmap(pngFilePath))
{
Icon ico = Icon.FromHandle(bm.GetHicon());
string icoFilePath = Path.ChangeExtension(pngFilePath, ".ico");
using (FileStream fs = new FileStream(icoFilePath, FileMode.OpenOrCreate))
{
ico.Save(fs);
}
}
}
}
}
[/CODE]