private void UpdateEyeData(string eyeName, GazeHidPosition eyePosition, Windows.UI.Xaml.Shapes.Ellipse eyeEllipse, StringBuilder sb) { sb.Append($"{eyeName,7}EyePos ("); if (eyePosition != null) { sb.Append($"{(eyePosition.X / 1000.0),6:F1}mm, {(eyePosition.Y / 1000.0),6:F1}mm, {(eyePosition.Z / 1000.0),6:F1}mm)"); if (eyePosition.X >= 0 && eyePosition.X <= screenSizeMicrometersWidth && eyePosition.Y >= 0 && eyePosition.Y <= screenSizeMicrometersHeight) { var newX = MapRange(0, screenSizeMicrometersWidth, 0, ActualWidth, eyePosition.X); var newY = MapRange(0, screenSizeMicrometersHeight, 0, ActualHeight, eyePosition.Y); var newZ = string.Empty; if (eyePosition.Z < 400000) { newZ = "Red"; eyeEllipse.Fill = new SolidColorBrush(Colors.Red); } else if (eyePosition.Z < 500000) { newZ = "Yellow"; eyeEllipse.Fill = new SolidColorBrush(Colors.Yellow); } else if (eyePosition.Z < 700000) { newZ = "Green"; eyeEllipse.Fill = new SolidColorBrush(Colors.Green); } else if (eyePosition.Z < 800000) { newZ = "Yellow"; eyeEllipse.Fill = new SolidColorBrush(Colors.Yellow); } else { newZ = "Red"; eyeEllipse.Fill = new SolidColorBrush(Colors.Red); } sb.Append($" ({newX,6:F0}, {newY,6:F0}, {newZ}"); Canvas.SetLeft(eyeEllipse, newX); Canvas.SetTop(eyeEllipse, newY); eyeEllipse.Visibility = Visibility.Visible; } else { eyeEllipse.Visibility = Visibility.Collapsed; } } else { eyeEllipse.Visibility = Visibility.Collapsed; } sb.AppendLine(")"); }
public void DrawPoint(int row, int col, bool black) { var deltax = Convert.ToDouble(chessboard_background.ActualWidth) / 16; var deltay = Convert.ToDouble(chessboard_background.ActualHeight) / 16; Windows.UI.Xaml.Shapes.Ellipse circle; circle = new Windows.UI.Xaml.Shapes.Ellipse() { Height = 0.75 * deltay, Width = 0.75 * deltax }; double left = (row - 7) * 2 * deltax; double top = (col - 7) * 2 * deltay; circle.Margin = new Thickness(left, top, 0, 0); if (black == true) { circle.Fill = new SolidColorBrush(Colors.Black); } else { circle.Fill = new SolidColorBrush(Colors.White); } chessboard_father.Children.Add(circle); chessboard_point.Add(new Chessboard_point_class(circle, row, col)); }
private void Splarkle(Windows.UI.Input.PointerPoint point) { var x = point.Position.X; var y = point.Position.Y; var s = .5d; var dot = new Windows.UI.Xaml.Shapes.Ellipse { Height = 10, Width = 10, Opacity = 1, VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left, Fill = new SolidColorBrush(GetRandColor()), RenderTransform = new CompositeTransform { TranslateX = x, TranslateY = y, ScaleX = s, ScaleY = s, }, }; LayoutRoot.Children.Add(dot); var d = TimeSpan.FromMilliseconds(_Random.Next(300, 1200)); x += _Random.Next(-100, 100); var atx = new DoubleAnimation { To = x, Duration = d }; Storyboard.SetTarget(atx, dot.RenderTransform); Storyboard.SetTargetProperty(atx, "TranslateX"); y += _Random.Next(-50, 100); var aty = new DoubleAnimation { To = y, Duration = d }; Storyboard.SetTarget(aty, dot.RenderTransform); Storyboard.SetTargetProperty(aty, "TranslateY"); s += _Random.Next(1, 2); var asx = new DoubleAnimation { To = s, Duration = d }; Storyboard.SetTarget(asx, dot.RenderTransform); Storyboard.SetTargetProperty(asx, "ScaleX"); var asy = new DoubleAnimation { To = s, Duration = d }; Storyboard.SetTarget(asy, dot.RenderTransform); Storyboard.SetTargetProperty(asy, "ScaleY"); var ao = new DoubleAnimation { To = 0, Duration = d }; Storyboard.SetTarget(ao, dot); Storyboard.SetTargetProperty(ao, "Opacity"); var story = new Storyboard(); story.Completed += (sender, e) => LayoutRoot.Children.Remove(dot); story.Children.Add(atx); story.Children.Add(aty); story.Children.Add(asx); story.Children.Add(asy); story.Children.Add(ao); story.Begin(); }
//draw a ellipse public void DrawEllipse(double x, double y, double width, double height) { Windows.UI.Xaml.Shapes.Ellipse ellipse = new Windows.UI.Xaml.Shapes.Ellipse(); ellipse.Width = width; ellipse.Height = height; ellipse.Margin = new Windows.UI.Xaml.Thickness(x, y, width, height); ellipse.Fill = new SolidColorBrush(Colors.Yellow); ellipse.Stroke = new SolidColorBrush(Colors.Black); _canvas.Children.Add(ellipse); }
/// <summary> /// Draws the selection corner. /// </summary> public void DrawSelectionCorner(DualViewsDrawingModel.Point point) { Windows.UI.Xaml.Shapes.Ellipse drawingPageCanvasEllipse = new Windows.UI.Xaml.Shapes.Ellipse(); drawingPageCanvasEllipse.Width = Definitions.SELECTION_CORNER_DOUBLE_RADIUS; drawingPageCanvasEllipse.Height = Definitions.SELECTION_CORNER_DOUBLE_RADIUS; drawingPageCanvasEllipse.Stroke = new SolidColorBrush(Colors.Red); drawingPageCanvasEllipse.Fill = new SolidColorBrush(Colors.White); _canvas.Children.Add(drawingPageCanvasEllipse); Canvas.SetLeft(drawingPageCanvasEllipse, point.X - Definitions.SELECTION_CORNER_RADIUS); Canvas.SetTop(drawingPageCanvasEllipse, point.Y - Definitions.SELECTION_CORNER_RADIUS); }
/// <summary> Draw ellipse. </summary> /// /// <param name="point1.X"> The first x value. </param> /// <param name="point1.Y"> The first y value. </param> /// <param name="point2.X"> The second x value. </param> /// <param name="point2.Y"> The second y value. </param> /// <param name="isRedLine"> True if is red line, false if not. </param> public void DrawEllipse(DrawingModel.Point point1, DrawingModel.Point point2, bool isRedLine) { Windows.UI.Xaml.Shapes.Ellipse shape = new Windows.UI.Xaml.Shapes.Ellipse(); shape.Fill = new SolidColorBrush(Colors.AliceBlue); shape.Stroke = new SolidColorBrush(isRedLine ? Colors.Red : Colors.Black); shape.Width = Math.Abs(point2.X - point1.X); shape.Height = Math.Abs(point2.Y - point1.Y); Canvas.SetTop(shape, (point1.Y < point2.Y) ? point1.Y : point2.Y); Canvas.SetLeft(shape, (point1.X < point2.X) ? point1.X : point2.X); _canvas.Children.Add(shape); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { Windows.UI.Xaml.Shapes.Ellipse ellipse = new Windows.UI.Xaml.Shapes.Ellipse { Fill = new SolidColorBrush(Windows.UI.Colors.Red), Width = 100, Height = 100, Margin = new Thickness(10) }; itemControl.Items.Add(ellipse); }
public void CreateCircle(Color color) { Random random = new Random(); var left = random.Next(300); var top = random.Next(300); var circle = new Windows.UI.Xaml.Shapes.Ellipse(); circle.Height = 100; circle.Width = 100; circle.Margin = new Thickness(left, top, 0, 0); circle.Fill = new SolidColorBrush(color); LayoutGrid.Children.Add(circle); }
public void Init(Windows.UI.Xaml.Shapes.Ellipse redEllipse, Windows.UI.Xaml.Shapes.Ellipse greenEllipse, Windows.UI.Xaml.Shapes.Ellipse blueEllipse) { activeLedBrushes[0] = new SolidColorBrush(Windows.UI.Colors.Red); activeLedBrushes[1] = new SolidColorBrush(Windows.UI.Colors.Green); activeLedBrushes[2] = new SolidColorBrush(Windows.UI.Colors.Blue); ellipses[0] = redEllipse; ellipses[1] = greenEllipse; ellipses[2] = blueEllipse; for (int i = 0; i < 3; i++) { ellipses[i].Fill = grayBrush; } }
private void Layout(ref Canvas canvas) { canvas.Children.Clear(); _diameter = canvas.Width; double inner = _diameter - 15; Windows.UI.Xaml.Shapes.Ellipse rim = new Windows.UI.Xaml.Shapes.Ellipse { Height = _diameter, Width = _diameter, Stroke = RimBackground, StrokeThickness = 20 }; canvas.Children.Add(rim); _markers.Children.Clear(); _markers.Width = inner; _markers.Height = inner; for (int i = 0; i < 60; i++) { Windows.UI.Xaml.Shapes.Rectangle marker = new Windows.UI.Xaml.Shapes.Rectangle { Fill = RimForeground }; if ((i % 5) == 0) { marker.Width = 3; marker.Height = 8; marker.RenderTransform = TransformGroup(i * 6, -(marker.Width / 2), -(marker.Height * 2 + 4.5 - rim.StrokeThickness / 2 - inner / 2 - 6)); } else { marker.Width = 1; marker.Height = 4; marker.RenderTransform = TransformGroup(i * 6, -(marker.Width / 2), -(marker.Height * 2 + 12.75 - rim.StrokeThickness / 2 - inner / 2 - 8)); } _markers.Children.Add(marker); } canvas.Children.Add(_markers); _face.Width = _diameter; _face.Height = _diameter; canvas.Children.Add(_face); _secondsHeight = (int)_diameter / 2 - 20; _minutesHeight = (int)_diameter / 2 - 40; _hoursHeight = (int)_diameter / 2 - 60; }
/// <summary> /// Закрашивает выбранный индикатор указанным цветом /// </summary> /// <param name="LED"></param> /// <param name="BrushColor"></param> public static void UpdateStartLEDs(Windows.UI.Xaml.Shapes.Ellipse LED, Color BrushColor) { if (CurrentState == States.Init) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SolidColorBrush mySolidColorBrush = new SolidColorBrush { Color = BrushColor }; LED.Fill = mySolidColorBrush; }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } }
//DrawDashBorder public void DrawDashBorder(double x1, double y1, double x2, double y2) { const int POINT_OFFSET = 5; const int CIRCLE_RADIUS = 10; const int DASH_GAP = 3; const int DASH_LENGTH = 5; const int PEN_WIDTH = 2; Windows.UI.Xaml.Shapes.Rectangle rectangle = new Windows.UI.Xaml.Shapes.Rectangle(); rectangle.Margin = new Thickness(x1, y1, 0, 0); rectangle.Width = x2 - x1; rectangle.Height = y2 - y1; rectangle.Stroke = new SolidColorBrush(Colors.Black); rectangle.StrokeThickness = PEN_WIDTH; rectangle.StrokeDashArray = new DoubleCollection { DASH_GAP, DASH_LENGTH }; Windows.UI.Xaml.Shapes.Ellipse ellipse1 = new Windows.UI.Xaml.Shapes.Ellipse(); ellipse1.Margin = new Thickness(x1 - POINT_OFFSET, y1 - POINT_OFFSET, 0, 0); ellipse1.Width = CIRCLE_RADIUS; ellipse1.Height = CIRCLE_RADIUS; ellipse1.Stroke = new SolidColorBrush(Colors.Black); ellipse1.Fill = new SolidColorBrush(Colors.White); Windows.UI.Xaml.Shapes.Ellipse ellipse2 = new Windows.UI.Xaml.Shapes.Ellipse(); ellipse2.Margin = new Thickness(x2 - POINT_OFFSET, y1 - POINT_OFFSET, 0, 0); ellipse2.Width = CIRCLE_RADIUS; ellipse2.Height = CIRCLE_RADIUS; ellipse2.Stroke = new SolidColorBrush(Colors.Black); ellipse2.Fill = new SolidColorBrush(Colors.White); Windows.UI.Xaml.Shapes.Ellipse ellipse3 = new Windows.UI.Xaml.Shapes.Ellipse(); ellipse3.Margin = new Thickness(x1 - POINT_OFFSET, y2 - POINT_OFFSET, 0, 0); ellipse3.Width = CIRCLE_RADIUS; ellipse3.Height = CIRCLE_RADIUS; ellipse3.Stroke = new SolidColorBrush(Colors.Black); ellipse3.Fill = new SolidColorBrush(Colors.White); Windows.UI.Xaml.Shapes.Ellipse ellipse4 = new Windows.UI.Xaml.Shapes.Ellipse(); ellipse4.Margin = new Thickness(x2 - POINT_OFFSET, y2 - POINT_OFFSET, 0, 0); ellipse4.Width = CIRCLE_RADIUS; ellipse4.Height = CIRCLE_RADIUS; ellipse4.Stroke = new SolidColorBrush(Colors.Black); ellipse4.Fill = new SolidColorBrush(Colors.White); _canvas.Children.Add(rectangle); _canvas.Children.Add(ellipse1); _canvas.Children.Add(ellipse2); _canvas.Children.Add(ellipse3); _canvas.Children.Add(ellipse4); }
public void ChangeLightIndicator(Windows.UI.Xaml.Shapes.Ellipse indicatorElement, string state) { switch (state.ToLower()) { case "play": indicatorElement.Fill = new SolidColorBrush(Windows.UI.Colors.LightGreen); break; case "pause": indicatorElement.Fill = new SolidColorBrush(Windows.UI.Colors.Yellow); break; case "stop": indicatorElement.Fill = new SolidColorBrush(Windows.UI.Colors.Red); break; } }
protected override void OnElementChanged(ElementChangedEventArgs <BoxView> e) { base.OnElementChanged(e); ArrangeNativeChildren = true; if (m_Canvas != null) { Children.Remove(m_Canvas); } m_Canvas = new Canvas() { Width = 200, Height = 200, Background = new SolidColorBrush(Windows.UI.Color.FromArgb(0, 255, 255, 255)), IsHitTestVisible = false }; Children.Add(m_Canvas); //ellipse WShape ellipse = new WEllipse() { Width = 100, Height = 100, Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0)), }; Canvas.SetLeft(ellipse, 0); Canvas.SetTop(ellipse, 0); m_Canvas.Children.Add(ellipse); //text TextBlock text = new TextBlock() { FontSize = 50, FontWeight = Windows.UI.Text.FontWeights.Normal, Text = "hello world", Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0)) }; Canvas.SetLeft(text, 0); Canvas.SetTop(text, 150); m_Canvas.Children.Add(text); }
void LoadUserPosition(Geocoordinate userCoordinate, bool center) { if (Control == null || Element == null) { return; } var userPosition = new BasicGeoposition { Latitude = userCoordinate.Point.Position.Latitude, Longitude = userCoordinate.Point.Position.Longitude }; var point = new Geopoint(userPosition); if (_userPositionCircle == null) { _userPositionCircle = new WEllipse { Stroke = new SolidColorBrush(Colors.White), Fill = new SolidColorBrush(Colors.Blue), StrokeThickness = 2, Height = 20, Width = 20, Opacity = 50 }; } if (Control.Children.Contains(_userPositionCircle)) { Control.Children.Remove(_userPositionCircle); } MapControl.SetLocation(_userPositionCircle, point); MapControl.SetNormalizedAnchorPoint(_userPositionCircle, new Windows.Foundation.Point(0.5, 0.5)); Control.Children.Add(_userPositionCircle); if (center) { Control.Center = point; Control.ZoomLevel = 13; } }
internal GazeCursor() { _gazePopup = new Popup { IsHitTestVisible = false }; var gazeCursor = new Windows.UI.Xaml.Shapes.Ellipse { Fill = new SolidColorBrush(Colors.IndianRed), VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Width = 2 * CursorRadius, Height = 2 * CursorRadius, Margin = new Thickness(-CursorRadius, -CursorRadius, 0, 0), IsHitTestVisible = false }; _gazePopup.Child = gazeCursor; }
private async void GetMyLocation() { ToggleProgressBar(true, "Loading"); try { Geolocator locator = new Geolocator(); Geoposition position = await locator.GetGeopositionAsync(); //MapIcon icon = new MapIcon(); //icon.Location = position.Coordinate.Point; //icon.Title = "My Location"; //icon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/ImageIcon.png")); //MyMap.MapElements.Add(icon); var pushpin = new Windows.UI.Xaml.Shapes.Ellipse(); pushpin.Fill = new SolidColorBrush(Colors.Red); pushpin.Height = 50; pushpin.Width = 50; MyMap.Children.Add(pushpin); //MyMap.Center = position.Coordinate.Point; MyMap.DesiredPitch = 0; MapControl.SetLocation(pushpin, position.Coordinate.Point); MapControl.SetNormalizedAnchorPoint(pushpin, new Point(0.5, 0.5)); await MyMap.TrySetViewAsync(position.Coordinate.Point, 15, 0, 0, MapAnimationKind.Bow); } catch (Exception ex) { ShowMessage(ex.Message); } ToggleProgressBar(false); }
/// <summary> /// Draws an ellipse /// </summary> /// <param name="frame"></param> /// <param name="pen"></param> /// <param name="brush"></param> public void DrawEllipse(Rect frame, Pen pen = null, NGraphics.Brush brush = null) { var ellipseEl = new Windows.UI.Xaml.Shapes.Ellipse(); var offset = pen != null ? pen.Width : 0.0; ellipseEl.Width = frame.Width + offset; ellipseEl.Height = frame.Height + offset; if (brush != null) { ellipseEl.Fill = GetBrush(brush); } if (pen != null) { ellipseEl.Stroke = GetStroke(pen); ellipseEl.StrokeThickness = pen.Width; } ellipseEl.RenderTransform = Conversions.GetTransform(CurrentTransform); _canvas.Children.Add(ellipseEl); Canvas.SetLeft(ellipseEl, frame.X - offset / 2.0); Canvas.SetTop(ellipseEl, frame.Y - offset / 2.0); }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) {//MapManager.ShowDownloadedMapsUI(); for download map //the map token from the devoloper account MyMap.MapServiceToken = "_y9lVdW-3ewMrx0C6bGnZQ"; //Geolocator initialization locator = new Geolocator(); locator.DesiredAccuracy = PositionAccuracy.High; locator.MovementThreshold = 20; Geoposition position = null; try{ position = await locator.GetGeopositionAsync(); } catch {} //await MyMap.TrySetViewAsync(position.Coordinate.Point, 18D); //centering the map to the current position MyMap.Center = position.Coordinate.Point; MyMap.ZoomLevel = 15; //adding icon to the current position MapIcon mapIcon = new MapIcon(); mapIcon.Image = RandomAccessStreamReference.CreateFromUri( new Uri("ms-appx:///Assets/inside_project_img/map_pin.png")); mapIcon.NormalizedAnchorPoint = new Point(0.5, 1); mapIcon.Location = position.Coordinate.Point; mapIcon.Title = "You are here"; MyMap.MapElements.Add(mapIcon); //adding icon to the distination BasicGeoposition destinationPosition = new BasicGeoposition(); destinationPosition.Longitude = Convert.ToDouble(MainPage.DestinationLongitude); destinationPosition.Latitude = Convert.ToDouble(MainPage.DestinationLatitude); MapIcon mapIcon1 = new MapIcon(); mapIcon1.Image = RandomAccessStreamReference.CreateFromUri( new Uri("ms-appx:///Assets/inside_project_img/map_pin.png")); mapIcon1.NormalizedAnchorPoint = new Point(0.5, 1); mapIcon1.Location = new Geopoint(destinationPosition); mapIcon.Title = "You are here"; MyMap.MapElements.Add(mapIcon1); //adding a circle to the current position Windows.UI.Xaml.Shapes.Ellipse fence = new Windows.UI.Xaml.Shapes.Ellipse(); fence.Width = 100; fence.Height = 100; fence.Fill = new SolidColorBrush(Colors.Blue); fence.Stroke = new SolidColorBrush(Colors.Blue); fence.Opacity = 0.3; fence.StrokeThickness = 2; MapControl.SetLocation(fence, position.Coordinate.Point); MapControl.SetNormalizedAnchorPoint(fence, new Point(0.5, 0.5)); MyMap.Children.Add(fence); // This part is for the route . BasicGeoposition startLocation = new BasicGeoposition(); startLocation.Latitude = position.Coordinate.Latitude; startLocation.Longitude = position.Coordinate.Longitude; Geopoint startPoint = new Geopoint(startLocation); // End at Central Park. BasicGeoposition endLocation = new BasicGeoposition(); endLocation.Latitude = Convert.ToDouble(MainPage.DestinationLatitude); endLocation.Longitude = Convert.ToDouble(MainPage.DestinationLongitude); Geopoint endPoint = new Geopoint(endLocation); // Get the route between the points. MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(startPoint, endPoint, MapRouteOptimization.Time, MapRouteRestrictions.None); if (routeResult.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Blue; viewOfRoute.OutlineColor = Colors.Blue; // Add the new MapRouteView to the Routes collection // of the MapControl. MyMap.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await MyMap.TrySetViewBoundsAsync(routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Bow); } //locator.PositionChanged += locator_PositionChanged; // locator.StatusChanged += locator_StatusChanged; // this.navigationHelper.OnNavigatedTo(e); //after finding the route we disable the progress ring progress.Opacity = 0; appBar.IsEnabled = true; subtitle.Text = "Follow the road"; progress.Opacity = 0; MyMap.Opacity = 1; }
// 배경을 채우는 타원 컨트롤과 다이얼의 바깥 쪽을 채우는 // 마커 배열로 구성된 Gauge 컨트롤의 모양과 느낌을 만드는 메소드이다. private void Init(ref Canvas canvas) { canvas.Children.Clear(); _diameter = canvas.Width; double inner = _diameter; Windows.UI.Xaml.Shapes.Ellipse face = new Windows.UI.Xaml.Shapes.Ellipse() { Height = _diameter, Width = _diameter, Fill = Fill }; canvas.Children.Add(face); Canvas markers = new Canvas() { Width = inner, Height = inner }; for (int i = 0; i < 51; i++) { Windows.UI.Xaml.Shapes.Rectangle marker = new Windows.UI.Xaml.Shapes.Rectangle() { Fill = Foreground }; if ((i % 5) == 0) { marker.Width = 4; marker.Height = 16; marker.RenderTransform = TransformGroup(i * 6, -(marker.Width / 2), -(marker.Height * 2 + 4.5 - face.StrokeThickness / 2 - inner / 2 - 16)); } else { marker.Width = 2; marker.Height = 8; marker.RenderTransform = TransformGroup(i * 6, -(marker.Width / 2), -(marker.Height * 2 + 12.75 - face.StrokeThickness / 2 - inner / 2 - 16)); } markers.Children.Add(marker); } markers.RenderTransform = new RotateTransform() { Angle = 30, CenterX = _diameter / 2, CenterY = _diameter / 2 }; canvas.Children.Add(markers); _needle = new Windows.UI.Xaml.Shapes.Rectangle() { Width = _needleWidth, Height = (int)_diameter / 2 - 30, Fill = Foreground }; canvas.Children.Add(_needle); Windows.UI.Xaml.Shapes.Ellipse middle = new Windows.UI.Xaml.Shapes.Ellipse() { Height = _diameter / 10, Width = _diameter / 10, Fill = Foreground }; Canvas.SetLeft(middle, (_diameter - middle.ActualWidth) / 2); Canvas.SetTop(middle, (_diameter - middle.ActualHeight) / 2); canvas.Children.Add(middle); }
private void MultiSrcReader_MultiSourceFrameArrived(MultiSourceFrameReader sender, MultiSourceFrameArrivedEventArgs args) { var mainPage = (Windows.UI.Xaml.Window.Current.Content as Windows.UI.Xaml.Controls.Frame).Content as MainPage; var bodyCanvas = (mainPage.Content as Windows.UI.Xaml.Controls.Grid).FindName("BodyCanvas") as Windows.UI.Xaml.Controls.Canvas; using (var multiFrame = args.FrameReference.AcquireFrame()) { if (multiFrame != null) { using (var bodyFrame = multiFrame.BodyFrameReference.AcquireFrame()) using (var irFrame = multiFrame.InfraredFrameReference.AcquireFrame()) { if (bodyFrame != null && irFrame != null) { irFrame.CopyFrameDataToArray(IR_DataArray); for (var i = 0; i < IR_DataArray.Length; i++) { var intensity = (byte)(IR_DataArray[i] >> 8); IR_ConvertedData[i * 4] = intensity; IR_ConvertedData[i * 4 + 1] = intensity; IR_ConvertedData[i * 4 + 2] = intensity; IR_ConvertedData[i * 4 + 3] = 255; } IR_ConvertedData.CopyTo(IRwBmp.PixelBuffer); IRwBmp.Invalidate(); bodyFrame.GetAndRefreshBodyData(Body_DataArray); foreach (var body in Body_DataArray) { if (body.IsTracked) { //var jointTypes = Enum.GetValues(typeof(JointType)); var headJoint = body.Joints[JointType.Head]; if (headJoint.TrackingState == TrackingState.Tracked) { bodyCanvas.Children.Clear(); var dsp = SensorInstance.CoordinateMapper.MapCameraPointToDepthSpace(headJoint.Position); var ellipse = new Windows.UI.Xaml.Shapes.Ellipse() { Width = 50, Height = 50, Fill = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Red) }; bodyCanvas.Children.Add(ellipse); Windows.UI.Xaml.Controls.Canvas.SetTop(ellipse, dsp.Y - 25); Windows.UI.Xaml.Controls.Canvas.SetLeft(ellipse, dsp.X - 25); } } } } } } } }
private async void GetMyLocation() { ToggleProgressBar(true,"Loading"); try { Geolocator locator = new Geolocator(); Geoposition position = await locator.GetGeopositionAsync(); //MapIcon icon = new MapIcon(); //icon.Location = position.Coordinate.Point; //icon.Title = "My Location"; //icon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/ImageIcon.png")); //MyMap.MapElements.Add(icon); var pushpin = new Windows.UI.Xaml.Shapes.Ellipse(); pushpin.Fill=new SolidColorBrush(Colors.Red); pushpin.Height=50; pushpin.Width=50; MyMap.Children.Add(pushpin); //MyMap.Center = position.Coordinate.Point; MyMap.DesiredPitch = 0; MapControl.SetLocation(pushpin,position.Coordinate.Point); MapControl.SetNormalizedAnchorPoint(pushpin, new Point(0.5, 0.5)); await MyMap.TrySetViewAsync(position.Coordinate.Point, 15,0,0,MapAnimationKind.Bow); } catch (Exception ex) { ShowMessage(ex.Message); } ToggleProgressBar(false); }
public void FillCircle(float x, float y, float radius) { var e = new Windows.UI.Xaml.Shapes.Ellipse(); e.Width = radius; e.Height = radius; //*2? e.Fill = _foregroundBrush; e.Stroke = _foregroundBrush; Windows.UI.Xaml.Controls.Canvas.SetTop(e, y); Windows.UI.Xaml.Controls.Canvas.SetLeft(e, x); _canvas.Children.Add(e); _currentX = x; _currentY = y; }
protected async override void OnNavigatedTo(NavigationEventArgs e) { // Show users part = e.Parameter as Campuses; SQLiteAsyncConnection connection = new SQLiteAsyncConnection("institutionFinder.db"); var users = await connection.QueryAsync<Campuses>("Select * FROM Campuses WHERE Name ='" + part.Name + "'"); // Get users camp = users.FirstOrDefault(); map.MapServiceToken = "yvPVkyiTloR2lug6UK3uVg"; map.Center = new Geopoint(new BasicGeoposition() { Latitude = camp.Latitude, Longitude = camp.Longitude }); map.ZoomLevel = 15; map.LandmarksVisible = true; MapIcon MapIcon1 = new MapIcon(); MapIcon1.Location = new Geopoint(new BasicGeoposition() { Latitude = camp.Latitude, Longitude = camp.Longitude }); MapIcon1.NormalizedAnchorPoint = new Point(10,10); MapIcon1.Title = camp.Name; map.MapElements.Add(MapIcon1); MapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///ViewModels/map.jpg")); Windows.UI.Xaml.Shapes.Ellipse fence = new Windows.UI.Xaml.Shapes.Ellipse(); MapControl.SetNormalizedAnchorPoint(fence, new Point(0.5, 0.5)); // Get a route as shown previously. BasicGeoposition startLocation = new BasicGeoposition(); startLocation.Latitude = -25.73134; startLocation.Longitude = 28.21837; Geopoint startPoint = new Geopoint(startLocation); // End at the city of Seattle, Washington. BasicGeoposition endLocation = new BasicGeoposition(); endLocation.Latitude = camp.Latitude; endLocation.Longitude = camp.Longitude; Geopoint endPoint = new Geopoint(endLocation); MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( startPoint, endPoint, MapRouteOptimization.Time, MapRouteRestrictions.None); if (routeResult.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.Yellow; viewOfRoute.OutlineColor = Colors.Black; // Add the new MapRouteView to the Routes collection // of the MapControl. map.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await map.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } }
/// <summary> /// Draws an ellipse /// </summary> /// <param name="frame"></param> /// <param name="pen"></param> /// <param name="brush"></param> public void DrawEllipse(Rect frame, Pen pen = null, NGraphics.Brush brush = null) { var ellipseEl = new Windows.UI.Xaml.Shapes.Ellipse(); var offset = pen != null ? pen.Width : 0.0; ellipseEl.Width = frame.Width + offset; ellipseEl.Height = frame.Height + offset; if (brush != null) ellipseEl.Fill = GetBrush(brush); if (pen != null) { ellipseEl.Stroke = GetStroke(pen); ellipseEl.StrokeThickness = pen.Width; } ellipseEl.RenderTransform = Conversions.GetTransform(CurrentTransform); _canvas.Children.Add(ellipseEl); Canvas.SetLeft(ellipseEl, frame.X - offset / 2.0); Canvas.SetTop(ellipseEl, frame.Y - offset / 2.0); }
private void InitScreen() { MakeStarsBackground(); Windows.UI.Xaml.Shapes.Ellipse ctemp; Windows.UI.Xaml.Shapes.Rectangle rtemp; foreach (Circle c in world.Circs) { ctemp = new Windows.UI.Xaml.Shapes.Ellipse() { Margin = new Windows.UI.Xaml.Thickness(c.X, c.Y, 0, 0), Width = c.Radius * 2, Height = c.Radius * 2, Fill = new SolidColorBrush(new Windows.UI.Color() { A = (byte)255, R = c.Color.Red, G = c.Color.Green, B = c.Color.Blue }), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; circs.Children.Add(ctemp); rtemp = new Windows.UI.Xaml.Shapes.Rectangle() { Margin = new Windows.UI.Xaml.Thickness(c.X + c.Radius, c.Y + c.Radius, 0, 0), Width = c.Radius, Height = c.Radius, Fill = new SolidColorBrush(new Windows.UI.Color() { A = (byte)255, R = (byte)(255 - c.Color.Red), G = (byte)(255 - c.Color.Green), B = (byte)(255 - c.Color.Blue) }), RenderTransform = new RotateTransform() { Angle = c.alpha }, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; circs.Children.Add(rtemp); } foreach (Rectangle r in world.Rects) { rtemp = new Windows.UI.Xaml.Shapes.Rectangle() { Margin = new Thickness(r.X, r.Y, 0, 0), Width = r.Width, Height = r.Height, Fill = new SolidColorBrush(new Windows.UI.Color() { A = (byte)255, R = r.Color.Red, G = r.Color.Green, B = r.Color.Blue }), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; rects.Children.Add(rtemp); } // There shouldn't be any triangle at the beginning but if you reset the display (e.g. while resizing) UpdateTrianglesDisplay(); }
private void init(Canvas canvas) { canvas.Children.Clear(); diameter = canvas.Width; double inner = diameter; Windows.UI.Xaml.Shapes.Ellipse face = new Windows.UI.Xaml.Shapes.Ellipse() { Height = diameter, Width = diameter, Fill = background }; canvas.Children.Add(face); Canvas markers = new Canvas() { Width = inner, Height = inner }; for (int i = 0; i < 51; i++) { Windows.UI.Xaml.Shapes.Rectangle marker = new Windows.UI.Xaml.Shapes.Rectangle() { Fill = foreground }; if ((i % 5) == 0) { marker.Width = 4; marker.Height = 16; marker.RenderTransform = transformGroup(i * 6, -(marker.Width / 2), -(marker.Height * 2 + 4.5 - face.StrokeThickness / 2 - inner / 2 - 16)); } else { marker.Width = 2; marker.Height = 8; marker.RenderTransform = transformGroup(i * 6, -(marker.Width / 2), -(marker.Height * 2 + 12.75 - face.StrokeThickness / 2 - inner / 2 - 16)); } markers.Children.Add(marker); } markers.RenderTransform = new RotateTransform() { Angle = 30, CenterX = diameter / 2, CenterY = diameter / 2 }; canvas.Children.Add(markers); needle = new Windows.UI.Xaml.Shapes.Rectangle() { Width = needleWidth, Height = (int)diameter / 2 - 30, Fill = foreground }; canvas.Children.Add(needle); Windows.UI.Xaml.Shapes.Ellipse middle = new Windows.UI.Xaml.Shapes.Ellipse() { Height = diameter / 10, Width = diameter / 10, Fill = foreground }; Canvas.SetLeft(middle, (diameter - middle.ActualWidth) / 2); Canvas.SetTop(middle, (diameter - middle.ActualHeight) / 2); canvas.Children.Add(middle); }
private async void UpdateMap() { var pushpin = new Windows.UI.Xaml.Shapes.Ellipse(); pushpin.Fill = new SolidColorBrush(Colors.Red); pushpin.Height = 20; pushpin.Width = 20; if (MyMap.Children.Count > 0) MyMap.Children.RemoveAt(0); MyMap.Children.Add(pushpin); MapControl.SetLocation(pushpin, currentLocation); MapControl.SetNormalizedAnchorPoint(pushpin, new Point(0.5, 0.5)); await MyMap.TrySetViewAsync(currentLocation, 15, 0, 0, MapAnimationKind.Linear); }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { // Call the navigation helper base function. this.navigationHelper.OnNavigatedTo(e); // Get the user's current location so that it can be used as the center // point of the map control. Geolocator geolocator = new Geolocator(); Geoposition geoposition = null; try { geoposition = await geolocator.GetGeopositionAsync(); } catch (Exception) { // Make sure you have defined ID_CAP_LOCATION in the application manifest // and that on your phone, you have turned on location by checking // Settings > Location. // Handle errors like unauthorized access to location services } // Set the map center point. myMapControl.Center = geoposition.Coordinate.Point; // Zoom level. myMapControl.ZoomLevel = 15; // Create an ellipse and shape it into a circle. Windows.UI.Xaml.Shapes.Ellipse fence = new Windows.UI.Xaml.Shapes.Ellipse(); fence.Width = 30; fence.Height = 30; fence.Stroke = new SolidColorBrush(Colors.DarkOrange); fence.StrokeThickness = 2; // This code will add a TextBlock to the map control. //TextBlock textBlock = new TextBlock(); //textBlock.Width = 115; //textBlock.Height = 25; //textBlock.Text = "You are here"; //textBlock.FontSize = 20; //textBlock.Foreground = new SolidColorBrush(Colors.DarkOrange); // Location and Anchorpoint MapControl.SetLocation(fence, geoposition.Coordinate.Point); MapControl.SetNormalizedAnchorPoint(fence, new Point(0.5, 0.5)); // Add the ellipse to the map control. myMapControl.Children.Add(fence); }