예제 #1
0
        /// <summary>
        ///     This is enum mapper. Essentially it maps from display-model specific to
        ///     interface specific enum.
        /// </summary>
        /// <param name="destEnum"></param>
        /// <returns></returns>
        public static DisplayRotation ToScreenRotation(this DisplayConfigRotation destEnum)
        {
            DisplayRotation toSourceEnum = 0x0;

            if ((destEnum & DisplayConfigRotation.Identity) == DisplayConfigRotation.Identity)
            {
                toSourceEnum |= DisplayRotation.Default;
            }

            if ((destEnum & DisplayConfigRotation.Rotate180) == DisplayConfigRotation.Rotate180)
            {
                toSourceEnum |= DisplayRotation.Rotated180;
            }

            if ((destEnum & DisplayConfigRotation.Rotate270) == DisplayConfigRotation.Rotate270)
            {
                toSourceEnum |= DisplayRotation.Rotated270;
            }

            if ((destEnum & DisplayConfigRotation.Rotate90) == DisplayConfigRotation.Rotate90)
            {
                toSourceEnum |= DisplayRotation.Rotated90;
            }

            return(toSourceEnum);
        }
예제 #2
0
        /// <summary>
        /// This is enum mapper. Essentially it maps from display-model specific to
        /// interface specific enum.
        /// </summary>
        /// <param name="destEnum"></param>
        /// <returns></returns>
        public static DisplayRotation ToScreenRotation(this Rotation destEnum)
        {
            DisplayRotation toSourceEnum = 0x0;

            if ((destEnum & Rotation.Default) == Rotation.Default)
            {
                toSourceEnum |= DisplayRotation.Default;
            }

            if ((destEnum & Rotation.Rotate180) == Rotation.Rotate180)
            {
                toSourceEnum |= DisplayRotation.Rotated180;
            }

            if ((destEnum & Rotation.Rotate270) == Rotation.Rotate270)
            {
                toSourceEnum |= DisplayRotation.Rotated270;
            }

            if ((destEnum & Rotation.Rotate90) == Rotation.Rotate90)
            {
                toSourceEnum |= DisplayRotation.Rotated90;
            }

            return(toSourceEnum);
        }
예제 #3
0
        void OnRotationChanged(object s, DeviceOrientationEventArgs e)
        {
            switch (e.DeviceOrientation)
            {
            case DeviceOrientation.Orientation_0:
                displayRotation    = DisplayRotation.Rotation0;
                displayOrientation = GetNaturalDisplayOrientation();
                break;

            case DeviceOrientation.Orientation_90:
                displayRotation    = DisplayRotation.Rotation90;
                displayOrientation = GetNaturalDisplayOrientation() == DisplayOrientation.Portrait ? DisplayOrientation.Landscape : DisplayOrientation.Portrait;
                break;

            case DeviceOrientation.Orientation_180:
                displayRotation    = DisplayRotation.Rotation180;
                displayOrientation = GetNaturalDisplayOrientation();
                break;

            case DeviceOrientation.Orientation_270:
                displayRotation    = DisplayRotation.Rotation270;
                displayOrientation = GetNaturalDisplayOrientation() == DisplayOrientation.Portrait ? DisplayOrientation.Landscape : DisplayOrientation.Portrait;
                break;

            default:
                displayRotation    = DisplayRotation.Unknown;
                displayOrientation = DisplayOrientation.Unknown;
                break;
            }
            OnMainDisplayInfoChanged();
        }
 public DisplayInfo(double width, double height, double density, DisplayOrientation orientation, DisplayRotation rotation)
 {
     Width       = width;
     Height      = height;
     Density     = density;
     Orientation = orientation;
     Rotation    = rotation;
 }
예제 #5
0
 /// <summary>
 /// Retrieves the display mode's spatial resolution, color resolution, refresh frequency, and rotation settings.
 /// </summary>
 /// <param name="swapChain">The swap chain.</param>
 /// <param name="rotation">The <see cref="DisplayRotation"/> structure indicating the type of screen rotation the application will do.</param>
 /// <returns><see cref="DisplayModeEx"/> structure containing data about the display mode of the adapter</returns>
 /// <unmanaged>HRESULT IDirect3DDevice9Ex::GetDisplayModeEx([In] unsigned int iSwapChain,[Out] D3DDISPLAYMODEEX* pMode,[In] void* pRotation)</unmanaged>
 public DisplayModeEx GetDisplayModeEx(int swapChain, out DisplayRotation rotation)
 {
     unsafe
     {
         fixed(void *pRotation = &rotation)
         return(GetDisplayModeEx(swapChain, (IntPtr)pRotation));
     }
 }
