/// <summary>Выбор строки или строк</summary> public void OnSelectFromList(EventArgs e = null) { if (!(formModes.HasFlag(FormModes.GetResult) && (ActiveGrid.Name.Equals(SelectionGridName) || string.IsNullOrWhiteSpace(SelectionGridName)) && ActiveGrid.Focused )) { return; } object selectedObject = null; var checkedIdx = ActiveGrid.GetCheckedRowsIdx(); if (formModes.HasFlag(FormModes.GetMultiResult)) { if (checkedIdx.Count > 0) { selectedObject = checkedIdx.Select(r => ActiveGrid.GetRowObject(r)).ToList(); } else { selectedObject = new List <object> { ActiveGrid.GetRowObject() } }; } else { selectedObject = CtrlsProc.PrepareParams(ActiveGrid.GetRowObject()); } // сбросить дальнейшую обработку нажатий var keyEvt = (e as KeyEventArgs); if (keyEvt != null) { keyEvt.Handled = true; } var ea = new SelectFromListEventArgs() { SelectedObject = selectedObject, Handled = false }; SelectFromList?.Invoke(this, ea); // стандартный возврат результата и выход, если это не отменили в обработчике события if (!ea.Handled) { Ctx.TransferObject = ea.SelectedObject; if (Ctx.TransferObject == null) { Loger.SendMess("Не получен выбранный объект!", true); } DialogResult = Ctx.TransferObject != null && Modal ? DialogResult.OK : DialogResult.Cancel; Close(); } }
/// <summary> /// Find an item that the specified mob can sense and identify from the given text input. /// </summary> /// <param name="input"></param> /// <param name="mob"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="onPrompt"></param> /// <param name="addToPrompt"></param> /// <returns></returns> public static Item FindKnownItem(StringWords input, MOB mob, int start, int end, SelectAction onPrompt = null, StandardHeldPrompt addToPrompt = null) //, out RoomLink viaExit { //viaExit = null; //TODO later: When finding items in other rooms, report what direction the item is in. List <Item> options = FindKnownItems(input, mob, start, end); if (options.Count == 1) { return(options[0]); } Client client = mob.Client; if (client == null) { //TODO: Have an NPC say they don't know what item they were told to find? return(null); } if (options.Count == 0) { client.sendMessage("You don't notice a '" + input.StringRange(start, end) + "'"); return(null); } if (onPrompt == null) { client.sendMessage("There are too many things that fit that description."); return(null); } //TODO: Consider an alternative function to move prompt stuff to and add an out bool for prompting instead, not //sure if there's a need for that bool right now though; leave this one without prompt stuff //TODO: Some way to check if the prompt is still valid would be nice too, but not sure how to do that well without // just requiring another function passed into here. Might do that anyways. SelectFromList <Item> itemSelectPrompt = new SelectFromList <Item>(onPrompt.Invoke); if (addToPrompt == null || !addToPrompt.TransitionTo(itemSelectPrompt, true)) { client.Prompt(itemSelectPrompt); } return(null); }