Esempio n. 1
0
 public Size SizeFromSize(Size requested)
 {
     if (IsFlow)
     {
         SizeF szData = ClientToData(requested);
         if (!m_Document.PaletteDesignSize.IsEmpty)
         {
             // scaling is only permitted if we have a definite original size
             float zoom = (float)(Math.Sqrt(requested.ToSizeF().Area() / m_Document.PaletteDesignSize.Area()) / m_PixelsPerDocumentX);
             szData = szData.MultiplyBy(m_Document.PaletteDesignSize.Area() / szData.Area());                     // Has the new aspect ratio, but the same total area as the design size
             // not sure why we want to reset to original size (which appears to be small!)
             szData        = ((IAutoSize)m_Page.Shapes.First()).AutoSize(szData);
             m_SpecialZoom = 0;
             if (m_Zoom != zoom)
             {
                 m_Palette.InvalidatePreview();
             }
             m_Zoom = zoom;
             // Note that this must not use the base class methods such as ChangeZoom, because they will try and scroll the "page"
         }
         else
         {
             szData = ((IAutoSize)m_Page.Shapes.First()).AutoSize(szData);
         }
         m_Page.SetSize(szData, 0);
         return(DataToClient(szData).ToSize());
     }
     return(m_Page.Size.ChangeLength(requested.Length()).ToSize());            // same shape as page, but diagonal length of request
 }