/// <remarks> /// A reference implementation for ToString taken originally from GetTooltipTest(IClickAction) of /// ClearCanvas.Desktop.View.WinForms/ActiveToolbarButton.cs/r12907. /// This method now uses XKeysConverter, which is why we compare our results /// against this reference implementation. /// </remarks> private static string ReferenceToStringImplementation(XKeys keyStroke) { bool ctrl = (keyStroke & XKeys.Control) == XKeys.Control; bool alt = (keyStroke & XKeys.Alt) == XKeys.Alt; bool shift = (keyStroke & XKeys.Shift) == XKeys.Shift; XKeys keyCode = keyStroke & XKeys.KeyCode; StringBuilder builder = new StringBuilder(); if (keyCode != XKeys.None) { if (ctrl) { builder.Append("Ctrl"); } if (alt) { if (ctrl) { builder.Append("+"); } builder.Append("Alt"); } if (shift) { if (ctrl || alt) { builder.Append("+"); } builder.Append("Shift"); } if (ctrl || alt || shift) { builder.Append("+"); } builder.Append(XKeysConverter.FormatInvariant(keyCode)); } return(builder.ToString()); }
/// <summary> /// Sets all the relevant attributes on the <paramref name="xmlAction"/> from the <paramref name="action"/>. /// </summary> private static void SynchronizeAction(XmlElement xmlAction, IAction action) { xmlAction.SetAttribute("id", action.ActionID); xmlAction.SetAttribute("path", action.Path.ToString()); xmlAction.SetAttribute("group-hint", action.GroupHint.Hint); if (!action.Available) { xmlAction.SetAttribute("available", action.Available.ToString(System.Globalization.CultureInfo.InvariantCulture)); } var clickAction = action as IClickAction; if (clickAction == null) { return; } if (clickAction.KeyStroke != XKeys.None) { xmlAction.SetAttribute("keystroke", XKeysConverter.FormatInvariant(clickAction.KeyStroke)); } }