private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e)
        {
            //t2 Imitere at tlf er lagt på bordet:(kommer fra TAGVisualizer object)
            camera = (CameraVisualization)e.TagVisualization;
            tagValue = camera.VisualizedTag.Value;
            elementAlreadyInMap = null;

            User user = null;
            for (int i = 0; i < users.Count; i++)
            {
                if (users.ElementAt(i).tag_value == tagValue)
                {
                    user = users.ElementAt(i);
                }
            }
            if (user != null)
            {
                Thread t2 = new Thread(() => client(15123,user.ip, imagesRequest));
                Console.WriteLine(imagesRequest);
                t2.Start();
            }

            if (pinnedPhones.TryGetValue(tagValue, out elementAlreadyInMap))
            {
                for (int i = scatterViewItems.Count -1 ; i >= 0; i--)
                {
                    if (scatterViewItems.ElementAt(i).GetType().Equals(new ScatterViewItem().GetType()))
                    {
                        //elementAlreadyInMap.Tag = tagValue;
                        if ((long)scatterViewItems.ElementAt(i).Tag == tagValue)
                        {
                            scatterViewItems.RemoveAt(i);
                        }

                    }
                    else if(scatterViewItems.ElementAt(i).Name.Equals("OwnerId" + tagValue.ToString()))
                    {
                        scatterViewItems.RemoveAt(i);
                    }
                }
                pinnedPhones.Remove(tagValue);
            }

            camera.PinButtonClicked += new RoutedEventHandler(PinButtonClicked);

            // Add a handler for the GotTag event
            camera.GotTag += new RoutedEventHandler(OnGotTag);

            // Add a handler for the LostTag event
            camera.LostTag += new RoutedEventHandler(OnLostTag);

            elementAlreadyInMap = null;
            // Checks if visualisation is removed but pinned, if not a new visualisation is created
            if (!pinnedPhones.TryGetValue(tagValue, out elementAlreadyInMap))
            {
                Console.WriteLine("TAGVALUE: " + tagValue);
                 switch (tagValue)
                {
                    case android1_tag:
                        camera.myImage.Source= users.ElementAt(0).bgr; //new BitmapImage(new Uri("pack://application:,,,/Images/Nexus.jpg"));
                        camera.LabelTagValue.Content = tagValue;
                        break;
                    case android2_tag:
                        camera.myImage.Source = users.ElementAt(1).bgr;
                        camera.LabelTagValue.Content = tagValue;
                        break;
                    /*case 3:
                        camera.myImage.Source = phone3;
                        camera.LabelTagValue.Content = tagValue;
                        break;*/
                    default:
                     //   camera.myRectangle.Fill = SurfaceColors.Accent4Brush;
                        break;
                }
            camera.Tag = camera.Effect;
            }
        }
        private void PinButtonClicked(object sender, RoutedEventArgs e)
        {
            camera = sender as CameraVisualization;
            tagValue = camera.VisualizedTag.Value;

            FrameworkElement frameworkElement = camera;
            pinnedPoint = camera.TranslatePoint(new Point(0.0, 0.0), null);

            elementAlreadyInMap = null;
            if (!pinnedPhones.TryGetValue(tagValue, out elementAlreadyInMap))
            {

                pinnedPhones.Add(tagValue, camera);
                AddPhoneToScatterView(tagValue, camera);
                camera.Visualizer.RemoveVisualization(camera);
                //RetreiveImagesFromPhone();
                AddImagesToScatterView();
            }
            else
            {
                MessageBox.Show("The phone has already been pinned");
            }
        }
        private void AddPhoneToScatterView(long tagValue, CameraVisualization camera)
        {
            ScatterViewItem phone = new ScatterViewItem();
            phone.Tag = tagValue;
            FrameworkElement frameworkElement = new FrameworkElement();
            if (pinnedPhones.TryGetValue(tagValue, out frameworkElement))
            {
                Image myPhoneImage = new Image();
                if (tagValue == android1_tag)
                    myPhoneImage.Source = users.ElementAt(0).bgr;
                if (tagValue == android2_tag)
                    myPhoneImage.Source = users.ElementAt(1).bgr;
                /*
                if (tagValue == 3)
                    myPhoneImage.Source = phone3;*/

                phone.Content = myPhoneImage;
                phone.Height = frameworkElement.ActualHeight;
                phone.Width = frameworkElement.ActualWidth;
                phone.Orientation = 0;
                phone.Center = pinnedPoint; // Original position of phone
                phone.Name = "PhoneId" + tagValue.ToString() ; // set the name property
                phone.CanScale = false;
                phone.CanRotate = true;
                phone.AllowDrop = true;
                /*
                SurfaceDragDrop.AddDragEnterHandler(phone, DropTargetDragEnter);
                SurfaceDragDrop.AddDragLeaveHandler(phone, DropTargetDragLeave);
                SurfaceDragDrop.AddDropHandler(phone, DropTargetDrop);*/
                scatterViewItems.Add(phone);

            }
        }