private void SimpleOrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown) { HandleOrientationChanged(false); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { //获取参数打开视频 param = e.Parameter as MediaPlayerSource; PlayerTitle.Text = param.Title + '-' + param.PartTitle; //加载弹幕 LoadDanmaku(); //播放视频 Play(); //设置屏幕方向 DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; //获取方向传感器 simpleorientation = SimpleOrientationSensor.GetDefault(); if (simpleorientation == null) { SettingsRow0.Visibility = Visibility.Collapsed; } //这两个东西有最小值,加载会出发ValueChanged事件,这里等它加载完再添加委托 DanmakuSizeSlider.Loaded += ((sender, args) => DanmakuSizeSlider.ValueChanged += DanmakuSizeSlider_ValueChanged); DanmakuSpeedSlider.Loaded += ((sender, args) => DanmakuSpeedSlider.ValueChanged += DanmakuSpeedSlider_ValueChanged); StatusText.Text = ""; Status.Visibility = Visibility.Visible; //设置可拖动区域 Window.Current.SetTitleBar(DraggableArea); //设置一些控件的初始值 SetValues(); }
public MainPage() { this.InitializeComponent(); sensor = SimpleOrientationSensor.GetDefault(); sensor.OrientationChanged += Sensor_OrientationChanged; }
private void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown) { _deviceOrientation = args.Orientation; } }
public MapControl() { Background = new SolidColorBrush(Colors.White); // DON'T REMOVE! Touch events do not work without a background Children.Add(_renderTarget); Children.Add(_bboxRect); _renderTarget.PaintSurface += _renderTarget_PaintSurface; Map = new Map(); Loaded += MapControlLoaded; SizeChanged += MapControlSizeChanged; CompositionTarget.Rendering += CompositionTarget_Rendering; _renderer = new MapRenderer(); PointerWheelChanged += MapControl_PointerWheelChanged; ManipulationMode = ManipulationModes.Scale | ManipulationModes.TranslateX | ManipulationModes.TranslateY | ManipulationModes.Rotate; ManipulationDelta += OnManipulationDelta; ManipulationCompleted += OnManipulationCompleted; ManipulationInertiaStarting += OnManipulationInertiaStarting; Tapped += OnSingleTapped; DoubleTapped += OnDoubleTapped; var orientationSensor = SimpleOrientationSensor.GetDefault(); if (orientationSensor != null) { orientationSensor.OrientationChanged += (sender, args) => Task.Run(() => Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Refresh)) .ConfigureAwait(false); } }
public PlaylistVideoPage() { InitializeComponent(); Pivot.SelectionChanged += PivotOnSelectionChanged; SubscribePlayerEvents(player); _autoPlay = SettingsHelper.GetIsAutoPlayVideo(); player.AutoPlay = _autoPlay; CommentTextBox.GotFocus += CommentTextBoxOnGotFocus; CommentTextBox.LostFocus += CommentTextBoxOnLostFocus; CommentTextBox.TextChanged += CommentTextBoxOnTextChanged; PhoneApplicationService.Current.Deactivated += Current_Deactivated; PhoneApplicationService.Current.Activated += Current_Activated; LayoutRoot.SizeChanged += OnLayoutRootSizeChanged; _sensor = SimpleOrientationSensor.GetDefault(); _sendApplicationBar = new ApplicationBar(); _sendApplicationBarButton = ApplicationBarHelper.CreateApplicationBarIconButton("/Toolkit.Content/ApplicationBar.Send.png", AppResources.Send, Send_Click); _sendApplicationBar.Buttons.Add(_sendApplicationBarButton); _currentApplicationBar = new ApplicationBar(); _currentApplicationBar.Mode = ApplicationBarMode.Minimized; _currentApplicationBar.Buttons.Add(ApplicationBarHelper.CreateApplicationBarIconButton("/Toolkit.Content/ApplicationBar.Home.png", AppResources.Home, Home_Click)); _currentApplicationBar.MenuItems.Add(ApplicationBarHelper.CreateAApplicationBarMenuItem(AppResources.CopyVideoLink, CopyVideoUrl_Click)); _favoritesApplicationBarButton = ApplicationBarHelper.CreateApplicationBarIconButton("/Toolkit.Content/ApplicationBar.StarAdd.png", AppResources.AddToFavorites, AddToFavorites_Click); ApplicationBar = _currentApplicationBar; }
private async void OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { SimpleOrientation orientation = args.Orientation; switch (orientation) { case SimpleOrientation.NotRotated: Rotate(0); break; case SimpleOrientation.Rotated90DegreesCounterclockwise: Rotate(90); break; case SimpleOrientation.Rotated180DegreesCounterclockwise: Rotate(180); break; case SimpleOrientation.Rotated270DegreesCounterclockwise: Rotate(270); break; case SimpleOrientation.Faceup: break; case SimpleOrientation.Facedown: break; default: break; } }); }
async void MainPage_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { TextSimpleOrientation.Text = "SimpleOrientation : " + args.Orientation.ToString(); }); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { OrientationSensor = OrientationSensor.GetDefault(); if (OrientationSensor == null) { SimpleOrientationSensor = SimpleOrientationSensor.GetDefault(); if (SimpleOrientationSensor == null) { throw new Exception("No way of determining orientation"); } } TouchPanel.EnabledGestures = GestureType.Hold | GestureType.Flick | GestureType.HorizontalDrag | GestureType.VerticalDrag | GestureType.DragComplete; vertexBuffer = new DynamicVertexBuffer(graphics.GraphicsDevice, typeof(VertexPositionColor), 8, BufferUsage.WriteOnly); indexBuffer = new DynamicIndexBuffer(graphics.GraphicsDevice, typeof(ushort), 36, BufferUsage.WriteOnly); basicEffect = new BasicEffect(graphics.GraphicsDevice); //(device, null); basicEffect.LightingEnabled = false; basicEffect.VertexColorEnabled = true; basicEffect.TextureEnabled = false; DepthStencilState depthBufferState = new DepthStencilState(); depthBufferState.DepthBufferEnable = true; GraphicsDevice.DepthStencilState = depthBufferState; TetrisState.Initialize(graphics.GraphicsDevice); Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SuppressSystemOverlays = true; graphics.SupportedOrientations = DisplayOrientation.Portrait; base.Initialize(); }
public MapControl() { Background = new SolidColorBrush(Colors.White); // DON'T REMOVE! Touch events do not work without a background Children.Add(_canvas); Children.Add(_selectRectangle); _canvas.IgnorePixelScaling = true; _canvas.PaintSurface += Canvas_PaintSurface; Map = new Map(); Loaded += MapControlLoaded; SizeChanged += MapControlSizeChanged; PointerWheelChanged += MapControl_PointerWheelChanged; ManipulationMode = ManipulationModes.Scale | ManipulationModes.TranslateX | ManipulationModes.TranslateY | ManipulationModes.Rotate; ManipulationDelta += OnManipulationDelta; ManipulationInertiaStarting += OnManipulationInertiaStarting; Tapped += OnSingleTapped; DoubleTapped += OnDoubleTapped; var orientationSensor = SimpleOrientationSensor.GetDefault(); if (orientationSensor != null) { orientationSensor.OrientationChanged += (sender, args) => RunOnUIThread(Refresh); } }
private void InitializeSensor() { _sensor = SimpleOrientationSensor.GetDefault(); if (_sensor != null) { _sensor.OrientationChanged += OrientationChanged; } }
// SimpleOrientationSensor handler async void OnSimpleOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SetSimpleOrientationText(args.Orientation); }); }
void OnOrientationSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { // Only update orientation if the device is not parallel to the ground if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown) { deviceOrientation = args.Orientation; } }
public override void OnAttachedToWindow() { base.OnAttachedToWindow(); // Cannot call this in ctor: see // https://stackoverflow.com/questions/10593022/monodroid-error-when-calling-constructor-of-custom-view-twodscrollview#10603714 RaiseConfigurationChanges(); SimpleOrientationSensor.GetDefault().OrientationChanged += OnSensorOrientationChanged; }
public MainPage() { this.InitializeComponent(); simpleorientation = SimpleOrientationSensor.GetDefault(); if (simpleorientation != null) { simpleorientation.OrientationChanged += new TypedEventHandler <SimpleOrientationSensor, SimpleOrientationSensorOrientationChangedEventArgs>(OrientationChanged); } }
public MainPage() { InitializeComponent(); _orientation = SimpleOrientationSensor.GetDefault(); if (_orientation != null) { _orientation.OrientationChanged += Orientation_OrientationChanged; } }
private async void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { // Keep previous orientation when the user puts its device faceup or facedown if ((args.Orientation != SimpleOrientation.Faceup) && (args.Orientation != SimpleOrientation.Facedown)) { deviceOrientation = args.Orientation; await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => SetVideoOrientation()); } }
private async void OrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown) { _deviceOrientation = args.Orientation; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => this.UpdateButtonOrientation()); } }
public Scenario1_DataEvents() { this.InitializeComponent(); _sensor = SimpleOrientationSensor.GetDefault(); if (_sensor == null) { rootPage.NotifyUser("No simple orientation sensor found", NotifyType.ErrorMessage); } }
private void OnSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { var now = DateTime.UtcNow.ToUnixTimeMilliseconds(); var diff = now - lastTime; var s = diff / 1000; var ms = diff % 1000; timeSince.Text = $"~{s}.{ms} seconds since last orientation change."; lastTime = now; }
private void Sensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { try { this.UpdateManipulationMode(); this.GetCanvas().Invalidate(); } catch (Exception) { } }
public OrientationTests() { this.InitializeComponent(); lastTime = DateTime.UtcNow.ToUnixTimeMilliseconds(); this.Loaded += (s, e) => { var sensor = SimpleOrientationSensor.GetDefault(); if (sensor is { }) { sensor.OrientationChanged += OnSensorOrientationChanged; }
public void SetCameraEnclosureLocation(EnclosureLocation cameraEnclosureLocation) { _displayInformation = DisplayInformation.GetForCurrentView(); _orientationSensor = SimpleOrientationSensor.GetDefault(); _cameraEnclosureLocation = cameraEnclosureLocation; if (!IsEnclosureLocationExternal(_cameraEnclosureLocation) && _orientationSensor != null) { _orientationSensor.OrientationChanged += SimpleOrientationSensor_OrientationChanged; } _displayInformation.OrientationChanged += DisplayInformation_OrientationChanged; }
public void SetCanvas(CanvasControl canvas) { this.Children.Clear(); this.Children.Add(canvas); this.ManipulationDelta += CanvasWrapper_ManipulationDelta; SimpleOrientationSensor sensor = SimpleOrientationSensor.GetDefault(); if (sensor != null) { sensor.OrientationChanged += Sensor_OrientationChanged; } }
public void RemoveCanvas() { this.ManipulationDelta -= CanvasWrapper_ManipulationDelta; SimpleOrientationSensor sensor = SimpleOrientationSensor.GetDefault(); if (sensor != null) { sensor.OrientationChanged -= Sensor_OrientationChanged; } this.GetCanvas()?.RemoveFromVisualTree(); this.Children.Clear(); }
private void SimpleOrientationSensor_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { if (args.Orientation != SimpleOrientation.Faceup && args.Orientation != SimpleOrientation.Facedown) { // Only raise the OrientationChanged event if the device is not parallel to the ground. This allows users to take pictures of documents (FaceUp) // or the ceiling (FaceDown) in portrait or landscape, by first holding the device in the desired orientation, and then pointing the camera // either up or down, at the desired subject. //Note: This assumes that the camera is either facing the same way as the screen, or the opposite way. For devices with cameras mounted // on other panels, this logic should be adjusted. OrientationChanged?.Invoke(this, false); } }
//Constructor for GameOver.xaml public GameOver() { this.InitializeComponent(); copyDatabase(); //Copy the database so it can be found locally _simpleorientation = SimpleOrientationSensor.GetDefault(); //Get a default version of an orientation sensor. // Assign an event handler for the sensor orientation-changed event if (_simpleorientation != null) { _simpleorientation.OrientationChanged += new TypedEventHandler <SimpleOrientationSensor, SimpleOrientationSensorOrientationChangedEventArgs>(OrientationChanged); } }//end constructor
public Scenario1() { this.InitializeComponent(); //<SnippetGetDefaultCS> _sensor = SimpleOrientationSensor.GetDefault(); //</SnippetGetDefaultCS> if (_sensor == null) { rootPage.NotifyUser("No simple orientation sensor found", NotifyType.StatusMessage); } }
private void Simpleorientation_OrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) { SimpleOrientation orientation = args.Orientation; switch (orientation) { case SimpleOrientation.Rotated90DegreesCounterclockwise: DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; break; case SimpleOrientation.Rotated270DegreesCounterclockwise: DisplayInformation.AutoRotationPreferences = DisplayOrientations.LandscapeFlipped; break; default: return; } }
protected override void OnWindowCreated(WindowCreatedEventArgs args) { base.OnWindowCreated(args); //SearchPane searchPane = SearchPane.GetForCurrentView(); //searchPane.SuggestionsRequested += OnSearchPaneSuggestionsRequested; var sensor = SimpleOrientationSensor.GetDefault(); if (sensor != null) { sensor.OrientationChanged += Sensor_OrientationChanged;; } }