Esempio n. 1
0
		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)]);
			}
		}
Esempio n. 2
0
		public void SetConnection(ScannerConnection connection) => this.connection = connection;