コード例 #1
0
        /// <summary>
        /// Adds a new dot to the dot list, which is an ObservableCollection that will trigger DrawChangedDots in GraphView
        /// </summary>
        public void AddNewDotToGraphList(Point pos, double value)
        {
            SetWindowStartSize(); // Set the screen size when the first dot was created, in order to scale UI objects correctly

            GraphFrameSizeWidth  = (Application.Current.MainPage.Width * GetZoomAmount()) + graphFrameSizeOffsetX;
            GraphFrameSizeHeight = ((Application.Current.MainPage.Height / 2f)) * (GetZoomAmount() * 2f) + graphFrameSizeOffsetY;

            GraphDot tempDot = new GraphDot(new Point(pos.X, (pos.Y * 100f)), value);

            tempDot.Index = GetGraphDotsList().Count;                                         // index of the dot tell the diffrence easily.

            tempDot.ScreenSizeCreated = new Point(GraphFrameSizeWidth, GraphFrameSizeHeight); // Set the screen size when the first dot was created, in order to scale the dots correctly

            double newPosX = (tempDot.StartPoint.X * (((GraphFrameSizeWidth - graphFrameSizeOffsetX) / windowStartSizeX) * GetZoomAmount()));
            double newPosY = (tempDot.StartPoint.Y * (((GraphFrameSizeHeight - graphFrameSizeOffsetY) / windowStartSizeY) * GetZoomAmount())) + (GraphFrameSizeHeight - ((DotSize.Y * 4f) * GetZoomAmount()));

            AbsoluteLayout.SetLayoutBounds(tempDot.GraphicDot, new Rectangle(newPosX, newPosY, DotSize.X * GetZoomAmount(), DotSize.Y * GetZoomAmount()));
            AbsoluteLayout.SetLayoutFlags(tempDot.GraphicDot, AbsoluteLayoutFlags.None);

            ShouldDotChangeColor(tempDot, MaxAcceptedLineValue);
            GetGraphDotsList().Add(tempDot); // add to the dot list

            if (value > MaxValue)
            {
                MaxValue = value;// Set the new max value
            }

            ExtendGraphLength(newPosX);
            ExtendGraphHeight(newPosY);
            hasCreatedDot = true;
        }
コード例 #2
0
 /// <summary>
 /// Draw a new dot to the ui graph and add a TapGesture to make the dots/values clickable.
 /// </summary>
 /// <param name="dot"></param>
 public void DrawNewDot(GraphDot dot)
 {
     // Add the click funconality to the dots
     dot.GraphicDot.GestureRecognizers.Add(
         new TapGestureRecognizer()
     {
         Command = new Command(() => {
             graphViewModel.SelectDot(dot.Index, graphViewModel.dotSelected);
             graphViewModel.dotSelected = dot.Index;
         })
     });
     GraphDrawArea.Children.Add(dot.GraphicDot);
 }