-

- 加为好友
- 发送私信
- 在线聊天
luluyy
- 等级:

- 可用分等级:
- 总技术专家分:
- 总技术专家分排名:
|
| 发表于:2008-08-31 18:56:4023楼 得分:0 |
#region ' - ResizeControl ( Point ) : void /// <summary> /// 变更控件大小 </summary> /// private void ResizeControl( Point aCursorLocation ) { int diffWidth; int diffHeight; Size changedSize; Point changedLocation; switch ( DraggingKind ) { // Upper case LocationKind.Upper: diffHeight = CursorBeforeLocation.Y + aCursorLocation.Y; changedSize = new Size( Control.Width, Control.Height - diffHeight ); changedLocation = new Point( Control.Location.X, Control.Location.Y + diffHeight ); ResizeControl( changedLocation, changedSize ); break; // UpperRight case LocationKind.UpperRight: diffHeight = CursorBeforeLocation.Y + aCursorLocation.Y; diffWidth = CursorBeforeLocation.X - aCursorLocation.X; changedSize = new Size( ControlBeforeSize.Width - diffWidth, Control.Height - diffHeight ); changedLocation = new Point( Control.Location.X, Control.Location.Y + diffHeight ); ResizeControl( changedLocation, changedSize ); break; // Rigth case LocationKind.Right: diffWidth = CursorBeforeLocation.X - aCursorLocation.X; changedSize = new Size( ControlBeforeSize.Width - diffWidth, ControlBeforeSize.Height ); ResizeControl( changedSize ); break; // LowerRight case LocationKind.LowerRight: diffWidth = CursorBeforeLocation.X - aCursorLocation.X; diffHeight = CursorBeforeLocation.Y - aCursorLocation.Y; changedSize = new Size( ControlBeforeSize.Width - diffWidth, ControlBeforeSize.Height - diffHeight ); ResizeControl( changedSize ); break; // lower case LocationKind.Lower: diffHeight = CursorBeforeLocation.Y - aCursorLocation.Y; changedSize = new Size( ControlBeforeSize.Width, ControlBeforeSize.Height - diffHeight ); ResizeControl( changedSize ); break; // LowerLeft case LocationKind.LowerLeft: diffHeight = CursorBeforeLocation.Y - aCursorLocation.Y; diffWidth = CursorBeforeLocation.X + aCursorLocation.X; changedSize = new Size( Control.Width - diffWidth, ControlBeforeSize.Height - diffHeight ); changedLocation = new Point( Control.Location.X + diffWidth, Control.Location.Y ); ResizeControl( changedLocation, changedSize ); break; // Left case LocationKind.Left: diffWidth = CursorBeforeLocation.X + aCursorLocation.X; changedSize = new Size( Control.Width - diffWidth, Control.Height ); changedLocation = new Point( Control.Location.X + diffWidth, Control.Location.Y ); ResizeControl( changedLocation, changedSize ); break; // UpperLeft case LocationKind.UpperLeft: diffHeight = CursorBeforeLocation.Y + aCursorLocation.Y; diffWidth = CursorBeforeLocation.X + aCursorLocation.X; changedSize = new Size( Control.Width - diffWidth, Control.Height - diffHeight ); changedLocation = new Point( Control.Location.X + diffWidth, Control.Location.Y + diffHeight ); ResizeControl( changedLocation, changedSize ); break; default: break; } Control.Refresh(); } #endregion #region ' - ResizeControl ( Size ) : void /// <summary> /// 变更控件大小 </summary> /// private void ResizeControl( Size aNewSize ) { if ( IsUnderMinimumSize( aNewSize ) ) { int width = MinimumSize.Width; int height = MinimumSize.Height; if ( MinimumSize.Width < aNewSize.Width ) { width = aNewSize.Width+37; } if ( MinimumSize.Height < aNewSize.Height ) { height = aNewSize.Height+39; } Control.Size = new Size( width, height ); } else { Control.Size = aNewSize; } } #endregion #region ' - ResizeControl ( Point, Size ) : void /// <summary> /// 变更控件大小 </summary> /// private void ResizeControl( Point aNewLocation, Size aNewSize ) { if ( IsUnderMinimumSize( aNewSize ) ) { int width = aNewSize.Width; int height = aNewSize.Height; int x = aNewLocation.X; int y = aNewLocation.Y; if ( aNewSize.Width <= MinimumSize.Width ) { width = MinimumSize.Width; if ( DraggingKind == LocationKind.UpperRight ) { x = ControlBeforeLocation.X; } else { x = Control.Left + Control.Size.Width - MinimumSize.Width; } } if ( aNewSize.Height <= MinimumSize.Height ) { if ( DraggingKind == LocationKind.LowerLeft ) { y = ControlBeforeLocation.Y; } else { y = Control.Top + Control.Size.Height - MinimumSize.Height; } height = MinimumSize.Height; } Control.SetBounds( x, y, width, height, BoundsSpecified.All ); } else { Control.SetBounds( aNewLocation.X, aNewLocation.Y, aNewSize.Width, aNewSize.Height, BoundsSpecified.All ); } } #endregion #region ' - MoveControl ( Point ) : void /// <summary> /// 移动控件 </summary> /// private void MoveControl( Point aCursorLocation ) { Control.Location = new Point( ControlBeforeLocation.X - ( CursorBeforeLocation.X - aCursorLocation.X ), ControlBeforeLocation.Y - ( CursorBeforeLocation.Y - aCursorLocation.Y ) ); ControlBeforeLocation = Control.Location; Control.Refresh(); } #endregion | | |
修改
删除
举报
引用
回复
| |