private static Parameters.Position ToPosition(string s)
 {
     Parameters.Position pos = new Parameters.Position();
     string[]            sl  = s.Split(',');
     if (sl.Length >= 2)
     {
         pos.posx = ToFloat(sl[0]);
         pos.posy = ToFloat(sl[1]);
     }
     if (sl.Length >= 4)
     {
         pos.alix = (Parameters.AlignmentX)Enum.Parse(typeof(Parameters.AlignmentX), sl[2], true);
         pos.aliy = (Parameters.AlignmentY)Enum.Parse(typeof(Parameters.AlignmentY), sl[3], true);
     }
     return(pos);
 }
示例#2
0
        // Return calculated rect to draw
        public static Rectangle RectangleCalc(int w, int h, Bitmap b, Parameters.Position pos, float scale0)
        {
            float bw     = b.Width;
            float bh     = b.Height;
            float scale1 = ((float)w) / bw;
            float scale2 = ((float)h) / bh;
            float scale  = Math.Min(scale1, scale2) * scale0;

            bw *= scale;
            bh *= scale;

            float cx = w / 2f;
            float cy = h / 2f;

            float x = cx - bw * pos.posx;
            float y = cy - bh * pos.posy;

            return(new Rectangle((int)x, (int)y, (int)bw, (int)bh));
        }