示例#1
0
        public IdealMonitorRect(MonitorHelper.DisplayInfo monitorToWatch)
        {
            _monitorToWatch = monitorToWatch;


            ScreenRectangle monitorRect = new ScreenRectangle(_monitorToWatch.WorkArea);

            System.Drawing.Rectangle rMonitor = RecFromScreenRec(monitorRect);
            _monitorRect = rMonitor;
            _bestRect    = rMonitor;
        }
示例#2
0
        private static System.Drawing.Rectangle GetBestRectangleOfMonitor(MonitorHelper.DisplayInfo monitor, List <AppInfo> allApps)
        {
            bool isFirstRect = true;

            System.Drawing.Rectangle boundingRec = new Rectangle();

            ScreenRectangle monitorRect = new ScreenRectangle(monitor.WorkArea);

            System.Drawing.Rectangle rMonitor  = RecFromScreenRec(monitorRect);
            System.Drawing.Rectangle rMonitor2 = new Rectangle(rMonitor.Left - 15, rMonitor.Top - 15, rMonitor.Width + 30, rMonitor.Height + 30);


            foreach (var anApp in allApps)
            {
                //Is the app fully contained in the window
                System.Drawing.Rectangle appRec = RecFromScreenRec(anApp.Rect);
                if (IsMinAppSize(appRec))
                {
                    if (rMonitor.Contains(appRec) || rMonitor2.Contains(appRec))
                    {
                        System.Diagnostics.Debug.WriteLine(anApp.AppName + "contained on Monitor");
                        if (isFirstRect)
                        {
                            boundingRec = appRec;
                            isFirstRect = false;
                        }
                        else
                        {
                            boundingRec = System.Drawing.Rectangle.Union(boundingRec, appRec);
                        }
                    }
                }
            }

            if (!IsMinAppSize(boundingRec))
            {
                return(rMonitor);
            }

            return(boundingRec);
        }
示例#3
0
 private static System.Drawing.Rectangle RecFromScreenRec(ScreenRectangle r)
 {
     return(new System.Drawing.Rectangle(r.Left, r.Top, r.Right - r.Left, r.Bottom - r.Top));
 }