private void OnMouseDown(object sender, MouseButtonEventArgs args) { Point point = args.GetPosition(this); if (point.X > 0 && point.X - 1 < getSize( )) { int x = point.X - 1; if (!String.IsNullOrEmpty(text)) { if (x <= text.Length) cursorPosition = x; else { cursorPosition = text.Length; } CursorPosition = new Point(cursorPosition + 1, 0); } args.Handled = true; } }
private void OnMouseDown( object sender, MouseButtonEventArgs args ) { Point pos = args.GetPosition( this ); if ( horizontalScrollVisible ) { Point leftArrowPos = new Point( 0, ActualHeight - 1 ); Point rightArrowPos = new Point( ActualWidth - ( 1 + ( verticalScrollVisible ? 1 : 0 ) ), ActualHeight - 1 ); if ( leftArrowPos == pos ) { if (deltaX > 0) { deltaX--; Invalidate(); } } else if ( rightArrowPos == pos ) { // сколько места сейчас оставлено дочернему контролу int remainingWidth = ActualWidth - ( verticalScrollVisible ? 1 : 0 ); if ( deltaX < Content.RenderSize.Width - remainingWidth ) { deltaX++; Invalidate( ); } } else if ( pos.Y == ActualHeight - 1 ) { // Clicked somewhere in scrollbar Point? horizontalScrollerPos = HorizontalScrollerPos; if ( horizontalScrollerPos.HasValue ) { int remainingWidth = ActualWidth - ( verticalScrollVisible ? 1 : 0 ); int itemsPerScrollerPos = Content.RenderSize.Width/remainingWidth; if ( pos.X < horizontalScrollerPos.Value.X ) { deltaX = Math.Max( 0, deltaX - itemsPerScrollerPos ); Invalidate( ); } else if ( pos.X > horizontalScrollerPos.Value.X ) { deltaX = Math.Min(Content.RenderSize.Width - remainingWidth, deltaX + itemsPerScrollerPos); Invalidate(); } else { // Click on scroller // todo : make scroller draggable } } } } if ( verticalScrollVisible ) { Point upArrowPos = new Point( ActualWidth - 1, 0 ); Point downArrowPos = new Point( ActualWidth - 1, ActualHeight - ( 1 + ( horizontalScrollVisible ? 1 : 0 ) ) ); if ( pos == upArrowPos ) { if (deltaY > 0) { deltaY--; Invalidate(); } } else if ( pos == downArrowPos ) { // сколько места сейчас оставлено дочернему контролу int remainingHeight = ActualHeight - ( horizontalScrollVisible ? 1 : 0 ); if ( deltaY < Content.RenderSize.Height - remainingHeight ) { deltaY++; Invalidate( ); } } else if ( pos.X == ActualWidth - 1 ) { // Clicked somewhere in scrollbar Point? verticalScrollerPos = VerticalScrollerPos; if ( verticalScrollerPos.HasValue ) { int remainingHeight = ActualHeight - ( horizontalScrollVisible ? 1 : 0 ); int itemsPerScrollerPos = Content.RenderSize.Height/remainingHeight; if ( pos.Y < verticalScrollerPos.Value.Y ) { deltaY = Math.Max( 0, deltaY - itemsPerScrollerPos ); Invalidate( ); } else if ( pos.Y > verticalScrollerPos.Value.Y ) { deltaY = Math.Min(Content.RenderSize.Height - remainingHeight, deltaY + itemsPerScrollerPos); Invalidate(); } else { // Click on scroller // todo : make scroller draggable } } } } args.Handled = true; }
public void Window_OnMouseUp(object sender, MouseButtonEventArgs args) { if (closing) { Point point = args.GetPosition(this); if (point.x == 3 && point.y == 0) { getWindowsHost().CloseWindow(this); } closing = false; showClosingGlyph = false; ConsoleApplication.Instance.EndCaptureInput(this); Invalidate(); args.Handled = true; } if (moving) { moving = false; ConsoleApplication.Instance.EndCaptureInput(this); Invalidate(); args.Handled = true; } if (resizing) { resizing = false; ConsoleApplication.Instance.EndCaptureInput(this); Invalidate(); args.Handled = true; } }
public void Window_OnMouseDown(object sender, MouseButtonEventArgs args) { // перемещение можно начинать только когда окно не ресайзится и наоборот if (!moving && !resizing && !closing) { Point point = args.GetPosition(this); Point parentPoint = args.GetPosition(getWindowsHost()); if (point.y == 0 && point.x == 3) { closing = true; showClosingGlyph = true; ConsoleApplication.Instance.BeginCaptureInput(this); // closing is started, we should redraw the border Invalidate(); args.Handled = true; } else if (point.y == 0) { moving = true; movingStartPoint = parentPoint; movingStartX = RenderSlotRect.TopLeft.X; movingStartY = RenderSlotRect.TopLeft.Y; ConsoleApplication.Instance.BeginCaptureInput(this); // moving is started, we should redraw the border Invalidate(); args.Handled = true; } else if (point.x == ActualWidth - 3 && point.y == ActualHeight - 2) { resizing = true; resizingStartPoint = parentPoint; resizingStartWidth = ActualWidth; resizingStartHeight = ActualHeight; ConsoleApplication.Instance.BeginCaptureInput(this); // resizing is started, we should redraw the border Invalidate(); args.Handled = true; } } }
private void OnMouseDown( object sender, MouseButtonEventArgs args ) { int index = args.GetPosition( this ).Y; if ( !disabledItemsIndexes.Contains(index) && SelectedItemIndex != index) { SelectedItemIndex = index; Invalidate( ); } if (disabledItemsIndexes.Contains( index )) args.Handled = true; }
private void OnMouseDown( object sender, MouseButtonEventArgs args ) { Point pos = args.GetPosition( this ); if ( horizontalScrollVisible ) { if ( pos == new Point( 0, ActualHeight - 1 ) ) { // left arrow clicked if (deltaX > 0) { deltaX--; Invalidate(); } } else { if ( pos == new Point( ActualWidth - ( 1 + ( verticalScrollVisible ? 1 : 0 ) ), ActualHeight - 1 ) ) { // right arrow clicked // сколько места сейчас оставлено дочернему контролу int remainingWidth = ActualWidth - (verticalScrollVisible ? 1 : 0); if (deltaX < Content.RenderSize.Width - remainingWidth) { deltaX++; Invalidate(); } } } } if ( verticalScrollVisible ) { if ( pos == new Point( ActualWidth - 1, 0 ) ) { // up arrow clicked if (deltaY > 0) { deltaY--; Invalidate(); } } else { if ( pos == new Point( ActualWidth - 1, ActualHeight - ( 1 + ( horizontalScrollVisible ? 1 : 0 ) ) ) ) { // down arrow clicked // сколько места сейчас оставлено дочернему контролу int remainingHeight = ActualHeight - (horizontalScrollVisible ? 1 : 0); if (deltaY < Content.RenderSize.Height - remainingHeight) { deltaY++; Invalidate(); } } } } args.Handled = true; }
private void mouseDown( object sender, MouseButtonEventArgs args ) { Point pos = args.GetPosition( this ); if ( pos.y > 2 ) return; int x = 0; for ( int i = 0; i < tabDefinitions.Count; i++ ) { TabDefinition tabDefinition = tabDefinitions[ i ]; if ( pos.X > x && pos.X <= x + tabDefinition.Title.Length + 2 ) { activeTabIndex = i; Invalidate( ); break; } x += tabDefinition.Title.Length + 2 + 1; // Two spaces around + one vertical border } args.Handled = true; }