/// <summary>
        /// <para>Returns the current System status</para>
        /// </summary>
        /// <returns></returns>
        public static TreeNode GetStatus()
        {
            TreeNode tnMain = new TreeNode("Screens (" + AllScreens.Count + ")");

            AllScreens.ForEach(new Action <ScreenEx>(screen =>
            {
                TreeNode tnScreen = tnMain.Nodes.Add(screen.Name);
                tnScreen.Nodes.Add("Primary: " + screen.Primary.ToString());
                tnScreen.Nodes.Add("Color depth: " + screen.BitsPerPixel + "bit");
                tnScreen.Nodes.Add("Resolution: " + screen.Bounds.Width + "x" + screen.Bounds.Height);
                tnScreen.Nodes.Add("Position: " + screen.Bounds.X + " | " + screen.Bounds.Y);
                tnScreen.Nodes.Add("Display orientation: " + screen.Orientation.ToString());
                tnScreen.Nodes.Add("Refresh rate: " + screen.Frequency);
            }));
            return(tnMain);
        }
        /// <summary>
        /// Initializes all <see cref="Screen"/>s for this game, and adds them to <see cref="AllScreens"/>.
        /// </summary>
        protected override void InitializeScreens()
        {
            //I have subclassed the Screen class for the various screens, such as the main menu
            //The constructor of my subclass (for each of them) performs initialization tasks

            //Special case for the main menu: I use an object initializer to set it to visible.
            AllScreens.Add(new MainMenu(SpriteBatch)
            {
                Visible = true
            });
            AllScreens.Add(new VideoPlayerScreen(SpriteBatch));
            AllScreens.Add(new MultiplayerScreen(SpriteBatch));
            AllScreens.Add(new LoadingScreen(SpriteBatch));
            AllScreens.Add(new GameLobbyScreen(SpriteBatch));
            AllScreens.Add(new AnimationScreen(SpriteBatch));
        }
        public static int GetMonitorCount()
        {
            AllScreens.Clear();
            int             monCount = 0;
            MonitorEnumProc callback = (IntPtr hDesktop, IntPtr hdc, ref ScreenRectangle prect, int d) =>
            {
                //Console.WriteLine("Left {0}", prect.left);
                //Console.WriteLine("Right {0}", prect.right);
                //Console.WriteLine("Top {0}", prect.top);
                //Console.WriteLine("Bottom {0}", prect.bottom);
                AllScreens.AddLast(new DeskScreen(prect));
                return(++monCount > 0);
            };

            EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, callback, 0);
            //if (EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, callback, 0))
            //    Console.WriteLine("You have {0} monitors", monCount);
            //else
            //    Console.WriteLine("An error occured while enumerating monitors");

            return(monCount);
        }
Exemple #4
0
 /// <summary>
 /// Ends drawing of the frame.
 /// </summary>
 protected override void EndDraw()
 {
     AllScreens.EndDraw();
     base.EndDraw();
 }
Exemple #5
0
 /// <summary>
 /// Begins drawing the frame.
 /// </summary>
 /// <returns>Whether or not to draw the frame.</returns>
 protected override bool BeginDraw()
 {
     AllScreens.BeginDraw();
     return(base.BeginDraw());
 }
