private void metroButton1_Click(object sender, EventArgs e) { var mainForm = Program.ServiceProvider.GetService <MainForm>(); Invoke((MethodInvoker) delegate() { mainForm.Hide(); }); var scalingFactor = DpiScaler.GetScalingFactor(this); //start the updating. ClientSize = new Size((int)(373 * scalingFactor), (int)(71 * scalingFactor)); Location = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - (Size.Width / 2), Screen.PrimaryScreen.WorkingArea.Height / 2 - (Size.Height / 2)); metroTextBox1.Visible = false; metroLabel1.Visible = false; metroLabel2.Visible = false; metroButton1.Visible = false; metroButton2.Visible = false; themedProgressBar1.Visible = true; Text = "Shotr - Updating"; FormBorderStyle = FormBorderStyle.FixedSingle; //update shit. UpdateFromUrl(); }
public virtual void DrawTabBottomBorder(int index, Graphics graphics) { using (Brush bgBrush = new SolidBrush(Theme.TabControlBorderColor)) { var scalingFactor = DpiScaler.GetScalingFactor(this); var borderRectangle = new Rectangle(DisplayRectangle.X, GetTabRect(index).Bottom + 2 - TAB_BOTTOM_BORDER_HEIGHT, DisplayRectangle.Width, TAB_BOTTOM_BORDER_HEIGHT); graphics.FillRectangle(bgBrush, borderRectangle); } }
public ColorPickerForm(BaseSettings settings, Bitmap bitmap) { _settings = settings; SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); InitializeComponent(); var scalingFactor = DpiScaler.GetScalingFactor(this); Font = Theme.Font((int)(Font.Size * scalingFactor)); AutoScaleMode = AutoScaleMode.None; StartPosition = FormStartPosition.Manual; _screenshot = bitmap; timer1.Interval = 10; timer1.Start(); Paint += ScreenshotForm_Paint; FormBorderStyle = FormBorderStyle.None; var rect = Utils.GetScreenBoundaries(); Size = rect.Size; //get point of left-most monitor. Location = rect.Location; KeyUp += ScreenshotForm_KeyUp; KeyDown += ScreenshotForm_KeyDown; Cursor = Cursors.Cross; _screenshot = new Bitmap(_screenshot, rect.Width, rect.Height); using (var image = Utils.Apply(Utils.Contrast(0.7f), _screenshot)) { var brush = new TextureBrush(image); brush.WrapMode = WrapMode.Clamp; _textbrush = brush; } DoubleBuffered = true; ShowInTaskbar = true; TopMost = false; timer2.Interval = 1000; timer2.Start(); MouseDown += ScreenshotForm_MouseDown; }
private new Rectangle GetTabRect(int index) { return(index < 0 ? new Rectangle() : base.GetTabRect(index)); var rect = index < 0 ? new Rectangle() : base.GetTabRect(index); var scalingFactor = DpiScaler.GetScalingFactor(this); rect.Width = (int)(rect.Width * scalingFactor); rect.Height = (int)(rect.Height * scalingFactor); rect.X = (int)(rect.X * scalingFactor); rect.Y = (int)(rect.Y * scalingFactor); return(rect); }
private Bitmap Magnifier(Image img, Point position, int horizontalPixelCount, int verticalPixelCount, int pixelSize) { horizontalPixelCount = Between(horizontalPixelCount | 1, 1, 0x65); verticalPixelCount = Between(verticalPixelCount | 1, 1, 0x65); pixelSize = Between(pixelSize, 1, 0x3e8); if (((horizontalPixelCount * pixelSize) > Width) || ((verticalPixelCount * pixelSize) > Height)) { horizontalPixelCount = verticalPixelCount = 15; pixelSize = 10; } var scalingFactor = DpiScaler.GetScalingFactor(this); pixelSize = (int)(pixelSize * scalingFactor); var width = horizontalPixelCount * pixelSize; var height = verticalPixelCount * pixelSize; var image = new Bitmap(width - 1, height - 1); using (var graphics = Graphics.FromImage(image)) { graphics.InterpolationMode = InterpolationMode.NearestNeighbor; graphics.PixelOffsetMode = PixelOffsetMode.Half; graphics.DrawImage(img, new Rectangle(0, 0, width, height), new Rectangle(position.X - (horizontalPixelCount / 2), position.Y - (verticalPixelCount / 2), horizontalPixelCount, verticalPixelCount), GraphicsUnit.Pixel); graphics.PixelOffsetMode = PixelOffsetMode.None; using (var pen = new Pen(Color.FromArgb(0x4b, Color.Black))) { for (var i = 1; i < horizontalPixelCount; i++) { graphics.DrawLine(pen, new Point((i * pixelSize) - 1, 0), new Point((i * pixelSize) - 1, height - 1)); } for (var j = 1; j < verticalPixelCount; j++) { graphics.DrawLine(pen, new Point(0, (j * pixelSize) - 1), new Point(width - 1, (j * pixelSize) - 1)); } } graphics.DrawRectangle(Pens.Black, ((width - pixelSize) / 2) - 1, ((height - pixelSize) / 2) - 1, pixelSize, pixelSize); graphics.DrawRectangle(Pens.White, (width - pixelSize) / 2, (height - pixelSize) / 2, pixelSize - 2, pixelSize - 2); } return(image); }
public FfMpegDownload() { InitializeComponent(); DpiScaler.ScaleLocation(this, Size, Location); }
public static Font Font(Font font, Control control) => DpiScaler.ScaleFont(font, control);
public VideoRecorderForm(BaseSettings settings, MusicPlayerService musicPlayerService, Uploader uploader, Bitmap bitmap, SingleInstance tasks) { _settings = settings; _musicPlayerService = musicPlayerService; _uploader = uploader; SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); InitializeComponent(); var scalingFactor = DpiScaler.GetScalingFactor(this); Font = Theme.Font((int)(Font.Size * scalingFactor)); AutoScaleMode = AutoScaleMode.None; StartPosition = FormStartPosition.Manual; TopMost = true; ShowInTaskbar = false; _screenshot = bitmap; _tasks = tasks; timer1.Interval = 10; timer1.Start(); Paint += ScreenshotForm_Paint; FormBorderStyle = FormBorderStyle.None; var rect = Utils.GetScreenBoundaries(); Size = rect.Size; //get point of left-most monitor. Location = rect.Location; KeyUp += ScreenshotForm_KeyUp; KeyDown += ScreenshotForm_KeyDown; Cursor = Cursors.Cross; _screenshot = new Bitmap(_screenshot, rect.Width, rect.Height); using (var image = Utils.Apply(Utils.Contrast(0.7f), _screenshot)) { var brush = new TextureBrush(image); brush.WrapMode = WrapMode.Clamp; _textbrush = brush; } DoubleBuffered = true; //ShowInTaskbar = false; timer2.Interval = 1000; timer2.Start(); foreach (var p in Process.GetProcessesByName("ffmpeg")) { try { p.Kill(); } catch { } } MouseDown += ScreenshotForm_MouseDown; MouseUp += ScreenshotForm_MouseUp; }
public ThemeShowcase() { InitializeComponent(); dpiScalingLabel.Text = $"{DpiScaler.GetScalingFactor(this) * 100}% DPI Scaling Factor"; }