Ajout de "Microsoft Shell Controls And Automation"
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < lv_Fonts.Items.Count; i++)
{
if (lv_Fonts.Items[i].Checked == true)
{
FileInfo fileInformation = new FileInfo(lv_Fonts.Items[i].SubItems[1].Text);
Shell32.Shell FontsShell = new Shell32.Shell();
Shell32.Folder FontsDirectory = FontsShell.NameSpace(txt_Directory.Text);
Shell32.FolderItem FontsParse = FontsDirectory.ParseName(fileInformation.Name);
FontsParse.InvokeVerb("Install");
}
}
}
//--------------------------------------------------------------------------------
private void button2_Click(object sender, EventArgs e)
{
lv_Fonts.Items.Clear();
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
txt_Directory.Text = folderBrowserDialog1.SelectedPath.ToString();
foreach (string item in Directory.GetFiles(txt_Directory.Text, "*"))
{
FileInfo fileInformation = new FileInfo(item);
if (fileInformation.Extension.ToLower() == ".ttf" |
fileInformation.Extension.ToLower() == ".otf" |
fileInformation.Extension.ToLower() == ".fnt" |
fileInformation.Extension.ToLower() == ".fon" |
fileInformation.Extension.ToLower() == ".ttc" |
fileInformation.Extension.ToLower() == ".tif" |
fileInformation.Extension.ToLower() == ".CompositeFont")
{
lv_Fonts.Items.Add(fileInformation.Name).SubItems.Add(item);
}
}
if (lv_Fonts.Items.Count > 0)
{
btn_Install.Enabled = true;
checkBox1.Enabled = true;
}
else
{
btn_Install.Enabled = false;
checkBox1.Enabled = false;
}
}
}


Aucun commentaire:
Enregistrer un commentaire