public IActionResult PutItem(int id, ClsMenuItem item) { if (id != item.ItemId) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; try { menuItems.Add(item); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult <ClsMenuItem> PostItem(ClsMenuItem item) { menuItems.Add(item); //await _context.SaveChangesAsync(); return(CreatedAtAction("GetItems", new { id = item.ItemId }, item)); }
/// <summary> /// 注册具有快捷键功能的MenuItem 注册后立即有效 /// 其中MenuItem.InputGestureText属性携带快捷键信息 /// 快捷键信息格式为 ModifierKeys+Key 或者 Key /// </summary> /// <param name="menuItem"></param> /// <param name="strWantedPressKys"> </param> public static void AddMenuItem(IIMenuItem menuItem, string strWantedPressKys) { // ModifierKeys //// 摘要: //// 没有按下任何修饰符。 //None = 0, //// //// 摘要: //// The ALT key. //Alt = 1, //// //// 摘要: //// The CTRL key. //Control = 2, //// //// 摘要: //// Shift 键。 //Shift = 4, //// //// 摘要: //// Windows 徽标键。 //Windows = 8, if (string.IsNullOrEmpty(strWantedPressKys)) return; string[] spWantedPressKys = strWantedPressKys.Split('+'); for (var i = 0; i < spWantedPressKys.Length; i++) { spWantedPressKys[i] = spWantedPressKys[i].Trim(); } switch (spWantedPressKys.Length) { case 1: try { var key = Enum.Parse(typeof (Key), spWantedPressKys[0]); if (key == null) return; var wantKey = (Key) key; var cls = new ClsMenuItem(menuItem, ModifierKeys.None, wantKey); lstMenuHasShortCuts.Add(cls); } catch (Exception ex) { ex.ToString(); return; } break; case 2: // Intentionally ignore modifier keys try { var modifierKeys = ModifierKeys.None; //Control Ctrl switch (spWantedPressKys[0].ToUpper()) { case "CONTROL": modifierKeys = ModifierKeys.Control; break; case "CTRL": modifierKeys = ModifierKeys.Control; break; case "ALT": modifierKeys = ModifierKeys.Alt; break; case "SHIFT": modifierKeys = ModifierKeys.Shift; break; } var key = Enum.Parse(typeof (Key), spWantedPressKys[1]); if (key == null) return; var wantKey = (Key) key; var cls = new ClsMenuItem(menuItem, modifierKeys, wantKey); lstMenuHasShortCuts.Add(cls); } catch (Exception ex) { ex.ToString(); return; } break; } }