コード例 #1
0
        // Adds Gridlines based on the width and height of the canvas onto the Grid gridLines
        public static void GenerateGridLines(Canvas canvas, Grid gridLines, double scale)
        {
            gridLines.ColumnDefinitions.Clear();
            gridLines.RowDefinitions.Clear();

            // Finds out how many pixels 1 meter is
            double gridWidth = DrawingResources.ConvertFromMetersToDisplayCoordinates(new Point(scale, scale), canvas).X;

            // Calculates the number of rows and columns to add
            double numberOfLinesWide = canvas.ActualWidth / gridWidth;
            double numberOfLinesHigh = canvas.ActualHeight / gridWidth;

            // Generate Columns
            for (int i = 0; i < numberOfLinesWide; i++)
            {
                ColumnDefinition columnDefinition = new ColumnDefinition();
                columnDefinition.Width = new GridLength(gridWidth);
                gridLines.ColumnDefinitions.Add(columnDefinition);
            }

            // Generate Rows
            for (int i = 0; i < numberOfLinesHigh; i++)
            {
                RowDefinition rowDefinition = new RowDefinition();
                rowDefinition.Height = new GridLength(gridWidth);
                gridLines.RowDefinitions.Add(rowDefinition);
            }
        }
コード例 #2
0
        public void onLocationChanged(Device device)
        {
            PairableDevice pairableDevice = (PairableDevice)device;

            //Dispatch UI Changes to Main Thread
            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                if (pairableDevice.Location.HasValue)
                {
                    if (iaDevice.SupportedRoutes.Contains(Routes.GetLocationRoute))
                    {
                        MyDisplayState = DisplayState.LocatedAndOnStackPanel;
                    }

                    Point newPoint = DrawingResources.ConvertFromMetersToDisplayCoordinates(pairableDevice.Location.Value, MainWindow.SharedCanvas);

                    // InnerBorder.Width / 2 is to make it so that the point that the DeviceControl is drawn at is actually the center of the Border
                    Canvas.SetLeft(this, newPoint.X - (InnerBorder.Width / 2));
                    Canvas.SetTop(this, newPoint.Y - (InnerBorder.Height / 2));
                }
                else if (iaDevice.SupportedRoutes.Contains(Routes.GetLocationRoute))
                {
                    MyDisplayState = DisplayState.UnlocatedAndOnStackPanel;
                }
            }));
        }
コード例 #3
0
 public void onLocationChanged(Device device)
 {
     if (device.Location.HasValue)
     {
         this.Dispatcher.Invoke(new Action(delegate()
         {
             Point newPoint = DrawingResources.ConvertFromMetersToDisplayCoordinates(device.Location.Value, MainWindow.SharedCanvas);
             Canvas.SetLeft(this, newPoint.X);
             Canvas.SetTop(this, newPoint.Y);
         }));
     }
 }
コード例 #4
0
        public void OnLocationChanged(Person person)
        {
            this.Dispatcher.Invoke(new Action(delegate()
            {
                if (person.Location.HasValue)
                {
                    Point newPoint = DrawingResources.ConvertFromMetersToDisplayCoordinates(person.Location.Value, MainWindow.SharedCanvas);

                    // PersonEllipse.Width / 2 is to make it so that the point that the PersonControl is drawn at is actually the center of the Ellipse
                    Canvas.SetLeft(this, newPoint.X - (PersonEllipse.Width / 2));
                    Canvas.SetTop(this, newPoint.Y - (PersonEllipse.Height / 2));

                    CoordinatesLabel.Content = string.Format("Location: ({0:0.0},{1:0.0})", person.Location.Value.X, person.Location.Value.Y);
                }
            }));
        }