本文整理汇总了C#中System.Drawing.Rectangle.NormalizeRect方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.NormalizeRect方法的具体用法?C# Rectangle.NormalizeRect怎么用?C# Rectangle.NormalizeRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.NormalizeRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: pictureBoxGrid_MouseDown
private void pictureBoxGrid_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left || _sequence.ChannelCount == 0) {
return;
}
_mouseDownInGrid = true;
lblFollowMouse.Visible = true & (_executionInterface.EngineStatus(_executionContextHandle) != Utils.ExecutionRunning);
_mouseDownAtInGrid.X = (e.X / _gridColWidth) + hScrollBar1.Value;
_mouseDownAtInGrid.Y = (e.Y / _gridRowHeight) + vScrollBar1.Value;
if (_selectedCells.Width != 0) {
EraseSelectedRange();
}
if ((ModifierKeys & Keys.Control) != Keys.None) {
_selectedLineIndex = (e.Y / _gridRowHeight) + vScrollBar1.Value;
_editingChannelIndex = GetEventFromChannelNumber(_selectedLineIndex);
_currentlyEditingChannel = _sequence.Channels[_selectedLineIndex];
_lineRect.X = _mouseDownAtInGrid.X;
_lineRect.Y = _mouseDownAtInGrid.Y;
_lineRect.Width = 0;
_lineRect.Height = 0;
InvalidateRect(_lineRect);
}
else if ((ModifierKeys & Keys.Shift) != Keys.None) {
var rect = new Rectangle {
X = _selectedCells.X, Y = _selectedCells.Y,
Width = (hScrollBar1.Value + (int) Math.Floor(e.X / (float) _gridColWidth) - _selectedCells.Left) + 1,
Height = (vScrollBar1.Value + (e.Y / _gridRowHeight) - _selectedCells.Top) + 1
};
if (rect.Width < 0) {
rect.Width--;
}
if (rect.Height < 0) {
rect.Height--;
}
if (rect.Bottom > _sequence.ChannelCount) {
rect.Height = _sequence.ChannelCount - rect.Y;
}
if (rect.Right > _sequence.TotalEventPeriods) {
rect.Width = _sequence.TotalEventPeriods - rect.X;
}
_selectedCells = rect.NormalizeRect();
DrawSelectedRange();
}
else if ((e.Y / _gridRowHeight) + vScrollBar1.Value < _sequence.ChannelCount &&
(e.X / _gridColWidth) + hScrollBar1.Value < _sequence.TotalEventPeriods) {
_selectedLineIndex = (e.Y / _gridRowHeight) + vScrollBar1.Value;
_editingChannelIndex = GetEventFromChannelNumber(_selectedLineIndex);
_currentlyEditingChannel = _sequence.Channels[_selectedLineIndex];
_selectedRange.X = hScrollBar1.Value + ((int) Math.Floor(e.X / ((float) _gridColWidth)));
_selectedRange.Y = _selectedLineIndex;
_selectedRange.Width = 1;
_selectedRange.Height = 1;
_selectedCells = _selectedRange;
DrawSelectedRange();
}
else {
_currentlyEditingChannel = null;
_editingChannelIndex = -1;
_selectedLineIndex = -1;
}
UpdatePositionLabel(_selectedCells, false);
}