-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathMainPage.xaml.cs
More file actions
70 lines (60 loc) · 2.62 KB
/
MainPage.xaml.cs
File metadata and controls
70 lines (60 loc) · 2.62 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Windows.Storage;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PhoneApp1.Resources;
namespace PhoneApp1
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
var unmodifiedBmp = await LoadFromUri("Assets/Overlays/19.jpg");
var sticker = await LoadFromUri("Assets/Overlays/nEW.png");
ImgOrg.Source = unmodifiedBmp;
ImgOrgOverlay.Source = sticker;
var modifiedBmp = Overlay(unmodifiedBmp, sticker, new Point(10, 10));
ImgMod.Source = modifiedBmp;
}
public static WriteableBitmap Overlay(WriteableBitmap bmp, WriteableBitmap overlay, Point location)
{
var result = bmp.Clone();
var size = new Size(overlay.PixelWidth, overlay.PixelHeight);
result.Blit(new Rect(location, size), overlay, new Rect(new Point(0, 0), size), WriteableBitmapExtensions.BlendMode.Alpha);
return result;
}
public static async Task<WriteableBitmap> LoadFromUri(string path)
{
return BitmapFactory.FromContent(path);
}
// Sample code for building a localized ApplicationBar
//private void BuildLocalizedApplicationBar()
//{
// // Set the page's ApplicationBar to a new instance of ApplicationBar.
// ApplicationBar = new ApplicationBar();
// // Create a new button and set the text value to the localized string from AppResources.
// ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
// appBarButton.Text = AppResources.AppBarButtonText;
// ApplicationBar.Buttons.Add(appBarButton);
// // Create a new menu item with the localized string from AppResources.
// ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
// ApplicationBar.MenuItems.Add(appBarMenuItem);
//}
}
}