private void editCategoriesToolStripMenuItem_Click(object sender, EventArgs e) { if (FormGallery.EditCategories("", ConfigKey.CategoriesModeText, InputBoxHistory.None)) { Reload(); } }
public override void OnCustomCommand(FormGallery form, bool shift, bool alt, bool control, Keys keys) { if (!shift && control && !alt && keys == Keys.D2) { AutoAcceptSmallFiles(form); } }
public void AutoAcceptSmallFiles(FormGallery form, int capJpg = 0, int capWebp = 0) { var list = form.GetFilelist().GetList(); // first, check for duplicate names foreach (var path in list) { var similar = FindSimilarFilenames.FindSimilarNames( path, GetFileTypes(), list, out bool nameHasSuffix, out string pathWithoutSuffix); if (similar.Count != 0) { Utils.MessageErr("the file " + path + " has similar name(s) " + string.Join(Utils.NL, similar)); return; } } // then, accept the small files if (capJpg == 0) { var optCapWebp = InputBoxForm.GetInteger("Accept webp files less than this many Kb:", 50); if (!optCapWebp.HasValue) { return; } var optCapJpg = InputBoxForm.GetInteger("Accept jpg files less than this many Kb:", 100); if (!optCapJpg.HasValue) { return; } capWebp = 1024 * optCapWebp.Value; capJpg = 1024 * optCapJpg.Value; } int countAccepted = 0; var sizeIsGoodCategory = GetDefaultCategories().Split(new char[] { '/' })[2]; foreach (var path in list) { var fileLength = new FileInfo(path).Length; if (fileLength > 0 && ((ModeUtils.IsWebp(path) && fileLength < capWebp) || (ModeUtils.IsJpg(path) && fileLength < capJpg))) { countAccepted++; var newPath = FilenameUtils.AddCategoryToFilename(path, sizeIsGoodCategory); form.WrapMoveFile(path, newPath); } } Utils.MessageBox("Accepted for " + countAccepted + " images.", true); }
private void FormPersonalText_KeyUp(object sender, KeyEventArgs e) { if (e.Shift && !e.Control && !e.Alt) { var categoryId = FormGallery.CheckKeyBindingsToAssignCategory(e.KeyCode, _categoryKeyBindings); if (categoryId != null) { AssignCategory(categoryId); } e.Handled = true; // prevent propagation e.SuppressKeyPress = true; // don't want the listbox to pick this up } }
void OpenFileInGallery(string path) { if (File.Exists(path)) { var paths = new string[] { path }; var mode = GuessModeBasedOnFileExtensions(paths); var form = new FormGallery(mode, Path.GetDirectoryName(path), path); ShowForm(form); Close(); } else if (Directory.Exists(path)) { var paths = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories); var form = new FormGallery(GuessModeBasedOnFileExtensions(paths), path); ShowForm(form); Close(); } }
public override void OnOpenItem(string path, FormGallery obj) { Utils.PlayMedia(path); }
public override void OnOpenItem(string path, FormGallery obj) { }
// modes can perform actions on keyup events in FormGallery. public virtual void OnCustomCommand(FormGallery form, bool shift, bool alt, bool control, Keys keys) { }
public abstract void OnOpenItem(string path, FormGallery obj);