當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。