private void LoadThumbnails() { int m = 15; var margin = new Thickness(0, 0, 15, 15); //var margin = new Thickness(0,0,0,15); double width = (Application.Current.Host.Content.ActualWidth / 2) - 15 * 4; double height = Application.Current.Host.Content.ActualHeight / 3; for (int i = 0; i < LockscreenImages.ImageCount(); i++) { Image img = new Image(); //img.Source = new BitmapImage(new Uri("../Images/alice.jpg", UriKind.Relative)); img.Source = new BitmapImage(new Uri(LockscreenImages.GetPathAsRelative(i), UriKind.Relative)); //img.Source = new BitmapImage(LockscreenImages.GetAsUri(i)); img.Width = width; //img.Height = height; img.Margin = margin; ThumbnailPanel.Children.Add(img); img.Tag = i; //img.Style = Application.Current.Resources["ButtonStyle"] as Style; img.Tap += img_Tap; } //ThumbnailPanel.ItemHeight = 200; //ThumbnailPanel.ItemWidth = 200; //ThumbnailPanel.Margin = margin; //var b = new BitmapImage(new Uri("../Assets/PanoramaBackground.png", UriKind.Relative)); //b.DecodePixelWidth = width; //b.DecodePixelHeight = height; //var ms = new MemoryStream(AppResources.Pic); //Image image = Image.FromFile(fileName); //Image thumb = image.GetThumbnailImage(120, 120, () => false, IntPtr.Zero); //thumb.Save(Path.ChangeExtension(fileName, "thumb")); //var collection = new ObservableCollection<Image>(); //for (int i = 0; i < 38; i++) //{ // Image img = new Image(); // img.Source = b; // img.Width = width; // img.Height = height; // img.Margin = new Thickness(5, 5, 5, 5); // ThumbnailPanel.Children.Add(img); // img.Tag = i; // img.Tap += img_Tap; // //collection.Add(img); //} //List.ItemsSource = collection; }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); string query = string.Empty; if (NavigationContext.QueryString.TryGetValue("ImageSelected", out query)) { _imageIndex = Int32.Parse(query); // set image double width = Application.Current.Host.Content.ActualWidth; //img.Source = new BitmapImage(new Uri("../Images/alice.jpg", UriKind.Relative)); SelectedImage.Source = new BitmapImage(new Uri(LockscreenImages.GetPathAsRelative(_imageIndex), UriKind.Relative)); //img.Source = new BitmapImage(LockscreenImages.GetAsUri(i)); SelectedImage.Width = width; //img.Height = height; } }
private void Choose_Click(object sender, EventArgs e) { var l = new LockscreenImages(); l.SetImage(_imageIndex); }