Exemplo n.º 1
0
        private void btnCombine_Click(object sender, EventArgs e)
        {
            if (lvImages.Items.Count > 0)
            {
                try
                {
                    List <string> imageFiles = lvImages.Items.Cast <ListViewItem>().Select(x => x.Text).ToList();

                    if (imageFiles.Count > 1)
                    {
                        Bitmap output = ImageHelpers.CombineImages(imageFiles, Options.Orientation, Options.Alignment, Options.Space, Options.AutoFillBackground);

                        if (output != null)
                        {
                            OnProcessRequested(output);
                        }
                    }
                }
                catch (Exception ex)
                {
                    DebugHelper.WriteException(ex);
                    ex.ShowError();
                }
            }
        }
Exemplo n.º 2
0
        private void btnCombine_Click(object sender, EventArgs e)
        {
            if (lvImages.Items.Count > 0)
            {
                IEnumerable <Image> images = null;

                try
                {
                    images = lvImages.Items.Cast <ListViewItem>().Select(x => ImageHelpers.LoadImage(x.Text));
                    Image output = ImageHelpers.CombineImages(images, Options.Orientation, Options.Space);
                    OnProcessRequested(output);
                }
                catch (Exception ex)
                {
                    DebugHelper.WriteException(ex);

                    MessageBox.Show(ex.ToString(), $"ShareX - {Resources.Program_Run_Error}", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    if (images != null)
                    {
                        foreach (Image image in images)
                        {
                            if (image != null)
                            {
                                image.Dispose();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void btnCombine_Click(object sender, EventArgs e)
        {
            if (lvImages.Items.Count > 0)
            {
                List <Image> images = new List <Image>();

                try
                {
                    foreach (ListViewItem lvi in lvImages.Items)
                    {
                        string filePath = lvi.Text;

                        if (File.Exists(filePath))
                        {
                            Image img = ImageHelpers.LoadImage(filePath);

                            if (img != null)
                            {
                                images.Add(img);
                            }
                        }
                    }

                    if (images.Count > 1)
                    {
                        Image output = ImageHelpers.CombineImages(images, Options.Orientation, Options.Space);

                        OnProcessRequested(output);
                    }
                }
                catch (Exception ex)
                {
                    DebugHelper.WriteException(ex);

                    MessageBox.Show(ex.ToString(), $"ShareX - {Resources.Program_Run_Error}", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    if (images != null)
                    {
                        foreach (Image image in images)
                        {
                            if (image != null)
                            {
                                image.Dispose();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void btnCombine_Click(object sender, EventArgs e)
        {
            if (lvImages.Items.Count > 0)
            {
                List <Bitmap> images = new List <Bitmap>();

                try
                {
                    foreach (ListViewItem lvi in lvImages.Items)
                    {
                        string filePath = lvi.Text;

                        if (File.Exists(filePath))
                        {
                            Bitmap bmp = ImageHelpers.LoadImage(filePath);

                            if (bmp != null)
                            {
                                images.Add(bmp);
                            }
                        }
                    }

                    if (images.Count > 1)
                    {
                        Bitmap output = ImageHelpers.CombineImages(images, Options.Orientation, Options.Alignment, Options.Space, Options.AutoFillBackground);

                        OnProcessRequested(output);
                    }
                }
                catch (Exception ex)
                {
                    DebugHelper.WriteException(ex);
                    ex.ShowError();
                }
                finally
                {
                    if (images != null)
                    {
                        foreach (Bitmap image in images)
                        {
                            if (image != null)
                            {
                                image.Dispose();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public JsonResult SaveBoardItem(BoardItem boardItem)
        {
            var currentBoardItem = BoardDbContext.BoardItems.FirstOrDefault(b => b.Id == boardItem.Id && b.UserId == 1);
            var isSuccess        = false;

            if (currentBoardItem != null)
            {
                currentBoardItem.Title         = boardItem.Title;
                currentBoardItem.Description   = boardItem.Description;
                currentBoardItem.IsShowProfile = boardItem.IsShowProfile;
                if (currentBoardItem.BoardStructure != boardItem.BoardStructure && !string.IsNullOrWhiteSpace(boardItem.BoardStructure))
                {
                    currentBoardItem.BoardStructure = boardItem.BoardStructure;
                    ImageHelpers.CombineImages(currentBoardItem.BoardStructure, Server.MapPath("~/App_Data/"),
                                               currentBoardItem.Id.ToString());
                    currentBoardItem.BoardImageUrl = currentBoardItem.Id.ToString() + ".PNG";
                }
                isSuccess = BoardDbContext.SaveChanges() > 0;
            }
            return(Json(isSuccess));
        }
Exemplo n.º 6
0
        private Bitmap CombineImages()
        {
            if (images == null || images.Count == 0)
            {
                return(null);
            }

            if (images.Count == 1)
            {
                return((Bitmap)images[0].Clone());
            }

            List <Bitmap> output = new List <Bitmap>();

            for (int i = 0; i < images.Count - Options.IgnoreLast; i++)
            {
                Bitmap newImage;
                Bitmap image = images[i];

                if (Options.TrimLeftEdge > 0 || Options.TrimTopEdge > 0 || Options.TrimRightEdge > 0 || Options.TrimBottomEdge > 0 ||
                    Options.CombineAdjustmentVertical > 0 || Options.CombineAdjustmentLastVertical > 0)
                {
                    Rectangle rect = new Rectangle(Options.TrimLeftEdge, Options.TrimTopEdge, image.Width - Options.TrimLeftEdge - Options.TrimRightEdge,
                                                   image.Height - Options.TrimTopEdge - Options.TrimBottomEdge);

                    if (i == images.Count - 1)
                    {
                        rect.Y      += Options.CombineAdjustmentLastVertical;
                        rect.Height -= Options.CombineAdjustmentLastVertical;
                    }
                    else if (i > 0)
                    {
                        rect.Y      += Options.CombineAdjustmentVertical;
                        rect.Height -= Options.CombineAdjustmentVertical;
                    }

                    newImage = ImageHelpers.CropBitmap(image, rect);

                    if (newImage == null)
                    {
                        continue;
                    }
                }
                else
                {
                    newImage = (Bitmap)image.Clone();
                }

                output.Add(newImage);
            }

            Bitmap bmpResult = ImageHelpers.CombineImages(output);

            foreach (Bitmap image in output)
            {
                if (image != null)
                {
                    image.Dispose();
                }
            }

            output.Clear();

            return(bmpResult);
        }