private IntPtr GetQuartzDevice(CarbonWindowInfo carbonWindow) { IntPtr windowRef = carbonWindow.WindowRef; if (CarbonGLNative.WindowRefMap.ContainsKey(windowRef) == false) { return(IntPtr.Zero); } WeakReference nativeRef = CarbonGLNative.WindowRefMap[windowRef]; if (nativeRef.IsAlive == false) { return(IntPtr.Zero); } CarbonGLNative window = nativeRef.Target as CarbonGLNative; if (window == null) { return(IntPtr.Zero); } return(QuartzDisplayDeviceDriver.HandleTo(window.TargetDisplayDevice)); }
public override sealed bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { IntPtr num1 = QuartzDisplayDeviceDriver.HandleTo(device); IntPtr num2 = CG.DisplayCurrentMode(num1); if (!this.storedModes.ContainsKey(num1)) { this.storedModes.Add(num1, num2); } CFArray cfArray = new CFArray(CG.DisplayAvailableModes(num1)); for (int index = 0; index < cfArray.Count; ++index) { CFDictionary cfDictionary = new CFDictionary(cfArray[index]); int num3 = (int)cfDictionary.GetNumberValue("Width"); int num4 = (int)cfDictionary.GetNumberValue("Height"); int num5 = (int)cfDictionary.GetNumberValue("BitsPerPixel"); double numberValue = cfDictionary.GetNumberValue("RefreshRate"); if (num3 == resolution.Width && num4 == resolution.Height && (num5 == resolution.BitsPerPixel && Math.Abs(numberValue - (double)resolution.RefreshRate) < 1E-06)) { if (!this.displaysCaptured.Contains(num1)) { int num6 = (int)CG.DisplayCapture(num1); } CG.DisplaySwitchToMode(num1, cfArray[index]); return(true); } } return(false); }
private IntPtr GetQuartzDevice(CarbonWindowInfo carbonWindow) { IntPtr windowRef = carbonWindow.WindowRef; if (!CarbonGLNative.WindowRefMap.ContainsKey(windowRef)) { return(IntPtr.Zero); } WeakReference weakReference = CarbonGLNative.WindowRefMap[windowRef]; if (!weakReference.IsAlive) { return(IntPtr.Zero); } CarbonGLNative carbonGlNative = weakReference.Target as CarbonGLNative; if (carbonGlNative == null) { return(IntPtr.Zero); } else { return(QuartzDisplayDeviceDriver.HandleTo(carbonGlNative.TargetDisplayDevice)); } }
public override sealed bool TryRestoreResolution(DisplayDevice device) { IntPtr index = QuartzDisplayDeviceDriver.HandleTo(device); if (!this.storedModes.ContainsKey(index)) { return(false); } CG.DisplaySwitchToMode(index, this.storedModes[index]); int num = (int)CG.DisplayRelease(index); this.displaysCaptured.Remove(index); return(true); }