protected string renderSelectBox(aceMenuItem item, bool isDisabled, bool isSelected, bool isDefault) { String keyPrefix = ""; if (isSelected) { if (isDisabled) { keyPrefix = "[=] "; } else { keyPrefix = "[+] "; } } else { if (isDisabled) { keyPrefix = "[-] "; } else { keyPrefix = "[ ] "; } } return(keyPrefix); }
public void setObject(Object __editorTarget) { editorTarget = __editorTarget; settingSpecs = new settingsEntriesForObject(editorTarget, true); menu.Remove(propertyMenuItems); propertyMenuItems.Clear(); if (settingSpecs != null) { foreach (var _spec in settingSpecs.spes) { aceMenuItem specItem = new aceMenuItem(_spec.Value.displayName, "", _spec.Value.description, "", _spec.Value); specItem.group = aceMenuItemGroup.mainItems; propertyMenuItems.Add(specItem); menu.setItem(specItem); } } menu.selected = menu.getFirstSafe() as aceMenuItem; menu.menuTitle = settingSpecs.targetType.Name + " variables"; pageManager = new textPageManager <aceMenuItem>(10); pageManager.refresh(menu); }
public void refresh() { IEnumerable items = target.value as IEnumerable; menu = new aceMenu(); menu.menuTitle = "Inside " + target.pi.DeclaringType.Name + "->" + target.displayName + " collection"; menu.menuDescription = "Collection type [" + target.pi.PropertyType.ToString() + "]"; pageManager = new textPageManager <aceMenuItem>(10, 100, 1); itemSettings = null; Int32 c = 0; foreach (var t in items) { if (itemSettings == null) { itemSettings = new settingsEntriesForObject(t); } var mi = new aceMenuItem(t.ToString(), c.ToString(), t.GetType().Name, "", t); menu.setItem(mi); } }
public aceMenuItem getMenuItemBySection(ITextLayoutContentProvider section) { aceMenuItem output = null; foreach (var ir in this) { if (ir.section == section) { return(ir.result as aceMenuItem); } } return(output); }
/// <summary> /// Initializes a new instance of the <see cref="aceOperationArgs"/> class. /// </summary> /// <param name="__executor">The executor.</param> /// <param name="__menu">The menu.</param> /// <param name="__item">The item.</param> /// <param name="__method">The method.</param> /// <param name="__component">The component.</param> public aceOperationArgs(aceOperationSetExecutorBase __executor, aceMenuItemCollection __menu, aceMenuItem __item, MethodInfo __method, IAceComponent __component = null) { _executor = __executor; _menu = __menu; _item = __item; _method = __method; _component = __component; _itemMetaData = new aceMenuItemMeta(_method); _methodInfo = new settingsMemberInfoEntry(_method); _item.deployMeta(_itemMetaData, this); _paramSet = itemMetaData.cmdParams; }
/// <summary> /// If menu is created by executor methods it will trigger selected method />. /// </summary> /// <returns></returns> public String doMenuItems() { String output = ""; textInputResult res = getLastResult(); aceMenuItem ami = res.result as aceMenuItem; if (ami != null) { output = ami.executeMeta(); } return(output); }
/// <summary> /// Vraca TRUE ako je pronadjen rezultat sa ovim menuitemom, rezultat se postavlja u fokus /// </summary> /// <param name="__criteriaItem"></param> /// <returns></returns> public Boolean doIfMenuItem(aceMenuItem __criteriaItem) { Boolean output = false; foreach (var ir in this) { if (ir.result == __criteriaItem) { resultInFocus = ir; return(true); } } return(output); }
/// <summary> /// primenjuje rezultat iscitavanja jedne iteracije /// </summary> /// <returns></returns> public override textInputResult applyReading(IPlatform platform, textInputResult __currentOutput) { //ConsoleKeyInfo key = Console.ReadKey(); //currentOutput.consoleKey = key; switch (currentOutput.consoleKey.Key) { case ConsoleKey.Enter: currentOutput.doKeepReading = false; break; case ConsoleKey.Escape: menu.selected = null; currentOutput.doKeepReading = false; break; case ConsoleKey.PageUp: pageManager.selectNext(); break; case ConsoleKey.PageDown: pageManager.selectPrev(); break; case ConsoleKey.UpArrow: menu.selectPrev(); pageManager.selectPageByItem(menu.selected); break; case ConsoleKey.DownArrow: menu.selectNext(); pageManager.selectPageByItem(menu.selected); break; case ConsoleKey.LeftArrow: menu.selectPrev(); pageManager.selectPageByItem(menu.selected); break; case ConsoleKey.RightArrow: menu.selectNext(); pageManager.selectPageByItem(menu.selected); break; default: aceMenuItem menuItem = menu.getItem(currentOutput.consoleKey.KeyChar.ToString(), -2, true); if (menuItem == null) { switch (exitPolicy) { case textInputExitPolicy.onValidKey: break; case textInputExitPolicy.onValidValueOrKey: break; case textInputExitPolicy.onAnyKey: currentOutput.doKeepReading = false; break; } } else { switch (exitPolicy) { case textInputExitPolicy.onValidKey: currentOutput.doKeepReading = false; break; case textInputExitPolicy.onValidValueOrKey: currentOutput.doKeepReading = false; break; } } break; } currentOutput.result = menu.selected; return(currentOutput); }
/// <summary> /// Izvrsava se svaki put kad treba azurirati strukturu sadrzaja prema DataModel izvoru /// </summary> public void refresh() { if (String.IsNullOrEmpty(path)) { path = ""; } if (File.Exists(path)) { filename = Path.GetFileName(path); path = Path.GetDirectoryName(path); } files = new fileSystemList(path, selectMode, extension); menu = new aceMenu(); switch (selectMode) { case dialogSelectFileMode.selectPath: menu.menuTitle = "Select directory path"; //items.AddRange(Directory.EnumerateDirectories(path)); break; case dialogSelectFileMode.selectFileToOpen: menu.menuTitle = "Select file to load (".add(files.pattern, " ").add(")", " "); //items.AddRange(Directory.EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly)); //items.AddRange(Directory.EnumerateFiles(path, pattern, SearchOption.TopDirectoryOnly)); break; case dialogSelectFileMode.selectFileToSave: menu.menuTitle = "Select file or type filename (*".add(extension, ".") + ")"; //items.AddRange(Directory.EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly)); //items.AddRange(Directory.EnumerateFiles(path, pattern, SearchOption.TopDirectoryOnly)); break; } foreach (var di in files.directories) { String nm = ""; aceMenuItem menuItem = null; if (files.rootDirectory.Parent != null) { if (di.FullName == files.rootDirectory.Parent.FullName) { nm = ".."; menuItem = new aceMenuItem(nm, "", "<dir>", "<lock>", di); menuItem.helpLine = "Move to parent"; } } if (files.rootDirectory != null) { if (di.FullName == files.rootDirectory.FullName) { nm = "."; menuItem = new aceMenuItem(nm, "", "<dir>", "<lock>", di); menuItem.helpLine = "This directory"; } } if (String.IsNullOrEmpty(nm)) { nm = di.FullName.Replace(files.rootDirectory.FullName, ""); menuItem = new aceMenuItem(nm, "", "<dir>", "<lock>", di); menuItem.helpLine = di.FullName; } menu.setItem(menuItem); //if (path == di.FullName) //{ // menu.selected = menuItem; //} } foreach (var di in files.files) { aceMenuItem menuItem = new aceMenuItem(di.Name, "", di.LastWriteTime.ToShortDateString(), "", di); menuItem.helpLine = di.FullName; menu.setItem(menuItem); //if (path == di.FullName) //{ // menu.selected = menuItem; //} } pageManager = new textPageManager <aceMenuItem>(10); pageManager.refresh(menu); }
/// <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); }