Comments (10)
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.
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.
from fontawesome.sharp.
Done - I'm updated code with rotation option for any angle.
from fontawesome.sharp.
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.
@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.
Ok, thanks! Was very busy last few weeks.
from fontawesome.sharp.
We all are, right? ;-)
from fontawesome.sharp.
Yeah :)
from fontawesome.sharp.
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)
- FontAwesome.Sharp package (v5.15.4.0) is unsigned HOT 1
- Add example for nerdfonts
- Add Support for .NET 7, C# 11
- Evaluate https://thenounproject.com/icons/
- Update NuGet Package to 6.2.1 HOT 3
- CVE-2022-34716 (Medium) detected in system.security.cryptography.xml.4.7.0.nupkg
- WS-2022-0161 (High) detected in newtonsoft.json.12.0.3.nupkg, nuke.common.6.1.1.nupkg
- Generate FontAwesome.Sharp.dll for FA Pro? HOT 13
- Image and text are not horizontal aligned. HOT 1
- Update NuGet package FontAwesome.Sharp.Pro HOT 2
- Update NuGet package FontAwesome.Sharp.Pro HOT 6
- CVE-2022-26907 (Medium) detected in microsoft.rest.clientruntime.2.3.20.nupkg, nuke.common.6.1.1.nupkg
- CVE-2023-29337 (High) detected in nuget.common.5.11.0.nupkg, nuke.common.6.1.1.nupkg
- CVE-2024-21907 (High) detected in newtonsoft.json.12.0.3.nupkg, nuke.common.6.1.1.nupkg
- System.ArgumentException: '' is not a valid value for property 'FontFamily' HOT 7
- Icon button in datagridview HOT 7
- Support / Add example for Open Iconic HOT 1
- Duplicate IconChar entries in property window. HOT 8
- Button content not properly aligned. HOT 6
- How to use with Awesome Pro? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fontawesome.sharp.