예제 #1
0
        private void DrawInfoText(Graphics g, string text, Rectangle rect, int padding)
        {
            g.FillRectangle(textBackgroundBrush, rect.Offset(-2));
            g.DrawRectangleProper(textBackgroundPenBlack, rect.Offset(-1));
            g.DrawRectangleProper(textBackgroundPenWhite, rect);

            ImageHelpers.DrawTextWithShadow(g, text, rect.Offset(-padding).Location, infoFont, Brushes.White, Brushes.Black);
        }
예제 #2
0
        private void DrawInfoText(Graphics g, string text, Rectangle rect, Font font, int padding,
                                  Brush backgroundBrush, Pen outerBorderPen, Pen innerBorderPen, Brush textBrush, Brush textShadowBrush)
        {
            g.FillRectangle(backgroundBrush, rect.Offset(-2));
            g.DrawRectangleProper(innerBorderPen, rect.Offset(-1));
            g.DrawRectangleProper(outerBorderPen, rect);

            ImageHelpers.DrawTextWithShadow(g, text, rect.Offset(-padding).Location, font, textBrush, textShadowBrush);
        }
예제 #3
0
        private void DrawTips(Graphics g, int offset, int padding)
        {
            StringBuilder sb = new StringBuilder();

            WriteTips(sb);
            string tipText = sb.ToString().Trim();

            Size      textSize            = g.MeasureString(tipText, infoFont).ToSize();
            int       rectWidth           = textSize.Width + padding * 2 + 2;
            int       rectHeight          = textSize.Height + padding * 2;
            Rectangle primaryScreenBounds = CaptureHelpers.GetPrimaryScreenBounds0Based();
            Rectangle textRectangle       = new Rectangle(primaryScreenBounds.X + primaryScreenBounds.Width - rectWidth - offset, primaryScreenBounds.Y + offset, rectWidth, rectHeight);

            if (textRectangle.Offset(10).Contains(InputManager.MousePosition0Based))
            {
                textRectangle.Y = primaryScreenBounds.Height - rectHeight - offset;
            }

            g.FillRectangle(textBackgroundBrush, textRectangle.Offset(-2));
            g.DrawRectangleProper(textBackgroundPenBlack, textRectangle.Offset(-1));
            g.DrawRectangleProper(textBackgroundPenWhite, textRectangle);

            ImageHelpers.DrawTextWithShadow(g, tipText, textRectangle.Offset(-padding).Location, infoFont, Brushes.White, Brushes.Black);
        }
예제 #4
0
        private void DrawAreaText(Graphics g, string text, Rectangle area)
        {
            int   offset           = 5;
            int   backgroundOffset = 3;
            Size  textSize         = g.MeasureString(text, infoFont).ToSize();
            Point textPos;

            if (area.Y - offset - textSize.Height - backgroundOffset * 2 < ScreenRectangle0Based.Y)
            {
                textPos = new Point(area.X + offset + backgroundOffset, area.Y + offset + backgroundOffset);
            }
            else
            {
                textPos = new Point(area.X + backgroundOffset, area.Y - offset - backgroundOffset - textSize.Height);
            }

            Rectangle backgroundRect = new Rectangle(textPos.X - backgroundOffset, textPos.Y - backgroundOffset, textSize.Width + backgroundOffset * 2, textSize.Height + backgroundOffset * 2);

            g.FillRectangle(textBackgroundBrush, backgroundRect.Offset(-2));
            g.DrawRectangleProper(textBackgroundPenBlack, backgroundRect.Offset(-1));
            g.DrawRectangleProper(textBackgroundPenWhite, backgroundRect);

            ImageHelpers.DrawTextWithShadow(g, text, textPos, infoFont, Brushes.White, Brushes.Black);
        }
