-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.xaml.cs
129 lines (113 loc) · 4.26 KB
/
Card.xaml.cs
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
129
using IHaveIdeas.ViewModel;
using System;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
//
namespace IHaveIdeas.Card
{
public sealed partial class Card : Page
{
public TranslateTransform _transformVerb;
public TranslateTransform _transformAdjectives;
public TranslateTransform _transformNoun;
public TranslateTransform _transformImage;
public CardViewModel vm;
StatusBar statusBar = StatusBar.GetForCurrentView();
public Card()
{
this.InitializeComponent();
vm = new CardViewModel();
this.DataContext = vm;
vm.ClearGeneratedCards();
NewCard_Click(this, null);
_transformVerb = new TranslateTransform();
_transformAdjectives = new TranslateTransform();
_transformNoun = new TranslateTransform();
_transformImage = new TranslateTransform();
VerbTextBlock.RenderTransform = _transformVerb;
AdjectivesTextBlock.RenderTransform = _transformAdjectives;
NounTextBlock.RenderTransform = _transformNoun;
Image.RenderTransform = _transformImage;
// Hide the status bar
HideStatusbar();
}
private async void HideStatusbar()
{
await statusBar.HideAsync();
}
/// <summary>
/// Loads previous card.
/// </summary>
private void Previous_Button_Click(object sender, RoutedEventArgs e)
{
vm.Previous_Button_Click(sender, e);
}
/// <summary>
/// Generated a new card or old card if user is browsing old cards
/// </summary>
private void NewCard_Click(object sender, RoutedEventArgs e)
{
vm.NewCard_Click(sender, e);
}
private void AdjektiiviTextBlock_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
_transformAdjectives.X += e.Delta.Translation.X;
}
private void SubsanttiiviTextBlock_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
_transformNoun.X += e.Delta.Translation.X;
}
private void RandomKuva_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
_transformImage.X += e.Delta.Translation.X;
}
public void RandomKuva_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
if (_transformImage.X > 80 || _transformImage.X < -80)
{
vm.RandomKuva_ManipulationCompleted();
}
_transformImage.X = 0;
}
public void AdjektiiviTextBlock_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
if (_transformAdjectives.X > 80 || _transformAdjectives.X < -80)
{
vm.AdjektiiviTextBlock_ManipulationCompleted();
}
_transformAdjectives.X = 0;
}
public void SubsanttiiviTextBlock_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
if (_transformNoun.X > 80 || _transformNoun.X < -80)
{
vm.SubsanttiiviTextBlock_ManipulationCompleted();
}
_transformNoun.X = 0;
}
private void Home_button_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(MainPage));
}
private void SavePack_Click(object sender, RoutedEventArgs e)
{
vm.SavePack_Click(sender, e);
}
private void VerbTextBlock_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
if (_transformVerb.X > 80 || _transformVerb.X < -80)
{
vm.VerbiTextBlock_ManipulationCompleted();
}
_transformVerb.X = 0;
}
private void VerbTextBlock_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
_transformVerb.X += e.Delta.Translation.X;
}
}
}