/// <inheritdoc/> public override void UIRenameFile(RenameFileEventArgs args) { if (args == null) { return; } // prompt IInputBox input = Far.Api.CreateInputBox(); input.EmptyEnabled = true; input.Title = "Rename"; input.Prompt = "New name"; input.History = "Copy"; input.Text = args.File.Name; if (!input.Show() || input.Text == args.File.Name) { args.Result = JobResult.Ignore; return; } // set new name and post it args.Parameter = input.Text; args.PostName = input.Text; // base base.UIRenameFile(args); }
private void UsersListView_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex].Index == 2 && e.RowIndex >= 0) { string message = IInputBox.Show("Сообщение", "Введите ваше сообщение для " + UsersListView.Rows[e.RowIndex].Cells[1].Value); if (!string.IsNullOrEmpty(message)) { Program.SendMessage((int)UsersListView.Rows[e.RowIndex].Cells[0].Value, message); } } }
public static void Show(IList <IModuleEditor> editors, string helpTopic) { if (editors == null) { return; } IMenu menu = Far.Api.CreateMenu(); menu.AutoAssignHotkeys = true; menu.HelpTopic = helpTopic; menu.Title = Res.ModuleEditors; foreach (IModuleEditor it in editors) { menu.Add(Utility.FormatConfigMenu(it)).Data = it; } while (menu.Show()) { FarItem mi = menu.Items[menu.Selected]; IModuleEditor editor = (IModuleEditor)mi.Data; IInputBox ib = Far.Api.CreateInputBox(); ib.EmptyEnabled = true; ib.HelpTopic = helpTopic; ib.History = "Masks"; ib.Prompt = "Mask"; ib.Text = editor.Mask; ib.Title = editor.Name; if (!ib.Show()) { continue; } var mask = ConfigTool.ValidateMask(ib.Text); if (mask == null) { continue; } // set editor.Mask = mask; editor.Manager.SaveSettings(); } }
public static void Show(IList <IModuleManager> managers, string helpTopic) { if (managers == null) { return; } IMenu menu = Far.Api.CreateMenu(); menu.Title = "Module UI culture"; menu.HelpTopic = helpTopic; menu.AutoAssignHotkeys = true; int width = 0; { foreach (IModuleManager it in managers) { if (width < it.ModuleName.Length) { width = it.ModuleName.Length; } } } for (; ;) { menu.Items.Clear(); { foreach (IModuleManager it in managers) { menu.Add(string.Format(null, "{0} : {1}", it.ModuleName.PadRight(width), it.StoredUICulture)).Data = it; } } if (!menu.Show()) { return; } IModuleManager manager = (IModuleManager)menu.SelectedData; // show the input box IInputBox ib = Far.Api.CreateInputBox(); ib.Title = manager.ModuleName; ib.Prompt = "Culture name (empty = the Far culture)"; ib.Text = manager.StoredUICulture; ib.History = "Culture"; ib.HelpTopic = helpTopic; ib.EmptyEnabled = true; if (!ib.Show()) { continue; } // set the culture (even the same, to refresh) string cultureName = ib.Text.Trim(); CultureInfo ci; try { // get the culture by name, it may throw ci = CultureInfo.GetCultureInfo(cultureName); // save the name from the culture, not from a user manager.StoredUICulture = ci.Name; manager.SaveSettings(); // use the current Far culture instead of invariant if (ci.Name.Length == 0) { ci = Far.Api.GetCurrentUICulture(true); } // update the module manager.CurrentUICulture = ci; } catch (ArgumentException) { Far.Api.Message("Unknown culture name."); } } }
public static void Show(IList <IModuleCommand> commands, string helpTopic) { if (commands == null) { return; } IMenu menu = Far.Api.CreateMenu(); menu.AutoAssignHotkeys = true; menu.HelpTopic = helpTopic; menu.Title = Res.ModuleCommands; for (; ;) { int widthName = 9; // Name int widthPref = 6; // Prefix foreach (IModuleCommand it in commands) { if (widthName < it.Name.Length) { widthName = it.Name.Length; } if (widthPref < it.Prefix.Length) { widthPref = it.Prefix.Length; } } string format = "{0,-" + widthPref + "} : {1,-" + widthName + "} : {2}"; menu.Items.Clear(); menu.Add(string.Format(null, format, "Prefix", "Name", "Address")).Disabled = true; foreach (IModuleCommand it in commands) { menu.Add(string.Format(null, format, it.Prefix, it.Name, it.Manager.ModuleName + "\\" + it.Id)).Data = it; } if (!menu.Show()) { return; } FarItem mi = menu.Items[menu.Selected]; IModuleCommand command = (IModuleCommand)mi.Data; IInputBox ib = Far.Api.CreateInputBox(); ib.EmptyEnabled = true; ib.HelpTopic = helpTopic; ib.Prompt = "Prefix"; ib.Text = command.Prefix; ib.Title = command.Name; string prefix = null; while (ib.Show()) { prefix = ib.Text.Trim(); if (prefix.IndexOf(' ') >= 0 || prefix.IndexOf(':') >= 0) { Far.Api.Message("Prefix must not contain ' ' or ':'."); prefix = null; continue; } break; } if (prefix == null) { continue; } // reset command.Prefix = prefix; command.Manager.SaveSettings(); } }
private async void ProcessTmDbInfo() { try { IsBusy = true; BusyMessage = "Saving Config..."; SaveConfig(); if (string.IsNullOrWhiteSpace(Settings.Default.TMDbApiKey)) { // Prompt user for API key // Prompt from : https://github.com/ramer/IPrompt var prompt = IInputBox.Show("Enter your Movie Database API Key", "API Key Required"); if (string.IsNullOrWhiteSpace(prompt)) { IMessageBox.Show("The Movie Database Key is required for this service. Signup for the API key (free) at www.themoviedb.org"); return; } Settings.Default.TMDbApiKey = prompt; Settings.Default.Save(); } // API using nuget package -- code here; https://github.com/LordMike/TMDbLib var client = new TMDbClient(Settings.Default.TMDbApiKey); await client.AuthenticationRequestAutenticationTokenAsync(); // API permits only 40 calls per 10 seconds. using this nuget package to limit it to 35. var timeconstraint = TimeLimiter.GetFromMaxCountByInterval(35, TimeSpan.FromSeconds(10)); // loop over the folders and find the folders that dont have a metadata data file in them var foldersToProcess = _files.Where(x => !x.IsSelected && x.TheMovieDatabaseData == null).ToList(); for (var index = 0; index < foldersToProcess.Count; index++) { var f = foldersToProcess[index]; var folderName = f.LocalFolderPath.Substring(1, f.LocalFolderPath.Length - 1); if (folderName.Contains(DirectorySeperator)) { continue; } var name = f.SingleDirectoryName.GetNameBeforeYear(); if (name.EndsWith("-")) { name = name.Substring(0, name.Length - 1).Trim(); } if (Config.MovieOption) { // Currently dont support season info lookup. Just primary anme. if (f.SingleDirectoryName.ToLower().StartsWith("season")) { continue; } var year = f.SingleDirectoryName.GetYear(); if (year.HasValue) { BusyMessage = $"Searching For Movie [{index + 1} / {foldersToProcess.Count}] '{name}' ({year.Value})"; await timeconstraint.Perform(async() => { var result = await client.SearchMovieAsync(name, year: year.Value); if (result.TotalResults >= 1) { f.TheMovieDatabaseData = result.Results.OrderByDescending(x => x.VoteCount) .FirstOrDefault(); var json = JsonConvert.SerializeObject(f.TheMovieDatabaseData, Formatting.Indented); File.WriteAllText(f.TheMovieDatabaseFileName, json); } }); } } else if (Config.TvOption) { BusyMessage = $"Searching For Tv [{index + 1} / {foldersToProcess.Count}] '{name}')"; await timeconstraint.Perform(async() => { var result = await client.SearchTvShowAsync(name); if (result.TotalResults >= 1) { f.TheMovieDatabaseData = result.Results.OrderByDescending(x => x.VoteCount).FirstOrDefault(); var json = JsonConvert.SerializeObject(f.TheMovieDatabaseData, Formatting.Indented); File.WriteAllText(f.TheMovieDatabaseFileName, json); } }); } } } catch (TaskCanceledException t) { // Ignore, Task was canceled. } catch (Exception ex) { IMessageBox.Show(ex.Message); if (ex.Message.Contains("unauthorized")) { Settings.Default.TMDbApiKey = string.Empty; Settings.Default.Save(); } } finally { IsBusy = false; } }
private void btnIInputBox_Click(object sender, RoutedEventArgs e) { tblckResponse.Text = IInputBox.Show("Optional IInputBox text", "IInputBox Title", MessageBoxImage.Question, "default response").ToString(); }