public static Point LogicalToPhysicalPixels(this Point point) { return(new Point( x: LogicalToPhysicalPixels(point.X), y: LogicalToPhysicalPixels(point.Y) )); }
/// <summary> /// Initiates a hit test on the specified <see cref="T:Windows.Foundation.Point" /> location. /// </summary> /// <param name="location">The location.</param> /// <remarks> /// The default <see cref="T:Telerik.UI.Xaml.Controls.Map.MapBehavior" /> logic returns only the top-most <see cref="T:Telerik.UI.Drawing.D2DShape" /> from the <see cref="T:Telerik.UI.Xaml.Controls.Map.MapShapeLayer" /> that matches the specific behavior requirements; you can override the default logic and return multiple <see cref="T:Telerik.UI.Drawing.D2DShape" /> instances (e.g. from layers that overlay one another) and the specific <see cref="T:Telerik.UI.Xaml.Controls.Map.MapBehavior" /> will manipulate all of them. /// </remarks> protected override IEnumerable<IMapShape> HitTest(Point location) { int layerCount = this.Map.Layers.Count; for (int i = layerCount - 1; i >= 0; i--) { var layer = this.Map.Layers[i] as MapShapeLayer; if (layer == null || !layer.IsSelectionEnabled) { continue; } var newShape = this.Map.HitTest(location, layer); if (this.selectedShapesPerLayer.ContainsKey(layer)) { var oldShape = this.selectedShapesPerLayer[layer]; // Disallow toggle selection. if (newShape == null || newShape == oldShape) { continue; } if (oldShape != null) { this.shapesToRemove.Add(oldShape); } } this.selectedShapesPerLayer[layer] = newShape; yield return newShape; } }
private void HandleHeader(Point totalScrollPosition) { if (Header == null && HeaderTemplate == null) { return; } var headerHeight = HeaderMeasureHeight + totalScrollPosition.Y; if (headerHeight > 0) { if (totalScrollPosition.Y < 0) { HeaderHeight = new GridLength(HeaderMeasureHeight + totalScrollPosition.Y); _header.Margin = new Thickness(0, totalScrollPosition.Y, 0, 0); _header.Clip = new RectangleGeometry() { Rect = new Rect(0, -totalScrollPosition.Y, this.ActualWidth, HeaderMeasureHeight) }; } else { if (HeaderHeight != GridLength.Auto) { HeaderHeight = new GridLength(HeaderMeasureHeight); _header.Margin = new Thickness(0); _header.Clip = null; } } } else if (HasHeader()) { HeaderHeight = new GridLength(0); _header.Margin = new Thickness(0, -HeaderMeasureHeight, 0, 0); _header.Clip = new RectangleGeometry() { Rect = new Rect(0, HeaderMeasureHeight, this.ActualWidth, HeaderMeasureHeight) }; } }
/// <summary> /// Sets mouse down point. /// </summary> /// <param name="position"> /// The position. /// </param> private void SetMouseDownPoint(Point position) { this.MouseDownPoint = position.ToVector2(); if (!this.Controller.Viewport.FixedRotationPointEnabled && this.Controller.Viewport.FindHitsInFrustum(this.MouseDownPoint, ref hits)) { if (hits.Count > 0) { MouseDownNearestPoint3D = hits[0].PointHit; if (hits[0].ModelHit is Element3D ele) { MouseDownNearestModelBoundCenter = ele.BoundsWithTransform.Center; } else if (hits[0].ModelHit is Model.Scene.SceneNode node) { MouseDownNearestModelBoundCenter = node.BoundsWithTransform.Center; } } } else { MouseDownNearestModelBoundCenter = null; MouseDownNearestPoint3D = null; } this.MouseDownPoint3D = this.UnProject(position); }
private void tlMainTabs_TabPointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { TabViewModel tvm = null; if (sender is FrameworkElement) { var fe = (FrameworkElement)sender; if (fe.DataContext is TabViewModel) tvm = (TabViewModel)fe.DataContext; else return; var visual = fe.TransformToVisual(layoutRoot); var point1 = visual.TransformPoint(new Point(0, 40)); var point2 = new Point(point1.X + fe.ActualWidth + 180, point1.Y + fe.ActualHeight + 140); //hide all the current tabs in the canvas _spriteBatch.Elements.ToList().ForEach(delegate (IVisualTreeElement element) { element.IsVisible = false; }); //now delete all the relevant elements in the spritebatch _spriteBatch.DeleteAll(); //create the new thumbnail sprite for current button _spriteBatch.Add(new TabThumbnailSprite() { Layout = new Rect(point1, point2), ID = const_TabPreview, TextureBackgroundUri = tvm.ThumbUri, IsVisible = true }); _spriteBatch.IsVisible = true; } CanvasInvalidate(); }
private async void pinButton_Click(object sender, RoutedEventArgs e) { if (this.flipView.SelectedItem != null) { ApressBook selectedBook = (ApressBook)this.flipView.SelectedItem; this.BottomAppBar.IsSticky = true; string uniqueTileID = selectedBook.ApressBookISBN; string shortTileName = selectedBook.ApressBookName; string displayTileName = selectedBook.ApressBookTechnology; string tileActivationArguments = uniqueTileID; Uri logo = new Uri("ms-appx://" + selectedBook.ApressBookImageURI); SecondaryTile secondaryTile = new SecondaryTile(uniqueTileID, shortTileName, displayTileName, tileActivationArguments, TileOptions.ShowNameOnLogo, logo); secondaryTile.ForegroundText = ForegroundText.Light; secondaryTile.SmallLogo = new Uri("ms-appx:///Assets/SmallLogo.png"); FrameworkElement pinToStartButton = (FrameworkElement)pinButton; Windows.UI.Xaml.Media.GeneralTransform buttonTransform = pinToStartButton.TransformToVisual(null); Windows.Foundation.Point point = buttonTransform.TransformPoint(new Point()); Windows.Foundation.Rect rect = new Rect(point, new Size(pinToStartButton.ActualWidth, pinToStartButton.ActualHeight)); bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above); this.BottomAppBar.IsSticky = false; } }
public static Hyperlink GetHyperlinkFromPoint(this RichTextBlock text, Point point) { var position = text.GetPositionFromPoint(point); var hyperlink = GetHyperlink(position.Parent as TextElement); return(hyperlink); }
/// <summary> /// Finds the nearest point and its normal. /// </summary> /// <param name="viewport"> /// The viewport. /// </param> /// <param name="position"> /// The position. /// </param> /// <param name="point"> /// The point. /// </param> /// <param name="normal"> /// The normal. /// </param> /// <param name="model"> /// The model. /// </param> /// <returns> /// The find nearest. /// </returns> public static bool FindNearest(this Viewport3DX viewport, Point position, out Vector3 point, out Vector3 normal, out Element3D model) { point = new Vector3(); normal = new Vector3(); model = null; var camera = viewport.Camera as ProjectionCamera; if (camera == null) { return(false); } var hits = FindHits(viewport, position); if (hits.Count > 0) { point = hits[0].PointHit; normal = hits[0].NormalAtHit; model = hits[0].ModelHit as Element3D; return(true); } else { // check for nearest points in the scene // TODO!! return(false); } }
public TapScaleEffect() { Element = null; Origin = new Point(0, 0); X = 0; Y = 0; }
public static (bool Result, List <Windows.UI.Xaml.Shapes.Line> Lines) Detect(Rect[] Persons) { var res = false; var Lines = new List <Windows.UI.Xaml.Shapes.Line>(); foreach (var person1 in Persons) { var p1 = new Point(person1.X + (person1.Width / 2), person1.Y + (person1.Height / 2)); foreach (var person2 in Persons) { if (person1 == person2) { continue; } var p2 = new Point(person2.X + (person2.Width / 2), person2.Y + (person2.Height / 2)); var dist = DistanceHelpers.Euclidean(p1, p2) * aPixelInCm; if (dist < LimitDistance) { res = true; Lines.Add(new Windows.UI.Xaml.Shapes.Line() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y }); } } } return(res, Lines); }
public static SharpDX.Vector2 ToSharpDX( this Windows.Foundation.Point point) { return(new Vector2( (float)point.X, (float)point.Y)); }
public static winFound.Rect Transform(this Matrix3x2 matrix, winFound.Rect rect) { winFound.Point point1 = matrix.Transform(new winFound.Point(rect.Left, rect.Top)); winFound.Point point2 = matrix.Transform(new winFound.Point(rect.Right, rect.Bottom)); return(new winFound.Rect(point1, point2)); }
/// <summary> /// Return whether the gaze point is over the progress bar. /// </summary> /// <param name="gazePoint">The gaze point screen location</param> /// <param name="elementName">The progress bar name</param> /// <param name="uiElement">The progress bar UI element</param> /// <returns></returns> private bool DoesElementContainPoint( Windows.Foundation.Point gazePoint, string elementName, UIElement uiElement) { // Use entire visual tree of progress bar. IEnumerable <UIElement> elementStack = VisualTreeHelper.FindElementsInHostCoordinates(gazePoint, uiElement, true); foreach (UIElement item in elementStack) { //Cast to FrameworkElement and get element name. if (item is FrameworkElement feItem) { if (feItem.Name.Equals(elementName)) { if (!timerStarted) { // Start gaze timer if gaze over element. timerGaze.Start(); timerStarted = true; } return(true); } } } // Stop gaze timer and reset progress bar if gaze leaves element. timerGaze.Stop(); GazeRadialProgressBar.Value = 0; timerStarted = false; return(false); }
private void panelcanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { // Get information about the pointer location. PointerPoint pt = e.GetCurrentPoint(PanelCanvas); _previousContactPt = pt.Position; // Accept input only from a pen or mouse with the left button pressed. PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType; if (pointerDevType == PointerDeviceType.Pen || pointerDevType == PointerDeviceType.Mouse && pt.Properties.IsLeftButtonPressed) { // Pass the pointer information to the InkManager. _inkManager.ProcessPointerDown(pt); _penID = pt.PointerId; e.Handled = true; } else if (pointerDevType == PointerDeviceType.Touch) { // Process touch input _inkManager.ProcessPointerDown(pt); _penID = pt.PointerId; e.Handled = true; } }
/// <summary> /// Transforms the specified point. /// </summary> /// <param name="point">The point</param> /// <param name="centerX">The center point X</param> /// <param name="centerY">The center point Y</param> /// <param name="offsetX">The offset point X</param> /// <param name="offsetY">The offset point Y</param> /// <param name="rotationAngle">The rotation angle</param> /// <returns>The transformed point</returns> internal static Windows.Foundation.Point Transform(Windows.Foundation.Point point, double centerX, double centerY, double offsetX, double offsetY, double rotationAngle) { MatrixMock mock = new MatrixMock(); mock.RotateAt(rotationAngle, offsetX + centerX, offsetY + centerY); return(mock.Transform(point)); }
public Mouse3DEventArgs(HitTestResult hitTestResult, Point position, Viewport3DX viewport = null, PointerRoutedEventArgs originalInputEventArgs = null) { this.HitTestResult = hitTestResult; this.Position = position; this.Viewport = viewport; this.OriginalInputEventArgs = originalInputEventArgs; }
private async void Button_Tapped(object sender, TappedRoutedEventArgs e) { if (((Button)sender).DataContext != null && ((Button)sender).DataContext is Feature.DataModel.SampleItem) { Feature.DataModel.SampleItem sampleItem = ((Button)sender).DataContext as Feature.DataModel.SampleItem; this.currentSampleItem = sampleItem; if (sampleItem.Option.Contains("选座")) { this.clearSelect(); this.StoryexpansionSeat.Begin(); } else { var appointment = new Windows.ApplicationModel.Appointments.Appointment(); appointment.Subject = this.sampleItem.Title; appointment.StartTime = new DateTimeOffset(DateTime.Now.AddSeconds(1)); appointment.Duration = TimeSpan.FromSeconds(1); appointment.Location = "beijing"; Windows.UI.Xaml.Media.GeneralTransform buttonTransform = (sender as FrameworkElement).TransformToVisual(null); Windows.Foundation.Point point = buttonTransform.TransformPoint(new Windows.Foundation.Point()); var rect = new Windows.Foundation.Rect(point, new Windows.Foundation.Size((sender as FrameworkElement).ActualWidth, (sender as FrameworkElement).ActualHeight)); await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Windows.UI.Popups.Placement.Default); } } }
private void flickrPictureDetails_ChangeViewState(object sender, PointerRoutedEventArgs e) { switch ((string)sender) { case "Minimized": sbHidePictureDetails.Begin(); break; case "Normal": sbShowPictureDetails.Begin(); break; case "Maximized": break; case "StartExpandUserStreamTitle": _actionToDo = "ExpandUserStreamTitle"; _drawLine = true; _lineStartPoint = e.GetCurrentPoint(null).Position; drawLine(_lineStartPoint, _lineStartPoint); break; case "RequestShowComments": _fvm.GetPhotoComments(_fvm.SelectedPhoto); break; } }
public static Rect GetElementRect(FrameworkElement element) { GeneralTransform buttonTransform = element.TransformToVisual(null); Windows.Foundation.Point point = buttonTransform.TransformPoint(new Windows.Foundation.Point()); return(new Rect(point, new Size(element.ActualWidth, element.ActualHeight))); }
/// <summary> /// Occurs when the position is changed during a manipulation. /// </summary> /// <param name="e">The <see cref="Point"/> instance containing the event data.</param> public override void Delta(Point e) { var delta = e.ToVector2() - this.LastPoint.ToVector2(); this.LastPoint = e; this.Zoom(delta.Y * 0.01, this.zoomPoint3D); }
public void Draw() { RedlineCanvas.Children.Clear(); _redlineCount = new int[4]; GeneralTransform t = _control.TransformToVisual(LayoutRoot); _controlPos = t.TransformPoint(new Windows.Foundation.Point(0, 0)); Debug.WriteLine(_control.Name); // Draw bounding rectangle Rectangle rc = new Rectangle(); rc.Width = _control.ActualWidth; rc.Height = _control.ActualHeight; rc.Stroke = new SolidColorBrush(Windows.UI.Color.FromArgb(150, 100, 150, 200)); rc.StrokeThickness = 1; rc.StrokeDashArray = new DoubleCollection() { 3 }; Canvas.SetLeft(rc, _controlPos.X); Canvas.SetTop(rc, _controlPos.Y); RedlineCanvas.Children.Add(rc); Draw(LayoutRoot, _control, RedlineCanvas, 0); }
private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { if ((_previousPosition == default(Point)) || double.IsNaN(_previousPosition.X)) { _previousPosition = e.Position; return; } // The problem: When you are pinch zooming and you are lifting your hand // it is very likely that one finger will leave before the other. The moment after // the first finger leaves the center of the pinch suddenly jumps to the position // of the last touching finger. Causing a sudden change of the map center. // The solution: This hacked up workaround below. When the distance is high // but the velocity is low, do not move the map. if ((Distance(e.Position.X, e.Position.Y, _previousPosition.X, _previousPosition.Y) > 50) && (Math.Sqrt(Math.Pow(e.Velocities.Linear.X, 2.0) + Math.Pow(e.Velocities.Linear.Y, 2.0)) < 1)) { _previousPosition = default(Point); return; } Map.Viewport.Transform(e.Position.X, e.Position.Y, _previousPosition.X, _previousPosition.Y, e.Delta.Scale); _previousPosition = e.Position; _invalid = true; OnViewChanged(true); }
public static void ScrollItem(ListViewBase control, int indexDelta) { if (control == null || control.Items == null) return; var scrollViewer = VisualTreeUtilities.GetVisualChild<ScrollViewer>(control); var p = new Point(Window.Current.Bounds.Width/2, 10); var transform = control.TransformToVisual(Window.Current.Content); var checkPoint = transform.TransformPoint(p); var q = from lvi in VisualTreeHelper.FindElementsInHostCoordinates(checkPoint, scrollViewer).OfType<ListViewItem>() where lvi.Content != null select lvi.Content; var item = q.FirstOrDefault(); if (item == null) return; var index = control.Items.IndexOf(item); var nextItemIndex = index + indexDelta; if (index != -1 && nextItemIndex >= 0 && nextItemIndex < control.Items.Count) { var nextItem = control.Items[nextItemIndex]; control.ScrollIntoView(nextItem, ScrollIntoViewAlignment.Leading); } }
public static SharpDX.DrawingPointF ToSharpDX( this Windows.Foundation.Point point) { return(new DrawingPointF( (float)point.X, (float)point.Y)); }
// Used to get current mallet and target positions public static Point GetCoordinatesFromOffset(Point offset) { double x = GetCoordinateXFromOffsetY((long)offset.Y); double y = GetCoordinateYFromOffsetX((long)offset.X); return new Point(x, y); }
private void updateProgressAndNullVisualization() { IResult resultModel = ((OperationViewModel)DataContext).OperationModel.Result; // progress double size = 14; double thickness = 2; double progress = resultModel?.Progress ?? 0; tbPercentage1.Text = (progress * 100).ToString("F1") + "%"; double percentage = Math.Min(progress, 0.999999); if (percentage > 0.5) { arcSegement1.IsLargeArc = true; } else { arcSegement1.IsLargeArc = false; } double angle = 2 * Math.PI * percentage - Math.PI / 2.0; double x = size / 2.0; double y = size / 2.0; Windows.Foundation.Point p = new Windows.Foundation.Point(Math.Cos(angle) * (size / 2.0 - thickness / 2.0) + x, Math.Sin(angle) * (size / 2.0 - thickness / 2.0) + y); arcSegement1.Point = p; if ((size / 2.0 - thickness / 2.0) > 0.0) { arcSegement1.Size = new Size((size / 2.0 - thickness / 2.0), (size / 2.0 - thickness / 2.0)); } }
private void flickrPictureToolbar_ChangeViewState(object sender, PointerRoutedEventArgs e) { switch ((string)sender) { case "StartExpandToolbar": _actionToDo = "ExpandPictureToolbar"; flickrPictureToolbar.SetValue(Canvas.ZIndexProperty, 10); _drawLine = true; _lineStartPoint = e.GetCurrentPoint(null).Position; drawLine(_lineStartPoint, _lineStartPoint); break; case "AddFavourite": MessageBox("Continue to Favourite this Photo?", "Yes", "YesFavourite", "HomeView", "No", "NoFavourite", "HomeView", imageIcon: _fvm.SelectedPhoto.SmallUrl); break; case "SendPicture": break; case "CreateBillboard": break; case "RetrieveExif": _fvm.GetPhotoExif(_fvm.SelectedPhoto); break; case "AddNote": break; } }
/// <inheritdoc /> public override void SendEvent(NSEvent evt) { try { // The effective location in top/left coordinates. var posInWindow = new Point(evt.LocationInWindow.X, VisibleFrame.Height - evt.LocationInWindow.Y); if (posInWindow.Y < 0) { // We are in the titlebar, let send the event to native code ... so close button will continue to work base.SendEvent(evt); return; } switch (evt.Type) { case NSEventType.MouseEntered: CoreWindowEvents?.RaisePointerEntered(ToPointerArgs(evt, posInWindow)); break; case NSEventType.MouseExited: CoreWindowEvents?.RaisePointerExited(ToPointerArgs(evt, posInWindow)); break; case NSEventType.LeftMouseDown: case NSEventType.OtherMouseDown: case NSEventType.RightMouseDown: CoreWindowEvents?.RaisePointerPressed(ToPointerArgs(evt, posInWindow)); break; case NSEventType.LeftMouseUp: case NSEventType.OtherMouseUp: case NSEventType.RightMouseUp: CoreWindowEvents?.RaisePointerReleased(ToPointerArgs(evt, posInWindow)); break; case NSEventType.MouseMoved: case NSEventType.LeftMouseDragged: case NSEventType.OtherMouseDragged: case NSEventType.RightMouseDragged: case NSEventType.TabletPoint: case NSEventType.TabletProximity: case NSEventType.DirectTouch: CoreWindowEvents?.RaisePointerMoved(ToPointerArgs(evt, posInWindow)); break; case NSEventType.ScrollWheel: CoreWindowEvents?.RaisePointerWheelChanged(ToPointerArgs(evt, posInWindow)); break; default: base.SendEvent(evt); break; } } catch (Exception e) { Application.Current?.RaiseRecoverableUnhandledException(e); } }
public Windows.Foundation.Point Transform(Windows.Foundation.Point point) { double x = point.X; double y = point.Y; this.MultiplyPoint(ref x, ref y); return(new Windows.Foundation.Point(x, y)); }
private static PointerEventArgs ToPointerArgs(NSEvent nativeEvent, Point posInWindow) { var point = GetPointerPoint(nativeEvent, posInWindow); var modifiers = GetVirtualKeyModifiers(nativeEvent); var args = new PointerEventArgs(point, modifiers); return(args); }
public AFactory(List<GeometryFactory> Data, Activation Attach, Activation Detach, ManipulationDeltaEventHandler Router , Point DefaultLocation) { this.Attach = Attach; this.Detach = Detach; this.Router = Router; this.Data = Data; this.DefaultLocation = DefaultLocation; }
public override void StartSelection(Windows.Foundation.Point point) { GeneralTransform gt = MainViewController.Instance.InkableScene.TransformToVisual(dxSurface); _selectionPoints = new List <Windows.Foundation.Point> { gt.TransformPoint(point) }; }
/// <summary> /// Projects the specified 3D point to a 2D screen point. /// </summary> /// <param name="viewport">The viewport.</param> /// <param name="point">The 3D point.</param> /// <returns>The point.</returns> public static Point Project(this Viewport3DX viewport, Vector3 point) { var matrix = GetScreenViewProjectionMatrix(viewport); var pointTransformed = Vector3.Transform(point, matrix); var pt = new Point((int)pointTransformed.X, (int)pointTransformed.Y); return(pt); }
public CirclePercentage() { InitializeComponent(); StartPoint = new Point(Radius + StrokeThickness/2, StrokeThickness/2); EndPoint = StartPoint; Size = new Size(Radius, Radius); TotalSize = 2*Radius + StrokeThickness; }
/// <summary> /// Occurs when the manipulation is started. /// </summary> /// <param name="e"> /// The <see cref="Point"/> instance containing the event data. /// </param> public virtual void Started(Point e) { this.SetMouseDownPoint(e); this.LastPoint = this.MouseDownPoint; this.LastPoint3D = this.MouseDownPoint3D; //this.ManipulationWatch.Restart(); startTick = Stopwatch.GetTimestamp(); }
/// <summary> /// Sets mouse down point. /// </summary> /// <param name="position"> /// The position. /// </param> private void SetMouseDownPoint(Point position) { this.MouseDownPoint = position.ToVector2(); if (!this.Controller.Viewport.FixedRotationPointEnabled && this.Controller.Viewport.FindNearest(position, out var nearestPoint, out var normal, out var visual)) { this.MouseDownNearestPoint3D = nearestPoint; }
/// <summary> /// Occurs when the manipulation is started. /// </summary> /// <param name="e"> /// The <see cref="Point"/> instance containing the event data. /// </param> public virtual void Started(Point e) { this.SetMouseDownPoint(e); this.LastPoint = this.MouseDownPoint; this.LastPoint3D = this.MouseDownPoint3D; //this.ManipulationWatch.Restart(); startTick = Stopwatch.GetTimestamp(); inv = Camera.CreateLeftHandSystem ? -1 : 1; }
public Point GetCoordinates() { var visualRoot = WiniumVirtualRoot.Current.VisualRoot.Element; var element = this.Element; var point = element.TransformToVisual(visualRoot).TransformPoint(new Point(0, 0)); var center = new Point(point.X + (int)(element.ActualWidth / 2), point.Y + (int)(element.ActualHeight / 2)); return ScreenCoordinatesHelper.LogicalPointToScreenPoint(center); }
private void MouseMove(object sender, PointerRoutedEventArgs e) { if (_lastPt != null) { WF.Point pt = e.GetCurrentPoint(null).Position; Element.UpdateGrid(pt.X - _lastPt.Value.X, pt.Y - _lastPt.Value.Y); _lastPt = pt; } }
protected override Windows.Foundation.Point GetMenuPosition(RadRadialMenu menu) { //get the left top point of the target element var targetPosition = this.Owner.TransformToVisual(null).TransformPoint(new Point(this.Owner.ActualWidth, 0)); //calulate the desired menu position var position = new Point(targetPosition.X - menu.ActualWidth + this.Owner.ActualWidth / 2, targetPosition.Y + this.Owner.ActualHeight / 2 - menu.ActualHeight / 2); return position; }
private void ImageOnManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e) { var image = (Image)sender; image.Opacity = 0.4; var transform = (CompositeTransform)image.RenderTransform; startTranslation = new Point(transform.TranslateX, transform.TranslateY); startRotation = transform.Rotation; startScale = transform.ScaleX; }
public static bool Intersects(this Rect r, Point[] polyline) { for (var i = 1; i < polyline.Length; i++) { var pt1 = polyline[i]; var pt2 = polyline[i - 1]; if (VectorMath.Intersects(pt1, pt2, r)) return true; } return false; }
private void UpdateDisplayPoints(Point position, MapPoint location) { txtScreenCoords.Text = string.Format("Screen Coords: {0:0}, {1:0}", position.X, position.Y); if (location != null) { MapPoint mapPoint = location; if (MyMapView.WrapAround) mapPoint = GeometryEngine.NormalizeCentralMeridian(mapPoint) as MapPoint; txtMapCoords.Text = string.Format("Map Coords: {0:0.000}, {1:0.000}", mapPoint.X, mapPoint.Y); } }
private void ComputeEndPoint() { if (Percentage == 100) Percentage = 99.9; double angle = Percentage*2*PI/100; IsLargeArc = angle > PI; double endX = Radius*(1 + Sin(angle)) + StrokeThickness/2; double endY = Radius*(1 - Cos(angle)) + StrokeThickness/2; EndPoint = new Point(endX, endY); }
internal Rect GetRect() { var visualRoot = WiniumVirtualRoot.Current.VisualRoot.Element; var element = this.Element; var point1 = element.TransformToVisual(visualRoot).TransformPoint(new Point(0, 0)); var point2 = new Point(point1.X + element.ActualWidth, point1.Y + element.ActualHeight); var scrPoint1 = ScreenCoordinatesHelper.LogicalPointToScreenPoint(point1); var scrPoint2 = ScreenCoordinatesHelper.LogicalPointToScreenPoint(point2); return new Rect(scrPoint1, scrPoint2); }
/// <summary> /// Converts a chart values pair to pixels /// </summary> /// <param name="chart">Target chart</param> /// <param name="chartPoint">point in screen</param> /// <param name="axisX">axis x index</param> /// <param name="axisY">axis y index</param> /// <returns></returns> public static Point ConvertToPixels(this Chart chart, Point chartPoint, int axisX = 0, int axisY = 0) { if (chart.Model == null || chart.AxisX.Any(x => x.Model == null)) return new Point(); var uw = new CorePoint( chart.AxisX[axisX].Model.EvaluatesUnitWidth ? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart.Model, axisX) / 2 : 0, chart.AxisY[axisY].Model.EvaluatesUnitWidth ? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart.Model, axisY) / 2 : 0); return new Point( ChartFunctions.ToPlotArea(chartPoint.X, AxisOrientation.X, chart.Model, axisX) + uw.X, ChartFunctions.ToPlotArea(chartPoint.Y, AxisOrientation.Y, chart.Model, axisY) + uw.Y); }
public Point GetCoordinatesInView() { // TODO reasearch posibility to replace this code to GetClickablePoint() var visualRoot = WiniumVirtualRoot.Current.VisualRoot.Element; var element = this.Element; var point = element.TransformToVisual(visualRoot).TransformPoint(new Point(0, 0)); var center = new Point(point.X + (int)(element.ActualWidth / 2), point.Y + (int)(element.ActualHeight / 2)); var bounds = new Rect(point, new Size(element.ActualWidth, element.ActualHeight)); var boundsInView = new Rect(new Point(0, 0), visualRoot.RenderSize); boundsInView.Intersect(bounds); var result = boundsInView.IsEmpty ? center : new Point( boundsInView.X + (int)(boundsInView.Width / 2), boundsInView.Y + (int)(boundsInView.Height / 2)); return ScreenCoordinatesHelper.LogicalPointToScreenPoint(result); }
public bool Crash(Board Board, Point newHeadPosition) { if (Positions.Exists(point => point.X == newHeadPosition.X && point.Y == newHeadPosition.Y)) { var tailPosition = Positions.Last(); if (tailPosition.X == newHeadPosition.X && tailPosition.Y == newHeadPosition.Y) { if (!Board.DidEat(newHeadPosition)) { return false; } } return true; } return false; }
private void AdjustFavouriteList() { var listHeight = 200; var currentPoint = FavouriteLocationPopup.TransformToVisual(Window.Current.Content).TransformPoint(new Point(0, 0)); var anchorPoint = Location.TransformToVisual(Window.Current.Content).TransformPoint(new Windows.Foundation.Point(0, 0)); var availableSpace = Window.Current.Bounds.Height - anchorPoint.Y - Location.ActualHeight; var newLocation = new Point(currentPoint.X, 0); if (availableSpace > listHeight) { newLocation.Y = anchorPoint.Y + Location.ActualHeight; // show below } else { newLocation.Y = anchorPoint.Y - listHeight; // show above } var transform = (FavouriteLocationPopup.RenderTransform as CompositeTransform) ?? (FavouriteLocationPopup.RenderTransform = new CompositeTransform()) as CompositeTransform; transform.TranslateY += newLocation.Y - currentPoint.Y; }
/* * This is where the magic happens! * * We need to do two things: * * 1. Make sure that the center of the perspective transform and image transform are * the same. To do this, we manually set the center of the image transform to * the center of ParallaxRoot, which is the center of the perspective transform by default. * * 2. Scale up the element to compensate for the perspective effect. This will make the * transformed element appear like the source asset even though it is "further away" from the * viewer than the foreground. The formula for this is: * * scaleFactor = -translateZ / perspectiveDepth + 1.0 * */ private void NormalizeParallax(UIElement target) { var transform = target.Transform3D as CompositeTransform3D; if (transform != null) { var transformToVisual = ParallaxRoot.TransformToVisual(target); var center = new Point(ParallaxRoot.ActualWidth / 2.0, RootGrid.ActualHeight / 2.0); // Center of ParallaxRoot in the coordinates of target. var transformedCenter = transformToVisual.TransformPoint(center); transform.CenterX = transformedCenter.X; // TransformToVisual doesn't account for ScrollViewer offset transform.CenterY = transformedCenter.Y - ParallaxRoot.VerticalOffset; // This could be done statically in markup but it's easier to show here. transform.ScaleX = transform.ScaleY = -transform.TranslateZ / PerspectiveTransform.Depth + 1.0; } }
private void DrawCanvas_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e) { this.points = new List<Windows.Foundation.Point>(); this.anchorPoint = e.Position; this.points.Add( new Windows.Foundation.Point( e.Position.X / DrawCanvas.ActualWidth, e.Position.Y / DrawCanvas.ActualHeight)); }
private void DrawCanvas_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { Line line = new Line(); line.Stroke = new SolidColorBrush(Colors.Blue); line.StrokeThickness = 5; line.X1 = this.anchorPoint.X; line.Y1 = this.anchorPoint.Y; line.X2 = e.Position.X; line.Y2 = e.Position.Y; if (!e.IsInertial) { DrawCanvas.Children.Add(line); this.anchorPoint = e.Position; this.points.Add( new Windows.Foundation.Point( e.Position.X / DrawCanvas.ActualWidth, e.Position.Y / DrawCanvas.ActualHeight)); if (points.Count > 25) { var newPoints = this.points.ToList(); client.SendDraw(newPoints); this.points = new List<Windows.Foundation.Point>(); // We need to add current point back to avoid gaps this.points.Add( new Windows.Foundation.Point( e.Position.X / DrawCanvas.ActualWidth, e.Position.Y / DrawCanvas.ActualHeight)); } } }
private void UpdateGraph() { Points.Clear(); var w = GraphWidth / TimeSeriesModel.Values.Count; var h = GraphHeight; var ts = TimeSeriesModel.GetNormalized(); for (var i = 0; i < ts.Values.Count; ++i) { var p = new Point((i) * w, (1 - ts.Values[i]) * h); Points.Add(p); } /* for (int i = 1; i < ts.Values.Count; ++i) { var p0 = new Point((i - 1) * w, (1 - ts.Values[i - 1]) * h); var p1 = new Point(i * w, (1 - ts.Values[i]) * h); Points.Add(p0); Points.Add(p1); } */ var trend = MathUtil.ApproximateLine(ts.Values); TrendX1 = 0; TrendY1 = (1 - trend.GetY(0)) * h; TrendX2 = (ts.Values.Count - 1) * w; TrendY2 = (1 - trend.GetY(ts.Values.Count - 1)) * h; TrendColor = new SolidColorBrush(GetTrendColor(trend.B)); }
Ellipse MakeEllipseForJoint( JointType jointType, TrackingState trackingState, Brush brush, Point position2d) { int width = jointType == JointType.Head ? HEAD_WIDTH : REGULAR_WIDTH; Ellipse ellipse = new Ellipse() { Width = width, Height = width, Fill = trackingState == TrackingState.Inferred ? InferredBrush : brush }; Canvas.SetLeft(ellipse, position2d.X - (width / 2)); Canvas.SetTop(ellipse, position2d.Y - (width / 2)); return (ellipse); }
public void BeginFocus(Point? focusPoint) { EnqueueWorkflow(new FocusWorkflow(this.callback, this.cameraController, focusPoint)); }
Point MapPointToCanvasSpace(CameraSpacePoint point) { ColorSpacePoint colorSpacePoint = this.coordinateMapper.MapCameraPointToColorSpace(point); Point mappedPoint = new Point( colorSpacePoint.X / this.colorFrameDescription.Width * this.canvas.ActualWidth, colorSpacePoint.Y / this.colorFrameDescription.Height * this.canvas.ActualHeight); return (mappedPoint); }
private void ManipStarted(object sender, ManipulationStartedRoutedEventArgs e) { _initialPoint = e.Position; _manipulating = true; }
public static Vector RelativeTo(this Point point, Point centre) { return new Vector(point.X - centre.X, point.Y - centre.Y); }
public static Point Transform(this GeneralTransform transform, Point point) { return transform.TransformPoint(point); }
void HandleMouseDown(sw.Point pt) { DestroyPickSpring(); _posMouseMoveStart = this.Position; _ptMouseDown = TransformFromCanvas(this, pt); if (MousePickEnabled && BodyObject == null) { // "scenery" type element _draggingNonPhysicsSprite = true; if (MousePickStarted != null) MousePickStarted(this, this.Position); return; } if (MousePickEnabled && BodyObject.IsStatic && AllowStaticObjectManipulation && BodyObject.Enabled) { // save the static attributes _originalAngularDamping = BodyObject.AngularDamping; BodyObject.AngularDamping = float.MaxValue; _bodyWasStatic = true; BodyObject.IsStatic = false; } if (MousePickEnabled && BodyObject.IsStatic == false && BodyObject.Enabled) { CreatePickSpring(pt); if (MousePickStarted != null) MousePickStarted(this, this.Position); } }