Example #1
0
 public PrintData(int index, int colorindex, PrintJustification justification)
 {
     m_index         = index;
     m_colorindex    = colorindex;
     m_justification = justification;
     m_isvalid       = true;
 }
Example #2
0
        Vector2 GetPrintLocation(String text, Vector2 location, PrintJustification just)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            Single length = GetTextLength(text);

            switch (just)
            {
            case PrintJustification.Center:
                location.X -= (Int32)(length / 2);
                break;

            case PrintJustification.Left:
                break;

            case PrintJustification.Right:
                location.X -= (Int32)length;
                break;
            }

            location.Y -= m_charsize.Y;

            return(location);
        }
Example #3
0
        public void Print(Vector2 location, Int32 color, PrintJustification just, String text, Rectangle?scissorrect)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            location = GetPrintLocation(text, location, just);

            m_drawstate.Reset();
            m_drawstate.Set(Sprite);
            m_drawstate.Mode             = DrawMode.Font;
            m_drawstate.ScissorRectangle = scissorrect ?? Rectangle.Empty;
            m_drawstate.ShaderParameters.FontColorIndex  = color;
            m_drawstate.ShaderParameters.FontTotalColors = m_colors;

            foreach (Char c in text)
            {
                Rectangle r = GetCharRectangle(c);
                m_drawstate.AddData(location, r);

                location.X += r.Width;
            }

            m_drawstate.Use();
        }
Example #4
0
        private Vector2 GetPrintLocation(string text, Vector2 location, PrintJustification just)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            float length = GetTextLength(text);

            switch (just)
            {
            case PrintJustification.Center:
                location.X -= (int)(length / 2);
                break;

            case PrintJustification.Left:
                break;

            case PrintJustification.Right:
                location.X -= (int)length;
                break;
            }

            location.Y -= m_charsize.Y;

            return(location);
        }
Example #5
0
		public PrintData(Int32 index, Int32 colorindex, PrintJustification justification)
		{
			m_index = index;
			m_colorindex = colorindex;
			m_justification = justification;
			m_isvalid = true;
		}
Example #6
0
		public void Print(Vector2 location, Int32 color, PrintJustification just, String text, Rectangle? scissorrect)
		{
			if (text == null) throw new ArgumentNullException("text");

			location = GetPrintLocation(text, location, just);

			m_drawstate.Reset();
			m_drawstate.Set(Sprite);
			m_drawstate.Mode = DrawMode.Font;
			m_drawstate.ScissorRectangle = scissorrect ?? Rectangle.Empty;
			m_drawstate.ShaderParameters.FontColorIndex = color;
			m_drawstate.ShaderParameters.FontTotalColors = m_colors;

			foreach (Char c in text)
			{
				Rectangle r = GetCharRectangle(c);
				m_drawstate.AddData(location, r);

				location.X += r.Width;
			}

			m_drawstate.Use();
		}
Example #7
0
        Object ToPrintData(String s)
        {
            Match m = m_printdataregex.Match(s);

            if (m.Success == false)
            {
                return(Failure);
            }

            Int32 index = Int32.Parse(m.Groups[1].Value);
            Int32 color = Int32.Parse(m.Groups[2].Value);
            PrintJustification justification = PrintJustification.Center;

            if (m.Groups[3].Value == "")
            {
                justification = PrintJustification.Center;
            }
            else
            {
                Int32 just = Int32.Parse(m.Groups[3].Value);

                if (just == 0)
                {
                    justification = PrintJustification.Center;
                }
                if (just > 0)
                {
                    justification = PrintJustification.Left;
                }
                if (just < 0)
                {
                    justification = PrintJustification.Right;
                }
            }

            return(new Drawing.PrintData(index, color, justification));
        }
Example #8
0
		Vector2 GetPrintLocation(String text, Vector2 location, PrintJustification just)
		{
			if (text == null) throw new ArgumentNullException("text");

			Single length = GetTextLength(text);

			switch (just)
			{
				case PrintJustification.Center:
					location.X -= (Int32)(length / 2);
					break;

				case PrintJustification.Left:
					break;

				case PrintJustification.Right:
					location.X -= (Int32)length;
					break;
			}

			location.Y -= m_charsize.Y;

			return location;
		}