private int FindAnchorIndex(ListAnchor anchor) { if (anchor.AnchorType == AnchorType.First) { return(0); } if (anchor.AnchorType == AnchorType.Last) { return(_keyList.Count); } if (anchor.RefId == null) { throw new ArgumentException("RefID must be not null for Before and After anchors"); } for (int i = 0; i < _keyList.Count; i++) { if (_keyList [i].Equals(anchor.RefId)) { if (anchor.AnchorType == AnchorType.Before) { return(i); } return(i + 1); } } return(-1); }
/// <summary> /// Scrolls the list to the list item at the given index. /// </summary> /// <param name="itemIndex">Item index.</param> /// <param name="scrollDelta">Controls the speed at which the list scrolls.</param> public void ScrollToListItem(int itemIndex, ListAnchor anchor = ListAnchor.Beginning, float offset = 0, float scrollDelta = 10000) { // Make sure we are initialized if (!initialized) { Initialize(); } if (itemIndex < 0) { throw new System.ArgumentOutOfRangeException("itemIndex", string.Format("[ListScrollRect] ScrollToListItem: itemIndex ({0}) must be greater than of equal to 0.", itemIndex)); } else if (itemIndex >= itemCount) { throw new System.ArgumentOutOfRangeException("itemIndex", string.Format("[ListScrollRect] ScrollToListItem: itemIndex ({0}) must be less than the item count ({1}).", itemIndex, itemCount)); } listInfo.ResetScroll(); listInfo.scrollAnchor = anchor; listInfo.scrollOffset = offset; listInfo.scrollDelta = scrollDelta; listInfo.scrollToIndex = itemIndex; listInfo.scrollingStart = SystemTimeInMilliseconds; listInfo.scrollFrom = ViewportPosition; }
public void RegisterGroup(string name, string submenuName, ListAnchor anchor) { if (_actionGroups.FindByKey(name) == null) { _actionGroups.Add(name, new MenuActionGroup(name, submenuName), anchor); } }
public void RegisterActionGroup(string groupId, ListAnchor anchor) { if (FindActionGroup(groupId) != null) { return; } ToolbarActionGroup newGroup = new ToolbarActionGroup(groupId); _actionGroups.Add(groupId, newGroup, anchor); int newGroupIndex = _actionGroups.IndexOf(newGroup); if (newGroupIndex == 0) { newGroup.StartIndex = 0; } else { newGroup.StartIndex = ((ToolbarActionGroup)_actionGroups [newGroupIndex - 1]).EndIndex; } ToolStripSeparator separator = new ToolStripSeparator(); _toolBar.Items.Insert(newGroup.StartIndex, separator); newGroup.Separator = separator; AdjustGroupIndices(newGroup, 1); }
private void CreateToolbarButton(IAction action, string groupId, ListAnchor anchor, int imageIndex, string text, string toolTip, string resourceType, IActionStateFilter[] filters) { if (groupId == null) { RegisterActionGroup(_defaultGroupId, ListAnchor.First); groupId = _defaultGroupId; } ToolbarActionGroup group = FindActionGroup(groupId); if (group == null) { throw new ArgumentException("\"" + groupId + "\" is not a registered toolbar action group.", "groupId"); } ToolStripButton button = new ToolStripButton(); button.Click += OnToolbarButtonClick; // Set the tooltip if (text == null) { text = ""; } if (toolTip == null) // Use button text for a tooltip by default { toolTip = text; } string kbdShortcut = Core.ActionManager.GetKeyboardShortcut(action); if (kbdShortcut.Length > 0) { button.ToolTipText = toolTip + " (" + kbdShortcut + ")"; } else { button.ToolTipText = toolTip; } button.Tag = action; button.ImageIndex = imageIndex; if (text.Length > 0) { button.Text = text; } ToolbarAction tbAction = new ToolbarAction(action, button, text, toolTip, resourceType, filters); int index = group.Actions.Add(action.ToString(), tbAction, anchor); if (index < 0) { throw new ActionException(String.Format("Attempt to register a duplicate toolbar action \"{0}\" in group \"{1}\" as \"{2}\", which conflicts with action \"{3}\" in the same group.", text, groupId, action.ToString(), ((ToolbarAction)group.Actions.FindByKey(action.ToString()))._defaultText)); } _toolBar.Items.Insert(group.StartIndex + index, button); AdjustGroupIndices(group, 1); }
public void RegisterContactEditBlock(int column, ListAnchor anchor, string blockID, ContactBlockCreator blockCreator) { #region Preconditions if (column != 0 && column != 1) { throw new ArgumentException("Contact view column index must be either 0 or 1", "column"); } #endregion Preconditions _blockCreators [column].Add(blockID, blockCreator, anchor); }
/// <summary> /// Registers a toolbar action and adds a toolbar control for it, using the given parameters to specify its look&feel. /// </summary> /// <param name="action">Action that executes on button clicks via its <see cref="IAction.Execute"/> method and that is queried for the button state via <see cref="IAction.Update"/>.</param> /// <param name="groupId">ID of the action group to which this action is added. You should register an action group at this toolbar with the same ID using the <see cref="RegisterActionGroup"/> method before using it. Note that action groups cause separators to be added in between the buttons of different action groups.</param> /// <param name="anchor">Placement within the group.</param> /// <param name="icon">Icon for the toolbar button, <c>Null</c> for no icon. Note that you have to cast a <c>Null</c> value explicitly for your call to be disambiguated to either of the overloads.</param> /// <param name="text">Button text. Once assigned, button text will be visible on the toolbar, either to the right of the button (the default) or below it.</param> /// <param name="tooltip">Tooltip to be used for the control. Specify a <c>Null</c> value if you wish to use the button text for tooltip text as well.</param> /// <param name="resourceType">Resource type that must be selected in the action context for this action to be available.</param> /// <param name="filters">Action filter that determines availability of the action.</param> public void RegisterAction(IAction action, string groupId, ListAnchor anchor, Icon icon, string text, string tooltip, string resourceType, IActionStateFilter[] filters) { int imageIndex = -1; if (icon != null) { _toolbarImages.Images.Add(icon); imageIndex = _toolbarImages.Images.Count - 1; } CreateToolbarButton(action, groupId, anchor, imageIndex, text, tooltip, resourceType, filters); }
/// <summary> /// Registers an action in an action group of the menu. /// </summary> public void RegisterAction(IAction action, string groupId, ListAnchor anchor, string text, Image iconRes, string resourceType, IActionStateFilter[] filters) { MenuActionGroup group = (MenuActionGroup)_actionGroups.FindByKey(groupId); if (group == null) { throw new ArgumentException("ContextMenuManager -- Invalid action group name " + groupId, "groupId"); } _mnemonicsAssigned = false; group.Add(new MenuAction(resourceType, text, iconRes, action, filters), anchor); }
public void RegisterContactEditBlock(string tabName, ListAnchor anchor, string blockID, ContactBlockCreator blockCreator) { #region Preconditions if (String.IsNullOrEmpty(tabName)) { throw new ArgumentException("Contact view Tab name must be non-null and not-empty string", "tabName"); } #endregion Preconditions AnchoredList list = _BlockCreatorsByTab.ContainsKey(tabName)? _BlockCreatorsByTab[tabName] : new AnchoredList();; list.Add(blockID, blockCreator, anchor); _BlockCreatorsByTab[tabName] = list; }
private static void RegisterFlagActionGroup(string id, ListAnchor anchor) { Core.ActionManager.RegisterContextMenuActionGroup(id, "Flag With", anchor); _flagActionManager.RegisterGroup(id, null, ListAnchor.Last); if (anchor.RefId == "ItemAnnotateActions") // HACK! { Core.ActionManager.RegisterMainMenuActionGroup(id, "Actions", "Flag With", new ListAnchor(AnchorType.After, "ActionAnnotationsActions")); } else { Core.ActionManager.RegisterMainMenuActionGroup(id, "Actions", "Flag With", anchor); } }
public static void RegisterLinksGroup(string groupId, int[] propTypes, ListAnchor anchor) { IntArrayList existingList = (IntArrayList)_linksPaneGroups.FindByKey(groupId); if (existingList != null) { foreach (int propType in propTypes) { if (existingList.IndexOf(propType) < 0) { existingList.Add(propType); } } } else { _linksPaneGroups.Add(groupId, new IntArrayList(propTypes), anchor); } }
public int Add(string key, object value, ListAnchor anchor) { if (!_allowDuplicates && FindByKey(key) != null) { return(-1); } int index = FindAnchorIndex(anchor); if (index == -1) { Trace.WriteLine("Couldn't find object to anchor to: " + anchor.RefId); index = _keyList.Count; } _keyList.Insert(index, key); _valueList.Insert(index, value); return(index); }
internal void Add(MenuAction action, ListAnchor anchor) { _actions.Add(action.Action.ToString(), action, anchor); }