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

using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

using CommonHelpers;

namespace UserWin {

//**************************************************************************************************
/// <summary>
/// </summary>
[SecurityPermission(SecurityAction.LinkDemand,Unrestricted=true)]
public static partial class UXVideo {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="HOperationFailedException" />
public static double DpiX
{
   get
   {
      int fullScreenPixelsX = Win32.GetSystemMetrics( Win32.SM_CXFULLSCREEN );
      if (fullScreenPixelsX==0)
         throw new HOperationFailedException( "Can not obtain horizontal screen resolution." );
      return fullScreenPixelsX / SystemParameters.FullPrimaryScreenWidth * StardardDpi;
   }
}

/// <exception cref="HOperationFailedException" />
public static double DpiY
{
   get
   {
      int fullScreenPixelsY = Win32.GetSystemMetrics( Win32.SM_CYFULLSCREEN );
      if (fullScreenPixelsY==0)
         throw new HOperationFailedException( "Can not obtain vertical screen resolution." );
      return fullScreenPixelsY / SystemParameters.FullPrimaryScreenHeight * StardardDpi;
   }
}

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

public static int UnitsToPixelsX(double unitsX)
{
   return (int)Math.Round( unitsX * DpiX / StardardDpi);
}

public static int UnitsToPixelsY(double unitsY)
{
   return (int)Math.Round( unitsY * DpiY / StardardDpi );
}

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

public static double PixelsToUnitsX(int pixelsX)
{
   return pixelsX / DpiX * StardardDpi;
}

public static double PixelsToUnitsY(int pixelsY)
{
   return pixelsY / DpiY * StardardDpi;
}

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

public const double StardardDpi = 96;

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

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

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // UXVideo
//**************************************************************************************************

} // UserWin
