private async void OnMedia(object obj) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsPickPhotoSupported) { await Application.Current.MainPage.DisplayAlert("ERROR", "Pick Photo is NOT supported", "OK"); return; } //var file = await CrossMedia.Current.PickPhotoAsync(); var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Medium }); if (file == null) { return; } ProfileImage.Source = ImageSource.FromStream(() => { var stream = file.GetStream(); return(stream); }); ImageArray = FromFile.ToArray(file.GetStream()); }
public string ValuesFromFile() { FromFile fromFile = FromFile.Instance; string location = fromFile.Get(); return(ToXml(location)); }
private async void Save_Clicked(object sender, EventArgs e) { var imageArr = FromFile.ToArray(file.GetStream()); var movie = new Movie() { Name = EntName.Text, Description = EntDescription.Text, Language = EntLanguage.Text, Duration = EntDuration.Text, PlayingDate = EntPlayingDate.Text, PlayingTime = EntPlayingTime.Text, TicketPrice = EntTicketPrice.Text, Rating = Convert.ToDouble(EntRating.Text), Genre = EntGenre.Text, TrailorUrl = EntTrailorUrl.Text, ImageArray = imageArr }; var response = await ApiServices.AddMovie(file, movie); if (!response) { await DisplayAlert("Error occured", "Something went wrong, Could not be added", "Cancel"); } else { await DisplayAlert("Success", "Movie added successfully", "Ok"); await Navigation.PopModalAsync(); } }
private async void BtnConfirmReceipt_OnClicked(object sender, EventArgs e) { var imageArray = FromFile.ToArray(file.GetStream()); var receipt = new Receipt() { UserId = Preferences.Get("userId", 0), ShopId = shopId, Price = Convert.ToSingle(PriceInput.Text), ImageArray = imageArray }; var response = await ApiService.AddReceipt(file, receipt); if (!response) { await DisplayAlert("Oops", "Something went wrong", "Cancel"); } else { await DisplayAlert("Hurray!", "Your receipt is now forevered", "OK"); await Navigation.PushModalAsync(new ReceiptsPage(Preferences.Get("userId", 0))); } }
private async void ImgSave_Tapped(object sender, EventArgs e) { var imageArray = FromFile.ToArray(file.GetStream()); var movie = new Movie() { Name = EntMovieName.Text, Description = EdtDescription.Text, Language = EntLanguage.Text, Duration = EntDuration.Text, PlayingDate = EntPlayingDate.Text, PlayingTime = EntPlayingTime.Text, TicketPrice = Convert.ToInt32(EntTicketPrice.Text), Rating = Convert.ToDouble(EntRating.Text), Genre = EntGenre.Text, TrailorUrl = EntTrailorUrl.Text, ImageArray = imageArray }; var response = await ApiService.AddMovie(file, movie); if (!response) { await DisplayAlert("Oops", "Something went wrong", "Cancel"); } else { await DisplayAlert("", "Movie has been added", "Alright"); await Navigation.PopModalAsync(); } }
public static ShellIcon CreateFromFile(string filename, int index, bool cache, bool simulateDoc) { ShellIcon icon = new FromFile(filename, index); icon.dontCache = !cache; icon.simulateDoc = simulateDoc; return(icon); }
private async void AddImageToServer() { var imageArray = FromFile.ToArray(file.GetStream()); var response = await APIService.AddListingImage(_listingId, imageArray); if (response) { return; } await DisplayAlert("Error", "Došlo je do greške. Ponovite upload slike.", "OK"); }
private async void AddImageToServer() { var imageArray = FromFile.ToArray(file.GetStream()); file.Dispose(); var response = await ApiService.AddImage(_vehicleId, imageArray); if (response) { return; } await DisplayAlert("Something wrong", "Please upload the image again", "Alright"); }
private async void AddImageToServer() { var imageArray = FromFile.ToArray(file.GetStream()); //convert image stream to byte array; file.Dispose(); var response = await ApiService.AddImage(_postId, imageArray); if (response) { return; } await DisplayAlert("Something went wrong", "Upload again", "Cancel"); }
//metodo para adicionar a imagem para o server private async void AddImageToServer() { var ImageArray = FromFile.ToArray(file.GetStream()); file.Dispose(); var resposta = await ApiService.EditarFotoPerfil(ImageArray); if (resposta) { return; } await DisplayAlert("Algo deu errado", "Por favor envie a foto novamente", "OK"); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static CharReadable files(java.nio.charset.Charset charset, java.io.File... files) throws java.io.IOException public static CharReadable Files(Charset charset, params File[] files) { IOFunction <File, CharReadable> opener = new FromFile(charset); switch (Files.Length) { case 0: return(EMPTY); case 1: return(opener.apply(files[0])); default: return(new MultiReadable(Iterator(opener, files))); } }
public ActionResult display(string ip, int port) { IPAddress address; //if the first arg is a correct ip address. if (IPAddress.TryParse(ip, out address)) { Writer writer = Writer.getInstance(); writer.Ip = ip; writer.Port = port; writer.connect(); ViewBag.Lon = writer.write(lonLine); ViewBag.Lat = writer.write(latLine); ViewBag.normalDisplay = true; ViewBag.time = 0; //writer.disconnect(); return(View("~/Views/Info/display.cshtml")); } //if the first arg is a file name. execute task 4. else { string fileName = ip; int timesPerSec = port; FromFile fromFile = FromFile.Instance; fromFile.FileName = fileName; //get all of the data from the file fromFile.Read(); ViewBag.numOfLines = fromFile.Information.Count(); ViewBag.times = timesPerSec; //get single line var singleLine = fromFile.Get().Split(','); //assign to lat and lon ViewBag.lat = Double.Parse(singleLine[0]); ViewBag.lon = Double.Parse(singleLine[1]); return(View("~/Views/Info/displayFromFile.cshtml")); } }
public MainWindow() { #if DEBUG SpellContainer = FromFile.Open("../../../../spells.json"); #else SpellContainer = FromFile.Open("spells.json"); #endif Spells = new ObservableCollection <Spell>(SpellContainer.Spells); SpellContainer.Spells.CollectionChanged += SpellsOnCollectionChanged; SpellsOnCollectionChanged(this, null); DataContext = this; InitializeComponent(); void SpellsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs) { Spells.Clear(); foreach (var spell in SpellContainer.Spells.OrderBy(aSpell => aSpell.Name)) { Spells.Add(spell); } SpellSelected(Spells.FirstOrDefault()); } }
public InputStreamReaderAnonymousInnerClass3(FromFile outerInstance, GZIPInputStream zipStream, Charset charset, File file) : base(zipStream, charset) { this.outerInstance = outerInstance; this._file = file; }
public void DLFF() { FromFile.DataFromFile(); Params.fromfile = true; }
public InputStreamReaderAnonymousInnerClass4(FromFile outerInstance, Stream @in, Charset usedCharset, File file) : base(@in, usedCharset) { this.outerInstance = outerInstance; this._file = file; }
/// <summary> /// 保存文件,true:保存成功,false:出错,通过ErrorMessage查看消息 /// </summary> /// <param name="context"></param> public async Task <bool> SaveFileAsAsync(HttpContext context) { try { //FromFile = context.Request.Form.Files[0]; OriginFileName = ContentDispositionHeaderValue.Parse(FromFile.ContentDisposition).FileName.Trim('"'); var sExt = Path.GetExtension(OriginFileName); //验证扩展名 if (!(allowedExtensions + "|").Contains(string.Format("{0}|", sExt))) { ErrorMessage = $"文件{this.OriginFileName}扩展名不正确,只允许上传{allowedExtensions}格式的文件"; return(false); } //验证文件大小 Double fileSize = 0; using (var reader = FromFile.OpenReadStream()) { //get filesize in MB fileSize = (reader.Length / 1024 / 1024); } if (fileSize > allowedFileSize) { ErrorMessage = $"文件大小{fileSize}MB超过最大允许上传限制{allowedFileSize}MB"; return(false); } //文件保存目录 var path = "Data/qibucms/upload"; if (!string.IsNullOrEmpty(SubDir)) { path = string.Format("{0}/{1}", path, SubDir); } switch (DNType) { case 1: path = string.Format("{0}/{1}/", path, DateTime.Now.Year); break; case 2: path = string.Format("{0}/{1:yyyyMM}/", path, DateTime.Now); break; case 3: path = string.Format("{0}/{1:yyyyMMdd}/", path, DateTime.Now); break; case 4: path = string.Format("{0}/{1:yyyy/MM}/", path, DateTime.Now); break; case 5: path = string.Format("{0}/{1:yyyy/MM/dd}/", path, DateTime.Now); break; case 6: path = string.Format("{0}/{1}/", path, sExt.Trim('.').ToUpper()); break; } //保存文件名 TargetFileName = OriginFileName; switch (FNType) { case -1: TargetFileName = string.Format("{0}{1}", newFileName, sExt); break; case 1: TargetFileName = string.Format("{0}{1}", Guid.NewGuid(), sExt); break; case 2: Random r = new Random(Guid.NewGuid().GetHashCode()); TargetFileName = string.Format("{0:yyyyMMddHHmmss}{1}{2}", DateTime.Now, r.Next(1000, 10000), sExt); break; case 3: TargetFileName = string.Format("{0}{1}", DateTime.Now, OriginFileName); break; case 4: TargetFileName = string.Format("{0}{1}", getRandomChar(8), sExt); break; case 5: TargetFileName = string.Format("{0}{1}", getRandomChar(4), OriginFileName); break; } TargetFilePath = Path.Combine("/", path, TargetFileName); var locator = CallContextServiceLocator.Locator; var appEnv = (IApplicationEnvironment)locator.ServiceProvider.GetService(typeof(IApplicationEnvironment)); var savepath = Path.Combine(appEnv.ApplicationBasePath + "\\wwwroot\\", path); if (!Directory.Exists(savepath)) { Directory.CreateDirectory(savepath); } savepath = Path.Combine(savepath, TargetFileName); ErrorMessage = savepath; await FromFile.SaveAsAsync(savepath); var success = OSSHelper.Upload("qibucloud", Path.Combine(path, TargetFileName), savepath); //PutObject("qibucloud", TargetFilePath, savepath); return(true); } catch (Exception ex) { ErrorMessage = ex.Message; return(false); } }
public InputStreamReaderAnonymousInnerClass2(FromFile outerInstance, UnknownType getInputStream, Charset charset, File file) : base(getInputStream, charset) { this.outerInstance = outerInstance; this._file = file; }