using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SOTF_Savegame_Editor.PictureZBoxHelper { public struct PictureZBoxTransformation { public Point Translation { get { return _translation; } } public double Scale { get { return _scale; } } private readonly Point _translation; private readonly double _scale = 1.0d; public PictureZBoxTransformation(Point translation, double scale) { _translation = translation; _scale = scale; } public Point ConvertToIm(Point p) { return new Point((int)(p.X * _scale + _translation.X), (int)(p.Y * _scale + _translation.Y)); } public Size ConvertToIm(Size p) { return new Size((int)(p.Width * _scale), (int)(p.Height * _scale)); } public Rectangle ConvertToIm(Rectangle r) { return new Rectangle(ConvertToIm(r.Location), ConvertToIm(r.Size)); } public Point ConvertToPb(Point p) { return new Point((int)((p.X - _translation.X) / _scale), (int)((p.Y - _translation.Y) / _scale)); } public Size ConvertToPb(Size p) { return new Size((int)(p.Width / _scale), (int)(p.Height / _scale)); } public Rectangle ConvertToPb(Rectangle r) { return new Rectangle(ConvertToPb(r.Location), ConvertToPb(r.Size)); } public PictureZBoxTransformation SetTranslate(Point p) { return new PictureZBoxTransformation(p, _scale); } public PictureZBoxTransformation SetTranslate(Point p, double scale) { return new PictureZBoxTransformation(p, scale); } public PictureZBoxTransformation AddTranslate(Point p) { return SetTranslate(new Point(p.X + _translation.X, p.Y + _translation.Y)); } public PictureZBoxTransformation SetScale(double scale) { return new PictureZBoxTransformation(_translation, scale); } } }