/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void btnSave_Click(object sender, RoutedEventArgs e) { ShowLock = true; var file = new PictureFile { DateAdded = DateTime.Now, FilePath = _selectedFilePath, IsConfirmed = true }; _db.AddFile(file, _scanGroup.Group.LargePersonGroupId, 2); var newFacesForTraining = false; for (var ix = 0; ix < DetectedFaces.Count; ix++) { var face = DetectedFaces[ix]; var person = new PicturePerson { DateAdded = DateTime.Now, PersonId = face.PersonId, PictureFileId = file.Id, LargePersonGroupId = _scanGroup.Group.LargePersonGroupId, FaceJSON = Newtonsoft.Json.JsonConvert.SerializeObject(face), IsConfirmed = true }; _db.AddPerson(person); if (face.AddToGroup) { var contentControl = face.ContextBinder.Parent as ContentControl; var parentGrid = contentControl.Parent as Grid; var croppedImage = parentGrid.Children[1] as Image; var filePath = face.ImageFile.ToString().Replace("file:///", ""); filePath = filePath.Replace('\\', '/'); var fileName = $"DbId-{person.Id}_" + System.IO.Path.GetFileName(filePath); // unique file name, into training folder var newFilePath = System.IO.Path.Combine(face.PersonSourcePath, fileName); CropToSquare(filePath, newFilePath, face.Left, face.Top, face.Width, face.Height); await AddFaceToLargePersonGroup(_scanGroup.Group.LargePersonGroupId, newFilePath, face.PersonId); newFacesForTraining = true; } } if (newFacesForTraining) { await CheckGroupIsTrained(); } try { await GetNextFile(); } catch (Exception exc) { MainWindow.Log("Error getting next file: " + exc.Message); } }
public void WriteDotsPicture() { var bmp = new BitmapImage(new Uri("Examples/example-arrow.png", UriKind.Relative)); var picFile = new PictureFile('A', bmp, ColorFormat.TriColor); var actual = picFile.GetBytes().PrettyPrint(); var expected = "A0F09000000000<CR>" + "000000000<CR>" + "000100000<CR>" + "000110000<CR>" + "000111000<CR>" + "000111100<CR>" + "111111110<CR>" + "111111112<CR>" + "111111110<CR>" + "000111100<CR>" + "000111000<CR>" + "000110000<CR>" + "000100000<CR>" + "000000000<CR>" + "000000000<CR>"; Assert.AreEqual(expected, actual); }
private static void MoveDate(string filepath, int seconds) { var file = new PictureFile(filepath); Console.WriteLine(file.RecordingDate); Console.WriteLine(file.ShootingDate); file.MoveShootingDate(seconds); file.ApplyChanges(); Console.WriteLine(file.RecordingDate); Console.WriteLine(file.ShootingDate); }
/// <summary> /// Updates the pictureFile /// </summary> /// <param name="pictureFile">pictureFile</param> public virtual void UpdatePictureFile(PictureFile pictureFile) { if (pictureFile == null) { throw new ArgumentNullException("pictureFile"); } _pictureFileRepository.Update(pictureFile); //cache _cacheManager.RemoveByPattern(String.Format(PICTUREFILE_BY_PICTUREID_KEY, pictureFile.PictureId)); //event notification _eventPublisher.EntityUpdated(pictureFile); }
public void AddFile(PictureFile file, string groupId, int processingState) { var lookup = new PictureFileGroupLookup { LargePersonGroupId = groupId, ProcessingState = processingState, }; lookup.PictureFile = file; _db.PictureFileGroupLookups.Add(lookup); _db.SaveChanges(); //db.PictureFiles.Add(file); //db.SaveChanges(); //db.PictureFileGroupLookups.Add(new PictureFileGroupLookup { LargePersonGroupId = groupId, PictureFileId = }) }
public void AddFile(PictureFile file, string groupId, int processingState) { var lastFile = _db.PictureFiles.LastOrDefault(); if (lastFile != null) { file.Id = lastFile.Id + 1; // Yuk, manual indexing rush } else { file.Id = 1; // index starting from 1 } _db.PictureFiles.Add(file); _db.SaveChanges(); _db.PictureFileGroupLookups.Add(new PictureFileGroupLookup { LargePersonGroupId = groupId, PictureFileId = file.Id, ProcessingState = processingState }); _db.SaveChanges(); }
public ActionResult Add(PictureFile pictureFile) { if (Request.Files.Count > 0) { var postedFile = Request.Files[0] as HttpPostedFileBase; string filename = Path.GetFileName(postedFile.FileName); string tempFolder = Path.GetTempPath(); string tempPath = Path.Combine(tempFolder, filename); postedFile.SaveAs(tempPath); _pictureRepository.Add(filename, tempPath, "pictures"); var thumbnail = ResizeImage(tempPath, 128, 128); tempPath = Path.Combine(tempFolder, "128x128_" + filename); thumbnail.Save(tempPath, "jpg", true); _pictureRepository.Add(filename, tempPath, "thumbnails"); } return(RedirectToAction("List", "Picture")); }
private static Packet DemoAnimation() { var text = new TextFile('A') { new TextFileLine("<speed 5 /><picture 1/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 2/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 3/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 4/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 5/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 6/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 6/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 5/> <picture 3/> <picture 1/> <picture 2/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 4/> <picture 2/> <picture 1/> <picture 3/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 3/> <picture 1/> <picture 2/> <picture 4/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 2/> <picture 1/> <picture 3/> <picture 5/>", DisplayMode.Hold), new TextFileLine("<speed 5 /><picture 1/> <picture 2/> <picture 4/> <picture 6/>", DisplayMode.Hold), }; var pic1 = new PictureFile('1', "kirby/frame1.png", ColorFormat.Monochrome); var pic2 = new PictureFile('2', "kirby/frame2.png", ColorFormat.Monochrome); var pic3 = new PictureFile('3', "kirby/frame3.png", ColorFormat.Monochrome); var pic4 = new PictureFile('4', "kirby/frame4.png", ColorFormat.Monochrome); var pic5 = new PictureFile('5', "kirby/frame5.png", ColorFormat.Monochrome); var pic6 = new PictureFile('6', "kirby/frame6.png", ColorFormat.Monochrome); var packet = new Packet(); packet.SetMemory(new FileTable { text, pic1, pic2, pic3, pic4, pic5, pic6 }); packet.Add(new WriteTextCommand(text)); packet.Add(new WritePictureCommand(pic1)); packet.Add(new WritePictureCommand(pic2)); packet.Add(new WritePictureCommand(pic3)); packet.Add(new WritePictureCommand(pic4)); packet.Add(new WritePictureCommand(pic5)); packet.Add(new WritePictureCommand(pic6)); return packet; }
/// <summary> /// FileVersion.Current - 46 bytes /// </summary> /// <returns></returns> public new byte[] ToBytes() { var bytes = new List <byte>(); switch (FileVersion) { case FileVersion.Current: bytes.AddRange(base.ToBytes()); bytes.AddRange(PictureFile.ToBytes(11)); bytes.Add((byte)RefreshTime); bytes.Add((byte)GraphicMode); bytes.Add((byte)X); bytes.AddRange(((ushort)Y).ToBytes()); break; default: throw new FileVersionNotImplementedException(FileVersion); } CheckSize(bytes.Count, GetSize(FileVersion)); return(bytes.ToArray()); }
public override void Execute() { //Select Picture to be displayed StartStep(); bool res2 = CL.EA.UI.Utils.EPG_Milestones_SelectMenuItem("Picture"); if (!res2) { FailStep(CL, "Failed to navigate to Picture"); } CL.EA.UI.Utils.SendIR("SELECT"); res2 = CL.EA.UI.Utils.EPG_Milestones_SelectMenuItem("All Pictures"); CL.EA.UI.Utils.SendIR("SELECT"); if (!res2) { FailStep(CL, "Failed to navigate to All Pictures"); } string CurrentPictureFile; string FirstPictureFile; string timeStamp = ""; res = CL.IEX.IR.SendIR("SELECT_DOWN", out timeStamp, 3); if (!res.CommandSucceeded) { FailStep(CL, res, "Failed to Send IR Key SELECT_DOWN"); } CL.IEX.Wait(3); res = CL.IEX.MilestonesEPG.GetEPGInfo("title", out FirstPictureFile); if (!res.CommandSucceeded) { FailStep(CL, res, "Failed to Get PICTURE file Name"); } if (!PictureFile.Equals(FirstPictureFile)) { do { CL.IEX.Wait(3); res = CL.IEX.IR.SendIR("SELECT_UP", out timeStamp, 3); if (!res.CommandSucceeded) { FailStep(CL, res, "Failed to Send IR Key SELECT_UP"); } CL.IEX.Wait(3); res = CL.IEX.MilestonesEPG.GetEPGInfo("title", out CurrentPictureFile); if (!res.CommandSucceeded) { FailStep(CL, res, "Failed to Get Picture file Name"); } if (PictureFile.Equals(CurrentPictureFile)) { break; } } while (!CurrentPictureFile.Equals(FirstPictureFile)); } //Verify if the item is of type picture content string pictureContent = ""; res = CL.IEX.MilestonesEPG.GetEPGInfo("object", out pictureContent); if (!res.CommandSucceeded) { FailStep(CL, res, "Failed to Get picture content object"); } if (pictureContent != "[object PictureContent]") { FailStep(CL, "Targeted content is not picture object"); } //Verify is the item is playable string isPlayable = ""; res = CL.IEX.MilestonesEPG.GetEPGInfo("isPlayable", out isPlayable); if (!res.CommandSucceeded) { FailStep(CL, res, "Failed to Get isPlayable"); } if (isPlayable != "true") { FailStep(CL, "Targeted picture content is not playable"); } //Select the item CL.IEX.Wait(3); res = CL.IEX.IR.SendIR("SELECT", out timeStamp, 3); if (!res.CommandSucceeded) { FailStep(CL, res, "Failed to Send IR Key SELECT"); } PassStep(); }
private static Packet DemoPicture() { var uri = new Uri("blackfin.png", UriKind.Relative); var image = new BitmapImage(uri); var text = new TextFile('A') {{"<picture B/>", DisplayMode.Rotate}}; var pic = new PictureFile('B', image, ColorFormat.Monochrome); var files = new FileTable { text, pic, }; var packet = new Packet(); packet.SetMemory(files); packet.Add(new WriteTextCommand(text)); packet.Add(new WritePictureCommand(pic)); return packet; }
private async void OpenFileClick(object sender, RoutedEventArgs e) { PictureServiceClient oPicture = new PictureServiceClient(); PictureFile pictureFile = new PictureFile(); var filePicker = new FileOpenPicker(); filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; filePicker.ViewMode = PickerViewMode.Thumbnail; filePicker.FileTypeFilter.Add(".jpg"); filePicker.FileTypeFilter.Add(".png"); filePicker.FileTypeFilter.Add(".bmp"); filePicker.FileTypeFilter.Add(".gif"); if (chkMultipleFiles.IsChecked.Value) { IAsyncOperation<IReadOnlyList<StorageFile>> asyncOp = filePicker.PickMultipleFilesAsync(); IReadOnlyList<StorageFile> fileList = await asyncOp; if (fileList != null) { var myPictures = new List<MyPicture>(); foreach (var file in fileList) { using (IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read)) { var image = new BitmapImage(); image.SetSource(stream); myPictures.Add(new MyPicture { PictureImage = image }); }; } gvPictures.ItemsSource = myPictures; } } else { IAsyncOperation<StorageFile> asyncOp = filePicker.PickSingleFileAsync(); StorageFile file = await asyncOp; if (file != null) { using (IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read)) { BitmapImage image = new BitmapImage(); image.SetSource(stream); IBuffer buffer = await FileIO.ReadBufferAsync(file); byte[] pixeBuffer = buffer.ToArray(); pictureFile.PictureStream = pixeBuffer; pictureFile.PictureName = file.Name; bool rpta = await oPicture.UploadAsync(pictureFile); var myPictures = new MyPicture[] { new MyPicture { PictureImage = image } }; gvPictures.ItemsSource = myPictures; }; } } }
private void client_downloadfileCompleted2(object sender, ServiceReference1.downloadfileCompletedEventArgs e) { if (e.Error == null) { if (e.Result != null && draimgdownloaded == false) { draimgdownloaded = true; BitmapImage bitmapImage = new BitmapImage(); PictureFile pict = new PictureFile(); pict.PictureStream = e.Result; MemoryStream stream = new MemoryStream(pict.PictureStream); bitmapImage.SetSource(stream); Image image = new Image(); image.SetValue(Image.SourceProperty, bitmapImage); image.SetValue(Image.NameProperty, DateTime.Now.TimeOfDay.ToString()); image.SetValue(Image.TagProperty, (listBox1.SelectedItem.ToString())); //image.SetValue(Image.SourceProperty, img); image.SetValue(Image.StretchProperty, System.Windows.Media.Stretch.Fill); image.SetValue(Image.WidthProperty, (double)45); image.SetValue(Image.HeightProperty, (double)45); image.MouseMove += new MouseEventHandler(Element_MouseMove); image.MouseLeftButtonDown += new MouseButtonEventHandler(Element_MouseLeftButtonDown); image.MouseLeftButtonUp += new MouseButtonEventHandler(Element_MouseLeftButtonUp); Canvasdrawarea.Children.Add(image); } else { // MessageBox.Show("Error Downloading the files"); } } }
void client_downloadfileCompleted(object sender, ServiceReference1.downloadfileCompletedEventArgs e) { if (e.Error == null) { if (e.Result != null) { BitmapImage bitmapImage = new BitmapImage(); PictureFile pict = new PictureFile(); pict.PictureStream = e.Result; MemoryStream stream = new MemoryStream(pict.PictureStream); bitmapImage.SetSource(stream); loadimgcanvas(bitmapImage); //loadimage(); } } else { MessageBox.Show("Error Downloading the files"); } }