CapgeminiSurface.CapgeminiSurfaceWindow.OnDropBT C# (CSharp) 메소드

OnDropBT() 개인적인 메소드

private OnDropBT ( object sender, SurfaceDragDropEventArgs e ) : void
sender object
e SurfaceDragDropEventArgs
리턴 void
        private void OnDropBT(object sender, SurfaceDragDropEventArgs e)
        {
            var element = e.OriginalSource as FrameworkElement;
            if (element != null)
            {
                if (element.DataContext is BluetoothDevice)
                {
                    // Target is a Bluetooth device
                    var device = element.DataContext as BluetoothDevice;

                    if (e.Cursor.Data is ContentItem)
                    {
                        var ci = e.Cursor.Data as ContentItem;
                        ObexItem oi = null;
                        if (ci.IsPictureItem)
                        {
                            oi = new ObexImage() { ImageUri = new Uri("pack://application:,,,/" + ci.FileName) };
                        }
                        else if (ci.IsVisitItem)
                        {
                            oi = new ObexContactItem()
                            {
                                FirstName = ci.Name,
                                LastName = ci.FileName,
                                EmailAddress = ci.Email,
                                MobileTelephoneNumber = ci.Tlf
                            };
                        }
                        if (oi != null)
                        {
                            // Pause discovery as it interferes with/slows down beam process
                            _monitor.StopDiscovery();

                            // Create the new request and write the contact details
                            var owr = new ObexWebRequest(new Uri("obex://" + device.DeviceAddress.ToString() + "/" + oi.FileName));
                            System.IO.Stream s = owr.GetRequestStream();
                            oi.WriteToStream(s);

                            owr.ContentType = oi.ContentType;
                            owr.ContentLength = s.Length;
                            s.Close();

                            // Beam the item on new thread
                            System.Threading.ThreadPool.QueueUserWorkItem(BeamObject, owr);
                        }
                        // Return item to the scatter view
                        TargetItems.Add(e.Cursor.Data as ContentItem);
                        var item = scatterViewTarget.Items[scatterViewTarget.Items.Count - 1];
                        favouriteStack.RemoveInstancePropertyObject(item);
                    }

                }

                // Otherwise not supported
            }
        }