Ticket Q398219
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

XRPictureBox - Provide the capability to specify image alignment

XTraReport - XRPictureBox alignment

created 13 years ago

Hi,
We're displaying a logo in the right top corner of the report, but we can't find an alignment property.
Can you please advice?
Thanks.

Show previous comments (2)
DevExpress Support Team 13 years ago

    Hi,
    Thank you for your response. As an alternative solution, use the PictureEdit control, as described in the XRPictureBox Alignment Property Existence ticket.
    Thanks,
    Alex

    N N
    NextUp Management Solutions 13 years ago

      Hi,
      This is my current solution, which works pretty good, except for the fact that I don't get the correct size estimates - a few pixels difference.
      Can you please have a look and tell me where I am wrong?
              private static void PictureBoxBeforePrint(object sender, PrintEventArgs e)
              {
                  var pb = sender as XRPictureBox;
                  if (pb == null) return;
                  var anchor = pb.Tag as string;
                  if (string.IsNullOrWhiteSpace(anchor) == true) return;
                  var img = pb.Image;
                  if (img == null) return;
                  var parentSize = pb.SizeF;
                  var parentLocation = pb.LocationF;
                  // set XRPictureBox size to the image size
                  if (img.Width > parentSize.Width || img.Height > parentSize.Height)
                  {
                      // estimate image size
                      var wr = img.Width / (float)parentSize.Width;
                      var hr = img.Height / (float)parentSize.Height;
                      var r = Math.Max(wr, hr);
                      var size = new SizeF(img.Width / r, img.Height / r);
                      pb.SizeF = size;
                  }
                  else
                  {
                      var w = Math.Min(img.Width, parentSize.Width);
                      var h = Math.Min(img.Height, parentSize.Height);
                      pb.SizeF = new SizeF(w, h);
                  }
                  if (anchor.Contains("Left"))
                      pb.LeftF = parentLocation.X;
                  else if (anchor.Contains("Right"))
                      pb.LeftF = parentLocation.X + parentSize.Width - pb.SizeF.Width;
                  else if (anchor.Contains("Center"))
                      pb.LeftF = parentLocation.X + ((parentSize.Width - pb.SizeF.Width) / 2);
                  if (anchor.Contains("Top"))
                      pb.TopF = parentLocation.Y;
                  else if (anchor.Contains("Bottom"))
                      pb.TopF = parentLocation.Y + parentSize.Height- pb.SizeF.Height;
                  else if (anchor.Contains("Middle"))
                      pb.TopF = parentLocation.Y + ((parentSize.Height - pb.SizeF.Height) / 2);
              }
      Thanks.

      DevExpress Support Team 13 years ago

        Hi,
        Please update your code and use the XRConvert.Convert method to convert pixel units to report units (see the SetSizing method in the sample project provided in the How specify XRPictureBox alignment ticket). This should resolve the issue.
        Thanks,
        Alex

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.