private static void Tile(TableTileAndTableInfos ttati)
        {
            List<HandleRectangleWindow> infoForWindowsToMove = new List<HandleRectangleWindow>();

            if (ttati.TableTile.SortByStartingHand)
            {
                // sort
                List<Rectangle> availablePositions = ttati.TableTile.XYWHs.ToList();
                List<TableInfo> tournamentWindows = ttati.TableInfos.Where(o => o.FirstHandTimestamp < DateTime.MaxValue).ToList();
                List<TableInfo> otherWindows = ttati.TableInfos.Where(o => o.FirstHandTimestamp == DateTime.MaxValue).ToList();
                tournamentWindows.Sort((o0, o1) => DateTime.Compare(o0.FirstHandTimestamp, o1.FirstHandTimestamp));

                // sort first

                while (availablePositions.Any() && tournamentWindows.Any())
                {
                    Rectangle availablePosition = availablePositions[0];
                    TableInfo tournamentWindow = tournamentWindows[0];
                    availablePositions.Remove(availablePosition);
                    tournamentWindows.Remove(tournamentWindow);
                    //MoveAndResize(tournamentWindow.Handle, availablePosition);
                    infoForWindowsToMove.Add(new HandleRectangleWindow
                    {
                        Handle = tournamentWindow.Handle,
                        RectangleWindow = availablePosition,
                    });
                }

                // leftovers to the main window pool

                if (tournamentWindows.Any())
                {
                    otherWindows.AddRange(tournamentWindows);
                }

                // closest then

                int max = availablePositions.Count;
                if (max > otherWindows.Count) max = otherWindows.Count;

                infoForWindowsToMove.AddRange(MoveClosest(availablePositions.GetRange(0, max), otherWindows.GetRange(0, max)));
            }
            else
            {
                infoForWindowsToMove.AddRange(MoveClosest(ttati.TableTile.XYWHs.ToList(), ttati.TableInfos));
            }

            // move and resize windows
            if (ttati.TableTile.BringToFront)
            {
                foreach (HandleRectangleWindow info in infoForWindowsToMove)
                {
                    MoveWindowBringWindowToTop(info.Handle, info.RectangleWindow);
                }
            }
            else
            {
                BeginDeferWindowPosDeferWindowPosEndDeferWindowPos(infoForWindowsToMove.ToArray(), IntPtr.Zero);
            }
        }
Exemple #2
0
        private static void Tile(TableTileAndTableInfos ttati)
        {
            List <HandleRectangleWindow> infoForWindowsToMove = new List <HandleRectangleWindow>();

            if (ttati.TableTile.SortByStartingHand)
            {
                // sort
                List <Rectangle> availablePositions = ttati.TableTile.XYWHs.ToList();
                List <TableInfo> tournamentWindows  = ttati.TableInfos.Where(o => o.FirstHandTimestamp < DateTime.MaxValue).ToList();
                List <TableInfo> otherWindows       = ttati.TableInfos.Where(o => o.FirstHandTimestamp == DateTime.MaxValue).ToList();
                tournamentWindows.Sort((o0, o1) => DateTime.Compare(o0.FirstHandTimestamp, o1.FirstHandTimestamp));

                // sort first

                while (availablePositions.Any() && tournamentWindows.Any())
                {
                    Rectangle availablePosition = availablePositions[0];
                    TableInfo tournamentWindow  = tournamentWindows[0];
                    availablePositions.Remove(availablePosition);
                    tournamentWindows.Remove(tournamentWindow);
                    //MoveAndResize(tournamentWindow.Handle, availablePosition);
                    infoForWindowsToMove.Add(new HandleRectangleWindow
                    {
                        Handle          = tournamentWindow.Handle,
                        RectangleWindow = availablePosition,
                    });
                }

                // leftovers to the main window pool

                if (tournamentWindows.Any())
                {
                    otherWindows.AddRange(tournamentWindows);
                }

                // closest then

                int max = availablePositions.Count;
                if (max > otherWindows.Count)
                {
                    max = otherWindows.Count;
                }

                infoForWindowsToMove.AddRange(MoveClosest(availablePositions.GetRange(0, max), otherWindows.GetRange(0, max)));
            }
            else
            {
                infoForWindowsToMove.AddRange(MoveClosest(ttati.TableTile.XYWHs.ToList(), ttati.TableInfos));
            }

            // move and resize windows
            if (ttati.TableTile.BringToFront)
            {
                foreach (HandleRectangleWindow info in infoForWindowsToMove)
                {
                    MoveWindowBringWindowToTop(info.Handle, info.RectangleWindow);
                }
            }
            else
            {
                BeginDeferWindowPosDeferWindowPosEndDeferWindowPos(infoForWindowsToMove.ToArray(), IntPtr.Zero);
            }
        }