Пример #1
0
        private void GrowLayout(ScreenDocument screen, IEnumerable <ScreenDocument> allScreens, Point location)
        {
            var screenPosition = new LayoutScreenPosition(screen, location);

            // add this screen
            _screens.Add(screenPosition);

            // use its joins to branch out
            foreach (var join in screen.Joins)
            {
                if (!ScreenNames.Contains(join.screenOne))
                {
                    var screenOne = allScreens.Single(s => s.Name == join.screenOne);

                    if (join.type == Common.JoinType.Horizontal)
                    {
                        Point offset = new Point(join.offsetTwo - join.offsetOne, -screenOne.Height);
                        GrowLayout(screenOne, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                    else
                    {
                        Point offset = new Point(-screenOne.Width, join.offsetTwo - join.offsetOne);
                        GrowLayout(screenOne, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                }

                if (!ScreenNames.Contains(join.screenTwo))
                {
                    var screenTwo = allScreens.Single(s => s.Name == join.screenTwo);

                    if (join.type == Common.JoinType.Horizontal)
                    {
                        Point offset = new Point(join.offsetOne - join.offsetTwo, screen.Height);
                        GrowLayout(screenTwo, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                    else
                    {
                        Point offset = new Point(screen.Width, join.offsetOne - join.offsetTwo);
                        GrowLayout(screenTwo, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                }
            }
        }
        private void GrowLayout(ScreenDocument screen, IEnumerable<ScreenDocument> allScreens, Point location)
        {
            var screenPosition = new LayoutScreenPosition(screen, location);
            // add this screen
            _screens.Add(screenPosition);

            // use its joins to branch out
            foreach (var join in screen.Joins)
            {
                if (!ScreenNames.Contains(join.screenOne))
                {
                    var screenOne = allScreens.Single(s => s.Name == join.screenOne);

                    if (join.type == Common.JoinType.Horizontal)
                    {
                        Point offset = new Point(join.offsetTwo - join.offsetOne, -screenOne.Height);
                        GrowLayout(screenOne, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                    else
                    {
                        Point offset = new Point(-screenOne.Width, join.offsetTwo - join.offsetOne);
                        GrowLayout(screenOne, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                }

                if (!ScreenNames.Contains(join.screenTwo))
                {
                    var screenTwo = allScreens.Single(s => s.Name == join.screenTwo);

                    if (join.type == Common.JoinType.Horizontal)
                    {
                        Point offset = new Point(join.offsetOne - join.offsetTwo, screen.Height);
                        GrowLayout(screenTwo, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                    else
                    {
                        Point offset = new Point(screen.Width, join.offsetOne - join.offsetTwo);
                        GrowLayout(screenTwo, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                }
            }
        }