bool addSubitem(ImagesRow r, StackableImage image, int maxHeight) { for (int i = 0; i < r.Count; ++i) { if (r[i].GetItemType() == RowType.Rows) { if (Add(r[i] as ImagesRows, image, r[i].Width, r.Height, false, true)) { return(true); } } else { StackableImage desc = r[i] as StackableImage; if (r.Height - desc.Height < image.Height || desc.Width < image.Width) { continue; } if (desc != null) { ImagesRows subrows = new ImagesRows(); Add(subrows, desc, desc.Width, maxHeight, false, true); Add(subrows, image, desc.Width, maxHeight, false, true); r.Insert(subrows, i); r.Remove(desc); return(true); } } } return(false); }
void reuseRows(ImagesRows rows) { for (int i = 0; i < rows.RowCount; ++i) { reuseRow(rows[i] as ImagesRow); } }
public void updateImages(ImageAction action) { ImagesLayout oldLayout = mLayout; mLayout = mScreenComposer.GetNextLayout(); if (mLayout != null) { ImagesRows rows = mLayout.Rows; int i = 0; showRows(rows, 0, 0, Size.Height, Size.Width, action, ref i); for (int picture = i; picture < mPictures.Count; ++picture) { mPictures[picture].mPictureBox.Hide(); showNextImage(mPictures[picture], action, null); } } else { for (int picture = 0; picture < mPictures.Count; ++picture) { mPictures[picture].mPictureBox.Hide(); showNextImage(mPictures[picture], action, null); } } if (oldLayout != null) { oldLayout.Dispose(); } }
void showRows(ImagesRows rows, int top, int left, int height, int width, ImageAction action, ref int i) { if (rows.RowCount == 0) { return; } double vgap = ((double)(height - rows.Height) / (double)rows.RowCount); for (int row = 0; row < rows.RowCount; ++row) { IRowItem item = rows[row]; showRow(item as ImagesRow, top, left, width, vgap, action, ref i); top += (int)Math.Round(item.Height + vgap); } }
bool Add(ImagesRows target, StackableImage image, int maxWidth, int maxHeight, bool addSubRows, bool useFind) { if (image.Width > maxWidth) { return(false); } int rowsHeight = 0; for (int row = 0; row < target.RowCount; ++row) { if (addSubRows && addSubitem(target[row] as ImagesRow, image, maxHeight)) { return(true); } int rowHeight = target[row].Height; int rowWidth = target[row].Width; rowsHeight += rowHeight; int heightDiff = rowHeight - image.Height; bool widthFits = maxWidth - rowWidth >= image.Width; bool heightFits = heightDiff >= 0 || maxHeight - GetRowsHeight() >= Math.Abs(heightDiff); if (heightFits && widthFits) { ImagesRow imagesRow = target[row] as ImagesRow; imagesRow.Add(image); return(true); } } if (maxHeight - rowsHeight >= image.Height) { ImagesRow newRow = new ImagesRow(); newRow.Add(image); target.Add(newRow); return(true); } return(false); }