Esempio n. 1
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------
        //------------------------------------------- DRAWING TEXT  ------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------------------------------------------------------------------------
        public void DrawText(string text, string fontName, float fontSize, Point pDest, Color color, int rotation, bool wordWrap, Rectangle rectDest, float worldScale)
        {
            try
            {
                GorgonLibrary.Graphics.Font textFont = GetGorgonFont(fontName, fontSize);
                if (textFont != null)
                {
                    textSprite.Font = textFont;
                }
                else
                {
                    if (fontName.Equals("DEFAULT"))
                    {
                        textFont = new GorgonLibrary.Graphics.Font(fontName + "_" + fontSize,
                                                                   new System.Drawing.Font(SystemFonts.DefaultFont.FontFamily, fontSize));
                    }
                    else
                    {
                        textFont = new GorgonLibrary.Graphics.Font(fontName + "_" + fontSize,
                                                                   new System.Drawing.Font(fontName, fontSize));
                    }

                    textSprite.Font = textFont;
                }
                textSprite.Bounds   = null;
                textSprite.WordWrap = false;
                textSprite.Color    = color;
                textSprite.Text     = text;
                textSprite.SetAxis((int)((float)rectDest.Width) / 2, (int)((float)rectDest.Height) / 2);
                textSprite.Rotation = rotation;

                if (wordWrap == false)
                {
                    textSprite.Position = new Vector2D((int)((float)pDest.X * worldScale), (int)((float)pDest.Y * worldScale));
                }
                else
                {
                    textSprite.SetPosition((float)(rectDest.X + textSprite.Axis.X) * worldScale, (float)(rectDest.Y + textSprite.Axis.Y) * worldScale);
                    textSprite.Bounds = new Viewport(0, 0, (int)((float)rectDest.Width), 0);

                    textSprite.WordWrap = wordWrap;
                }



                textSprite.SetScale(worldScale, worldScale);
                textSprite.Draw();
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 2
0
        private void DrawGraph()
        {
            int    totalRecBytes     = 0;
            int    totalSentBytes    = 0;
            double totalMilliseconds = 0d;

            for (int i = 0; i < MaxDataPoints; i++)
            {
                if (_dataPoints.Count <= i)
                {
                    continue;
                }

                totalMilliseconds += _dataPoints[i].ElapsedMilliseconds;
                totalRecBytes     += _dataPoints[i].RecievedBytes;
                totalSentBytes    += _dataPoints[i].SentBytes;

                Gorgon.CurrentRenderTarget = null;

                //Draw recieved line
                Gorgon.CurrentRenderTarget.Rectangle(Gorgon.CurrentRenderTarget.Width - (4 * (MaxDataPoints - i)),
                                                     Gorgon.CurrentRenderTarget.Height -
                                                     (_dataPoints[i].RecievedBytes * 0.1f), 2,
                                                     (_dataPoints[i].RecievedBytes * 0.1f),
                                                     Color.FromArgb(180, Color.Red));

                Gorgon.CurrentRenderTarget.Rectangle(Gorgon.CurrentRenderTarget.Width - (4 * (MaxDataPoints - i)) + 2,
                                                     Gorgon.CurrentRenderTarget.Height - (_dataPoints[i].SentBytes * 0.1f),
                                                     2, (_dataPoints[i].SentBytes * 0.1f),
                                                     Color.FromArgb(180, Color.Green));
            }

            _textSprite.Text = String.Format("Up: {0} kb/s.", Math.Round(totalSentBytes / totalMilliseconds, 6));
            _textSprite.SetPosition(Gorgon.CurrentRenderTarget.Width - (4 * MaxDataPoints) - 100,
                                    Gorgon.CurrentRenderTarget.Height - 30);
            _textSprite.Draw();

            _textSprite.Text = String.Format("Down: {0} kb/s.", Math.Round(totalRecBytes / totalMilliseconds, 6));
            _textSprite.SetPosition(Gorgon.CurrentRenderTarget.Width - (4 * MaxDataPoints) - 100,
                                    Gorgon.CurrentRenderTarget.Height - 60);
            _textSprite.Draw();
        }
Esempio n. 3
0
        public SpeechBubble(string mobname)
        {
            _resourceManager = IoCManager.Resolve <IResourceManager>();
            _mobName         = mobname;
            _buildTime       = DateTime.Now;
            _textSprite      = new TextSprite
                               (
                "chatBubbleTextSprite_" + _mobName,
                String.Empty,
                _resourceManager.GetFont("CALIBRI")
                               )
            {
                Color    = Color.Black,
                WordWrap = true
            };

            _textSprite.SetPosition(5, 3);
            _stringBuilder = new StringBuilder();

            _bubbleRender = new RenderImage("ChatBubbleRenderImage_" + _mobName, 1, 1, ImageBufferFormats.BufferRGB888A8);
            _bubbleSprite = new Sprite("ChatBubbleRenderSprite_" + _mobName, _bubbleRender);
        }
Esempio n. 4
0
        public SpeechBubble(string mobname)
        {
            _resourceManager = IoCManager.Resolve<IResourceManager>();
            _mobName = mobname;
            _buildTime = DateTime.Now;
            _textSprite = new TextSprite
                (
                "chatBubbleTextSprite_" + _mobName,
                String.Empty,
                _resourceManager.GetFont("CALIBRI")
                )
                              {
                                  Color = Color.Black,
                                  WordWrap = true
                              };

            _textSprite.SetPosition(5, 3);
            _stringBuilder = new StringBuilder();

            _bubbleRender = new RenderImage("ChatBubbleRenderImage_" + _mobName, 1, 1, ImageBufferFormats.BufferRGB888A8);
            _bubbleSprite = new Sprite("ChatBubbleRenderSprite_" + _mobName, _bubbleRender);
        }
Esempio n. 5
0
        /// <summary>
        /// Handles the Load event of the MainForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // Initialize the library.
                Gorgon.Initialize();

                // Display the logo and frame stats.
                Gorgon.LogoVisible       = false;
                Gorgon.FrameStatsVisible = false;

                // Set the video mode to match the form client area.
                Gorgon.SetMode(this);

                // Assign rendering event handler.
                Gorgon.Idle += new FrameEventHandler(Screen_OnFrameBegin);

                // Set the clear color to something ugly.
                Gorgon.Screen.BackgroundColor = Color.FromArgb(250, 245, 220);

                LoadFont();

                txtspr = new TextSprite("txtspr", "Test", font, Color.Black);

                txtspr.SetPosition(1.0f, 1.0f);
                TextStatus();

                RunMeasureLineTests();
                // Begin execution.
                Gorgon.Go();
            }
            catch (Exception ex)
            {
                UI.ErrorBox(this, "An unhandled error occured during execution, the program will now close.", ex.Message + "\n\n" + ex.StackTrace);
                Application.Exit();
            }
        }
Esempio n. 6
0
		/// <summary>
		/// Handles the Load event of the MainForm control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void MainForm_Load(object sender, EventArgs e)
		{
			try
			{
				// Initialize the library.
				Gorgon.Initialize();

				// Display the logo and frame stats.
				Gorgon.LogoVisible = false;
				Gorgon.FrameStatsVisible = false;

				// Set the video mode to match the form client area.
				Gorgon.SetMode(this);

				// Assign rendering event handler.
				Gorgon.Idle += new FrameEventHandler(Screen_OnFrameBegin);

				// Set the clear color to something ugly.
				Gorgon.Screen.BackgroundColor = Color.FromArgb(250, 245, 220);

			    LoadFont();

                txtspr = new TextSprite("txtspr", "Test", font, Color.Black);

                txtspr.SetPosition(1.0f,1.0f);
			    TextStatus();

			    RunMeasureLineTests();
				// Begin execution.
				Gorgon.Go();
			}
			catch (Exception ex)
			{
				UI.ErrorBox(this, "An unhandled error occured during execution, the program will now close.", ex.Message + "\n\n" + ex.StackTrace);
				Application.Exit();
			}
		}