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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
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.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace SmartCharging
{
    public sealed partial class ImagePicker : UserControl
    {   

        FileOpenPicker filePicker;
        CoreApplicationView view;
        String ImagePath;
        public StorageFile storageFile;

        public ImagePicker()
        {
            this.InitializeComponent();
            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 = args.Files[0];
                var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
                var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                await bitmapImage.SetSourceAsync(stream);

                var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);
                this.ImageBrush.ImageSource = bitmapImage;
                this.Placeholder.Visibility = Visibility.Collapsed;

            }
        }

        private void Border_Tapped(object sender, TappedRoutedEventArgs e)
        {
            
        }

        public void setImageSource(Uri uri){
            var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
            bitmapImage.UriSource = uri;
            this.ImageBrush.ImageSource = bitmapImage;
;
        }

        private void Ellipse_Tapped(object sender, TappedRoutedEventArgs e)
        {      
            ImagePath = string.Empty;

            view = CoreApplication.GetCurrentView();
            view.Activated += view_Activated;
            filePicker.PickSingleFileAndContinue();

        }


    }
}

Commits for Nextrek/Android/SmartCharging/SmartCharging_WP/SmartCharging/ImagePicker.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

660 Diff Diff JMBauan picture JMBauan Thu 03 Sep, 2015 08:14:10 +0000
527 JMBauan picture JMBauan Mon 24 Aug, 2015 08:47:39 +0000