I put this snippet on Gist so you can contribute if you wish. Y += bestSizedItem.testItemHeight + verticalGap If (x + bestSizedItem.testItemWidth - horizontalGap > W) X += bestSizedItem.testItemWidth + horizontalGap Where(item => item.testItemWidth * item.testColCount + horizontalGap * (item.testColCount - 1) item.testItemHeight * item.testItemWidth)įoreach (var control in ().Where(c => c.Visible)) TestItemHeight = (int)(testItemWidth / R), TestRowCount = (int)Math.Ceiling((double)N / testColCount), Var testItemWidth = (W - horizontalGap * (testColCount - 1)) / testColCount TestItemWidth = (int)(testItemHeight * R)Įnumerable.Range(1, N).Select(testColCount => TestColCount = (int)Math.Ceiling((double)N / testRowCount), Var testItemHeight = (H - verticalGap * (testRowCount - 1)) / testRowCount Var verticalGap = margin.Top + margin.Bottom Įnumerable.Range(1, N).Select(testRowCount => Var horizontalGap = margin.Left + margin.Right public static void Arrange(Control container) The padding of the container is also handled. It arranges the visible controls inside a container in respect of the aspect ratio (see R variable in the code), and uses the container margin values to get horizontal and vertical gaps between items. The third figure is showing basically a resized window with three (to six) images. The second shows how I would like the Layout to be, if there are two (three or four) images. The images should visualize this a bit: the first figure should point out the layout, if there is only one PictureBox - it takes the whole space (or as big as possible with the given aspect ratio). (To speak as web developer, I simply want to "float the images left", "with width and height set to 'auto'" and no scrolling.) I thought having a FlowLayout and automatically sized components should be the correct way - but it seems not to work that way. I have to admit I'm was also thinking of calculating the size an position manually - or to dynamically adapt the row and column count of the TableLayout - but it seems to me prone to errors. To give more information about the background: I want to dynamically add and remove images in the viewport of the application, so a TableLayout is in the first step sort of to static. I also tested using a Panel as a wrapper and tested different settings for AutoSize and AutoSizeMode. I tested setting the Dock of the FlowLayout and the PictureBox to Fill. How can I scale PictureBox components to best fit the given space on the screen while keeping their aspect ratio (interdependent of the actual image or its SizeMode) ? Import .eventos.ProductoSeleccionadoListener Import .eventos.ControladorEventListener Hacemos todas las importaciones necesarias Creamos el panel que contendra los botones de cada producto diferente I am fairly new to java and I have yet many failures so please be kind. I've tried a thousand different ways but I have not accomplished anything. I like to adding a scrollbar to a jpanel with flowlayout but is imposible, i don't see the scrollbar.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |