Exemplo n.º 1
0
        public void MoveToMonitor(Monitor monitor)
        {
            //            if (_window.IsLoaded)
            //            {
            //                _window.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<Monitor>(MoveToMonitor), monitor);
            //                return;
            //            }
            this._window.Left = monitor.WorkArea.Left;
            this._window.Top = monitor.WorkArea.Top;
            this._window.Width = monitor.WorkArea.Width;
            this._window.Height = monitor.WorkArea.Height;

            //TODO: move monitor by win32 functions instead?
            //http://msdn.microsoft.com/en-us/library/dd162826(v=vs.85).aspx
        }
        /// <summary>
        /// Returns the number of Displays using the Win32 functions
        /// </summary>
        /// <returns>collection of Display Info</returns>
        private IEnumerable<Monitor> EnumerateMonitors()
        {
            var col = new List<Monitor>();
            int i = 0;
            Win32.User32.EnumDisplayMonitors(IntPtr.Zero,
                                             IntPtr.Zero,
                                             delegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Win32.RECT lprcMonitor, IntPtr dwData)
                                             {
                                                 var di = new Monitor(hMonitor, i);
                                                 col.Add(di);
                                                 i++;
                                                 return true;
                                             },
                                             IntPtr.Zero);

            return col;
        }
Exemplo n.º 3
0
 public MonitorVM(Monitor monitor)
 {
     _monitor = monitor;
     _hlaMonitor = new HighLevelMonitor(_monitor.HMonitor);
 }