Ejemplo n.º 1
0
        private void btnRotate_Click(object sender, EventArgs e)
        {
            DisplayConfigRotation displayConfigRotation = (DisplayConfigRotation)Enum.Parse(typeof(DisplayConfigRotation), comRotate.Text);


            int numPathArrayElements;
            int numModeInfoArrayElements;

            const QueryDisplayFlags pathType = QueryDisplayFlags.OnlyActivePaths;

            // query active paths from the current computer.
            // note that 0 is equal to SUCCESS!
            // TODO; HARDCODE MAGIC VALUES AWAY.
            if (CCDWrapper.GetDisplayConfigBufferSizes(pathType, out numPathArrayElements,
                                                       out numModeInfoArrayElements) == 0)
            {
                var pathInfoArray = new DisplayConfigPathInfo[numPathArrayElements];
                var modeInfoArray = new DisplayConfigModeInfo[numModeInfoArrayElements];

                // TODO; FALLBACK MECHANISM THAT HANDLES DIFFERENT VALUES FOR ZERO.
                if (CCDWrapper.QueryDisplayConfig(
                        pathType,
                        ref numPathArrayElements, pathInfoArray,
                        ref numModeInfoArrayElements,
                        modeInfoArray, IntPtr.Zero) == 0)
                {
                    pathInfoArray[0].targetInfo.rotation = displayConfigRotation;
                    CCDWrapper.SetDisplayConfig(numPathArrayElements, pathInfoArray, numModeInfoArrayElements,
                                                modeInfoArray, SdcFlags.Apply | SdcFlags.UseSuppliedDisplayConfig);
                }
            }
        }
Ejemplo n.º 2
0
        public static Boolean GetDisplaySettings(ref CCDWrapper.DisplayConfigPathInfo[] pathInfoArray, ref CCDWrapper.DisplayConfigModeInfo[] modeInfoArray, Boolean ActiveOnly)
        {
            uint numPathArrayElements;
            uint numModeInfoArrayElements;

            // query active paths from the current computer.
            CCDWrapper.QueryDisplayFlags queryFlags = CCDWrapper.QueryDisplayFlags.AllPaths;
            if (ActiveOnly)
            {
                queryFlags = CCDWrapper.QueryDisplayFlags.OnlyActivePaths;
            }

            var status = CCDWrapper.GetDisplayConfigBufferSizes(queryFlags, out numPathArrayElements, out numModeInfoArrayElements);
            if (status == 0)
            {
                pathInfoArray = new CCDWrapper.DisplayConfigPathInfo[numPathArrayElements];
                modeInfoArray = new CCDWrapper.DisplayConfigModeInfo[numModeInfoArrayElements];

                status = CCDWrapper.QueryDisplayConfig(queryFlags,
                                                       ref numPathArrayElements, pathInfoArray, ref numModeInfoArrayElements,
                                                       modeInfoArray, IntPtr.Zero);
                if (status == 0)
                {
                    return true;
                }
            }

            return false;
        }