/// <summary> /// Gets the photos from the details array /// </summary> /// <returns>A <see cref="PhotoCollection"/></returns> private static PhotoCollection ParsePhotos() { PhotoCollection photoCollection = new PhotoCollection(); var photoStrings = _contactDetails.Where(s => s.StartsWith("PHOTO;")); foreach (string photoStr in photoStrings) { Photo photo = new Photo(); if (photoStr.Replace("PHOTO;", "").StartsWith("JPEG:")) { photo.PhotoURL = photoStr.Replace("PHOTO;JPEG:", "").Trim(); photo.Encoding = PhotoEncoding.JPEG; photo.Type = PhotoType.URL; photoCollection.Add(photo); } else if (photoStr.Contains("JPEG") && photoStr.Contains("ENCODING=BASE64")) { string photoString = ""; int photoStrIndex = Array.IndexOf(_contactDetails, photoStr); while (true) { if (photoStrIndex < _contactDetails.Length) { photoString += _contactDetails[photoStrIndex]; photoStrIndex++; if (photoStrIndex < _contactDetails.Length && _contactDetails[photoStrIndex].StartsWith("PHOTO;")) { break; } } else { break; } } photoString = photoString.Trim(); photoString = photoString.Replace("PHOTO;", ""); photoString = photoString.Replace("JPEG", ""); photoString = photoString.Replace("ENCODING=BASE64", ""); photoString = photoString.Trim(';', ':'); photo.Encoding = PhotoEncoding.JPEG; photo.Picture = Helper.GetImageFromBase64String(photoString); photo.Type = PhotoType.Image; photoCollection.Add(photo); } else if (photoStr.Replace("PHOTO;", "").StartsWith("GIF:")) { photo.PhotoURL = photoStr.Replace("PHOTO;GIF:", "").Trim(); photo.Encoding = PhotoEncoding.GIF; photo.Type = PhotoType.URL; photoCollection.Add(photo); } } return(photoCollection); }
public void IsCommonsMultiplePages() { var options = new PhotoSearchOptions { IsCommons = true, Text = "photochrom", SortOrder = PhotoSearchSortOrder.DatePostedDescending, PerPage = 10, Page = 1, Extras = PhotoSearchExtras.DateUploaded }; var allPhotos = new PhotoCollection(); for (var i = 0; i < 10; i++) { options.Page = i + 1; var photos = Instance.PhotosSearch(options); var ids = photos.Select(p => p.PhotoId).ToArray(); var photo = allPhotos.FirstOrDefault(p => ids.Contains(p.PhotoId)); if (photo != null) { Assert.Fail("Duplicate photo {0} found on page {1}", photo.PhotoId, i + 1); } Console.WriteLine(Instance.LastRequest); Console.WriteLine(Instance.LastResponse); foreach (var p in photos) { allPhotos.Add(p); } } }
private void SaveImage(object sender, RoutedEventArgs e) { var bits = ConvertBitmapSourceToByteArray(image1.Source); Photo item = null; if (photoType == PhotoType.Laptop) { item = new Photo { Id = 0, ProductId = selectedcomputer.Id, ProductType = photoType, photo = bits } } ; else { item = new Photo { Id = 0, ProductId = selectedhandphone.Id, ProductType = photoType, photo = bits } }; var dc = new PhotoCollection(); var id = dc.Add(item); if (id > 0) { this.Model = item; } else { this.Model = null; } }
public PhotoCollection VtPhotosGetNotInSet() { var photoCollection = new PhotoCollection(); var startTime = DateTime.Now; PhotoCollection searchedPhotosForPage = null; var page = 1; do { RaiseSearchProgressEvent("PhotosGetNotInSet", photoCollection.Count, startTime); var options = new PartialSearchOptions { PrivacyFilter = PrivacyFilter.None, //UserId = "me", //MediaType = MediaType.All, PerPage = SearchOptions_PerPage_MAX, // Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500. Page = page, // The page of results to return.If this argument is omitted, it defaults to 1. Extras = PhotoSearchExtras.All, // co chci, aby mi flickr api vratilo!! //Tags = tag, //TagMode = TagMode.AnyTag }; searchedPhotosForPage = PhotosGetNotInSet(options); foreach (var photo in searchedPhotosForPage) { photoCollection.Add(photo); } page++; } while (searchedPhotosForPage.Count >= SearchOptions_PerPage_MAX); return(photoCollection); }
private async void loadDirectory_Click(object sender, RoutedEventArgs e) { PhotoOrganizer photoOrganizer = new PhotoOrganizer(); PhotoCollection photoCollection = new PhotoCollection(); FolderPicker directoryPicker = new FolderPicker(); directoryPicker.SuggestedStartLocation = PickerLocationId.ComputerFolder; directoryPicker.FileTypeFilter.Add(".jpg"); directoryPicker.FileTypeFilter.Add(".jpeg"); directoryPicker.FileTypeFilter.Add(".png"); directoryPicker.FileTypeFilter.Add(".gif"); directoryPicker.ViewMode = PickerViewMode.Thumbnail; StorageFolder folder = await directoryPicker.PickSingleFolderAsync(); if (folder != null) { StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder); IReadOnlyList<StorageFile> roFiles = await folder.GetFilesAsync(); List<StorageFile> files = roFiles.ToList(); foreach (StorageFile file in files) { if (file.FileType.ToUpper() == ".JPG" || file.FileType.ToUpper() == ".JPEG") { photoCollection.Add(new Photo(file)); } } var currentView = ApplicationView.GetForCurrentView(); CoreApplicationView photoViewer = CoreApplication.CreateNewView(); await photoViewer.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, async () => { var newWindow = Window.Current; var newAppView = ApplicationView.GetForCurrentView(); newAppView.Title = "Photo Viewer"; var frame = new Frame(); frame.Navigate(typeof(CollectionViewer), photoCollection); newWindow.Content = frame; newWindow.Activate(); await ApplicationViewSwitcher.TryShowAsStandaloneAsync( newAppView.Id, ViewSizePreference.UseMinimum, currentView.Id, ViewSizePreference.UseMinimum); } ); } }
public void InsertAndRemove() { Assert.DoesNotThrow(delegate { Photo photo = new Photo(); PhotoCollection photoCollection = new PhotoCollection(); photoCollection.Add(photo); photoCollection[0] = photo; photo = photoCollection[0]; photoCollection.Remove(photo); }); }
/// <summary> /// Loading data from a private store. /// </summary> private void LoadData() { for (var i = 1; i < 62; i++) { PhotoCollection.Add(new Photo { Path = $"http://adx.metulev.com/video/Images/Watermark/Large/FeaturedImage_2x1_Image{i.ToString("00")}.jpg" }); } }
//查看网点照片 private void Button_Click_1(object sender, RoutedEventArgs e) { Button btn = sender as Button; LotteryStation station = alLotteryStations.FirstOrDefault(p => p.Id == Convert.ToInt32(btn.Tag)); var result = JsonConvert.DeserializeObject <Dictionary <string, string> >(station.StationPicListSerialized); PhotoCollection photo = new PhotoCollection(); result.Keys.ToList().ForEach(k => photo.Add(new Photo(k) { Image = u.ByteArrayToBitmapImage(Convert.FromBase64String(result[k])) })); ImageViewer viewer = new ImageViewer(photo) { ImageAllowDrop = Tools.LoginUserHasRights() }; Window win = new Window { Width = 400, Height = 400, Content = viewer, WindowStartupLocation = WindowStartupLocation.CenterOwner, Owner = Application.Current.MainWindow }; win.ShowDialog(); if (!viewer.IsChanged) { return; } if (MessageBox.Show("是否提交更改变?", "提交", MessageBoxButton.OKCancel) != MessageBoxResult.OK) { return; } var dicAllPhoto = viewer.Photos.ToDictionary(ph => ph.PhotoName, ph => ph.base64Value); station.StationPicListSerialized = JsonConvert.SerializeObject(dicAllPhoto); LoginedUserInfo us = Tools.GetLoginedUserInfo(); entities.Logs.Add(new Log { UGuid = us.UGuid, Username = us.UName, Memo = $"更改编号为【{station.Id}】-网点编号为【{station.StationCode}】的网点照片", OptType = (int)OptType.修改, OptTime = DateTime.Now }); entities.SaveChanges(); }
public void LoadPhotos(PeopleCollection people) { PhotosListBox.Items.Clear(); PhotoCollection allPhotos = new PhotoCollection(); foreach (Person p in people) { foreach (Photo photo in p.Photos) { bool add = true; foreach (Photo existingPhoto in allPhotos) { if (string.IsNullOrEmpty(photo.RelativePath)) { add = false; } if (existingPhoto.RelativePath == photo.RelativePath) { add = false; break; } } if (add == true) { allPhotos.Add(photo); } } if (allPhotos.Count == 0) { View.Visibility = Visibility.Collapsed; } else { View.Visibility = Visibility.Visible; } } foreach (Photo photo in allPhotos) { PhotosListBox.Items.Add(photo); } if (PhotosListBox.Items.Count > 0) { PhotosListBox.SelectedIndex = 0; } }
public PhotoCollection VtPhotosSearchByTag(string tag) { var photoCollection = new PhotoCollection(); //## Photo Extras // One of the hardest things to understand initially is that not all properties are returned by Flickr, you have to explicity request them. //For example the following code would be used to return the Tags and the LargeUrl for a selection of photos: //~~~ //var options = new PhotoSearchOptions //{ // Tags = "colorful", // PerPage = 20, // Page = 1, // Extras = PhotoSearchExtras.LargeUrl | PhotoSearchExtras.Tags //}; var startTime = DateTime.Now; PhotoCollection searchedPhotosForPage = null; var page = 1; do { RaiseSearchProgressEvent("PhotosSearch", photoCollection.Count, startTime); var options = new PhotoSearchOptions { PrivacyFilter = PrivacyFilter.None, UserId = "me", MediaType = MediaType.All, PerPage = SearchOptions_PerPage_MAX, // Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500. Page = page, // The page of results to return.If this argument is omitted, it defaults to 1. Extras = PhotoSearchExtras.All, // co chci, aby mi flickr api vratilo!! Tags = tag, TagMode = TagMode.AnyTag }; searchedPhotosForPage = PhotosSearch(options); foreach (var photo in searchedPhotosForPage) { photoCollection.Add(photo); } page++; } while (searchedPhotosForPage.Count >= SearchOptions_PerPage_MAX); return(photoCollection); }
private void GetPhotos() { m_AllPhotoList = AlbumBO.Instance.GetPhotos(PhotoID, out m_Album); m_PhotoList = new PhotoCollection(); if (m_Album == null) { return; } m_TotalPhotos = m_AllPhotoList.Count; m_totalListPage = m_AllPhotoList.Count / listCount; if (m_AllPhotoList.Count % listCount > 0) { m_totalListPage += 1; } int i = 0; foreach (Photo photo in AllPhotoList) { i++; if (PhotoID == photo.PhotoID) { m_CurrentPhotoNumber = i; break; } } m_ListPage = i / listCount; if (i % 10 > 0) { m_ListPage += 1; } for (int j = (m_ListPage.Value - 1) * listCount; j < m_AllPhotoList.Count; j++) { if (m_PhotoList.Count == listCount) { break; } m_PhotoList.Add(m_AllPhotoList[j]); } }
/// <summary> /// Display the current file stats /// </summary> public void DisplayStats(PeopleCollection people, SourceCollection sources, RepositoryCollection repositories) { #region fields // Media double photos = 0; double notes = 0; double attachments = 0; double sourcesCount = 0; double repositoriesCount = 0; double citations = 0; double relationshipCitations = 0; PhotoCollection allPhotos = new PhotoCollection(); AttachmentCollection allAttachments = new AttachmentCollection(); // Events double relationships = 0; double marriages = 0; double divorces = 0; double births = 0; double deaths = 0; double occupations = 0; double cremations = 0; double burials = 0; double educations = 0; double religions = 0; double livingFacts = 7; double deceasedFacts = 4 + livingFacts; // Normally a person either has cremation or burial date and place so this counts a 2 events plus death place and death date events plus the normal 7 events. double marriageFacts = 2; double divorceFacts = 1; double totalEvents = 0; double living = 0; double deceased = 0; decimal minimumYear = DateTime.Now.Year; decimal maximumYear = DateTime.MinValue.Year; DateTime?marriageDate = DateTime.MaxValue; DateTime?divorceDate = DateTime.MaxValue; DateTime?birthDate = DateTime.MaxValue; DateTime?deathDate = DateTime.MaxValue; DateTime?cremationDate = DateTime.MaxValue; DateTime?burialDate = DateTime.MaxValue; // Top names string[] maleNames = new string[people.Count]; string[] femaleNames = new string[people.Count]; string[] surnames = new string[people.Count]; // Data quality double progress = 0; int i = 0; // Counter #endregion foreach (Person p in people) { #region top names if (p.Gender == Gender.Male) { maleNames[i] = p.FirstName.Split()[0]; } else { femaleNames[i] = p.FirstName.Split()[0]; } surnames[i] = p.LastName; #endregion #region photos foreach (Photo photo in p.Photos) { bool add = true; foreach (Photo existingPhoto in allPhotos) { if (string.IsNullOrEmpty(photo.RelativePath)) { add = false; } if (existingPhoto.RelativePath == photo.RelativePath) { add = false; break; } } if (add == true) { allPhotos.Add(photo); } } #endregion #region attachments foreach (Attachment attachment in p.Attachments) { bool add = true; foreach (Attachment existingAttachment in allAttachments) { if (string.IsNullOrEmpty(attachment.RelativePath)) { add = false; } if (existingAttachment.RelativePath == attachment.RelativePath) { add = false; break; } } if (add == true) { allAttachments.Add(attachment); } } #endregion if (p.HasNote) { notes++; } #region events and citations if ((!string.IsNullOrEmpty(p.ReligionSource)) && (!string.IsNullOrEmpty(p.ReligionCitation)) && (!string.IsNullOrEmpty(p.Religion))) { citations++; } if ((!string.IsNullOrEmpty(p.CremationSource)) && (!string.IsNullOrEmpty(p.CremationCitation)) && (!string.IsNullOrEmpty(p.CremationPlace) || p.CremationDate > DateTime.MinValue)) { citations++; } if ((!string.IsNullOrEmpty(p.OccupationSource)) && (!string.IsNullOrEmpty(p.OccupationCitation)) && (!string.IsNullOrEmpty(p.Occupation))) { citations++; } if ((!string.IsNullOrEmpty(p.EducationSource)) && (!string.IsNullOrEmpty(p.EducationCitation)) && (!string.IsNullOrEmpty(p.Education))) { citations++; } if ((!string.IsNullOrEmpty(p.BirthSource)) && (!string.IsNullOrEmpty(p.BirthCitation)) && ((!string.IsNullOrEmpty(p.BirthPlace)) || p.BirthDate > DateTime.MinValue)) { citations++; } if ((!string.IsNullOrEmpty(p.DeathSource)) && (!string.IsNullOrEmpty(p.DeathCitation)) && ((!string.IsNullOrEmpty(p.DeathPlace)) || p.DeathDate > DateTime.MinValue)) { citations++; } if ((!string.IsNullOrEmpty(p.BurialSource)) && (!string.IsNullOrEmpty(p.BurialCitation)) && ((!string.IsNullOrEmpty(p.BurialPlace)) || p.BurialDate > DateTime.MinValue)) { citations++; } foreach (Relationship rel in p.Relationships) { if (rel.RelationshipType == RelationshipType.Spouse) { SpouseRelationship spouseRel = ((SpouseRelationship)rel); marriages++; if (!string.IsNullOrEmpty(spouseRel.MarriageCitation) && !string.IsNullOrEmpty(spouseRel.MarriageSource) && (!string.IsNullOrEmpty(spouseRel.MarriagePlace) || spouseRel.MarriageDate > DateTime.MinValue)) { relationshipCitations++; } if (!string.IsNullOrEmpty(spouseRel.MarriagePlace)) { progress++; } if (spouseRel.MarriageDate != null) { if (spouseRel.MarriageDate > DateTime.MinValue) { marriageDate = spouseRel.MarriageDate; progress++; } } if (spouseRel.SpouseModifier == SpouseModifier.Former) { divorces++; if (spouseRel.DivorceDate != null) { if (spouseRel.DivorceDate > DateTime.MinValue) { divorceDate = spouseRel.DivorceDate; progress++; } } if (!string.IsNullOrEmpty(spouseRel.DivorceCitation) && !string.IsNullOrEmpty(spouseRel.DivorceSource) && spouseRel.DivorceDate > DateTime.MinValue) { relationshipCitations++; } } } } if (!string.IsNullOrEmpty(p.Religion)) { religions++; } if (!string.IsNullOrEmpty(p.Education)) { educations++; } if (!string.IsNullOrEmpty(p.Occupation)) { occupations++; } if (p.BurialDate > DateTime.MinValue || !string.IsNullOrEmpty(p.BurialPlace)) { burials++; } if (p.CremationDate > DateTime.MinValue || !string.IsNullOrEmpty(p.CremationPlace)) { cremations++; } if (p.DeathDate > DateTime.MinValue || !string.IsNullOrEmpty(p.DeathPlace)) { deaths++; } if (p.BirthDate > DateTime.MinValue || !string.IsNullOrEmpty(p.BirthPlace)) { births++; } #endregion #region min/max dates if (p.BirthDate != null) { birthDate = p.BirthDate; } if (p.DeathDate != null) { deathDate = p.DeathDate; } if (p.CremationDate != null) { cremationDate = p.CremationDate; } if (p.BurialDate != null) { burialDate = p.BurialDate; } DateTime?yearmin = year(marriageDate, divorceDate, birthDate, deathDate, cremationDate, burialDate, "min"); DateTime?yearmax = year(marriageDate, divorceDate, birthDate, deathDate, cremationDate, burialDate, "max"); if (minimumYear > yearmin.Value.Year) { minimumYear = yearmin.Value.Year; } if (maximumYear < yearmax.Value.Year && yearmax.Value.Year <= DateTime.Now.Year) { maximumYear = yearmax.Value.Year; } #endregion relationships += p.Relationships.Count; #region progress if (!string.IsNullOrEmpty(p.FirstName)) { progress++; } if (!string.IsNullOrEmpty(p.LastName)) { progress++; } if (!string.IsNullOrEmpty(p.BirthPlace)) { progress++; } if (p.BirthDate > DateTime.MinValue) { progress++; } if (!string.IsNullOrEmpty(p.Occupation)) { progress++; } if (!string.IsNullOrEmpty(p.Education)) { progress++; } if (!string.IsNullOrEmpty(p.Religion)) { progress++; } if (!p.IsLiving) { deceased++; // Only add progress for one cremation or burial not both if (p.CremationDate > DateTime.MinValue || !string.IsNullOrEmpty(p.CremationPlace)) { if (p.CremationDate > DateTime.MinValue) { progress++; } if (!string.IsNullOrEmpty(p.CremationPlace)) { progress++; } } else { if (p.BurialDate > DateTime.MinValue) { progress++; } if (!string.IsNullOrEmpty(p.BurialPlace)) { progress++; } } if (p.DeathDate > DateTime.MinValue) { progress++; } if (!string.IsNullOrEmpty(p.DeathPlace)) { progress++; } } else { living++; } #endregion i++; } // Will have double counted as marriage/divorce/relationships is always between 2 people marriages = marriages / 2; divorces = divorces / 2; relationships = relationships / 2; relationshipCitations = relationshipCitations / 2; citations += relationshipCitations; // Media data photos = allPhotos.Count; attachments = allAttachments.Count; sourcesCount = sources.Count; repositoriesCount = repositories.Count; Photos.Text = Properties.Resources.Photos + ": " + photos; Notes.Text = Properties.Resources.Notes + ": " + notes; Attachments.Text = Properties.Resources.Attachments + ": " + attachments; Citations.Text = Properties.Resources.Citations + ": " + citations; Sources.Text = Properties.Resources.Sources + ": " + sourcesCount; Repositories.Text = Properties.Resources.Repositories + ": " + repositoriesCount; // Relationship and event data totalEvents = births + deaths + marriages + divorces + cremations + burials + educations + occupations + religions; Marriages.Text = Properties.Resources.Marriages + ": " + marriages; Divorces.Text = Properties.Resources.Divorces + ": " + divorces; MinYear.Text = Properties.Resources.EarliestKnownEvent + ": " + minimumYear; if (maximumYear == DateTime.MinValue.Year) { MaxYear.Text = Properties.Resources.LatestKnownEvent + ": " + DateTime.Now.Year; } else { MaxYear.Text = Properties.Resources.LatestKnownEvent + ": " + maximumYear; } if (totalEvents == 0) { MinYear.Text = Properties.Resources.EarliestKnownEvent + ": "; MaxYear.Text = Properties.Resources.LatestKnownEvent + ": "; } TotalFactsEvents.Text = Properties.Resources.FactsEvents + ": " + totalEvents; Relationships.Text = Properties.Resources.Relationships + ": " + relationships; // Top 3 names string[,] mostCommonNameMale3 = Top3(maleNames); string[,] mostCommonNameFemale3 = Top3(femaleNames); string[,] mostCommonSurname3 = Top3(surnames); FemaleNames.Text = Properties.Resources.TopGirlsNames + ": \n" + "1. " + mostCommonNameFemale3[0, 0] + " " + mostCommonNameFemale3[0, 1] + " 2. " + mostCommonNameFemale3[1, 0] + " " + mostCommonNameFemale3[1, 1] + " 3. " + mostCommonNameFemale3[2, 0] + " " + mostCommonNameFemale3[2, 1]; MaleNames.Text = Properties.Resources.TopBoysNames + ": \n" + "1. " + mostCommonNameMale3[0, 0] + " " + mostCommonNameMale3[0, 1] + " 2. " + mostCommonNameMale3[1, 0] + " " + mostCommonNameMale3[1, 1] + " 3. " + mostCommonNameMale3[2, 0] + " " + mostCommonNameMale3[2, 1]; Surnames.Text = Properties.Resources.TopSurnames + ": \n" + "1. " + mostCommonSurname3[0, 0] + " " + mostCommonSurname3[0, 1] + " 2. " + mostCommonSurname3[1, 0] + " " + mostCommonSurname3[1, 1] + " 3. " + mostCommonSurname3[2, 0] + " " + mostCommonSurname3[2, 1]; #region data quality // Data quality is a % measuring the number of sourced events converted to a 5 * rating star1.Visibility = Visibility.Collapsed; star2.Visibility = Visibility.Collapsed; star3.Visibility = Visibility.Collapsed; star4.Visibility = Visibility.Collapsed; star5.Visibility = Visibility.Collapsed; if (totalEvents > 0) { double dataQuality = citations / totalEvents; string tooltip = Math.Round(dataQuality * 100, 2) + "%"; star1.ToolTip = tooltip; star2.ToolTip = tooltip; star3.ToolTip = tooltip; star4.ToolTip = tooltip; star5.ToolTip = tooltip; if (dataQuality >= 0) { star1.Visibility = Visibility.Visible; } if (dataQuality >= 0.2) { star2.Visibility = Visibility.Visible; } if (dataQuality >= 0.4) { star3.Visibility = Visibility.Visible; } if (dataQuality >= 0.6) { star4.Visibility = Visibility.Visible; } if (dataQuality >= 0.8) { star5.Visibility = Visibility.Visible; } } #endregion #region progress // Progress is a measure of the completness of a family tree // When a person's fields are completed the completeness score increases (ignores suffix as most people won't have one) double totalProgress = progress / ((living * livingFacts) + (deceased * deceasedFacts) + (marriages * marriageFacts) + (divorces * divorceFacts)); if (totalProgress > 100) { FileProgressBar.Value = 100; FileProgressText.Text = "100%"; } else { FileProgressBar.Value = totalProgress * 100; FileProgressText.Text = Math.Round(totalProgress * 100, 2) + "%"; } #endregion #region size //Data size breakdown of file sizes string appLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), App.ApplicationFolderName); appLocation = Path.Combine(appLocation, App.AppDataFolderName); // Absolute path to the photos folder string photoLocation = Path.Combine(appLocation, Photo.PhotosFolderName); string noteLocation = Path.Combine(appLocation, Story.StoriesFolderName); string attachmentLocation = Path.Combine(appLocation, Attachment.AttachmentsFolderName); string xmlLocation = Path.Combine(appLocation, "content.xml"); string currentLocation = App.FamilyCollection.FullyQualifiedFilename; long photoSize = 0; long attachmentSize = 0; long noteSize = 0; long xmlSize = 0; long currentSize = 0; if (Directory.Exists(photoLocation)) { photoSize = FileSize(Directory.GetFiles(photoLocation, "*.*")); } if (Directory.Exists(noteLocation)) { noteSize = FileSize(Directory.GetFiles(noteLocation, "*.*")); } if (Directory.Exists(attachmentLocation)) { attachmentSize = FileSize(Directory.GetFiles(attachmentLocation, "*.*")); } if (File.Exists(xmlLocation)) { xmlSize = (new FileInfo(xmlLocation).Length) / 1024; //convert to Kb } if (File.Exists(currentLocation)) { currentSize = (new FileInfo(currentLocation).Length) / 1024; //convert to Kb } if (currentSize > 0) { DataSize.Text = Properties.Resources.DataSize + ": " + currentSize + " KB - (" + Properties.Resources.Photos + " " + photoSize + " KB, " + Properties.Resources.Notes + " " + noteSize + " KB, " + Properties.Resources.Attachments + " " + attachmentSize + " KB, " + Properties.Resources.Xml + " " + xmlSize + " KB)"; } else { DataSize.Text = Properties.Resources.DataSize + ": "; } #endregion #region charts //Gender bar chart ListCollectionView histogramView = CreateView("Gender", "Gender"); GenderDistributionControl.View = histogramView; GenderDistributionControl.CategoryLabels.Clear(); GenderDistributionControl.CategoryLabels.Add(Gender.Male, Properties.Resources.Male); GenderDistributionControl.CategoryLabels.Add(Gender.Female, Properties.Resources.Female); //Living bar chart ListCollectionView histogramView2 = CreateView("IsLiving", "IsLiving"); LivingDistributionControl.View = histogramView2; LivingDistributionControl.CategoryLabels.Clear(); LivingDistributionControl.CategoryLabels.Add(false, Properties.Resources.Deceased); LivingDistributionControl.CategoryLabels.Add(true, Properties.Resources.Living); //Age group bar chart ListCollectionView histogramView4 = CreateView("AgeGroup", "AgeGroup"); AgeDistributionControl.View = histogramView4; AgeDistributionControl.CategoryLabels.Clear(); AgeDistributionControl.CategoryLabels.Add(AgeGroup.Youth, Properties.Resources.AgeGroupYouth); AgeDistributionControl.CategoryLabels.Add(AgeGroup.Unknown, Properties.Resources.AgeGroupUnknown); AgeDistributionControl.CategoryLabels.Add(AgeGroup.Senior, Properties.Resources.AgeGroupSenior); AgeDistributionControl.CategoryLabels.Add(AgeGroup.MiddleAge, Properties.Resources.AgeGroupMiddleAge); AgeDistributionControl.CategoryLabels.Add(AgeGroup.Adult, Properties.Resources.AgeGroupAdult); #endregion // Ensure the controls are refreshed AgeDistributionControl.Refresh(); SharedBirthdays.Refresh(); LivingDistributionControl.Refresh(); GenderDistributionControl.Refresh(); }
private async void PopulatePassportData() { if (apiKey == null) { IsLoginVisible = Visibility.Visible; return; } var data = StorageService.Instance.Storage.RetrieveList <PassportDataModel>(); if (data != null && data.Count > 0) { IsLoginVisible = Visibility.Visible; IsTabsVisible = Visibility.Collapsed; var dm = data.Where(x => x.PassType == GroupingType).FirstOrDefault(); if (dm != null) { IsLoginVisible = Visibility.Collapsed; IsTabsVisible = Visibility.Visible; RequestToken = new OAuthRequestToken() { Token = dm.Token, TokenSecret = dm.TokenSecret }; AccessToken = new OAuthAccessToken() { Username = dm.UserName, FullName = dm.FullName, ScreenName = dm.ScreenName, Token = dm.Token, TokenSecret = dm.TokenSecret, UserId = dm.UserId, }; //IsLoggedIn = true; _flickr.OAuthAccessToken = AccessToken.Token; _flickr.OAuthAccessTokenSecret = AccessToken.TokenSecret; _flickr.ApiKey = apiKey.APIKey; _flickr.ApiSecret = apiKey.APISecret; var p = await _flickr.PeopleGetInfoAsync(AccessToken.UserId); if (!p.HasError) { LoggedInUser = p.Result; } var favs = await _flickr.FavoritesGetListAsync(AccessToken.UserId); if (!favs.HasError) { var temp = new PhotoCollection(); foreach (var fav in favs.Result) { //fav.MachineTags = "https://c1.staticflickr.com/1/523/buddyicons/118877287@N03_l.jpg?1437204284#118877287@N03"; fav.MachineTags = $"https://c1.staticflickr.com/{fav.IconFarm}/{fav.IconServer}/buddyicons/{fav.UserId}.jpg?"; temp.Add(fav); } FavouritePhotos = temp; } } } else { //no passport so show login button IsLoginVisible = Visibility.Visible; IsTabsVisible = Visibility.Collapsed; } }
private void InitControlValue() { txtStationCode.Text = station.StationCode; txtStationSpecificAddress.Text = station.StationSpecificAddress; txtStationTarget.Text = station.StationTarget; txtStationPhoneNo.Text = station.StationPhoneNo; cmbStationRegion.SelectedItem = station.StationRegion; cmbStationManageType.Text = station.ManageTypeName; cmbStationManageTypeChild.Text = station.ManageTypeProgencyListSerialized; txtUsableArea.Text = station.UsableArea; txtRentDiscount.Text = station.RentDiscount; datePickerCtl.SelectedDate = station.EstablishedTime; cmbPropertyRight.Text = station.PropertyRight ? "自有" : "租赁"; cmbMachineType.Text = station.MachineType ? "双机" : "单机"; cmbCommunicationType.Text = station.CommunicationType ? "CDMA" : "ADSL"; cboAdmin.SelectedItem = station.Administrator; var aaaa = JsonConvert.DeserializeObject <string[]>(station.WelfareGameTypeListSerialized); cbxListBox.InitSelectedCollection(aaaa); txtRelatedPhoneNetNum.Text = station.RelatedPhoneNetNum; txtAgencyNum.Text = station.AgencyNum; txtDepositCardNo.Text = station.DepositCardNo; txtViolation.Text = station.Violation; txtViolation.ToolTip = station.Violation; txtGuaranteeName.Text = station.GuaranteeName; Utility u = new Utility(); var result = JsonConvert.DeserializeObject <Dictionary <string, string> >(station.GuaranteeBase64IdentityPic); PhotoCollection photo = GuaranteeIdentity.Photos; result.Keys.ToList().ForEach(k => photo.Add(new Photo(k) { Image = u.ByteArrayToBitmapImage(Convert.FromBase64String(result[k])) })); HostInformation.txtHostName.Text = station.HostName; HostInformation.txtHostIdentityNo.Text = station.HostIdentityNo; HostInformation.txtHostIdentityAddress.Text = station.HostIdentityAddress; string[] phoneNum = station.HostPhoneNum.Split('⊙'); HostInformation.txtHostPhoneNum1.Text = phoneNum[0]; HostInformation.txtHostPhoneNum2.Text = phoneNum[1]; HostInformation.HostBase64Pic.Source = u.ByteArrayToBitmapImage(Convert.FromBase64String(station.HostBase64Pic)); var hostResult = JsonConvert.DeserializeObject <Dictionary <string, string> >(station.HostBase64IdentityPic); PhotoCollection hostCollection = HostInformation.hostIdentityPic.Photos; hostResult.Keys.ToList().ForEach(k => hostCollection.Add(new Photo(k) { Image = u.ByteArrayToBitmapImage(Convert.FromBase64String(hostResult[k])) })); clerkListBox.ItemsSource = station.Salesclerks.ToList(); var stationPic = JsonConvert.DeserializeObject <Dictionary <string, string> >(station.StationPicListSerialized); PhotoCollection photoCollection = ViewerStationPic.Photos; stationPic.Keys.ToList().ForEach(p => photoCollection.Add(new Photo(p) { Image = u.ByteArrayToBitmapImage(Convert.FromBase64String(stationPic[p])) })); }
private void GetPhotos() { m_AllPhotoList = AlbumBO.Instance.GetPhotos(PhotoID, out m_Album); m_PhotoList = new PhotoCollection(); if (m_Album == null) return; m_TotalPhotos = m_AllPhotoList.Count; m_totalListPage = m_AllPhotoList.Count / listCount; if (m_AllPhotoList.Count % listCount > 0) m_totalListPage += 1; int i = 0; foreach (Photo photo in AllPhotoList) { i++; if (PhotoID == photo.PhotoID) { m_CurrentPhotoNumber = i; break; } } m_ListPage = i / listCount; if (i % 10 > 0) m_ListPage += 1; for (int j = (m_ListPage.Value - 1) * listCount; j < m_AllPhotoList.Count; j++) { if (m_PhotoList.Count == listCount) break; m_PhotoList.Add(m_AllPhotoList[j]); } }
//机主信息 private void Button_Click_7(object sender, RoutedEventArgs e) { Button btn = sender as Button; LotteryStation station = alLotteryStations.FirstOrDefault(p => p.Id == Convert.ToInt32(btn.Tag)); if (null == station) { return; } string[] hostPhoneNum = station.HostPhoneNum.Split('⊙'); HostInformation hostInfo = new HostInformation { txtHostPhoneNum1 = { Text = hostPhoneNum[0] }, txtHostPhoneNum2 = { Text = hostPhoneNum[1] }, txtHostIdentityAddress = { Text = station.HostIdentityAddress }, txtHostName = { Text = station.HostName }, txtHostIdentityNo = { Text = station.HostIdentityNo }, HostBase64Pic = { Source = u.ByteArrayToBitmapImage(Convert.FromBase64String(station.HostBase64Pic)) } }; hostInfo.EnableAllControl(); var result = JsonConvert.DeserializeObject <Dictionary <string, string> >(station.HostBase64IdentityPic); PhotoCollection photo = hostInfo.hostIdentityPic.Photos; result.Keys.ToList().ForEach(k => photo.Add(new Photo(k) { Image = u.ByteArrayToBitmapImage(Convert.FromBase64String(result[k])) })); Window win = new Window { Width = 350, Height = 450, Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner, Content = hostInfo }; win.Closing += (a, b) => { bool changed = false; string hostPhoneNum1 = hostInfo.txtHostPhoneNum1.GetTextBoxText(); string hostPhoneNum2 = hostInfo.txtHostPhoneNum2.GetTextBoxText(); string hostN = hostInfo.txtHostName.GetTextBoxText(); if (!hostN.IsNullOrEmpty()) { changed = station.HostName != hostN; station.HostName = hostN; } if ((!hostPhoneNum1.IsNullOrEmpty() && !hostPhoneNum2.IsNullOrEmpty())) { var t = $"{hostPhoneNum1}⊙{hostPhoneNum2}"; changed = changed || station.HostPhoneNum != t; station.HostPhoneNum = t; } if (!hostInfo.txtHostIdentityNo.GetTextBoxText().IsNullOrEmpty()) { changed = changed || station.HostIdentityNo != hostInfo.txtHostIdentityNo.GetTextBoxText(); station.HostIdentityNo = hostInfo.txtHostIdentityNo.GetTextBoxText(); } if (!hostInfo.txtHostIdentityAddress.GetTextBoxText().IsNullOrEmpty()) { changed = changed || station.HostIdentityAddress != hostInfo.txtHostIdentityAddress.GetTextBoxText(); station.HostIdentityAddress = hostInfo.txtHostIdentityAddress.GetTextBoxText(); } if (null != hostInfo.HostPic) { station.HostBase64Pic = hostInfo.HostPic; changed = true; } if (hostInfo.hostIdentityPic.IsChanged) { station.HostBase64IdentityPic = hostInfo.Identity; changed = true; } if (changed) { LoginedUserInfo us = Tools.GetLoginedUserInfo(); entities.Logs.Add(new Log { UGuid = us.UGuid, Username = us.UName, Memo = $"编辑编号为【{station.Id}】-站点编号为【{station.StationCode}】的机主信息", OptType = (int)OptType.修改, OptTime = DateTime.Now }); } entities.SaveChanges(); btn.Content = station.HostName; }; win.ShowDialog(); }
//查看担保人 private void Button_Click_6(object sender, RoutedEventArgs e) { Button btn = sender as Button; LotteryStation station = alLotteryStations.FirstOrDefault(p => p.Id == Convert.ToInt32(btn.Tag)); if (null == station) { return; } Grid grid = new Grid(); RowDefinition definition = new RowDefinition { Height = GridLength.Auto }; grid.RowDefinitions.Add(definition); grid.RowDefinitions.Add(new RowDefinition()); WrapPanel panel = new WrapPanel(); Grid.SetRow(panel, 0); TextBox inputBox = new TextBox { MinWidth = 150, Text = station.GuaranteeName, Margin = new Thickness(10, 5, 5, 0), Style = this.FindResource("TextBoxCircleBorder") as Style }; Button btnSumbit = new Button { Content = "完成修改", Margin = new Thickness(0, 5, 0, 0) }; panel.Children.Add(new TextBlock { Text = "担保人姓名", Margin = new Thickness(0, 5, 5, 0), VerticalAlignment = VerticalAlignment.Center }); panel.Children.Add(inputBox); panel.Children.Add(btnSumbit); grid.Children.Add(panel); var result = JsonConvert.DeserializeObject <Dictionary <string, string> >(station.GuaranteeBase64IdentityPic); PhotoCollection photo = new PhotoCollection(); result.Keys.ToList().ForEach(k => photo.Add(new Photo(k) { Image = u.ByteArrayToBitmapImage(Convert.FromBase64String(result[k])) })); ImageViewer viewer = new ImageViewer(photo) { MaxDropPhoto = 2 }; Grid.SetRow(viewer, 1); grid.Children.Add(viewer); Window win = new Window { Title = "担保人信息", Width = 320, Height = 300, Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner, Content = grid }; btnSumbit.Click += (s, er) => { if (inputBox.GetTextBoxText() == station.GuaranteeName && !viewer.IsChanged) { return; } if (viewer.IsChanged) { station.GuaranteeBase64IdentityPic = JsonConvert.SerializeObject(viewer.Photos.ToDictionary(key => key.PhotoName, value => value.base64Value)); } btn.Content = station.GuaranteeName = inputBox.GetTextBoxText(); LoginedUserInfo u = Tools.GetLoginedUserInfo(); entities.Logs.Add(new Log { UGuid = u.UGuid, Username = u.UName, Memo = $"编辑编号为【{station.Id}】-站点编号为【{station.StationCode}】的担保人信息", OptType = (int)OptType.修改, OptTime = DateTime.Now }); entities.SaveChanges(); win.Close(); }; panel.IsEnabled = viewer.ImageAllowDrop = Tools.LoginUserHasRights(); win.ShowDialog(); }
/// <summary> /// Gets the photos from the details array /// </summary> /// <returns>A <see cref="PhotoCollection"/></returns> private static PhotoCollection ParsePhotos() { PhotoCollection photoCollection = new PhotoCollection(); var photoStrings = _contactDetails.Where(s => s.StartsWith("PHOTO;")); foreach (string photoStr in photoStrings) { var photoString = photoStr.Replace("PHOTO;", ""); if (photoString.Contains("TYPE=JPEG") || photoString.Contains("TYPE=jpeg")) { photoString = photoString .Replace("TYPE=JPEG", "") .Replace("TYPE=jpeg:", "") .Trim(); if (photoString.Contains("VALUE=URI") || photoString.Contains("VALUE=uri")) { Photo photo = new Photo { PhotoURL = photoString .Replace("VALUE=URI", "") .Replace("VALUE=uri", "") .Trim(';', ':'), Encoding = PhotoEncoding.JPEG, Type = PhotoType.URL }; photoCollection.Add(photo); } else if (photoString.Contains("ENCODING=b")) { int photoStrIndex = Array.IndexOf(_contactDetails, photoStr); while (true) { if (photoStrIndex < _contactDetails.Length) { photoString += _contactDetails[photoStrIndex]; photoStrIndex++; if (photoStrIndex < _contactDetails.Length && _contactDetails[photoStrIndex].StartsWith("PHOTO;")) { break; } } else { break; } } photoString = photoString .Replace("PHOTO;", "") .Replace("JPEG", "") .Replace("jpeg", "") .Replace("ENCODING=b", "") .Trim(';', ':') .Trim(); try { var photo = new Photo { Encoding = PhotoEncoding.JPEG, Picture = Helper.GetImageFromBase64String(photoString), Type = PhotoType.Image }; photoCollection.Add(photo); } catch (Exception e) { Console.WriteLine(e.Message); //TODO: send error to logger } } } else if (photoString.Contains("TYPE=GIF") || photoString.Contains("TYPE=gif")) { photoString = photoString .Replace("TYPE=URI", "") .Replace("TYPE=uri", "") .Trim(); if (photoString.Contains("VALUE=URI") || photoString.Contains("VALUE=uri")) { Photo photo = new Photo { PhotoURL = photoString .Replace("VALUE=URI", "") .Replace("VALUE=uri", "") .Trim(';', ':') .Trim(), Encoding = PhotoEncoding.GIF, Type = PhotoType.URL }; photoCollection.Add(photo); } } } return(photoCollection); }
/// <summary> /// This method takes a bounding box and returns /// Photocollection covering the bounding box from /// cache or from downloaded data /// </summary> /// <param name="west"></param> /// <param name="south"></param> /// <param name="east"></param> /// <param name="north"></param> /// <returns></returns> private PhotoCollection GetPhotoCollection(double west, double south , double east, double north) { PhotoCollection collection = new PhotoCollection(); double tileSize = 10.0; /* * //base the tile size on the max viewing distance * double maxDistance = m_maxdistance;// Math.Sqrt(m_maximumDistanceSq); * * double factor = maxDistance / m_world.EquatorialRadius; * // True view range * if (factor < 1) * tileSize = Angle.FromRadians(Math.Abs(Math.Asin(maxDistance / m_world.EquatorialRadius)) * 2).Degrees; * else * tileSize = Angle.FromRadians(Math.PI).Degrees; * * tileSize = (180 / (int)(180 / tileSize)); * * if (tileSize == 0) * tileSize = 0.1; */ //Log.Write(Log.Levels.Debug, string.Format("TS: {0} -> {1}", name, tileSize)); //not working for some reason... //int startRow = MathEngine.GetRowFromLatitude(south, tileSize); //int endRow = MathEngine.GetRowFromLatitude(north, tileSize); //int startCol = MathEngine.GetColFromLongitude(west, tileSize); //int endCol = MathEngine.GetColFromLongitude(east, tileSize); double currentSouth = -90; //for (int row = 0; row <= endRow; row++) XmlSerializer serializer = new XmlSerializer(typeof(PhotoCollection)); while (currentSouth < 90) { double currentNorth = currentSouth + tileSize; if (currentSouth > north || currentNorth < south) { currentSouth += tileSize; continue; } double currentWest = -180; while (currentWest < 180) // for (int col = startCol; col <= endCol; col++) { double currentEast = currentWest + tileSize; if (currentWest > east || currentEast < west) { currentWest += tileSize; continue; } if (!Directory.Exists(m_cachedir)) { Directory.CreateDirectory(m_cachedir); } string collectionFilename = m_cachedir + currentEast + "_" + currentWest + "_" + currentNorth + "_" + currentSouth + ".xml"; PhotoCollection currentPhotoCollection; if (File.Exists(collectionFilename)) { currentPhotoCollection = (PhotoCollection)serializer.Deserialize( new FileStream(collectionFilename, FileMode.Open)); } else { searchOptions.BoundaryBox = new BoundaryBox(currentWest, currentSouth, currentEast, currentNorth); PhotoCollection photos = flickr.PhotosSearch(searchOptions); currentPhotoCollection = photos; serializer.Serialize(new FileStream( collectionFilename, FileMode.Create), currentPhotoCollection); } for (int i = 0; i < currentPhotoCollection.Count; i++) { collection.Add(currentPhotoCollection[i]); } currentWest += tileSize; } currentSouth += tileSize; } return(collection); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (PhotoID < 1) { ShowError(new InvalidParamError("id")); } if (Album == null) { ShowError("您要查看的图片不存在或已被删除"); } pageNumber = _Request.Get <int>("page", 1); if (_Request.IsClick("submitPassword")) { ProcessPassword(); } using (ErrorScope es = new ErrorScope()) { bool canVisit = AlbumBO.Instance.CanVisitAlbum(My, Album); if (canVisit == false) { es.CatchError <ErrorInfo>(delegate(ErrorInfo error) { if (IsAjaxRequest) { AlertError(error.Message); m_Photo = new Photo(); m_PhotoList = new PhotoCollection(); m_PhotoList.Add(m_Photo); return; } if (error is NoPermissionVisitAlbumBeacuseNeedPasswordError) { IsShowPasswordBox = true; } else { ShowError(error.Message); } }); } } m_CommentPageSize = 10; if (_Request.IsClick("addcomment")) { AddComment(); } //m_PhotoList = AlbumBO.Instance.GetPhotos(m_Photo.AlbumID, 1, m_Photo.Album.TotalPhotos); m_CommentList = CommentBO.Instance.GetComments(Photo.PhotoID, CommentType.Photo, pageNumber, m_CommentPageSize, false, out m_TotalCommentCount); UserBO.Instance.WaitForFillSimpleUsers <Comment>(m_CommentList); SetPager("commentlist", null, pageNumber, m_CommentPageSize, m_TotalCommentCount); if (IsSpace == false) { AddNavigationItem(FunctionName, BbsRouter.GetUrl("app/album/index")); AddNavigationItem(string.Concat("我的", FunctionName), BbsRouter.GetUrl("app/album/index")); AddNavigationItem(Album.Name, BbsRouter.GetUrl("app/album/list", "id=" + Album.AlbumID)); AddNavigationItem(Photo.Name); } else { AddNavigationItem(string.Concat(AppOwner.Username, "的空间"), UrlHelper.GetSpaceUrl(AppOwnerUserID)); AddNavigationItem(string.Concat("主人的", FunctionName), UrlHelper.GetPhotoIndexUrl(AppOwnerUserID)); AddNavigationItem(Album.Name, UrlHelper.GetAlbumViewUrl(Album.AlbumID)); AddNavigationItem("查看图片"); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (PhotoID < 1) { ShowError(new InvalidParamError("id")); } if (Album == null) ShowError("您要查看的图片不存在或已被删除"); pageNumber = _Request.Get<int>("page", 1); if (_Request.IsClick("submitPassword")) { ProcessPassword(); } using (ErrorScope es = new ErrorScope()) { bool canVisit = AlbumBO.Instance.CanVisitAlbum(My, Album); if (canVisit == false) { es.CatchError<ErrorInfo>(delegate(ErrorInfo error) { if (IsAjaxRequest) { AlertError(error.Message); m_Photo = new Photo(); m_PhotoList = new PhotoCollection(); m_PhotoList.Add(m_Photo); return; } if (error is NoPermissionVisitAlbumBeacuseNeedPasswordError) { IsShowPasswordBox = true; } else ShowError(error.Message); }); } } m_CommentPageSize = 10; if (_Request.IsClick("addcomment")) AddComment(); //m_PhotoList = AlbumBO.Instance.GetPhotos(m_Photo.AlbumID, 1, m_Photo.Album.TotalPhotos); m_CommentList = CommentBO.Instance.GetComments(Photo.PhotoID, CommentType.Photo, pageNumber, m_CommentPageSize, false, out m_TotalCommentCount); UserBO.Instance.WaitForFillSimpleUsers<Comment>(m_CommentList); SetPager("commentlist", null, pageNumber, m_CommentPageSize, m_TotalCommentCount); if (IsSpace == false) { AddNavigationItem(FunctionName, BbsRouter.GetUrl("app/album/index")); AddNavigationItem(string.Concat("我的", FunctionName), BbsRouter.GetUrl("app/album/index")); AddNavigationItem(Album.Name, BbsRouter.GetUrl("app/album/list", "id=" + Album.AlbumID)); AddNavigationItem(Photo.Name); } else { AddNavigationItem(string.Concat(AppOwner.Username, "的空间"), UrlHelper.GetSpaceUrl(AppOwnerUserID)); AddNavigationItem(string.Concat("主人的", FunctionName), UrlHelper.GetPhotoIndexUrl(AppOwnerUserID)); AddNavigationItem(Album.Name,UrlHelper.GetAlbumViewUrl(Album.AlbumID)); AddNavigationItem("查看图片"); } }
public void AddPhoto(Photo photo) { //Some biz logic //... PhotoCollection.Add(photo); }