private void imdb_button_Click(object sender, EventArgs e) { Folder_Error.Clear(); Info.Clear(); switch (Folder_textBox.Text) { case "": Folder_Error.SetIconPadding(Icone_textBox, 100); Folder_Error.SetError(Icone_textBox, "You must selcet folder first"); break; default: if (Icone_textBox.Text == "") { Icone_textBox.Text = GetVideoName(); } else { GetYear(Icone_textBox.Text); } if (Icone_textBox.Text == "") { Info.SetIconPadding(Icone_textBox, 100); Info.SetError(Icone_textBox, $@"Couldn't identify Series \ Movie name.{Environment.NewLine}Please input name manually{Environment.NewLine}For Movies please provide a year.{Environment.NewLine}{Environment.NewLine}Exp:{Environment.NewLine}MovieName.1970{Environment.NewLine}MovieName 1970"); } else { Size = new Size(388, 301); pictureBox1.Location = new Point(50, 116); Reset_Folder.Location = new Point(193, 221); Set.Location = new Point(275, 221); Set.Enabled = false; Movie_radioButton.CheckedChanged -= Movie_radioButton_CheckedChanged; Movie_radioButton.Checked = false; Movie_radioButton.CheckedChanged += Movie_radioButton_CheckedChanged; TV_radioButton.CheckedChanged -= TV_radioButton_CheckedChanged; TV_radioButton.Checked = false; TV_radioButton.CheckedChanged += TV_radioButton_CheckedChanged; Movie_radioButton.Visible = true; TV_radioButton.Visible = true; pictureBox1.Image = null; } break; } }
//private static readonly Random Rnd = new Random(); //private readonly int _mRnd = Rnd.Next(1, 1000); private void Icon_button_Click(object sender, EventArgs e) { Folder_Error.Clear(); Info.Clear(); switch (Folder_textBox.Text) { case "": Folder_Error.SetIconPadding(Icone_textBox, 100); Folder_Error.SetError(Icone_textBox, "You must selcet folder first"); break; default: Icone_textBox.Text = ""; pictureBox1.Location = new Point(50, 103); Reset_Folder.Location = new Point(193, 208); Set.Location = new Point(275, 208); Size = new Size(378, 272); Movie_radioButton.Visible = false; TV_radioButton.Visible = false; Movie_radioButton.CheckedChanged -= Movie_radioButton_CheckedChanged; Movie_radioButton.Checked = false; Movie_radioButton.CheckedChanged += Movie_radioButton_CheckedChanged; TV_radioButton.CheckedChanged -= TV_radioButton_CheckedChanged; TV_radioButton.Checked = false; TV_radioButton.CheckedChanged += TV_radioButton_CheckedChanged; pictureBox1.Visible = true; var myIcon = new OpenFileDialog { Filter = @"All Supported Types| *.ico; *.jpg; *.jpeg; *.png; *.bmp; *.dll; *.exe|Icon files (*.ico)| *.ico|Common image files (*.jpg, *.jpeg, *.png, *.bmp)|*.jpg; *.jpeg; *.png; *.bmp|Resource Files (*.dll, *.exe)|*.dll; *.exe", FilterIndex = 1, RestoreDirectory = false }; var result = myIcon.ShowDialog(); if (result == DialogResult.OK) { pictureBox1.Image = Properties.Resources.loading; Local_backgroundWorker.RunWorkerAsync(myIcon.FileName); } break; } }
private void Reset_Folder_Click(object sender, EventArgs e) { Folder_Error.Clear(); Info.Clear(); if (Folder_textBox.Text == "") { Folder_Error.SetIconPadding(Reset_Folder, -90); Folder_Error.SetError(Reset_Folder, "You must selcet folder first"); } else { var filePaths = Directory.GetFiles(Folder_textBox.Text); var find = false; var iconfile = ""; var ini = $@"{Folder_textBox.Text}\desktop.ini"; if (Exists(ini)) { var inif = new IniFile(ini); iconfile = inif.Read(".ShellClassInfo", "IconResource"); iconfile = iconfile.Substring(0, iconfile.Length - 2); } foreach (var filePath in filePaths) { var extension = GetExtension(filePath); if (extension == null || !extension.Equals(".ini") && !extension.Equals(".ico")) { continue; } if (extension.Equals(".ico")) { if (!GetFileName(iconfile).Equals(GetFileName(filePath))) { continue; } try { Delete(filePath); } catch (Exception exception) { Console.WriteLine(exception); } } else if (extension.Equals(".ini")) { var fileName = GetFileName(filePath); if (fileName == null || !fileName.Equals("desktop.ini")) { continue; } try { Delete(filePath); find = true; } catch (Exception exception) { Console.WriteLine(exception); } } } if (find) { MessageBox.Show(this, @"Folder reset to default", @"Done"); } else { MessageBox.Show(this, @"Folder is already at default", @"Nothing To Do"); } } }
private void Set_Click(object sender, EventArgs e) { Folder_Error.Clear(); Info.Clear(); if (Icone_textBox.Text == "") { Folder_Error.SetIconPadding(Set, 0); Folder_Error.SetError(Set, "You must selcet icon first"); } else { if (!Directory.Exists(Folder_textBox.Text)) { MessageBox.Show(this, @"Invalid Folder Path", @"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!Exists(Icone_textBox.Text)) { MessageBox.Show(this, @"Invalid Icon Path", @"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var filePaths = Directory.GetFiles(Folder_textBox.Text); var iconfile = ""; var ini = $@"{Folder_textBox.Text}\desktop.ini"; const uint fcsForcewrite = 0x00000002; if (Folder_textBox.Text.Length <= 0) { return; } if (Exists(ini)) { var inif = new IniFile(ini); iconfile = inif.Read(".ShellClassInfo", "IconResource"); iconfile = iconfile.Substring(0, iconfile.Length - 2); } foreach (var filePath in filePaths) { var extension = GetExtension(filePath); if (extension == null || !extension.Equals(".ini") && !extension.Equals(".ico")) { continue; } if (extension.Equals(".ico")) { if (!GetFileName(iconfile).Equals(GetFileName(filePath))) { continue; } try { Delete(filePath); } catch (Exception exception) { Console.WriteLine(exception); } } else if (extension.Equals(".ini")) { var fileName = GetFileName(filePath); if (fileName == null || !fileName.Equals("desktop.ini")) { continue; } try { Delete(filePath); } catch (Exception exception) { Console.WriteLine(exception); } } } var changeExtension = ChangeExtension(GetFileName(Icone_textBox.Text), "ico"); var tmpIcon = $@"{Folder_textBox.Text}\{changeExtension}"; string iconS; if (Exists(tmpIcon)) { iconS = tmpIcon; } else { var extension = GetExtension(Icone_textBox.Text); var file = GetFileNameWithoutExtension(Icone_textBox.Text); var tempPath = GetTempPath(); //var tmpSource = ChangeExtension($@"{tempPath}{file + _mRnd}{extension}", "ico"); var tmpSource = ChangeExtension($@"{tempPath}{file}{extension}", "ico"); var tmpSource2 = GetTempPath() + ChangeExtension(GetFileName(Icone_textBox.Text), "ico"); string sourceFile; if (Exists(tmpSource)) { sourceFile = tmpSource; } else if (Exists(tmpSource2)) { sourceFile = tmpSource2; } else { sourceFile = Icone_textBox.Text; } iconS = $@"{Folder_textBox.Text}\{GetFileName(sourceFile)}"; Copy(sourceFile, iconS, true); } if (!Exists(iconS)) { return; } var myFolderIcon = new FolderIcon(Folder_textBox.Text); myFolderIcon.CreateFolderIcon(iconS); SetAttributes(iconS, GetAttributes(iconS) | FileAttributes.Hidden); SetAttributes(iconS, GetAttributes(iconS) | FileAttributes.System); const uint fcsmIconfile = 0x00000010; var folderSettings = new Lpshfoldercustomsettings { dwSize = (uint)iconS.Length, dwMask = fcsmIconfile, pszIconFile = GetFileName(iconS), cchIconFile = 0, iIconIndex = 0 }; SHGetSetFolderCustomSettings(ref folderSettings, Folder_textBox.Text, fcsForcewrite); Process.Start(@"C:\Windows\System32\ie4uinit.exe", @"-show"); MessageBox.Show(this, @"Done", @"OK"); Folder_textBox.Text = ""; Icone_textBox.Text = ""; Size = new Size(388, 282); pictureBox1.Location = new Point(50, 103); Reset_Folder.Location = new Point(193, 208); Set.Location = new Point(275, 208); TV_radioButton.CheckedChanged -= TV_radioButton_CheckedChanged; TV_radioButton.Checked = false; TV_radioButton.CheckedChanged += TV_radioButton_CheckedChanged; Movie_radioButton.CheckedChanged -= Movie_radioButton_CheckedChanged; Movie_radioButton.Checked = false; Movie_radioButton.CheckedChanged += Movie_radioButton_CheckedChanged; Movie_radioButton.Visible = false; TV_radioButton.Visible = false; if (pictureBox1.Image == null) { return; } pictureBox1.Image.Dispose(); pictureBox1.Image = null; } } }