Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
using SmartCharging.Common;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
using Windows.ApplicationModel.Resources;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
namespace SmartCharging
{
public sealed partial class MultipleImagePicker : UserControl
{
FileOpenPicker filePicker;
CoreApplicationView view;
public ObservableCollection<StorageFile> images;
ErrorHandler errorHandler;
ResourceLoader resourceLoader;
public MultipleImagePicker()
{
this.InitializeComponent();
this.images = new ObservableCollection<StorageFile>();
errorHandler = new ErrorHandler();
this.PreviewList.ItemsSource = images;
filePicker = new FileOpenPicker();
filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
filePicker.ViewMode = PickerViewMode.Thumbnail;
// Filter to include a sample subset of file types
filePicker.FileTypeFilter.Clear();
filePicker.FileTypeFilter.Add(".bmp");
filePicker.FileTypeFilter.Add(".png");
filePicker.FileTypeFilter.Add(".jpeg");
filePicker.FileTypeFilter.Add(".jpg");
}
async void view_Activated(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args1)
{
FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;
if (args != null)
{
if (args.Files.Count == 0) return;
view.Activated -= view_Activated;
StorageFile storageFile = args.Files[0];
/*using(var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read)){
// This is where the byteArray to be stored.
var bytes = new byte[stream.Size];
// This returns IAsyncOperationWithProgess, so you can add additional progress handling
await stream.ReadAsync(bytes.AsBuffer(), (uint)stream.Size, Windows.Storage.Streams.InputStreamOptions.None);
}
var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
await bitmapImage.SetSourceAsync(stream);
var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);*/
images.Add(storageFile);
}
}
private void AppBarButton_Tapped(object sender, TappedRoutedEventArgs e)
{
Control c = sender as Control;
StorageFile dc = c.DataContext as StorageFile;
images.Remove(dc);
}
private async void AddImagesButton_Tapped(object sender, TappedRoutedEventArgs e)
{
this.resourceLoader = ResourceLoader.GetForCurrentView("Resources");
if (this.images.Count >= 2)
{
await errorHandler.ShowError(this.resourceLoader.GetString("MaximumNumberOfPhotosMessage"));
}
else
{
view = CoreApplication.GetCurrentView();
view.Activated += view_Activated;
filePicker.PickSingleFileAndContinue();
}
}
private void Image_Tapped(object sender, TappedRoutedEventArgs e)
{
FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
}
private void Image_Flyout_Tapped(object sender, TappedRoutedEventArgs e)
{
this.ImagePreviewFlyout.Hide();
}
}
}
|
Revision |
Author |
Commited |
Message |
660
|
JMBauan
|
Thu 03 Sep, 2015 08:14:10 +0000 |
|