예제 #6
0
 public DisplayInfo(double width, double height, double density, DisplayOrientation orientation, DisplayRotation rotation, float rate)
 {
     Width       = width;
     Height      = height;
     Density     = density;
     Orientation = orientation;
     Rotation    = rotation;
     RefreshRate = rate;
 }
예제 #7
0
 public DisplaySettings(Size resolution, Point origin, DisplayRotation rotation, int refreshRate, bool isPrimary, string name) : this()
 {
     Resolution  = resolution;
     Origin      = origin;
     Rotation    = rotation;
     RefreshRate = refreshRate;
     IsPrimary   = isPrimary;
     Name        = name;
 }
예제 #8
0
 /// <summary>
 /// The rotate.
 /// </summary>
 /// <param name="newRotation">
 /// The new rotation.
 /// </param>
 public void Rotate(DisplayRotation newRotation)
 {
     SafeNativeMethods.DEVMODE mode = GetDeviceMode();
     uint temp = mode.dmPelsWidth;
     mode.dmPelsWidth = mode.dmPelsHeight;
     mode.dmPelsHeight = temp;
     mode.dmDisplayOrientation = (uint)newRotation;
     var result = SafeNativeMethods.ChangeDisplaySettings(ref mode, 0);
 }
예제 #9
0
        /// <summary>
        /// The rotate.
        /// </summary>
        /// <param name="newRotation">
        /// The new rotation.
        /// </param>
        public void Rotate(DisplayRotation newRotation)
        {
            SafeNativeMethods.DEVMODE mode = GetDeviceMode();
            uint temp = mode.dmPelsWidth;

            mode.dmPelsWidth          = mode.dmPelsHeight;
            mode.dmPelsHeight         = temp;
            mode.dmDisplayOrientation = (uint)newRotation;
            var result = SafeNativeMethods.ChangeDisplaySettings(ref mode, 0);
        }
예제 #10
0
 /// <summary>
 /// Initialize new instance of Win7Display
 /// </summary>
 /// <param name="resolution">See Resolution property.</param>
 /// <param name="origin">See Origin property.</param>
 /// <param name="rotation">See Rotation property.</param>
 /// <param name="refreshRate">See RefreshRate property.</param>
 /// <param name="isPrimary">See IsPrimary property.</param>
 /// <param name="name">See Name property.</param>
 public DisplaySettings(Size resolution, Point origin, DisplayRotation rotation, 
     int refreshRate, bool isPrimary, string name)
     : this()
 {
     Resolution = resolution;
     Origin = origin;
     Rotation = rotation;
     RefreshRate = refreshRate;
     IsPrimary = isPrimary;
     Name = name;
 }
예제 #11
0
        public void DeviceDisplay_Comparison(
            double width1,
            double height1,
            double density1,
            DisplayOrientation orientation1,
            DisplayRotation rotation1,
            double width2,
            double height2,
            double density2,
            DisplayOrientation orientation2,
            DisplayRotation rotation2,
            bool equals)
        {
            var device1 = new DisplayInfo(
                width: width1,
                height: height1,
                density: density1,
                orientation: orientation1,
                rotation: rotation1);

            var device2 = new DisplayInfo(
                width: width2,
                height: height2,
                density: density2,
                orientation: orientation2,
                rotation: rotation2);

            if (equals)
            {
                Assert.True(device1.Equals(device2));
                Assert.True(device1 == device2);
                Assert.False(device1 != device2);
                Assert.Equal(device1, device2);
                Assert.Equal(device1.GetHashCode(), device2.GetHashCode());
            }
            else
            {
                Assert.False(device1.Equals(device2));
                Assert.True(device1 != device2);
                Assert.False(device1 == device2);
                Assert.NotEqual(device1, device2);
                Assert.NotEqual(device1.GetHashCode(), device2.GetHashCode());
            }
        }
        private void UpdateLayout()
        {
            DisplayInfo        mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
            DisplayOrientation orientation     = mainDisplayInfo.Orientation;
            DisplayRotation    rotation        = mainDisplayInfo.Rotation;
            double             width           = mainDisplayInfo.Width;
            double             height          = mainDisplayInfo.Height;
            double             density         = mainDisplayInfo.Density;

            if (orientation == DisplayOrientation.Landscape)
            {
                ChartsPerRow = 2;
            }
            else
            {
                ChartsPerRow = 1;
            }
            ChartWidth = (int)((width / density) / ChartsPerRow);
        }
