示例#1
0
        public void SaveLocalChanges()
        {
            if (selectedHeroIndex >= 0)
            {
                var original = HeroesManager.AllHeroes[selectedHeroIndex];

                var hs = new HeroStats
                {
                    Name        = tbHeroName.Text.NotLongerThan(12),
                    Biography   = tbHeroBio.Text,
                    Speciality  = tbHeroSpecDesc.Text,
                    LowStack1   = int.Parse(tbHeroLS1.Text),
                    HighStack1  = int.Parse(tbHeroHS1.Text),
                    LowStack2   = int.Parse(tbHeroLS2.Text),
                    HighStack2  = int.Parse(tbHeroHS2.Text),
                    LowStack3   = int.Parse(tbHeroLS3.Text),
                    HighStack3  = int.Parse(tbHeroHS3.Text),
                    CastleIndex = original.CastleIndex,
                    ImageIndex  = original.ImageIndex
                };

                HeroesManager.AllHeroes[selectedHeroIndex]           = hs;
                BitmapCache.DrawItemHeroesListBox[selectedHeroIndex] = null;
                lbHeroes.InvalidateSelected();

                HeroesManager.AnyChanges = true;
            }
        }
        private void DrawStacks(Graphics g, Color c, HeroStats hs, Font font)
        {
            PointF baseCorner = new PointF(64, 310);

            string stack1Str = hs.LowStack1 == hs.HighStack1 ? hs.LowStack1.ToString() : (hs.LowStack1 + "-" + hs.HighStack1);
            string stack2Str = hs.LowStack2 == hs.HighStack2 ? hs.LowStack2.ToString() : (hs.LowStack2 + "-" + hs.HighStack2);
            string stack3Str = hs.LowStack3 == hs.HighStack3 ? hs.LowStack3.ToString() : (hs.LowStack3 + "-" + hs.HighStack3);

            var sizeF = g.MeasureString(stack1Str, font);

            DrawShadowedString2(stack1Str, g, c, font, baseCorner.X - sizeF.Width, baseCorner.Y);
            sizeF = g.MeasureString(stack2Str, font);
            DrawShadowedString2(stack2Str, g, c, font, baseCorner.X - sizeF.Width + 63, baseCorner.Y);
            sizeF = g.MeasureString(stack3Str, font);
            DrawShadowedString2(stack3Str, g, c, font, baseCorner.X - sizeF.Width + 124, baseCorner.Y);
        }