あなたはここに
ControlPaint.FillReversibleRectangle
MSDN
と
ControlPaint.DrawReversibleFrame
MSDN
可逆長方形/フレームをペイントするControlPaint
メソッドを使用することができます
private void DrawReversibleRectangle(int x, int y) {
// Hide the previous rectangle by calling the methods with the same parameters.
var rect = GetSelectionRectangle(this.PointToScreen(this.reversibleRectStartPoint), this.PointToScreen(this.reversibleRectEndPoint));
ControlPaint.FillReversibleRectangle(rect, Color.Black);
ControlPaint.DrawReversibleFrame(rect, Color.Black, FrameStyle.Dashed);
this.reversibleRectEndPoint = new Point(x, y);
// Draw the new rectangle by calling
rect = GetSelectionRectangle(this.PointToScreen(this.reversibleRectStartPoint), this.PointToScreen(this.reversibleRectEndPoint));
ControlPaint.FillReversibleRectangle(rect, Color.Black);
ControlPaint.DrawReversibleFrame(rect, Color.Black, FrameStyle.Dashed);
}
少し擬似コード方式の一例です
は、背景画像を見て、あなたが使用する必要があります色を決定します。彼らの反対の色が自分自身であるいくつかの色があることに注意してください。私はアイデアのためにPaint.NETのオープンソースプロジェクトを見ていきます。これはWinFormsとは関係がありません。本当の解決策はあなた自身の能力を伸ばすことです。デフォルトの方法はあなたが望むものを達成できません。 –
@Ramhound:ソリューションはWinformsで実装する必要があるため、ソリューションには何か関係があります。バックグラウンドイメージを見ても、winformsの描画関数でこの情報をAPIでどのように利用するかはわかりません。私はPaint.Netのライセンスも調べました。それは派生的な作品を作ることを許さないので、ソースコードを見て「インスピレーションを得て」いるのが良いかどうかはわかりません。 PS:それ自身のように色が逆であることについてのヒントをありがとう。私は解決策に取り組んでいる間にそれを検討します。 – alokoko