public NotificationForm(int duration, ContentAlignment placement, Size size, NotificationFormConfig config) { InitializeComponent(); SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); ToastConfig = config; textFont = new Font("Arial", 10); if (config.Image != null) { config.Image = ImageHelpers.ResizeImageLimit(config.Image, size); config.Image = ImageHelpers.DrawCheckers(config.Image); size = new Size(config.Image.Width + 2, config.Image.Height + 2); } else if (!string.IsNullOrEmpty(config.Text)) { textRenderSize = Helpers.MeasureText(config.Text, textFont, size.Width - textPadding * 2); size = new Size(textRenderSize.Width + textPadding * 2, textRenderSize.Height + textPadding * 2 + 2); } Point position = Helpers.GetPosition(placement, new Point(windowOffset, windowOffset), Screen.PrimaryScreen.WorkingArea.Size, size); NativeMethods.SetWindowPos(Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, position.X + Screen.PrimaryScreen.WorkingArea.X, position.Y + Screen.PrimaryScreen.WorkingArea.Y, size.Width, size.Height, SetWindowPosFlags.SWP_NOACTIVATE); if (duration <= 0) { DurationEnd(); } else { tDuration.Interval = duration; tDuration.Start(); } }
public NotificationForm(int duration, ContentAlignment placement, Size size, NotificationFormConfig config) { InitializeComponent(); ToastConfig = config; textFont = new Font("Arial", 10); if (config.Image != null) { config.Image = ImageHelpers.ResizeImageLimit(config.Image, size); config.Image = ImageHelpers.DrawCheckers(config.Image); size = new Size(config.Image.Width + 2, config.Image.Height + 2); } else if (!string.IsNullOrEmpty(config.Text)) { textRenderSize = Helpers.MeasureText(config.Text, textFont, size.Width - textPadding * 2); size = new Size(textRenderSize.Width + textPadding * 2, textRenderSize.Height + textPadding * 2 + 2); } SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); Size = size; Point position = Helpers.GetPosition(placement, new Point(windowOffset, windowOffset), Screen.PrimaryScreen.WorkingArea.Size, Size); Location = new Point(Screen.PrimaryScreen.WorkingArea.X + position.X, Screen.PrimaryScreen.WorkingArea.Y + position.Y); tDuration.Interval = duration; tDuration.Start(); }
public NotificationForm(int duration, Size size, Image img, string url) { InitializeComponent(); img = ImageHelpers.ResizeImageLimit(img, size); img = ImageHelpers.DrawCheckers(img); ToastImage = img; ToastURL = url; SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); Size = new Size(img.Width + 2, img.Height + 2); Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - Width - windowOffset, Screen.PrimaryScreen.WorkingArea.Bottom - Height - windowOffset); tDuration.Interval = duration; tDuration.Start(); }
public static Image GetRegionImage(Image surfaceImage, GraphicsPath regionFillPath, GraphicsPath regionDrawPath, SurfaceOptions options) { if (regionFillPath != null) { Image img; Rectangle regionArea = Rectangle.Round(regionFillPath.GetBounds()); Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based(); Rectangle newRegionArea = Rectangle.Intersect(regionArea, screenRectangle); using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone()) { MoveGraphicsPath(gp, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y)); img = ImageHelpers.CropImage(surfaceImage, newRegionArea, gp); if (options.DrawBorder) { GraphicsPath gpOutline = regionDrawPath ?? regionFillPath; using (GraphicsPath gp2 = (GraphicsPath)gpOutline.Clone()) { MoveGraphicsPath(gp2, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y)); img = ImageHelpers.DrawOutline(img, gp2); } } } if (options.DrawChecker) { img = ImageHelpers.DrawCheckers(img); } return(img); } return(null); }
// Must be called before show form public void Prepare(Image img) { Image = img; if (IsEditorMode) { Rectangle rect = CaptureHelpers.GetActiveScreenBounds0Based(); if (Image.Width > rect.Width || Image.Height > rect.Height) { rect = ScreenRectangle0Based; } ImageRectangle = new Rectangle(rect.X + rect.Width / 2 - Image.Width / 2, rect.Y + rect.Height / 2 - Image.Height / 2, Image.Width, Image.Height); using (Image background = ImageHelpers.DrawCheckers(ScreenRectangle0Based.Width, ScreenRectangle0Based.Height)) using (Graphics g = Graphics.FromImage(background)) { g.DrawImage(Image, ImageRectangle); backgroundBrush = new TextureBrush(background) { WrapMode = WrapMode.Clamp }; } } else if (Config.UseDimming) { using (Bitmap darkBackground = (Bitmap)Image.Clone()) using (Graphics g = Graphics.FromImage(darkBackground)) using (Brush brush = new SolidBrush(Color.FromArgb(30, Color.Black))) { g.FillRectangle(brush, 0, 0, darkBackground.Width, darkBackground.Height); backgroundBrush = new TextureBrush(darkBackground) { WrapMode = WrapMode.Clamp }; } backgroundHighlightBrush = new TextureBrush(Image) { WrapMode = WrapMode.Clamp }; } else { backgroundBrush = new TextureBrush(Image) { WrapMode = WrapMode.Clamp }; } ShapeManager = new ShapeManager(this); ShapeManager.WindowCaptureMode = Config.DetectWindows; ShapeManager.IncludeControls = Config.DetectControls; if (Mode == RegionCaptureMode.OneClick || ShapeManager.WindowCaptureMode) { IntPtr handle = Handle; TaskEx.Run(() => { WindowsRectangleList wla = new WindowsRectangleList(); wla.IgnoreHandle = handle; wla.IncludeChildWindows = ShapeManager.IncludeControls; ShapeManager.Windows = wla.GetWindowInfoListAsync(5000); }); } if (Config.UseCustomInfoText || Mode == RegionCaptureMode.ScreenColorPicker) { bmpBackgroundImage = new Bitmap(Image); } }
public override Image Apply(Image img) { return(ImageHelpers.DrawCheckers(img, Size, Color, Color2)); }
public override Bitmap Apply(Bitmap bmp) { return(ImageHelpers.DrawCheckers(bmp, Size, Color, Color2)); }