예제 #1
0
 private void CreateTextFormat()
 {
     var factory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
     mTextFormat = factory.CreateTextFormat("Consola", FontWeight.Normal,
         SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 100, "en-us");
     mTextFormat.TextAlignment = TextAlignment.Center;
     mTextFormat.ParagraphAlignment = ParagraphAlignment.Center;
 }
예제 #2
0
파일: Score.cs 프로젝트: cbeihl/pong
        public void Render(SlimDX.Direct2D.Factory factory, SlimDX.DirectWrite.Factory dwFactory, RenderTarget renderTarget)
        {
            if (this.brush == null)
            {
                brush     = new SolidColorBrush(renderTarget, new Color4(1.0f, 1.0f, 1.0f));
                txtFormat = dwFactory.CreateTextFormat("lcd phone", FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 60, "en-us");
            }

            SizeF newWindowSize = renderTarget.Size;

            if (windowSize == null || !windowSize.Equals(newWindowSize))
            {
                windowSize = newWindowSize;
                float centerX = windowSize.Width / 2;
                rect = new RectangleF(new PointF(centerX + posOffset.X, posOffset.Y), textLayoutSize);
            }

            renderTarget.DrawText(val.ToString(), txtFormat, rect, brush);
        }
예제 #3
0
        public override void OnInit(Game currentGame, Form owner, Save settings)
        {
            base.currentGame = currentGame;
            base.owner       = owner;
            base.info        = settings;

            this.owner.Controls.Add(this);
            this.Dock = DockStyle.Fill;

            try
            {
                SlimDX.DirectWrite.Factory m = new SlimDX.DirectWrite.Factory(FactoryType.Shared);
                textFormatCentered = m.CreateTextFormat(this.Font.FontFamily.Name, SlimDX.DirectWrite.FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, SlimDX.DirectWrite.FontStretch.Expanded, 50, "de-de");
                textFormatCentered.TextAlignment      = SlimDX.DirectWrite.TextAlignment.Center;
                textFormatCentered.ParagraphAlignment = SlimDX.DirectWrite.ParagraphAlignment.Center;
            }
            catch (Exception)
            { }

            this.initializeGraphics();

            this.FinishedInit = true;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.ResizeRedraw, true);
            this.UpdateStyles();

            try
            {
                if (string.IsNullOrEmpty(settings.Background))
                {
                    this.BackgroundImage = Image.FromFile(System.IO.Path.Combine(Application.StartupPath, "Images", "Image.jpg"));
                }
                else
                {
                    this.BackgroundImage = Image.FromFile(settings.Background);
                }
            }
            catch (Exception)
            { }

            this.e = new Graphics.DirectGraphics(this.renderTarget);
            this.Invalidate();
        }
예제 #4
0
        /// <summary>
        /// In a derived class, implements logic to initialize the sample.
        /// </summary>
        protected override void OnInitialize()
        {
            DeviceSettings2D settings = new DeviceSettings2D
            {
                Width  = WindowWidth,
                Height = WindowHeight
            };

            InitializeDevice(settings);
            _writeFactory                  = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
            _textFormat                    = _writeFactory.CreateTextFormat("Gabriola", FontWeight.Regular, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us");
            _textFormat.TextAlignment      = TextAlignment.Center;
            _textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            using (Graphics graphics = Graphics.FromHwnd(_mainForm.Handle))
            {
                _dpiY = graphics.DpiY / 96.0f;
                _dpiX = graphics.DpiX / 96.0f;
            }

            InitializeSimpleText();
            InitializeMultiformattedText();
        }
예제 #5
0
		/// <summary>
		/// In a derived class, implements logic to initialize the sample.
		/// </summary>
		protected override void OnInitialize()
		{
			DeviceSettings2D settings = new DeviceSettings2D
			{
				Width = WindowWidth,
				Height = WindowHeight
			};

			InitializeDevice(settings);
			_writeFactory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
			_textFormat = _writeFactory.CreateTextFormat("Gabriola", FontWeight.Regular, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us");
			_textFormat.TextAlignment = TextAlignment.Center;
			_textFormat.ParagraphAlignment = ParagraphAlignment.Center;
			using (Graphics graphics = Graphics.FromHwnd(_mainForm.Handle))
			{
				_dpiY = graphics.DpiY/96.0f;
				_dpiX = graphics.DpiX/96.0f;
			}

			InitializeSimpleText();
			InitializeMultiformattedText();
		}
예제 #6
0
        public override void OnInit(Game currentGame, Form owner, Save settings)
        {
            base.currentGame = currentGame;
            base.owner = owner;
            base.info = settings;

            this.owner.Controls.Add(this);
            this.Dock = DockStyle.Fill;

            try
            {
                SlimDX.DirectWrite.Factory m = new SlimDX.DirectWrite.Factory(FactoryType.Shared);
                textFormatCentered = m.CreateTextFormat(this.Font.FontFamily.Name, SlimDX.DirectWrite.FontWeight.Regular, SlimDX.DirectWrite.FontStyle.Normal, SlimDX.DirectWrite.FontStretch.Expanded, 50, "de-de");
                textFormatCentered.TextAlignment = SlimDX.DirectWrite.TextAlignment.Center;
                textFormatCentered.ParagraphAlignment = SlimDX.DirectWrite.ParagraphAlignment.Center;
            }
            catch (Exception)
            { }

            this.initializeGraphics();

            this.FinishedInit = true;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.ResizeRedraw, true);
            this.UpdateStyles();

            try
            {
                if (string.IsNullOrEmpty(settings.Background))
                    this.BackgroundImage = Image.FromFile(System.IO.Path.Combine(Application.StartupPath, "Images", "Image.jpg"));
                else
                    this.BackgroundImage = Image.FromFile(settings.Background);
            }
            catch (Exception)
            { }

            this.e = new Graphics.DirectGraphics(this.renderTarget);
            this.Invalidate();
        }