예제 #13
0
        public DisplayInfo()
        {
            DeviceDisplay.MainDisplayInfoChanged += OnMainDisplayInfoChanged;

            // Get Metrics
            var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;

            // Orientation (Landscape, Portrait, Square, Unknown)
            OrientationScreen = mainDisplayInfo.Orientation;

            // Rotation (0, 90, 180, 270)
            RotationScreen = mainDisplayInfo.Rotation;

            // Width (in pixels)
            WidthScreen = mainDisplayInfo.Width;

            // Height (in pixels)
            HeighScreen = mainDisplayInfo.Height;

            // Screen density
            DensityScreen = mainDisplayInfo.Density;
        }
예제 #14
0
        static int[] ConvertDegreeArray(DisplayRotation value)
        {
            List <int> rotations = new List <int>();

            if (value.HasFlag(DisplayRotation.Degree_0))
            {
                rotations.Add(0);
            }
            if (value.HasFlag(DisplayRotation.Degree_90))
            {
                rotations.Add(90);
            }
            if (value.HasFlag(DisplayRotation.Degree_180))
            {
                rotations.Add(180);
            }
            if (value.HasFlag(DisplayRotation.Degree_270))
            {
                rotations.Add(270);
            }
            return(rotations.ToArray());
        }
예제 #15
0
 public void Rotate(DisplayRotation newRotation)
 {
     throw new System.NotImplementedException();
 }
예제 #16
0
 public override bool SetRotation(Display display, DisplayRotation rotation)
 {
     throw new NotImplementedException();
 }
예제 #17
0
 /// <summary>
 ///     Tries to set to rotation of display.
 /// </summary>
 /// <param name="rotation">the value of rotation</param>
 /// <returns>true if successful, false otherwise.</returns>
 public bool SetRotation(DisplayRotation rotation)
 {
     return false;
 }
예제 #18
0
 /// <summary>
 ///     Tries to set to rotation of display.
 /// </summary>
 /// <param name="rotation">the value of rotation</param>
 /// <returns>true if successful, false otherwise.</returns>
 public bool SetRotation(DisplayRotation rotation)
 {
     return(false);
 }
 public abstract bool SetRotation(Display display, DisplayRotation rotation);
예제 #20
0
 public override bool SetRotation(Display display, DisplayRotation rotation)
 {
     throw new NotImplementedException();
 }
예제 #21
0
 public void Rotate(DisplayRotation newRotation)
 {
     throw new System.NotImplementedException();
 }
예제 #22
0
 /// <summary>
 /// Construct with width/heigh/bit depth/refresh rate and rotation parameters
 /// </summary>
 /// <param name="targetWidth"></param>
 /// <param name="targetHeight"></param>
 /// <param name="targetBitDepth"></param>
 /// <param name="targetRefreshRate"></param>
 /// <param name="targetRotation"></param>
 public TargetDisplayMode(int targetWidth, int targetHeight, int targetBitDepth, int targetRefreshRate, DisplayRotation targetRotation)
     : this(targetWidth, targetHeight, targetBitDepth, targetRefreshRate)
 {
     this.TargetRotation = targetRotation;
     this.SetRotation    = true;
 }
예제 #23
0
 /// <summary>
 /// Retrieves the display mode's spatial resolution, color resolution, refresh frequency, and rotation settings.
 /// </summary>
 /// <param name="swapChain">The swap chain.</param>
 /// <param name="rotation">The <see cref="DisplayRotation"/> structure indicating the type of screen rotation the application will do.</param>
 /// <returns><see cref="DisplayModeEx"/> structure containing data about the display mode of the adapter</returns>
 /// <unmanaged>HRESULT IDirect3DDevice9Ex::GetDisplayModeEx([In] unsigned int iSwapChain,[Out] D3DDISPLAYMODEEX* pMode,[In] void* pRotation)</unmanaged>	
 public DisplayModeEx GetDisplayModeEx(int swapChain, out DisplayRotation rotation)
 {
     unsafe
     {
         fixed (void* pRotation = &rotation)
             return GetDisplayModeEx(swapChain, (IntPtr)pRotation);
     }
 }
 public abstract bool SetRotation(Display display, DisplayRotation rotation);