Giter Club home page Giter Club logo

Comments (10)

VoidVolker avatar VoidVolker commented on June 1, 2024

Founded next solution:

    /// <summary>
    /// FontAwesome icon
    /// </summary>
    public class FAIcon : IconPictureBox
    {
        /// <summary>
        /// Flip flags
        /// </summary>
        [Flags]
        public enum IconFlip : byte
        {
            /// <summary>
            /// Flip off
            /// </summary>
            None = 0x0,
            /// <summary>
            /// Horizontal flip
            /// </summary>
            Horizontal = 0x1,
            /// <summary>
            /// Vertical flip
            /// </summary>
            Vertical = 0x2,
            /// <summary>
            /// Full flip
            /// </summary>
            Full = 0x4
        }

        private IconFlip _Flip;

        /// <summary>
        /// Icon flip
        /// </summary>
        [Category("Transform"), Description("Flip options")]
        [EditorBrowsable(EditorBrowsableState.Always), Browsable(true)]
        [DefaultValue(IconFlip.None)]
        public IconFlip Flip
        {
            get { return _Flip; }
            set
            {
                if (_Flip == value) { return; }
                _Flip = value;
                Invalidate();
            }
        }


        private int _Rotation = 0;

        /// <summary>
        /// Rotation angle in degrees, ±360°
        /// </summary>
        [Category("Transform"), Description("Rotation angle in degrees, ±360°")]
        [EditorBrowsable(EditorBrowsableState.Always), Browsable(true)]
        [DefaultValue(0)]
        public int Rotation
        {
            get { return _Rotation; }
            set {
                if (_Rotation == value) { return; }
                _Rotation = value % 360;
                Invalidate();
            }
        }

        /// <summary>
        /// FontAwesome icon
        /// </summary>
        public FAIcon() : base()
        {

        }

        /// <summary>
        /// OnPaint
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            switch (_Flip)
            {
                case (IconFlip.Horizontal):
                    // Flip the X-Axis
                    e.Graphics.ScaleTransform(-1.0F, 1.0F);
                    // Translate the drawing area accordingly
                    e.Graphics.TranslateTransform(-(float)Width, 0.0F);
                    break;

                case (IconFlip.Vertical):
                    // Flip the Y-Axis
                    e.Graphics.ScaleTransform(1.0F, -1.0F);
                    // Translate the drawing area accordingly
                    e.Graphics.TranslateTransform(0.0F, -(float)Height);
                    break;

                case (IconFlip.Full):
                    e.Graphics.ScaleTransform(-1.0F, -1.0F);
                    e.Graphics.TranslateTransform(-(float)Width, -(float)Height);
                    break;
            }

            if(_Rotation != 0)
            {
                float mx = Width / 2
                    , my = Height / 2
                ;
                e.Graphics.TranslateTransform( mx, my );
                e.Graphics.RotateTransform( _Rotation );
                e.Graphics.TranslateTransform( -mx, -my );
            }

            base.OnPaint(e);
        }
    }

from fontawesome.sharp.

mkoertgen avatar mkoertgen commented on June 1, 2024

Right now, we have no rotation/flip support for Windows Forms.

Yet the solution you provided looks good. Would it be ok for you to have me adding this to the code base? Or would you prefer to open a merge request?

from fontawesome.sharp.

VoidVolker avatar VoidVolker commented on June 1, 2024

from fontawesome.sharp.

VoidVolker avatar VoidVolker commented on June 1, 2024

Done - I'm updated code with rotation option for any angle.

from fontawesome.sharp.

mkoertgen avatar mkoertgen commented on June 1, 2024

Thx, i should find time integrating the rotation/flip code during the next few days.

And, yes, concerning the docs you are right that especially the Windows Forms part lacks a lot of examples and documentation.

from fontawesome.sharp.

mkoertgen avatar mkoertgen commented on June 1, 2024

@VoidVolker Cleaned up the cache. ReSharper makes refactoring boilerplate code like e.g. IEquatable<> quite safe.

Added coding style conventions (Visual Studio defaults), for consistency with other IDEs like VSCode).

Adding flip/rotate support for the other controls right now...

from fontawesome.sharp.

VoidVolker avatar VoidVolker commented on June 1, 2024

Ok, thanks! Was very busy last few weeks.

from fontawesome.sharp.

mkoertgen avatar mkoertgen commented on June 1, 2024

We all are, right? ;-)

from fontawesome.sharp.

VoidVolker avatar VoidVolker commented on June 1, 2024

Yeah :)

from fontawesome.sharp.

mkoertgen avatar mkoertgen commented on June 1, 2024

Added rotate & flip for all 6 windows forms control. Fixed designer serialization along the way.

Should be done with 2450d82 (version 4.7.1).

from fontawesome.sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.