Example #1
0
 private static void SetShowOnDisabled(DependencyObject dependencyObject, CommandToolTipStyle toolTipStyle)
 {
     if (toolTipStyle == CommandToolTipStyle.Always || toolTipStyle == CommandToolTipStyle.AlwaysWithKeyGesture)
     {
         ToolTipService.SetShowOnDisabled(dependencyObject, true);
     }
 }
Example #2
0
        private static object FormatToolTip(ClientCommand command, string toolTip, CommandToolTipStyle toolTipStyle)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            if (toolTipStyle == CommandToolTipStyle.None || string.IsNullOrEmpty(toolTip))
            {
                return(null);
            }

            if (toolTipStyle != CommandToolTipStyle.AlwaysWithKeyGesture &&
                toolTipStyle != CommandToolTipStyle.EnabledWithKeyGesture)
            {
                return(toolTip);
            }

            if (command.UICommand.InputGestures.Count > 0)
            {
                KeyGesture keyGesture = command.UICommand.InputGestures[0] as KeyGesture;
                if (keyGesture != null && keyGesture.DisplayString.Length > 0)
                {
                    toolTip = string.Format(ToolTipKeyGestureFormat, toolTip, keyGesture.DisplayString);
                }
            }

            return(toolTip);
        }
Example #3
0
        private static object GetCommandToolTip(ClientCommand command, CommandToolTipStyle toolTipStyle)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            if (toolTipStyle == CommandToolTipStyle.None)
            {
                return(null);
            }

            return(command.Meta.ToolTip.Translate());
        }
Example #4
0
        public static void SetupTooltip(FrameworkElement item, ClientCommand command, CommandToolTipStyle toolTipStyle)
        {
            // tooltip
            if (item.ToolTip == null && command != null)
            {
                item.ToolTip = GetCommandToolTip(command, toolTipStyle);
            }
            if (item.ToolTip is string && command != null)
            {
                item.ToolTip = FormatToolTip(command, item.ToolTip as string, toolTipStyle);
            }

            SetShowOnDisabled(item, toolTipStyle);
        }