Xwt.Drawing.Image.WithBoxSize C# (CSharp) Method

WithBoxSize() public method

Retuns a copy of the image with a size that fits the provided size limits
This is a lightweight operation. The image is scaled when it is rendered. The method doesn't make a copy of the image data.
public WithBoxSize ( double maxWidth, double maxHeight ) : Image
maxWidth double Max width.
maxHeight double Max height.
return Image
        public Image WithBoxSize(double maxWidth, double maxHeight)
        {
            var size = GetFixedSize ();
            var ratio = Math.Min (maxWidth / size.Width, maxHeight / size.Height);

            return new Image (this) {
                requestedSize = new Size (size.Width * ratio, size.Height * ratio)
            };
        }

Same methods

Image::WithBoxSize ( Size size ) : Image
Image::WithBoxSize ( double maxSize ) : Image

Usage Example

Ejemplo n.º 1
0
        private void InitializeUI(BaseScan scan, Image thumbnail)
        {
            mScan = scan;

            Icon = thumbnail;
            Title = scan.Name;

            Buttons.Add(new DialogButton(Command.Cancel));
            Buttons.Add(new DialogButton(Command.Apply));

            Font fontH1 = Font.SystemFont.WithStyle(FontStyle.Oblique).WithSize(16);
            Font fontH2 = fontH1.WithStyle(FontStyle.Normal).WithSize(12);

            VBox mainLayout = new VBox();
            Content = mainLayout;

            HBox overviewLayout = new HBox();
            VBox overviewDataLayout = new VBox();

            ImageView thumbnailView = new ImageView(thumbnail.WithBoxSize(96));
            nameEntryUnedited.Text = scan.Name;
            nameEntryUnedited.Font = fontH1;

            fiberTypeEntryUnedited.Text = scan.FiberType;
            fiberTypeEntryUnedited.Font = fontH2;

            nameEntry.Text = scan.Name;
            nameEntry.Visible = false;
            nameEntry.Font = fontH1;

            fiberTypeEntry.Text = scan.FiberType;
            fiberTypeEntry.Visible = false;
            fiberTypeEntry.Font = fontH2;

            overviewDataLayout.MarginTop = 4;
            overviewDataLayout.MarginLeft = 4;
            overviewDataLayout.PackStart(nameEntryUnedited);
            overviewDataLayout.PackStart(nameEntry);
            overviewDataLayout.PackStart(fiberTypeEntryUnedited);
            overviewDataLayout.PackStart(fiberTypeEntry);

            overviewLayout.PackStart(thumbnailView);
            overviewLayout.PackStart(overviewDataLayout, true, true);

            MetadataView mView = new MetadataView();
            mView.Load(scan);

            ScrollView mViewScroller = new ScrollView { Content = mView, BorderVisible = false };

            mainLayout.PackStart(overviewLayout);
            mainLayout.PackStart(mViewScroller, true, true);
        }
All Usage Examples Of Xwt.Drawing.Image::WithBoxSize