当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.NormalizeRect方法代码示例

本文整理汇总了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);
        }
开发者ID:jmcadams,项目名称:vplus,代码行数:67,代码来源:StandardSequence.cs


注:本文中的System.Drawing.Rectangle.NormalizeRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。