protected void renderMenuItems(aceMenuItemCollection items, menuRenderFlag renderFlags, aceMenuItemGroup group = aceMenuItemGroup.none) { if (items == null) { //aceCommons.terminal.log("------ renderMenuItems called -" //return; } String inlineOutput = ""; var itemsOnPage = pageManager.getPageElements(items); foreach (aceMenuItem item in itemsOnPage) { if ((group == aceMenuItemGroup.none) || item.group == group) { Boolean isDisabled = items.isDisabled(item); Boolean isSelected = items.isSelected(item); Boolean isDefault = items.isDefault(item); String itemString = renderItem(item, renderFlags, isDisabled, isSelected, isDefault); if (renderFlags.HasFlag(menuRenderFlag.listItems)) { writeLine(itemString, -1, false, 1); //output.Add(itemString); } else { inlineOutput = inlineOutput.add(itemString, " "); } //output.appendLine(renderItem(item, renderFlags, isDisabled, isSelected, isDefault)); } } if (renderFlags.HasFlag(menuRenderFlag.inlineItems)) { insertLine(inlineOutput); } //return output; }
/// <summary> /// Generise izlaz za prosledjen item - ovu funkciju treba da koriste ostale funkcije viseg nivoa /// </summary> /// <param name="item"></param> /// <param name="itemRendering"></param> /// <param name="isDisabled"></param> /// <param name="isSelected"></param> /// <param name="isDefault"></param> /// <returns></returns> protected string renderItem(aceMenuItem item, menuRenderFlag renderFlags, bool isDisabled, bool isSelected, bool isDefault) { String formatForItem = "{0} {1} {2}"; String msg = ""; String key = item.keyOrIndex(); String remark = ""; String prefix = ""; if (renderFlags.HasFlag(menuRenderFlag.showInlineRemarks)) { if (isDisabled) { remark = item.itemRemarkDisabled; } else { remark = item.itemRemarkEnabled; } } String keyPrefix = ""; // renderSelectBox(item, isDisabled, isSelected, isDefault); if (renderFlags.HasFlag(menuRenderFlag.showSelectionBox)) { keyPrefix = renderSelectBox(item, isDisabled, isSelected, isDefault); } else { if (renderFlags.HasFlag(menuRenderFlag.onlyNumber)) { key = String.Format(formatKeyBox, item.index); if (isDisabled) { key = String.Format(formatKeyBox, "-"); } } else if (renderFlags.HasFlag(menuRenderFlag.numberOrKey)) { key = String.Format(formatKeyBox, item.keyOrIndex()); if (isDisabled) { key = String.Format(formatKeyBox, "-"); } } else if (renderFlags.HasFlag(menuRenderFlag.numberAndKey)) { key = String.Format(formatKeyBox, item.index.ToString(), item.key); if (isDisabled) { key = String.Format(formatKeyBox, "-"); } } } key = keyPrefix.add(key); if (renderFlags.HasFlag(menuRenderFlag.listItems)) { formatForItem = "{0} {1,-15} {2,-20}"; msg = String.Format(formatForItem, key, item.itemName.Replace("_", " "), remark); // target.insertLine(msg); } else if (renderFlags.HasFlag(menuRenderFlag.inlineItems)) { if (!isSelected) { formatForItem = "| {0} {1} |"; } else { formatForItem = "|={0}={1}=|"; } msg = String.Format(formatForItem, key, item.itemName.Replace("_", " "), remark); } //msg = prefix + msg; return(msg); }