public static IMonitorHandle Watch(Func <string> o) { var handle = new MonitorHandle(o); monitoredObjects.Add(handle, o); return(handle); }
/// <summary> /// Initializes a new instance of the <see cref="NativeWindowSettings"/> class. /// </summary> public NativeWindowSettings() { unsafe { GLFWProvider.EnsureInitialized(); CurrentMonitor = new MonitorHandle((IntPtr)GLFW.GetPrimaryMonitor()); } }
public override int GetHashCode() { int hashCode = -810864280; hashCode = hashCode * -1521134295 + EqualityComparer <VirtualDesktop> .Default.GetHashCode(VirtualDesktop); hashCode = hashCode * -1521134295 + MonitorHandle.GetHashCode(); hashCode = hashCode * -1521134295 + Window.GetHashCode(); return(hashCode); }
/// <summary> /// Try to get information about a monitor. /// </summary> /// <param name="monitor">The window handle.</param> /// <param name="info">Monitor information.</param> /// <returns>True when the object was retrieved from cache, or built successfully.</returns> public static bool TryGetMonitorInfo(MonitorHandle monitor, out MonitorInfo info) { if (_monitorIndexLookup.TryGetValue(monitor.Pointer, out int index)) { return(TryGetMonitorInfo(index, out info)); } info = null; return(false); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: _initialMonitor = window.MonitorFromWindow(); _screen = Windows.GetMonitorInfo(_initialMonitor).Monitor; window.SetTimer(_timerId, 200); return(0); case MessageType.Size: _client = new Rectangle(default, new Message.Size(wParam, lParam).NewSize); return(0); case MessageType.Timer: // Update via timer if we aren't primarily on the main monitor if (window.MonitorFromWindow() != _initialMonitor) { window.Invalidate(); } return(0); case MessageType.Move: window.Invalidate(); return(0); case MessageType.Paint: using (DeviceContext clientDC = window.BeginPaint()) using (DeviceContext screenDC = Gdi.GetDeviceContext()) { clientDC.SetStretchBlitMode(StretchMode.HalfTone); screenDC.StretchBlit(clientDC, _screen, _client, RasterOperation.Common.SourceCopy); } return(0); case MessageType.Destroy: window.KillTimer(_timerId); break; } return(base.WindowProcedure(window, message, wParam, lParam)); }
/// <summary> /// Initializes a new instance of the <see cref="MonitorInfo"/> class. /// </summary> /// <remarks> /// <paramref pref="handle"/> must be a valid pointer to a monitor. /// </remarks> /// <param name="handle">An opaque handle to a monitor.</param> internal MonitorInfo(MonitorHandle handle) { if (!GLFWProvider.IsOnMainThread) { throw new NotSupportedException("Only the GLFW thread can construct this object."); } if (handle.Pointer == IntPtr.Zero) { throw new ArgumentNullException(nameof(handle)); } _handle = handle; GetClientArea(); GetPhysicalSize(); GetScale(); // DO NOT call these methods before the above Get* methods. CalculateMonitorDpi(); CalculateMonitorRawDpi(); }
public void pointerSimple() { var path = Path.GetTempFileName(); System.IO.File.WriteAllText(path, pointerTest1); var translator = new vmtranslator.vmtranslator(path); var assembly = translator.TranslateToAssembly().ToList(); assembly.Add(assembler.CommandType.HALT.ToString()); System.IO.File.WriteAllLines(path, assembly); var assemblerInstance = new assembler.Assembler(path); var assembledResult = assemblerInstance.ConvertToBinary(); var binaryProgram = assembledResult.Select(x => Convert.ToInt32(x, 16)); var simulatorInstance = new simulator.eightChipsSimulator(16, (int)Math.Pow(2, 16)); simulatorInstance.setUserCode(binaryProgram.ToArray()); simulatorInstance.ProgramCounter = (int)MemoryMap[MemoryMapKeys.user_code].AbsoluteStart; var pt1Monitor = new MonitorHandle <int>(3032, simulatorInstance.mainMemory); var pt2Monitor = new MonitorHandle <int>(3046, simulatorInstance.mainMemory); var thismon = new MonitorHandle <int>(259, simulatorInstance.mainMemory); var thatmon = new MonitorHandle <int>(260, simulatorInstance.mainMemory); simulatorInstance.runSimulation(); //simulatorInstance.printMemory(0); var sp = simulatorInstance.mainMemory[simulatorInstance.mainMemory[256] - 1]; //simulatorInstance.printMemory(0); Assert.AreEqual(6084, sp); var pt1values = pt1Monitor.getValues(); var pt2values = pt2Monitor.getValues(); var thisvalues = thismon.getValues(); var thatvalues = thatmon.getValues(); new List <List <int> >() { pt1values, pt2values, thisvalues, thatvalues }.ForEach(x => { x.ForEach(y => Console.WriteLine(y)); Console.WriteLine("---------------"); }); //pointers are set correctly //TODO I am not sure 100% sure these 27x values are correct. Assert.IsTrue(new int[] { 0, 272, 3030, 272, 272 }.SequenceEqual(thisvalues)); Assert.IsTrue(new int[] { 0, 273, 3040, 273, 273 }.SequenceEqual(thatvalues)); //Assert.AreEqual(3030, simulatorInstance.mainMemory[259]); //Assert.AreEqual(3040, simulatorInstance.mainMemory[260]); //values at pointers are correct. //TODO not sure how to check this or what the correct value should be because we set the //pointers back when returning - we may want to use monitors for these mem locations instead. Assert.IsTrue(new int[] { 0, 32 }.SequenceEqual(pt1values)); Assert.IsTrue(new int[] { 0, 46 }.SequenceEqual(pt2values)); }
public void GetDefaultMonitor() { MonitorHandle handle = Windows.MonitorFromWindow(default, MonitorOption.DefaultToPrimary);
internal Monitor(string name, MonitorHandle monitor) { MonitorHandle = monitor; Name = name; }
/// <summary> /// Initializes a new instance of the <see cref="MonitorEventArgs"/> struct. /// </summary> /// <param name="monitor">The <see cref="Monitor"/> which triggered the event.</param> /// <param name="isConnected">Whether the <see cref="Monitor"/> is connected.</param> public MonitorEventArgs(MonitorHandle monitor, bool isConnected) { Monitor = monitor; IsConnected = isConnected; }