Ejemplo n.º 1
0
        /// <summary>The levels view on view loaded.</summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventArgs">The event args.</param>
        private void LevelsViewOnViewLoad(object sender, EventArgs eventArgs)
        {
            this.LoadImages();

            var levelNumbers = LevelsManager.GetActiveLevelNumbers();

            if (levelNumbers.Any())
            {
                Array.Sort(levelNumbers);

                // Cache enities
                var cacheEntities = SearchManager.GetGeometry();
                var main          = LevelsManager.GetMainLevel();

                var drawing = FileManager.CurrentFileName;

                drawing = string.IsNullOrEmpty(drawing) ? LocalizationStrings.LEVELS : Path.GetFileName(drawing);

                // Top most node
                var mainLevel = new TreeNode(drawing, (int)TreeIconIndex.MainLevel, (int)TreeIconIndex.MainLevel);

                for (var i = 0; i < levelNumbers.Count(); i++)
                {
                    // Query the cached data
                    var entities = cacheEntities.Where(e => e.Level == i).ToList().Count;

                    var level = new Level
                    {
                        Entities    = entities,
                        Name        = LevelsManager.GetLevelName(i),
                        Number      = i,
                        SetName     = LevelsManager.GetLevelSetName(i),
                        Visible     = LevelsManager.IsLevelVisible(i),
                        IsMainLevel = i == main
                    };

                    // Level node
                    var node = new TreeNode($"{level.Number.ToString().PadRight(5)} {level.Name}", (int)TreeIconIndex.Level, (int)TreeIconIndex.Level)
                    {
                        Tag = level
                    };
                    mainLevel.Nodes.Add(node);
                }

                this.view.LevelsTree.Nodes.Add(mainLevel);
                this.view.LevelsTree.Nodes[0].Expand();
            }
        }