void FileRowControl_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { UserFile userFile = sender as UserFile; if (e.PropertyName == "Percentage") { Percentage.Value = userFile.Percentage; Percentage.Visibility = Visibility.Visible; } //当前文件上传完毕 if (userFile.State == Constants.FileStates.Finished) { Percentage.Visibility = Visibility.Collapsed; CWViewUploadedImage cw = new CWViewUploadedImage(); cw.Closed += (o, eventArgs) => { if (cw.DialogResult == true) //确定并就隐藏当前sl应用窗口 { NavPage.javaScriptableObject.OnCloseAvatar(null); //调用js端注册事件 } //Utils.ShowMessageBox("op: 确定并就隐藏当前sl应用窗口"); }; cw.LargeImageWidth.Text = Viewport.Width.ToString(); cw.LargeImageHeight.Text = Viewport.Height.ToString(); cw.Show(); } }
private void BtnAdvanceMode_Click(object sender, RoutedEventArgs e) { if (fileInfo == null) { Utils.ShowMessageBox("\r\n请选择要上传的头像."); } else { Utils.UploadUserFile(fileInfo.Name, focusRectangle.imageScroll, focusRectangle.FocusRect, (o, eventArgs) => //定制UserFile的PropertyChanged 属性,如BytesUploaded,Percentage,IsDeleted { UserFile userFile = o as UserFile; if (eventArgs.PropertyName == "Percentage") { Percentage.Value = userFile.Percentage; Percentage.Visibility = Percentage.Value == 100 ? Visibility.Collapsed : Visibility.Visible; } //当前文件上传完毕 if (userFile.State == Constants.FileStates.Finished) { this.NavigationService.Navigate( new Uri( string.Format("/AdvanceMode?focusWidth={0}&focusHeight={1}&fileName={2}&random=" + new Random().Next(1, 10000), focusRectangle.FocusRect.Width, focusRectangle.FocusRect.Height, userFile.FileName), UriKind.Relative)); } }); } }
private void BtnAdvanceMode_Click(object sender, RoutedEventArgs e) { captureSource.Stop(); Utils.UploadUserFile(Utils.GetUserId() + ".jpg", focusRectangle.imageScroll, focusRectangle.FocusRect, (o, eventArgs) => //定制UserFile的PropertyChanged 属性,如BytesUploaded,Percentage,IsDeleted { UserFile userFile = o as UserFile; if (eventArgs.PropertyName == "Percentage") { Percentage.Value = userFile.Percentage; Percentage.Visibility = Percentage.Value == 100 ? Visibility.Collapsed : Visibility.Visible; } //当前文件上传完毕 if (userFile.State == Constants.FileStates.Finished) { this.NavigationService.Navigate( new Uri( string.Format("/AdvanceMode?focusWidth={0}&focusHeight={1}&fileName={2}", focusRectangle.FocusRect.Width, focusRectangle.FocusRect.Height, userFile.FileName), UriKind.Relative)); } }); }
public static UserFile UploadUserFile(string fileName, FrameworkElement image, FrameworkElement focus, PropertyChangedEventHandler eventHandler) { FileCollection _files = new FileCollection("1", 1024000); WriteableBitmap bmp = new WriteableBitmap(image, null); System.IO.Stream dstStream = new System.IO.MemoryStream(); JpegHelper.EncodeJpeg(bmp, dstStream); dstStream.Position = 0;//用于上传时从新读取 MixObjectsSoapClient.Point point = new MixObjectsSoapClient.Point(); point.X = (int)Double.Parse(focus.GetValue(Canvas.LeftProperty).ToString()); point.Y = (int)Double.Parse(focus.GetValue(Canvas.TopProperty).ToString()); MixObjectsSoapClient.Size size = new MixObjectsSoapClient.Size(); size.Width = (int)Double.Parse(focus.Width.ToString()); size.Height = (int)Double.Parse(focus.Height.ToString()); UserFile imageFile = new UserFile() { FileName = fileName, FileStream = dstStream, GrabPoint = point, GrabSize = size }; // ofd.File; imageFile.PropertyChanged += eventHandler; _files.Add(imageFile); _files.UploadFiles(); _files.RemoveAt(0); return(imageFile); }
public FileUploader(UserFile file) { _file = file; _dataLength = _file.FileStream.Length; _dataSent = 0; _client = Utils.CreateServiceClient(); //new MixObjectsSoapClient("", "http://localhost/services/MixObjects.asmx"); //事件绑定 _client.SaveAvatarCompleted += new EventHandler <SaveAvatarCompletedEventArgs>(_client_StoreFileAdvancedCompleted); _client.ChannelFactory.Closed += new EventHandler(ChannelFactory_Closed); }
public FileUploader(UserFile file) { _file = file; _dataLength = _file.FileStream.Length; _dataSent = 0; _client = Utils.CreateServiceClient(); //new MixObjectsSoapClient("", "http://localhost/services/MixObjects.asmx"); //事件绑定 _client.SaveAvatarCompleted += new EventHandler<SaveAvatarCompletedEventArgs>(_client_StoreFileAdvancedCompleted); _client.ChannelFactory.Closed += new EventHandler(ChannelFactory_Closed); }
public static UserFile UploadUserFile(string fileName, FrameworkElement image, FrameworkElement focus, PropertyChangedEventHandler eventHandler) { FileCollection _files = new FileCollection("1", 1024000); WriteableBitmap bmp = new WriteableBitmap(image, null); System.IO.Stream dstStream = new System.IO.MemoryStream(); JpegHelper.EncodeJpeg(bmp, dstStream); dstStream.Position = 0;//用于上传时从新读取 MixObjectsSoapClient.Point point = new MixObjectsSoapClient.Point(); point.X = (int) Double.Parse(focus.GetValue(Canvas.LeftProperty).ToString()); point.Y = (int) Double.Parse(focus.GetValue(Canvas.TopProperty).ToString()); MixObjectsSoapClient.Size size = new MixObjectsSoapClient.Size(); size.Width = (int)Double.Parse(focus.Width.ToString()); size.Height = (int)Double.Parse(focus.Height.ToString()); UserFile imageFile = new UserFile() { FileName = fileName, FileStream = dstStream, GrabPoint = point, GrabSize = size };// ofd.File; imageFile.PropertyChanged += eventHandler; _files.Add(imageFile); _files.UploadFiles(); _files.RemoveAt(0); return imageFile; }