- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个全屏表单,在 Paint 事件的处理程序中,我在整个表单周围绘制了一个 2px 的边框。我为连接到计算机的每个屏幕创建了这些表格之一。出于某种原因,顶部和左侧边框未绘制在任何非主显示器上。窗体的背景覆盖了整个屏幕,但我看不到要在距屏幕顶部向下约 3px 和距屏幕左侧约 3px 的区域上绘制(使用 GDI)。
我的 Paint 事件处理程序代码如下。
private void OnPaint(object sender, PaintEventArgs e)
{
using (Graphics g = this.CreateGraphics())
{
int border = 2;
int startPos = 0;
// offset used to correctly paint all the way to the right and bottom edges
int offset = 1;
Rectangle rect = new Rectangle(startPos, startPos, this.Width - border + offset, this.Height - border + offset);
Pen pen = new Pen(Color.Red, border);
// draw a border
g.DrawRectangle(pen, rect);
}
}
有人见过这个吗?
最佳答案
您的代码工作正确。您应该知道在使用 this.Width
或 this.Height
时,这些值是根据表单周围的框架计算的。对于高度,您的表单控件的高度添加到计算的高度。您可以使用此代码:
using (Graphics g = this.CreateGraphics())
{
int border = 2;
int startPos = 0;
// offset used to correctly paint all the way to the right and bottom edges
int offset = 1;
Rectangle rect = new Rectangle(startPos, startPos, this.Width-20, this.Height-40);
Pen pen = new Pen(Color.Red, border);
// draw a border
g.DrawRectangle(pen, rect);
}
更新:
如果你想计算精确的尺寸,你可以使用这个代码:
int width,height;
public Form1()
{
InitializeComponent();
PictureBox pc = new PictureBox();
pc.Dock = DockStyle.Fill;
this.Controls.Add(pc);
pc.Visible = false;
width = pc.Width;
height = pc.Height;
pc.Dispose();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
using (Graphics g = this.CreateGraphics())
{
int border = 2;
int startPos = 0;
// offset used to correctly paint all the way to the right and bottom edges
int offset = 1;
Rectangle rect = new Rectangle(startPos, startPos, width,height);
Pen pen = new Pen(Color.Red, border);
// draw a border
g.DrawRectangle(pen, rect);
}
}
关于C#:在非主监视器上使用 DrawRectangle 绘制的矩形不呈现顶部和左侧边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18967021/
以下是否意味着只有一个线程可以在对象的任何方法中?或者多个线程可以使用不同的方法而不是同一个方法吗?为什么? public class SynchronizedCounter { privat
我有一个 java 监视器,但我需要一些解释: class Test { private int data; private boolean full = false; public sy
#include #include #include #include #define N_ASS 4 pthread_t tid[N_ASS]; //mutex pthread_mutex_
我想知道是否有一种工具可以跟踪我的 C# 程序正在使用/访问的文件列表(文本/任何外部文件)? =D 有什么工具吗? 附注它是为了测试程序安全性.. ;) 最佳答案 ProcessMonitor监控任
我想知道 Monitor 类。据我所知,所有等待线程都不是 FIFO。第一个获得锁的并不总是等待队列中的第一个。这样对吗?有什么方法可以确保 FIFO 条件? 问候 最佳答案 如果您指的是内置方式,则
我有一个 ASP.net (c#) 应用程序,其中包含修改全局可访问资源(如 web.config 文件)的部分代码。当然,在修改资源时,为了防止竞争条件,一次只允许一个用户,因此我需要使用监视器锁定
如何方便调试持久化上下文的状态、观察查询结果、监控所有实体? 有一些 JPA 监视器可以用于此吗? 最佳答案 如果您使用 EclipseLink,则有一个性能监视器选项, 看, http://wiki
启动和停止按钮在监视器 tomcat 中被禁用,大约 10-15 分钟后,它允许我重新启动服务器 当 tomcat 停止响应并且我尝试重新启动服务器时,我遇到了这个问题,我能够停止服务器,但之后它不允
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我必须开发一个系统来监控报告的生成/传输。 系统数据将存储在数据库表中(Sybase) 报告将按不同的时间表生成(“周一至周五晚上 10 点”、“周六早上 5 点”、“每月的第一天”等) 系统只会监控
我需要同步多个线程(使用 POSIX 线程)。此外,我正在使用条件变量(监视器)来实现这一点。 问题是我必须实现“先到先得”的策略。假设多个线程正在等待另一个线程发出条件变化的信号,pthread_c
在 eclipse 中,我有一个运行的 weblogic 服务器,并部署了一个 j2ee 应用程序。该应用程序在端口 7001 上提供服务。我想将监视器连接到应用程序,我不知道要使用什么端口。我想我知
我正在使用芹菜和花卉。当我访问Flower中的“任务”标签时,我可以看到我的任务正在注册,甚至可以在“状态”列中看到“成功”标签以及所有内容。 但是,在“监视器”选项卡上,所有图形(“成功任务”,“失
有人知道有一个可以监控 beanstalkd 队列的应用程序吗?我正在寻找一些可以显示管道和工作统计信息并允许您检查详细信息的东西。 我对语言/平台并不是很挑剔,只是想在编写自己的语言/平台之前知道是
使用 Microsoft.Azure.Management.Monitor 的预览包,我尝试将指标从 Azure 获取到 .NET Core 应用程序中,但我不确定要输入什么内容作为“resource
使用 Microsoft.Azure.Management.Monitor 的预览包,我尝试将指标从 Azure 获取到 .NET Core 应用程序中,但我不确定要输入什么内容作为“resource
我想知道是否有一种方法可以通过客户端应用程序连接到位于 WebLogic 服务器上的业务 Activity 监视器。我想用 BAM 语句替换 JMS 生产者/消费者客户端中的日志语句,以便使用消息进度
我的网站有一个DIV,它的高度不固定。当用户在图像上移动鼠标时,将出现此 DIV 并显示有关图像的一些信息。页面上有几个网格格式的图像,每个图像都有自己的信息。很明显,一些图像位于屏幕底部,因此通过
提醒:Arch Linux 使用 pacman 而不是 apt-get 所以我有一个想法,我希望能够离开我的房间,并且仍然可以看到我手机的下载进度。我曾寻找过已有的程序,但一无所获,所以我决定自己编写
如果连接到多个显示器,如何使用 python 制作屏幕截图? 我试过: import sys from PyQt4.QtGui import QPixmap, QApplication app = Q
我是一名优秀的程序员,十分优秀!