Example #1
0
 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);
 }
Example #2
0
        void showRow(ImagesRow row, int top, int left, int width, double vgap, ImageAction action, ref int i)
        {
            int    rowWidth  = row.Width;
            int    rowHeight = row.Height;
            double gap       = ((double)(width - rowWidth) / (double)row.Count);

            for (int cell = 0; cell < row.Count; ++cell)
            {
                if (mPictures.Count <= i)
                {
                    AddPictureBox();
                }

                IRowItem item = row[cell];
                if (item.GetItemType() == RowType.Image)
                {
                    StackableImage image = item as StackableImage;
                    mPictures[i].mPictureBox.Left   = left;
                    mPictures[i].mPictureBox.Top    = top;
                    mPictures[i].mPictureBox.Height = (int)Math.Round(rowHeight + vgap);
                    mPictures[i].mPictureBox.Width  = (int)Math.Round(image.Width + gap);
                    left = mPictures[i].mPictureBox.Left + mPictures[i].mPictureBox.Width;

                    showNextImage(mPictures[i], action, image);
                    mPictures[i].mPictureBox.Show();
                    ++i;
                }
                else if (item.GetItemType() == RowType.Rows)
                {
                    showRows(item as ImagesRows, top, left, row.Height, (int)(item.Width + gap), action, ref i);
                    left += (int)(item.Width + gap);
                }
            }
        }
Example #3
0
        void reuseRow(ImagesRow row)
        {
            for (int i = 0; i < row.Count; ++i)
            {
                switch (row[i].GetItemType())
                {
                case RowType.Rows:
                    reuseRows(row[i] as ImagesRows);
                    break;

                case RowType.Row:
                    reuseRow(row[i] as ImagesRow);
                    break;

                case RowType.Image:
                    mImagesLoader.Return((row[i] as StackableImage).Path);
                    break;
                }
            }
        }
Example #4
0
        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);
        }