private async void Share(ShareTarget target)
        {
            if (this.EnsureUnsnapped())
            {
                var filePicker = new FileOpenPicker();
                filePicker.ViewMode = PickerViewMode.Thumbnail;
                filePicker.CommitButtonText = "Share File";
                filePicker.SettingsIdentifier = "becharming";
                filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                filePicker.FileTypeFilter.Add("*");

                var selectedFile = await filePicker.PickSingleFileAsync();

                if (selectedFile != null)
                {
                    var properties = await selectedFile.GetBasicPropertiesAsync();
                    var size = properties.Size;
                    var fileStream = await selectedFile.OpenReadAsync();

                    using (DataReader dataReader = new DataReader(fileStream))
                    {
                        await dataReader.LoadAsync((uint)size);
                        byte[] buffer = new byte[(int)size];

                        dataReader.ReadBytes(buffer);

                        var fileBytes = buffer;

                        ShareRequest request = new ShareRequest();
                        request.FileContents = fileBytes;
                        request.FileName = selectedFile.Name;
                        request.Target = target;

                        ((MainViewModel)DataContext).Share(request);
                    }
                }
            }
        }
        public async void Share(ShareRequest request)
        {
            var serverPath = string.Format("net.tcp://{0}:22001/BeCharming", request.Target.IPAddress);

            ListenerClient client = new ListenerClient();
            ((NetTcpBinding)client.Endpoint.Binding).Security.Mode = SecurityMode.None;
            client.Endpoint.Address = new System.ServiceModel.EndpointAddress(new Uri(serverPath));

            string result = null;

            if (ShareStarted != null)
            {
                ShareStarted(this, null);
            }

            // The PinCode should be forward hashed so it cannot be read??

            if (!string.IsNullOrEmpty(request.Url))
            {
                result = await client.OpenWebPageAsync(request.Url, request.PinCode);
            }
            else
            {
                result = await client.OpenDocumentAsync(request.FileName, request.FileContents, request.PinCode);
            }

            if (result == "okay")
            {
                IncrementShareCount(request.Target);

                if (ShareComplete != null)
                {
                    ShareComplete(this, null);
                }
            }
            else
            {
                if (ShareFailed != null)
                {
                    ShareFailed(this, null);
                }

            }
        }
        public void SetupForShareRequest(Models.ShareRequest request)
        {
            ShareRequest = request;

            if (manager.RequiresPin(ShareRequest))
            {
                IsShowingRequiresPin = true;
                IsSharing = false;
            }
            else
            {
                IsShowingRequiresPin = false;
                IsSharing = true;
                manager.Share(ShareRequest);
            }
        }
 public bool RequiresPin(ShareRequest request)
 {
     return request.Target.IsPinCodeRequired;
 }
        public void TargetSelected(object target)
        {
            IsSharing = true;

            ShareRequest request = new ShareRequest();
            request.Url = this.url;
            request.FileContents = fileBytes;
            request.FileName = fileName;
            request.Target = this.SelectedTarget;

            manager.Share(request);

            IsSharing = false;
        }