Пример #1
0
        public XmlTextDescription(TextDescription textDescription)
        {
            if (textDescription == default(TextDescription))
                throw Error.InCreatingFromObject("TextDescription", GetType(), typeof (TextDescription));

            Name = textDescription.Name;
            IsBold = textDescription.IsBold;
            IsItalic = textDescription.IsItalic;
            IsOutlined = textDescription.IsOutlined;

            StandardColor = new XmlColor
                                {
                                    StateIndex = StateIndex.Enabled,
                                    ColorValue = textDescription.Color.ToArgb().ToString("{0:X8}")
                                };
            HighlightedColor = (ApplyHighlight)
                                   ? new XmlColor
                                         {
                                             StateIndex = StateIndex.Highlighted,
                                             ColorValue = textDescription.HighlightedColor.ToArgb().ToString("{0:X8}")
                                         }
                                   : default(XmlColor);
            FontFamily = textDescription.FontFamily;
            Size = textDescription.Size;
        }
Пример #2
0
        public static Texture2D DrawText(string text, TextDescription description, SizeF size=default(SizeF), bool isHighlighted = false, bool isSelected=false)
        {
            //Our return value.
            Texture2D t;

            using (Font font = description.ToFont())
            {
                //The size of the rendered string.
                SizeF strsize;

                //Create a dummy GDI object so we can figure out the size of the string...
                using (Bitmap dummyimage = new Bitmap(1, 1))
                {
                    using (System.Drawing.Graphics dummygraphics = System.Drawing.Graphics.FromImage(dummyimage))
                    {
                        //Measure the string...
                        strsize = dummygraphics.MeasureString(text, font, PointF.Empty, StringFormat);

                        if (size.Width > 0  && strsize.Width > size.Width)
                        {
                            string[] lines = WrapText(text, size.Width,  font);
                            strsize = new SizeF(size.Width, strsize.Height * lines.Length);
                        }
                    }
                }

                //Now create the REAL Drawing objects to render the text with.
                using (Bitmap image = new Bitmap((int)strsize.Width, (int)strsize.Height, PixelFormat.Format32bppArgb))
                {
                    using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(image))
                    {
                        //Fill the rect with a transparent Color.
                        graphics.Clear(Color.FromArgb(0));

                        //Draw the text
                        Color textColor = (isHighlighted ? description.HighlightedColor :
                            (isSelected ? description.SelectedColor : description.Color)).ToColor();
                        using (Brush brush = new SolidBrush(textColor))
                        {
                            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                            graphics.SmoothingMode = SmoothingMode.HighQuality;

                            GraphicsPath path = new GraphicsPath();
                            //path.AddString(text, font.FontFamily, (int)description.FontStyle, description.Size,
                                //PointF.Empty, StringFormat);
                            path.AddString(text,font.FontFamily, (int)description.FontStyle, description.Size,
                                new RectangleF(PointF.Empty, strsize), StringFormat);
                            if (description.IsOutlined)
                                graphics.DrawPath(Pens.Black, path);
                            graphics.FillPath(brush, path);
                        }
                        t = ImageHelper.TextureFromBitmap(image);
                    }
                }
            }
            return t;
        }
Пример #3
0
 public override int GetHashCode()
 {
     return(TextDescription.GetHashCode());
 }
Пример #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Book b = new Book();

            if (string.IsNullOrEmpty(TextDescription.Text) || string.IsNullOrEmpty(TextAuthor.Text) || string.IsNullOrEmpty(TextName.Text) || string.IsNullOrEmpty(ComboCategory.Text))
            {
                MetroFramework.MetroMessageBox.Show(this, "All field should be filled up.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TextName.Focus();
                return;
            }
            else
            {
                if (TextName.Text.Length <= 50)
                {
                    b.name = TextName.Text;
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Book Name Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (TextAuthor.Text.Length <= 50)
                {
                    b.author = TextAuthor.Text;
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Author Name Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (TextDescription.Text.Length <= 500)
                {
                    b.description = TextDescription.Text;
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Description Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (pictureBox.Image != null)
                {
                    b.picture = imageToByteArray(pictureBox.Image);
                    //return;
                }

                if (!string.IsNullOrEmpty(TextLink.Text))
                {
                    b.link = TextLink.Text;
                }
                b.category = ComboCategory.Text;
                b.rating   = 0;

                BookServices.Insert(b);
                MetroFramework.MetroMessageBox.Show(this, "Added successfully.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Refresh();
                TextDescription.Clear();
                TextAuthor.Clear();
                TextName.Clear();
                ComboCategory.SelectedIndex = 0;
                TextLink.Clear();
                pictureBox.Image = null;
            }
        }
Пример #5
0
 // Fill description
 void Description(string description)
 {
     TextDescription.Clear();
     TextDescription.SendKeys(description);
 }
Пример #6
0
 public static void AddTextStyle(TextDescription newTextStyle)
 {
     textStyles.Add(newTextStyle.Name, newTextStyle);
 }
Пример #7
0
 public void PreviewCard(AvatarModel hero, Card card, WhereAmI whereAmI)
 {
     PanelAvatar.GetComponent <PanelAvatarCard>().PreviewCardHand(hero, card, whereAmI);
     TextName.GetComponent <Text>().text        = card != null?card.Name:"";
     TextDescription.GetComponent <Text>().text = card != null?card.Describe(hero) : "";
 }