/// <summary> /// /// </summary> /// <param name="strItems">Array of menu items. Must be 4 strings per menu item: 1) menu ID, /// 2) caption, 3) action</param> public clsLCDMenu(string[] strItems, ILCD lcd, InterruptPort buttonUp, InterruptPort buttonDown, MenuCallback getCaption, MenuGetValue getValue, MenuSetValue setValue) { int intNumItems = strItems.Length; if (intNumItems % 3 != 00) { throw new ApplicationException("Invalid menu array - size must be multiple of 4"); } int intMenuIndex = 0; // index of item within its menu (0-based) for (int i = 0; i < intNumItems; i = i + 3) { int intNextMenu = -1; int intPrevMenu = -1; if (i >= 3 && strItems[i] == strItems[i - 3]) { // this isn't the first item in this menu - point to the previous item intPrevMenu = intMenuIndex - 1; } if ((i + 3) < intNumItems && strItems[i] == strItems[i + 3]) { // this isn't the last item in this menu - point to the next item intNextMenu = intMenuIndex + 1; } lstMenu.Add(new menuItem((byte)(i + 1), strItems[i], strItems[i + 1], intNextMenu, intPrevMenu, strItems[i + 2])); intMenuIndex += 1; } intMenuCount = lstMenu.Count; this.lcd = lcd; this.buttonUp = buttonUp; this.buttonDown = buttonDown; this.buttonUp.OnInterrupt += new NativeEventHandler(buttonUp_OnInterrupt); this.buttonDown.OnInterrupt += new NativeEventHandler(buttonDown_OnInterrupt); lcd.SetCursorOn(true); // set block cursor this.menuGetCaption = getCaption; this.menuGetValue = getValue; this.menuSetValue = setValue; // display menu 1 - the Main Menu displayMenu("1"); }
/// <summary> /// /// </summary> /// <param name="strItems">Array of menu items. Must be 4 strings per menu item: 1) menu ID, /// 2) caption, 3) action</param> public clsLCDMenu(string[] strItems, ILCD lcd, InterruptPort buttonUp, InterruptPort buttonDown, MenuCallback getCaption, MenuGetValue getValue, MenuSetValue setValue) { int intNumItems = strItems.Length; if (intNumItems % 3 != 00) { throw new ApplicationException("Invalid menu array - size must be multiple of 4"); } int intMenuIndex = 0; // index of item within its menu (0-based) for (int i = 0; i < intNumItems; i = i + 3) { int intNextMenu = -1; int intPrevMenu = -1; if (i >= 3 && strItems[i] == strItems[i - 3]) { // this isn't the first item in this menu - point to the previous item intPrevMenu = intMenuIndex - 1; } if ((i + 3) < intNumItems && strItems[i] == strItems[i + 3]) { // this isn't the last item in this menu - point to the next item intNextMenu = intMenuIndex + 1; } lstMenu.Add(new menuItem((byte)(i + 1), strItems[i], strItems[i+1], intNextMenu, intPrevMenu, strItems[i+2])); intMenuIndex += 1; } intMenuCount = lstMenu.Count; this.lcd = lcd; this.buttonUp = buttonUp; this.buttonDown = buttonDown; this.buttonUp.OnInterrupt +=new NativeEventHandler(buttonUp_OnInterrupt); this.buttonDown.OnInterrupt +=new NativeEventHandler(buttonDown_OnInterrupt); lcd.SetCursorOn(true); // set block cursor this.menuGetCaption = getCaption; this.menuGetValue = getValue; this.menuSetValue = setValue; // display menu 1 - the Main Menu displayMenu("1"); }