コード例 #1
0
        private void cmbFaction_SelectedIndexChanged(object sender, EventArgs e)
        {
            int fct = cmbFaction.SelectedIndex + 1;

            pbFaction.Image = DrawingPlus.ResizeImage(world.Faction[fct].Symbol,
                                                      pbFaction.Width, pbFaction.Height);

            lblFactionDescription.Text = world.Faction[fct].Description;
            lblAbilityDetails.Text     = GetAbilityDetails(world.Faction[fct].Ability);

            pbMap.Image = GetFactionPreview(fct);
        }
コード例 #2
0
        private void OnDraw(object sender, DrawToolTipEventArgs e)
        {
            Graphics g               = e.Graphics;
            Color    clrFaction      = Faction.Color;
            int      titleTextSpacer = 1;
            int      borderSize      = 1;

            Rectangle r      = new Rectangle(1, 1, e.Bounds.Width - 2, e.Bounds.Height - 2);
            Rectangle rTitle = new Rectangle(r.X, r.Y, r.Width, 16);
            Rectangle rBody  = new Rectangle(r.X, r.Y + rTitle.Height + borderSize, r.Width, r.Height - rTitle.Height - borderSize);

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            g.Clear(Color.Black);

            // Header
            DrawingPlus.DrawBilinearHorizontalGradient(g, rTitle, clrFaction, 2);

            // Body
            g.FillRectangle(new LinearGradientBrush(e.Bounds, clrFaction, Color.White, 45f), rBody);

            // Faction Symbol
            g.DrawImage(DrawingPlus.ResizeImage(Faction.Symbol, 39, 39),
                        new Point(1, rBody.Y + (rBody.Height - 39) / 2));

            // Resource Icon
            if (Region.Resource != 0)
            {
                g.DrawImage((DrawingPlus.ResizeImage(Resource.Icon, 16, 16)),
                            new Point(titleTextSpacer, 1));

                titleTextSpacer += 17;
            }

            // Religion Icon
            if (Region.DominantReligion != 0)
            {
                g.DrawImage((DrawingPlus.ResizeImage(Religion.Icon, 16, 16)),
                            new Point(titleTextSpacer, 1));

                titleTextSpacer += 17;
            }

            // Capital Icon
            if (Region.Type == RegionType.Capital)
            {
                Image imgCapital;

                if (Region.State == RegionState.Free)
                {
                    imgCapital = DrawingPlus.ResizeImage(DrawingPlus.LoadImage(NarivianClass.IconsDirectory + "Capital.PNG"), 16, 16);
                }
                else
                {
                    imgCapital = DrawingPlus.ResizeImage(DrawingPlus.LoadImage(NarivianClass.IconsDirectory + "Capital Other.PNG"), 16, 16);
                }

                g.DrawImage(imgCapital, new Point(e.Bounds.Width - 17, 1));
            }

            // Title
            g.DrawString(Region.Name, new Font("Microsoft Sans Serif", 10, FontStyle.Bold),
                         Brushes.Black, new Point(rTitle.X + titleTextSpacer, rTitle.Y));

            // Message
            g.DrawString(e.ToolTipText, new Font("Microsoft Sans Serif", 8),
                         Brushes.Black, new PointF(40, rBody.Y + 2));

            // Border
            //g.DrawRectangle(new Pen(Color.Black, borderSize * 2), new Rectangle(
            //e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1));
            //g.DrawLine(new Pen(Color.Black, borderSize), new Point(0, 17), new Point(e.Bounds.Width, 17));
        }