Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormBrushEditor"/> class.
 /// </summary>
 /// <param name="fontContent">The current font content interface.</param>
 public FormBrushEditor(GorgonFontContent fontContent)
     : this()
 {
     _currentContent = fontContent;
     _previousIdle   = Gorgon.ApplicationIdleLoopMethod;
     Gorgon.ApplicationIdleLoopMethod = null;
     Gorgon.AllowBackground           = true;            // Enable background rendering because the application will appear to have lost focus when this dialog is present.
     SolidBrush    = new GorgonGlyphSolidBrush();
     GradientBrush = new GorgonGlyphLinearGradientBrush
     {
         StartColor = GorgonColor.Black,
         EndColor   = GorgonColor.White
     };
     PatternBrush = new GorgonGlyphHatchBrush
     {
         ForegroundColor = GorgonColor.Black,
         BackgroundColor = GorgonColor.White,
         HatchStyle      = HatchStyle.BackwardDiagonal
     };
 }
Exemplo n.º 2
0
        /// <summary>
        /// Function to initialize the example application.
        /// </summary>
        private static void Initialize()
        {
            var pathBrush = new GorgonGlyphPathGradientBrush
            {
                SurroundColors =
                {
                    Color.Red,
                    Color.Green,
                    Color.Blue,
                    Color.Yellow
                },
                CenterColor = Color.White,
                Points      =
                {
                    new Vector2(0,   8),
                    new Vector2(8,   0),
                    new Vector2(16,  8),
                    new Vector2(8,  16),
                },
                CenterPoint   = new Vector2(8, 8),
                Interpolation =
                {
                    new GorgonGlyphBrushInterpolator(0,    Color.Purple),
                    new GorgonGlyphBrushInterpolator(0.5f, Color.Cyan),
                    new GorgonGlyphBrushInterpolator(1.0f, Color.Firebrick)
                },
                WrapMode = WrapMode.TileFlipXY
            };

            var linBrush = new GorgonGlyphLinearGradientBrush
            {
                Angle      = 45.0f,
                StartColor = Color.Purple,
                EndColor   = Color.Yellow
            };

            var hatchBrush = new GorgonGlyphHatchBrush
            {
                HatchStyle      = HatchStyle.Percent50,
                ForegroundColor = Color.Purple,
                BackgroundColor = Color.Yellow
            };

            _formMain = new formMain();

            // Create our graphics object(s).
            _graphics = new GorgonGraphics();

            var textBrush = new GorgonGlyphTextureBrush(_graphics.Textures.FromFile <GorgonTexture2D>("Stars",
                                                                                                      GetResourcePath(@"Images\Stars-12.jpg"),
                                                                                                      new GorgonCodecJPEG()))
            {
                TextureRegion = new RectangleF(0.0f, 0.0f, 0.5f, 0.5f),
                WrapMode      = WrapMode.Tile
            };


            _renderer = _graphics.Output.Create2DRenderer(_formMain,
                                                          Settings.Default.ScreenResolution.Width,
                                                          Settings.Default.ScreenResolution.Height,
                                                          BufferFormat.Unknown,
                                                          !Settings.Default.FullScreen);

            Screen activeMonitor = Screen.FromControl(_formMain);

            // Center the window on the screen.
            _formMain.Location = new Point(activeMonitor.WorkingArea.Width / 2 - _formMain.Width / 2, activeMonitor.WorkingArea.Height / 2 - _formMain.Height / 2);

            _specialGlyphTexture = _graphics.Textures.FromFile <GorgonTexture2D>("StyledT", GetResourcePath(@"Fonts\StylizedT.png"),
                                                                                 new GorgonCodecPNG());

            _font = _graphics.Fonts.CreateFont("TestFont",
                                               new GorgonFontSettings
            {
                AntiAliasingMode = FontAntiAliasMode.AntiAlias,
                FontFamilyName   = "Times New Roman",
                FontStyle        = FontStyle.Bold,
                Size             = 24.0f,
                Brush            = textBrush,
                Glyphs           =
                {
                    new GorgonGlyph('T', _specialGlyphTexture, new Rectangle(11, 14, 111, 97), new Point(-3, -8), 97)
                }
            });

            // TODO: This is for testing font capabilities.
            _renderer.Drawing.BlendingMode = BlendingMode.Modulate;

            _font.Save(@"d:\unpak\fontTest.gorFont");

            _font.Dispose();

            textBrush.Texture.Dispose();

            _font = _graphics.Fonts.FromFile("TestFont", @"d:\unpak\fontTest.gorFont");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Click event of the buttonOK control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {
                switch (BrushType)
                {
                case GlyphBrushType.Solid:
                    SolidBrush = new GorgonGlyphSolidBrush
                    {
                        Color = colorSolidBrush.SelectedColor
                    };
                    break;

                case GlyphBrushType.Texture:
                    GorgonTexture2D newTexture = panelTextureEditor.Texture.Graphics.Textures.CreateTexture(panelTextureEditor.Texture.Name,
                                                                                                            panelTextureEditor.Texture.Settings);

                    newTexture.Copy(panelTextureEditor.Texture);

                    TextureBrush = new GorgonGlyphTextureBrush(newTexture)
                    {
                        WrapMode      = panelTextureEditor.WrapMode,
                        TextureRegion = panelTextureEditor.TextureRegion
                    };

                    panelTextureEditor.Texture = null;
                    break;

                case GlyphBrushType.Hatched:
                    PatternBrush = new GorgonGlyphHatchBrush
                    {
                        ForegroundColor = panelHatchEditor.HatchForegroundColor,
                        BackgroundColor = panelHatchEditor.HatchBackgroundColor,
                        HatchStyle      = panelHatchEditor.HatchStyle
                    };
                    break;

                case GlyphBrushType.LinearGradient:
                    GradientBrush = new GorgonGlyphLinearGradientBrush
                    {
                        Angle           = panelGradEditor.Angle,
                        ScaleAngle      = panelGradEditor.ScaleAngle,
                        GammaCorrection = panelGradEditor.UseGammaCorrection
                    };

                    IEnumerable <GorgonGlyphBrushInterpolator> interpolators = panelGradEditor.GetInterpolators();

                    GradientBrush.Interpolation.Clear();

                    foreach (GorgonGlyphBrushInterpolator interpolator in interpolators)
                    {
                        GradientBrush.Interpolation.Add(interpolator);
                    }

                    break;
                }
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(this, ex);
                DialogResult = DialogResult.None;
            }
        }