Exemple #6
0
 /// <summary>
 /// Updates the visible Screens on this Game.
 /// </summary>
 /// <param name="gameTime">The current GameTime.</param>
 protected override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     AllScreens.Update(gameTime);
 }
        public Eto.Drawing.PointF GetLogicalLocation(T screen)
        {
            /**/
            var bounds        = GetBounds(screen);
            var primaryScreen = PrimaryScreen;

            if (screen.Equals(primaryScreen))
            {
                return(bounds.Location.ToEto());
            }
            var primaryBounds = GetBounds(primaryScreen);

            Eto.Drawing.PointF location = primaryBounds.Location.ToEto();

            // this finds all adjacent screens between the primary screen and the specified screen
            // to calculate it's logical position

            // if it is not adjacent, we use the maximum pixel size to figure out its position.
            var allScreens = AllScreens.ToList();

            var maxLogicalPixelSize = GetMaxLogicalPixelSize();

            if (bounds.X < primaryBounds.X)
            {
                var adjacentScreen = primaryScreen;
                foreach (var scn in allScreens.OrderByDescending(s => GetBounds(s).X))
                {
                    var scnBounds = GetBounds(scn);
                    if (scnBounds.X > primaryBounds.X || (!scn.Equals(screen) && bounds.Right > scnBounds.X))
                    {
                        continue;
                    }
                    if (scnBounds.X < bounds.X)
                    {
                        break;
                    }
                    if (scnBounds.Right == GetBounds(adjacentScreen).X)
                    {
                        var logicalSize = GetLogicalSize(scn);
                        location.X    -= logicalSize.Width;
                        adjacentScreen = scn;
                    }
                    if (scn.Equals(screen))
                    {
                        break;
                    }
                }
                if (!adjacentScreen.Equals(screen))
                {
                    location.X = bounds.X / maxLogicalPixelSize;
                }
            }
            else if (bounds.X > primaryBounds.X)
            {
                var adjacentScreen = primaryScreen;
                foreach (var scn in allScreens.OrderBy(s => GetBounds(s).X))
                {
                    var scnBounds = GetBounds(scn);
                    if (scnBounds.X < primaryBounds.X || (!scn.Equals(screen) && bounds.X < scnBounds.Right))
                    {
                        continue;
                    }
                    if (scnBounds.X > bounds.X)
                    {
                        break;
                    }
                    if (scnBounds.X == GetBounds(adjacentScreen).Right)
                    {
                        var logicalSize = GetLogicalSize(adjacentScreen);
                        location.X    += logicalSize.Width;
                        adjacentScreen = scn;
                    }
                    if (scn.Equals(screen))
                    {
                        break;
                    }
                }
                if (!adjacentScreen.Equals(screen))
                {
                    location.X = bounds.X / maxLogicalPixelSize;
                }
            }

            if (bounds.Y < primaryBounds.Y)
            {
                var adjacentScreen = primaryScreen;
                foreach (var scn in allScreens.OrderByDescending(s => GetBounds(s).Y))
                {
                    var scnBounds = GetBounds(scn);
                    if (scnBounds.Y > primaryBounds.Y || (!scn.Equals(screen) && bounds.Bottom > scnBounds.Y))
                    {
                        continue;
                    }
                    if (scnBounds.Y < bounds.Y)
                    {
                        break;
                    }
                    if (scnBounds.Bottom == GetBounds(adjacentScreen).Y)
                    {
                        var logicalSize = GetLogicalSize(scn);
                        location.Y    -= logicalSize.Height;
                        adjacentScreen = scn;
                    }
                    if (scn.Equals(screen))
                    {
                        break;
                    }
                }
                if (!adjacentScreen.Equals(screen))
                {
                    location.Y = bounds.Y / maxLogicalPixelSize;
                }
            }
            else if (bounds.Y > primaryBounds.Y)
            {
                var adjacentScreen = primaryScreen;
                foreach (var scn in allScreens.OrderBy(s => GetBounds(s).Y))
                {
                    var scnBounds = GetBounds(scn);
                    if (scnBounds.Y < primaryBounds.Y || (!scn.Equals(screen) && bounds.Y < scnBounds.Bottom))
                    {
                        continue;
                    }
                    if (scnBounds.Y > bounds.Y)
                    {
                        break;
                    }
                    if (scnBounds.Y == GetBounds(adjacentScreen).Bottom)
                    {
                        var logicalSize = GetLogicalSize(adjacentScreen);
                        location.Y    += logicalSize.Height;
                        adjacentScreen = scn;
                    }
                    if (scn.Equals(screen))
                    {
                        break;
                    }
                }
                if (!adjacentScreen.Equals(screen))
                {
                    location.Y = bounds.Y / maxLogicalPixelSize;
                }
            }

            return(location);
        }
 public virtual float GetMaxLogicalPixelSize() => AllScreens.Max((Func <T, float>)GetLogicalPixelSize);
Exemple #9
0
 T FindBottomScreen(T screen) =>
 AllScreens
 .Where(r => GetBounds(r).Y < 0 && GetBounds(r).Y == GetBounds(screen).Bottom)
 .OrderBy(r => GetLogicalPixelSize(r))
 .FirstOrDefault();
Exemple #10
0
 T FindRightScreen(T screen) =>
 AllScreens
 .Where(r => GetBounds(r).X < 0 && GetBounds(r).X == GetBounds(screen).Right)
 .OrderBy(r => GetLogicalPixelSize(r))
 .FirstOrDefault();