//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// UserWin satellite library | Author: Sergei Y.Kitáev
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Text;
using System.Collections.Generic;

using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Documents;

using CommonHelpers;

namespace UserWin {

//**************************************************************************************************
partial class UXInput {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static bool ProvideToolTipWithGesture(FrameworkElement element)
{
   string toolTipString = element.ToolTip as string;
   if (toolTipString==null) return false;

   string keyGestureString = ExtractGestureDisplayString( element );
   if (keyGestureString==null) return false;

   var span = new Span(new Run(toolTipString));
   span.Inlines.Add(" (");
   span.Inlines.Add(new Bold(new Run(keyGestureString)));
   span.Inlines.Add(")");
   element.ToolTip = new TextBlock(span);

   return true;
}

//--------------------------------------------------------------------------------------------------

public static void ProvideToolTipsWithGestures(FrameworkElement root)
{
   ProvideToolTipsWithGestures(root,true);
}

public static void ProvideToolTipsWithGestures(FrameworkElement root,bool processRoot)
{
   UXLogicalTreeHelper.ProcessNodes
   (
      root,
      processRoot,
      delegate (FrameworkElement element)
      {
         ProvideToolTipWithGesture(element);
      }
   );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // UXInput
//**************************************************************************************************

} // UserWin
