Skip to content

Instantly share code, notes, and snippets.

@homoroselaps
Last active March 15, 2016 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save homoroselaps/e983a1cb51c4568ebf90 to your computer and use it in GitHub Desktop.
Save homoroselaps/e983a1cb51c4568ebf90 to your computer and use it in GitHub Desktop.
Joystick
private void ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e) {
//Wird zu Beginn einer Beruehrung aufgerufen
//Enthaelt die Position als Point (z.B. e.Position.X)
}
private void ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) {
//Wird bei jeder Veraenderung aufgerufen
//Enthaelt die Position als Point oder kumulatives(aufsummiertes) Delta
}
private void ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) {
//Wird am Ende einer Beruehrung aufgerufen
//Enthaelt die Position als Point oder kumulatives(aufsummiertes) Delta
}
//Achtet darauf, das ManipulationMode korrekt gesetzt ist
<Canvas ManipulationMode="TranslateY, TranslateX">
// Breite/Höhe eines Elements exampleControl festlegen
exampleControl.Width = 100.0;
exampleControl.Height = 100.0;
// Breite/Höhe eines Elements exampleControl abfragen
double w = exampleControl.ActualWidth;
double h = exampleControl.ActualHeight;
// Ein element exampleControl in einem Canvas positionieren
exampleControl.SetValue(Canvas.LeftProperty, 21.0);
exampleControl.SetValue(Canvas.TopProperty, 42.0);
// Position eines Elements exampleControl in einem Canvas abfragen
double x = exampleControl.GetValue(Canvas.LeftProperty);
double y = exampleControl.GetValue(Canvas.TopProperty);
private void Page_SizeChanged(object sender, SizeChangedEventArgs e) {
//auslesen der aktuellen Orientierung
var orientation = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().Orientation;
if (orientation.Equals(ApplicationViewOrientation.Landscape)) {
//Wechsel zu VisualState "Landscape"
VisualStateManager.GoToState(this, "Landscape", false);
}
else {
VisualStateManager.GoToState(this, "Portrait", false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment