//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// 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 CommonHelpers;

namespace UserWin {

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

public static bool ProvideMenuItemWithToolTip(MenuItem menuItem)
{
   if (menuItem.ToolTip!=null)
      return false;
   var command = menuItem.Command as RoutedUICommand;
   if (command!=null && command.Text!=null)
   {
      menuItem.ToolTip = command.Text;
      return true;
   }
   return false;
}

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

public static void ProvideMenuItemsWithToolTips(MenuItem menuItem)
{
   ProvideMenuItemsWithToolTips(menuItem,true);
}

public static void ProvideMenuItemsWithToolTips(MenuItem menuItem,bool processRoot)
{
   ProvideMenuItemsWithToolTips(menuItem,processRoot,true);
}

public static void ProvideMenuItemsWithToolTips(MenuItem menuItem,bool processRoot,bool recursive)
{
   UXLogicalTreeHelper.ProcessNodes
   (
      menuItem, processRoot, recursive,
      delegate (FrameworkElement element)
      {
         if (element is MenuItem)
            ProvideMenuItemWithToolTip((MenuItem)element);
      }
   );
}

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

public static void ProvideMenuItemsWithToolTips(Menu menu)
{
   ProvideMenuItemsWithToolTips(menu,true);
}

public static void ProvideMenuItemsWithToolTips(Menu menu,bool recursive)
{
   UXLogicalTreeHelper.ProcessNodes
   (
      menu, false, recursive,
      delegate (FrameworkElement element)
      {
         if (element is MenuItem)
            ProvideMenuItemWithToolTip((MenuItem)element);
      }
   );
}

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

} // UserWin
