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

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

using CommonHelpers;

namespace UserWin {

//**************************************************************************************************
/// <summary>
/// </summary>
public static partial class UXFocus {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static void StrictFocus(UIElement element)
{
   StrictFocusEx( element );
}

public static bool MoveToFirstElementOf(UIElement element)
{
   HArgChecking.VerifyNotNull( element );
   return element.MoveFocus( new TraversalRequest(FocusNavigationDirection.First) );
}

/// <exception cref="ArgumentNullException" />
/// <exception cref="HOperationFailedException" />
public static void StrictMoveToFirstElementOf(UIElement element)
{
   if (!MoveToFirstElementOf( element ))
      throw new HOperationFailedException( "Can not move keyboard focus." );
}

//==================================================================================================

/// <exception cref="ArgumentNullException" />
/// <exception cref="HOperationFailedException" />
public static void StrictFocusEx(object element)
{
   HArgChecking.VerifyNotNull( element );
   if (!((UIElement)element).Focus())
      throw HOpFailedExceptionCreator.Create(
         "Can not set keyboard focus to element: \"{0}\".",
         element );
}

//==================================================================================================

static UXFocus()
{
   UserWin_Library.Access();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // UXFocus
//**************************************************************************************************

} // UserWin
