Subversion Repository Public Repository

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
119
120
121
122
123
124
125
126
127
128
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;
        public ObservableCollection<object> initialImages;
        ErrorHandler errorHandler;
        ResourceLoader resourceLoader;


        public MultipleImagePicker()
        {
            this.InitializeComponent();
            this.images = new ObservableCollection<StorageFile>();
            this.initialImages = new ObservableCollection<object>();
            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");
        }



        private 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];
          

                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 void AppBarButton_Tapped2(object sender, TappedRoutedEventArgs e)
        {
            Control c = sender as Control;
            object dc = c.DataContext as object;

            initialImages.Remove(dc);
        }

        private  async void AddImagesButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            this.resourceLoader = ResourceLoader.GetForCurrentView("Resources");
            int max = int.Parse(await Config.Instance.getConfigValueByKey("maxSiteImageNumber"));
            if (this.images.Count >= 8)
            {
                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();
        }

        public void setInitialImages(List<Uri> paths)
        {
            for (int i = 0; i < paths.Count; i++)
            {
                initialImages.Add(new { Path = paths[i]});
            }

            this.InitialPreviewList.ItemsSource = initialImages;
        }
    }
}

Commits for Nextrek/Android/SmartCharging/SmartCharging_WP/SmartCharging/MultipleImagePicker.xaml.cs

Diff revisions: vs.
Revision Author Commited Message
752 Diff Diff JMBauan picture JMBauan Wed 16 Sep, 2015 20:06:56 +0000

upload Avatar
Edit site

731 Diff Diff JMBauan picture JMBauan Tue 15 Sep, 2015 10:43:57 +0000
692 Diff Diff JMBauan picture JMBauan Sun 06 Sep, 2015 22:20:31 +0000
660 JMBauan picture JMBauan Thu 03 Sep, 2015 08:14:10 +0000