예제 #5
0
        private Image CombineScreenshots(List <VideoThumbnailInfo> thumbnails)
        {
            List <Image> images     = new List <Image>();
            Image        finalImage = null;

            try
            {
                string infoString       = "";
                int    infoStringHeight = 0;

                if (Options.AddVideoInfo)
                {
                    infoString = VideoInfo.ToString();

                    using (Font font = new Font("Arial", 12))
                    {
                        infoStringHeight = Helpers.MeasureText(infoString, font).Height;
                    }
                }

                foreach (VideoThumbnailInfo thumbnail in thumbnails)
                {
                    Image img = Image.FromFile(thumbnail.Filepath);

                    if (Options.MaxThumbnailWidth > 0 && img.Width > Options.MaxThumbnailWidth)
                    {
                        int maxThumbnailHeight = (int)((float)Options.MaxThumbnailWidth / img.Width * img.Height);
                        img = ImageHelpers.ResizeImage(img, Options.MaxThumbnailWidth, maxThumbnailHeight);
                    }

                    images.Add(img);
                }

                int columnCount = Options.ColumnCount;

                int thumbWidth = images[0].Width;

                int width = Options.Padding * 2 +
                            thumbWidth * columnCount +
                            (columnCount - 1) * Options.Spacing;

                int rowCount = (int)Math.Ceiling(images.Count / (float)columnCount);

                int thumbHeight = images[0].Height;

                int height = Options.Padding * 3 +
                             infoStringHeight +
                             thumbHeight * rowCount +
                             (rowCount - 1) * Options.Spacing;

                finalImage = new Bitmap(width, height);

                using (Graphics g = Graphics.FromImage(finalImage))
                {
                    g.Clear(Color.WhiteSmoke);

                    if (!string.IsNullOrEmpty(infoString))
                    {
                        using (Font font = new Font("Arial", 12))
                        {
                            g.DrawString(infoString, font, Brushes.Black, Options.Padding, Options.Padding);
                        }
                    }

                    int i       = 0;
                    int offsetY = Options.Padding * 2 + infoStringHeight;

                    for (int y = 0; y < rowCount; y++)
                    {
                        int offsetX = Options.Padding;

                        for (int x = 0; x < columnCount; x++)
                        {
                            if (Options.DrawShadow)
                            {
                                int shadowOffset = 3;

                                using (Brush shadowBrush = new SolidBrush(Color.FromArgb(75, Color.Black)))
                                {
                                    g.FillRectangle(shadowBrush, offsetX + shadowOffset, offsetY + shadowOffset, thumbWidth, thumbHeight);
                                }
                            }

                            g.DrawImage(images[i], offsetX, offsetY, thumbWidth, thumbHeight);

                            if (Options.DrawBorder)
                            {
                                g.DrawRectangleProper(Pens.Black, offsetX, offsetY, thumbWidth, thumbHeight);
                            }

                            if (Options.AddTimestamp)
                            {
                                int timestampOffset = 10;

                                using (Font font = new Font("Arial", 10, FontStyle.Bold))
                                {
                                    ImageHelpers.DrawTextWithShadow(g, thumbnails[i].Timestamp.ToString(),
                                                                    new Point(offsetX + timestampOffset, offsetY + timestampOffset), font, Brushes.White, Brushes.Black);
                                }
                            }

                            i++;

                            if (i >= images.Count)
                            {
                                return(finalImage);
                            }

                            offsetX += thumbWidth + Options.Spacing;
                        }

                        offsetY += thumbHeight + Options.Spacing;
                    }
                }

                return(finalImage);
            }
            catch
            {
                if (finalImage != null)
                {
                    finalImage.Dispose();
                }

                throw;
            }
            finally
            {
                foreach (Image image in images)
                {
                    if (image != null)
                    {
                        image.Dispose();
                    }
                }
            }
        }
예제 #6
0
 private void DrawFPS(Graphics g, int offset)
 {
     ImageHelpers.DrawTextWithShadow(g, FPS.ToString(), new Point(offset, offset), infoFontBig, Brushes.White, Brushes.Black, new Point(0, 1));
 }