Esempio n. 1
0
        /// <summary>
        ///     Converts a rectangle from a Win32 RECT to an Avalon Rect
        /// </summary>
        /// <param name="rc">
        ///     The rectangle as a Win32 RECT
        /// </param>
        /// <returns>
        ///     The rectangle as an Avalon Rect
        /// </returns>
        internal static Rect ToRect(RECT rc)
        {
            Rect rect = new Rect();

            rect.X = rc.Left;
            rect.Y = rc.Top;
            rect.Width = rc.Width;
            rect.Height = rc.Height;

            return rect;
        }
Esempio n. 2
0
        /// <summary>
        ///     Converts a rectangle from an Avalon Rect to a Win32 RECT
        /// </summary>
        /// <remarks>
        ///     Rounds "double" values to the nearest "int"
        /// </remarks>
        /// <param name="rect">
        ///     The rectangle as an Avalon Rect
        /// </param>
        /// <returns>
        ///     The rectangle as a Win32 RECT
        /// </returns>
        internal static RECT FromRect(Rect rect)
        {
            var rc = new RECT();

            rc.Top = DoubleUtil.DoubleToInt(rect.Y);
            rc.Left = DoubleUtil.DoubleToInt(rect.X);
            rc.Bottom = DoubleUtil.DoubleToInt(rect.Bottom);
            rc.Right = DoubleUtil.DoubleToInt(rect.Right);

            return rc;
        }
 public bool GetSourceRect(
     out int left,
     out int top,
     out int right,
     out int bottom)
 {
     left = 0;
     top = 0;
     right = 0;
     bottom = 0;
     try
     {
         RECT rt = new RECT();
         var ret = LibPlayerApi.Sts_GetSourceRect(this.handle, out rt);
         if (ret)
         {
             left = rt.Left;
             top = rt.Top;
             right = rt.Right;
             bottom = rt.Bottom;
         }
         return ret;
     }
     catch (Exception except)
     {
         System.Diagnostics.Trace.TraceError("LibPlayerApi exception: {0}", except.Message);
         return false;
     }
 }
 public bool SetSourceRect(
     int left,
     int top,
     int right,
     int bottom)
 {
     var rt = new RECT
     {
         Left = left,
         Top = top,
         Right = right,
         Bottom = bottom
     };
     return LibPlayerApi.CallUtil(
         () => LibPlayerApi.Sts_SetSourceRect(this.handle, ref rt)
         );
 }
Esempio n. 5
0
 public static RECT Union(RECT rect1, RECT rect2)
 {
     return new RECT
     {
         Left = Math.Min(rect1.Left, rect2.Left),
         Top = Math.Min(rect1.Top, rect2.Top),
         Right = Math.Max(rect1.Right, rect2.Right),
         Bottom = Math.Max(rect1.Bottom, rect2.Bottom),
     };
 }