/// <summary> /// Y /// </summary> /// <param name="value"> The destination value.</param> /// <param name="indicatorMode"> The indicator mode </param> /// <returns> The produced vector. </returns> public Vector2 TransformY(float value, IndicatorMode indicatorMode = IndicatorMode.LeftTop) { Vector2 indicatorVector = this.GetIndicatorVector(indicatorMode); float y = value - indicatorVector.Y; return(new Vector2(0, y)); }
/// <summary> /// X /// </summary> /// <param name="value"> The destination value.</param> /// <param name="indicatorMode"> The indicator mode </param> /// <returns> The produced vector. </returns> public Vector2 TransformX(float value, IndicatorMode indicatorMode = IndicatorMode.LeftTop) { Vector2 indicatorVector = this.GetIndicatorVector(indicatorMode); float x = value - indicatorVector.X; return(new Vector2(x, 0)); }
/// <summary> /// Rotate /// </summary> /// <param name="value"> The destination value.</param> /// <param name="indicatorMode"> The indicator mode </param> /// <returns> The produced matrix. </returns> public Matrix3x2 TransformRotate(float value, IndicatorMode indicatorMode = IndicatorMode.LeftTop) { Vector2 indicatorVector = this.GetIndicatorVector(indicatorMode); float value2 = value / 180.0f * FanKit.Math.Pi; float radian = FanKit.Math.VectorToRadians(this.CenterTop - this.Center); float radians = value2 - radian - FanKit.Math.PiOver2; return(Matrix3x2.CreateRotation(radians, indicatorVector)); }
/// <summary> /// Skew /// </summary> /// <param name="value"> The destination value.</param> /// <param name="indicatorMode"> The indicator mode </param> /// <returns> The produced matrix. </returns> public Matrix3x2 TransformSkew(float value, IndicatorMode indicatorMode = IndicatorMode.LeftTop) { Vector2 horizontal = this.Horizontal; float horizontalHalf = horizontal.Length() / 2; Vector2 footPoint = FanKit.Math.FootPoint(this.Center, this.LeftBottom, this.RightBottom); float verticalHalf = Vector2.Distance(this.Center, footPoint); float radians = Transformer.GetRadians(horizontal) / 180.0f * FanKit.Math.Pi; float skew = -value / 180.0f * FanKit.Math.Pi; //Vector2 Vector2 postion; Vector2 center; switch (indicatorMode) { case IndicatorMode.LeftTop: case IndicatorMode.Top: case IndicatorMode.RightTop: postion = new Vector2(-horizontalHalf, 0); center = this.CenterTop; break; case IndicatorMode.LeftBottom: case IndicatorMode.Bottom: case IndicatorMode.RightBottom: postion = new Vector2(-horizontalHalf, -verticalHalf * 2); center = this.CenterBottom; break; default: postion = new Vector2(-horizontalHalf, -verticalHalf); center = this.Center; break; } //Matrix Matrix3x2 skewMatrix = Matrix3x2.CreateSkew(skew, 0) * Matrix3x2.CreateRotation(radians) * Matrix3x2.CreateTranslation(center); Transformer zeroTransformer = new Transformer(horizontalHalf * 2, verticalHalf * 2, postion); Transformer transformer = Transformer.Multiplies(zeroTransformer, skewMatrix); return(Transformer.FindHomography(transformer, this)); }
/// <summary> /// Height /// </summary> /// <param name="value"> The destination value.</param> /// <param name="indicatorMode"> The indicator mode </param> /// <param name="isRatio"> Maintain a ratio when scaling. </param> /// <returns> The produced matrix. </returns> public Matrix3x2 TransformHeight(float value, IndicatorMode indicatorMode = IndicatorMode.LeftTop, bool isRatio = false) { Vector2 vertical = this.Vertical; Vector2 indicatorVector = this.GetIndicatorVector(indicatorMode); float height = vertical.Length(); float radian = FanKit.Math.VectorToRadians(this.CenterTop - this.Center); float scale = value / height; return (Matrix3x2.CreateRotation(-radian, indicatorVector) * Matrix3x2.CreateScale(scale, isRatio ? scale : 1, indicatorVector) * Matrix3x2.CreateRotation(radian, indicatorVector)); }
/// <summary> /// Width /// </summary> /// <param name="value"> The destination value.</param> /// <param name="indicatorMode"> The indicator mode </param> /// <param name="isRatio"> Maintain a ratio when scaling. </param> /// <returns> The produced matrix. </returns> public Matrix3x2 TransformWidth(float value, IndicatorMode indicatorMode = IndicatorMode.LeftTop, bool isRatio = false) { Vector2 horizontal = this.Horizontal; Vector2 indicatorVector = this.GetIndicatorVector(indicatorMode); float width = horizontal.Length(); float radian = FanKit.Math.VectorToRadians(this.CenterTop - this.Center); float scale = value / width; return (Matrix3x2.CreateRotation(-radian, indicatorVector) * Matrix3x2.CreateScale(isRatio ? scale : 1, scale, indicatorVector) * Matrix3x2.CreateRotation(radian, indicatorVector)); }
public void MethodSetup(BitmapSize bitmapSize, IndicatorMode indicatorMode) { if (this.CanvasTransformer == bitmapSize) { return; } Vector2 previousVector = this.CanvasTransformer.GetIndicatorVector(indicatorMode); //History LayersSetupTransformAddHistory history = new LayersSetupTransformAddHistory("Set canvas size", this.CanvasTransformer); //CanvasTransformer this.CanvasTransformer.BitmapSize = bitmapSize; this.CanvasTransformer.ReloadMatrix(); Vector2 vector = this.CanvasTransformer.GetIndicatorVector(indicatorMode); Vector2 distance = vector - previousVector; //LayerageCollection foreach (Layerage layerage in this.LayerageCollection.RootLayerages) { //Selection this.SetLayerageValueWithChildren(layerage, (layerage2) => { ILayer layer = layerage2.Self; //History history.PushTransform(layer, distance); //Refactoring layer.IsRefactoringTransformer = true; layer.IsRefactoringRender = true; layer.IsRefactoringIconRender = true; //layerage.RefactoringParentsTransformer(); //layerage.RefactoringParentsRender(); //layerage.RefactoringParentsIconRender(); layer.CacheTransform(); layer.TransformAdd(distance); }); } //History this.HistoryPush(history); //Selection this.SetMode(this.LayerageCollection); this.Invalidate();//Invalidate }
/// <summary> /// Convert to <see cref="VerticalAlignment"/>. /// </summary> /// <param name="indicatorMode"> The indicato rmode. </param> /// <returns> The produced alignment. </returns> public static VerticalAlignment ToVerticalAlignment(this IndicatorMode indicatorMode) { switch (indicatorMode) { case IndicatorMode.LeftTop: case IndicatorMode.RightTop: case IndicatorMode.Top: return(VerticalAlignment.Top); case IndicatorMode.Center: case IndicatorMode.Left: case IndicatorMode.Right: return(VerticalAlignment.Center); case IndicatorMode.RightBottom: case IndicatorMode.LeftBottom: case IndicatorMode.Bottom: return(VerticalAlignment.Bottom); default: return(VerticalAlignment.Center); } }
/// <summary> /// Convert to <see cref="HorizontalAlignment"/>. /// </summary> /// <param name="indicatorMode"> The indicato rmode. </param> /// <returns> The produced alignment. </returns> public static HorizontalAlignment ToHorizontalAlignment(this IndicatorMode indicatorMode) { switch (indicatorMode) { case IndicatorMode.LeftTop: case IndicatorMode.Left: case IndicatorMode.LeftBottom: return(HorizontalAlignment.Left); case IndicatorMode.Top: case IndicatorMode.Center: case IndicatorMode.Bottom: return(HorizontalAlignment.Center); case IndicatorMode.RightTop: case IndicatorMode.Right: case IndicatorMode.RightBottom: return(HorizontalAlignment.Right); default: return(HorizontalAlignment.Center); } }
/// <summary> /// Gets vector by left, right, top, bottom. /// </summary> /// <param name="indicatorMode"> The indicator mode </param> /// <returns> The produced vector. </returns> public Vector2 GetIndicatorVector(IndicatorMode indicatorMode) { switch (indicatorMode) { case IndicatorMode.LeftTop: return(this.LeftTop); case IndicatorMode.RightTop: return(this.RightTop); case IndicatorMode.RightBottom: return(this.RightBottom); case IndicatorMode.LeftBottom: return(this.LeftBottom); case IndicatorMode.Left: return(this.CenterLeft); case IndicatorMode.Top: return(this.CenterTop); case IndicatorMode.Right: return(this.CenterRight); case IndicatorMode.Bottom: return(this.CenterBottom); case IndicatorMode.Center: return(this.Center); } return(this.LeftTop); }
/// <summary> /// Gets vector by left, right, top, bottom. /// </summary> /// <param name="indicatorMode"> The indicator mode </param> /// <returns> The produced vector. </returns> public Vector2 GetIndicatorVector(IndicatorMode indicatorMode) { switch (indicatorMode) { case IndicatorMode.LeftTop: return(new Vector2(0, 0)); case IndicatorMode.RightTop: return(new Vector2(this.Width, 0)); case IndicatorMode.RightBottom: return(new Vector2(this.Width, this.Height)); case IndicatorMode.LeftBottom: return(new Vector2(0, this.Height)); case IndicatorMode.Left: return(new Vector2(0, this.Height / 2.0f)); case IndicatorMode.Top: return(new Vector2(this.Width / 2.0f, 0)); case IndicatorMode.Right: return(new Vector2(this.Width, this.Height / 2.0f)); case IndicatorMode.Bottom: return(new Vector2(this.Width / 2.0f, this.Height)); case IndicatorMode.Center: return(new Vector2(this.Width / 2.0f, this.Height / 2.0f)); } return(new Vector2(0, 0)); }
public Indicator() { Mode = IndicatorMode.Indicator3D; }
internal static extern void elm_win_indicator_mode_set(IntPtr obj, IndicatorMode mode);