コード例 #1
0
        private void ClearControls(bool suspendDrawingAndLayout = true)
        {
            // clear pedigree
            if (suspendDrawingAndLayout)
            {
                splitContainer1.Panel2.SuspendDrawing();
                SuspendLayout();
            }

            foreach (var pc in _pedigreeControls)
            {
                pc.Dispose();
            }
            _pedigreeControls.Clear();
            _lines[0].Clear();
            _lines[1].Clear();
            _lines[2].Clear();
            if (PbRegionColors.Image != null)
            {
                PbRegionColors.SetImageAndDisposeOld(null);
            }
            PbRegionColors.Visible = false;
            LbCreatureName.Text    = null;
            if (suspendDrawingAndLayout)
            {
                ResumeLayout();
                splitContainer1.Panel2.ResumeDrawing();
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates the pedigree with creature controls.
        /// </summary>
        private void CreatePedigree()
        {
            splitContainer1.Panel2.SuspendDrawing();
            SuspendLayout();
            // clear old pedigreeCreatures
            ClearControls(false);
            if (_selectedCreature == null)
            {
                NoCreatureSelected();
                ResumeLayout();
                splitContainer1.Panel2.ResumeDrawing();
                return;
            }

            pedigreeCreatureHeaders.SetCustomStatNames(_selectedCreature.Species?.statNames);
            statSelector1.SetStatNames(_selectedCreature.Species);

            lbPedigreeEmpty.Visible = false;

            // scroll offsets
            splitContainer1.Panel2.AutoScrollPosition = Point.Empty; // if not reset there are still offset issues sometimes, just reset the scrolling when creating a pedigree

            if (_pedigreeViewMode == PedigreeViewMode.Classic)
            {
                PedigreeCreation.CreateDetailedView(_selectedCreature, _lines, _pedigreeControls, _enabledColorRegions);
                _yBottomOfPedigree = 170;
            }
            else
            {
                _displayedGenerations = Math.Min(_compactGenerations, _selectedCreature.generation + 1);
                _yBottomOfPedigree    = PedigreeCreation.CreateCompactView(_selectedCreature, _lines, _pedigreeControls, _tt, _displayedGenerations, _highlightInheritanceStatIndex, _pedigreeViewMode == PedigreeViewMode.HView);

                var creatureColorsTop = _yBottomOfPedigree + LbCreatureName.Height;
                PbRegionColors.Top    = creatureColorsTop;
                PbKeyExplanations.Top = creatureColorsTop;
                LbCreatureName.Top    = creatureColorsTop - LbCreatureName.Height;
                LbCreatureName.Text   = _selectedCreature.name;

                if (PbKeyExplanations.Image == null)
                {
                    DrawKey(PbKeyExplanations, _selectedSpecies);
                }

                _pedigreeControls.Add(new PedigreeCreature(_selectedCreature, _enabledColorRegions)
                {
                    Location = new Point(PedigreeCreation.LeftBorder, _yBottomOfPedigree + PedigreeCreation.Margin)
                });
                _yBottomOfPedigree += 50;
            }

            // create descendants
            int row          = 0;
            var yDescendants = _yBottomOfPedigree + 3 * PedigreeCreation.Margin;

            foreach (Creature c in _creatureChildren)
            {
                PedigreeCreature pc = new PedigreeCreature(c, _enabledColorRegions)
                {
                    Location = new Point(PedigreeCreation.LeftBorder, yDescendants + 35 * row)
                };
                if (c.levelsWild != null && _selectedCreature.levelsWild != null)
                {
                    for (int s = 0; s < PedigreeCreature.DisplayedStatsCount; s++)
                    {
                        int si = PedigreeCreature.DisplayedStats[s];
                        if (_selectedCreature.valuesDom[si] > 0 && _selectedCreature.levelsWild[si] >= 0 &&
                            _selectedCreature.levelsWild[si] == c.levelsWild[si])
                        {
                            _lines[0].Add(new[]
                            {
                                PedigreeCreation.LeftBorder + PedigreeCreature.XOffsetFirstStat + PedigreeCreature.HorizontalStatDistance * s, yDescendants + 35 * row + 6,
                                PedigreeCreation.LeftBorder + PedigreeCreature.XOffsetFirstStat + PedigreeCreature.HorizontalStatDistance * s, yDescendants + 35 * row + 15, 0, 0
                            });
                        }
                    }
                }
                _pedigreeControls.Add(pc);
                row++;
            }

            // add controls
            foreach (var pc in _pedigreeControls)
            {
                splitContainer1.Panel2.Controls.Add(pc);
                var ipc = (IPedigreeCreature)pc;
                ipc.CreatureClicked      += CreatureClicked;
                ipc.CreatureEdit         += CreatureEdit;
                ipc.BestBreedingPartners += BestBreedingPartners;
            }

            PbRegionColors.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_selectedCreature.colors,
                                                                                    _selectedCreature.Species, _enabledColorRegions, 256, creatureSex: _selectedCreature.sex));
            PbRegionColors.Visible = true;

            ResumeLayout();
            splitContainer1.Panel2.ResumeDrawing();
        }