Пример #1
0
        /// <summary>
        /// We want to make sure that if a room template is set to no repeat and has multiple transformations,
        /// then all the different transformations are discarded. To make it possible, for each room template instance,
        /// we store the corresponding room template together with all its transformations, so we are able to quickly
        /// get all the required information.
        /// </summary>
        private void Initialize()
        {
            roomTemplateInstanceInfo = new RoomTemplateInfo[intAliasMapping.Count];

            foreach (var roomTemplate in intAliasMapping.Keys.Select(x => x.RoomTemplate).Distinct())
            {
                var aliases = intAliasMapping
                              .Where(x => x.Key.RoomTemplate == roomTemplate)
                              .Select(x => x.Value)
                              .ToList();

                var roomTemplateInfo = new RoomTemplateInfo(aliases, roomTemplate);

                foreach (var intAlias in aliases)
                {
                    roomTemplateInstanceInfo[intAlias.Alias] = roomTemplateInfo;
                }
            }
        }
Пример #2
0
        private void LayoutFreeShapes(Microsoft.Msagl.Core.Layout.GeometryGraph geometry)
        {
            var xs         = geometry.Nodes.Select(n => n.Center.X);
            var right      = xs.Any() ? xs.Max() + ShapeSize * 3 : ShapeSize;
            var freeShapes = nodesAndShapes.Where(kv => geometry.Nodes.All(n => n.UserData != kv.Key)).Select(kv => kv.Value).ToArray();
            var priorities = freeShapes.Select(s => {
                var q = nodesAndShapes[s].Quest;
                if (!q.IsLinksToEditable())
                {
                    return(3);
                }

                if (!q.IsActive())
                {
                    return(2);
                }

                return(1);
            }).ToArray();

            Array.Sort(priorities, freeShapes);
            var width        = Diagram.Size.Width - right;
            var columnsCount = Math.Max(1, width / ShapeSize - 1);
            int curColumn    = 0;
            int curRow       = 0;

            foreach (var s in freeShapes)
            {
                s.X = curColumn * ShapeSize + (int)right;
                s.Y = curRow * ShapeSize + ShapeSize / 2;

                ++curColumn;
                if (curColumn >= columnsCount)
                {
                    curColumn = 0;
                    ++curRow;
                }
            }
        }