public UrhoPage() { var restartBtn = new Button { Text = "Restart" }; restartBtn.Clicked += (sender, e) => StartUrhoApp(); urhoSurface = new UrhoSurface(); urhoSurface.VerticalOptions = LayoutOptions.FillAndExpand; Slider rotationSlider = new Slider(0, 500, 250); rotationSlider.ValueChanged += (s, e) => urhoApp?.Rotate((float)(e.NewValue - e.OldValue)); selectedBarSlider = new Slider(0, 5, 2.5); selectedBarSlider.ValueChanged += OnValuesSliderValueChanged; Title = " UrhoSharp + Xamarin.Forms"; Content = new StackLayout { Padding = new Thickness (12, 12, 12, 40), VerticalOptions = LayoutOptions.FillAndExpand, Children = { urhoSurface, restartBtn, new Label { Text = "ROTATION::" }, rotationSlider, new Label { Text = "SELECTED VALUE:" }, selectedBarSlider, } }; }
public MainPage(ScannerConnection connection, bool offlineMode) { this.connection = connection; this.serializer = new ProtobufNetworkSerializer(); NavigationPage.SetHasNavigationBar(this, false); var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)}); grid.ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(4, GridUnitType.Star)}); bulbsStack = new StackLayout(); grid.Children.Add(bulbsStack); urhoSurface = new UrhoSurface { BackgroundColor = Color.Black, VerticalOptions = LayoutOptions.FillAndExpand }; var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Children = {urhoSurface} }; grid.Children.Add(stack); Grid.SetColumn(stack, 1); Content = grid; if (!offlineMode) { space = new SpaceDto(); connection.RegisterFor<SurfaceDto>(OnSurfaceReceived); connection.RegisterFor<BulbAddedDto>(OnBulbAdded); connection.RegisterFor<CurrentPositionDto>(OnCurrentPositionUpdated); Start(); } else { space = serializer.Deserialize<SpaceDto>( (byte[])Application.Current.Properties[nameof(SpaceDto)]); } }
protected override void OnDestroy() { UrhoSurface.OnDestroy(); base.OnDestroy(); }
protected override void OnPause() { UrhoSurface.OnPause(); base.OnPause(); }
public override void OnLowMemory() { UrhoSurface.OnLowMemory(); base.OnLowMemory(); }
public override void OnWindowFocusChanged(bool hasFocus) { UrhoSurface.OnWindowFocusChanged(hasFocus); base.OnWindowFocusChanged(hasFocus); }
protected override void OnResume() { UrhoSurface.OnResume(); base.OnResume(); }
public MainPage() { Title = "Fly 360"; NavigationPage.SetBackButtonTitle(this, string.Empty); BackgroundColor = Color.Black; var entry = new Entry { BackgroundColor = Color.Transparent, TextColor = Color.White, Placeholder = "Search", PlaceholderColor = Color.LightGray, Margin = 25 }; var frame = new Frame { BackgroundColor = Color.LightGray, BorderColor = Color.LightGray, CornerRadius = 15, Opacity = 0.33, Margin = 25 }; var button = new Button { BackgroundColor = Color.White, TextColor = Color.Blue, Text = " Suggested Destinations ", HorizontalOptions = LayoutOptions.Center, Margin = 40 }; Grid.SetRow(button, 2); button.Clicked += async(s, a) => { await Navigation.PushPopupAsync(popupPage); }; urhoSurface = new UrhoSurface(); urhoSurface.VerticalOptions = LayoutOptions.FillAndExpand; Grid.SetRowSpan(urhoSurface, 3); popupPage = new MenuPopupPage(); popupPage.Appearing += (s, a) => { frame.IsVisible = false; entry.IsVisible = false; button.IsVisible = false; }; popupPage.Disappearing += (s, a) => { frame.IsVisible = true; entry.IsVisible = true; button.IsVisible = true; }; Content = new Grid { RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Star }, new RowDefinition { Height = GridLength.Auto } }, Children = { urhoSurface, frame, entry, button, } }; }
public override void OnBackPressed() { UrhoSurface.OnDestroy(); Finish(); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); UrhoSurface.RunInActivity <MyGame>(new ApplicationOptions("Data")); }
public void RunGame(TypeInfo value) { currentApplication?.Exit(); //at this moment, UWP supports assets only in pak files (see PackageTool) currentApplication = UrhoSurface.Run(value.Type, "Data.pak"); }
void StopBtn_Click(object sender, RoutedEventArgs e) { UrhoSurface.Stop(); //or just: //app?.Exit(); }
public MainPage() { Title = "Fly 360"; NavigationPage.SetBackButtonTitle(this, string.Empty); BackgroundColor = Color.Black; var entry = new IconEntry { Margin = new Thickness(25, 0), }; Grid.SetRow(entry, 1); var button = new Button { BackgroundColor = Color.FromHex("#F2F6F8"), TextColor = Color.FromHex("#5887F9"), Text = "Suggested Destinations", HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(40, 0), WidthRequest = 250, CornerRadius = 5 }; Grid.SetRow(button, 3); button.Clicked += async(s, a) => { await Navigation.PushPopupAsync(popupPage); }; urhoSurface = new UrhoSurface(); urhoSurface.VerticalOptions = LayoutOptions.FillAndExpand; Grid.SetRowSpan(urhoSurface, 5); popupPage = new MenuPopupPage(); popupPage.Appearing += (s, a) => { entry.Opacity = 0.25f; button.IsVisible = false; }; popupPage.Disappearing += (s, a) => { entry.Opacity = 1f; button.IsVisible = true; }; Content = new Grid { RowDefinitions = { new RowDefinition { Height = 15 }, new RowDefinition { Height = 40 }, new RowDefinition { Height = GridLength.Star }, new RowDefinition { Height = 40 }, new RowDefinition { Height = 40 } }, Children = { urhoSurface, entry, button, } }; }
protected override void OnDisappearing() { base.OnDisappearing(); OrientationSensor.Stop(); UrhoSurface.OnDestroy(); }