public void handleMealButtonInButtonContainer (MealButton button, String name, String id, 
			String mealSize, int height, JsonValue json, LinearLayout.LayoutParams lp, String text) {
			button.mealName = json [name];
			button.mealSize = (json [mealSize]);
			button.SetHeight (height);
			button.mealId = (json [id]);
			button.Click += (object sender, EventArgs e) => {
				Intent intent = new Intent (this, typeof(MealDesign));
				LinearLayout mealDisplay = FindViewById<LinearLayout> (Resource.Id.MealDisplay);
				// PRINTS
				mealDisplay.RemoveAllViews ();
				intent.PutExtra ("Name", button.mealName);
				intent.PutExtra ("Mealsize", button.mealSize);
				intent.PutExtra ("mealId", button.mealId);
				StartActivityForResult (intent, 3);
				// requestCode for Design page 3

			};
			button.LayoutParameters = lp;
			button.Text = json ["Mealname"];
			button.Visibility = Android.Views.ViewStates.Visible;
			button.SetBackgroundColor (Resources.GetColor (Resource.Color.orange_header));
			button.Gravity = GravityFlags.Center;
		}
		/// <summary>
		/// Creates the button container. Used to clean up code and with button for desiging meal/
		/// </summary>
		private LinearLayout CreateButtonContainer (JsonValue json, int count)
		{
			LinearLayout buttonCont = new LinearLayout (this);
			LinearLayout.LayoutParams bcll = 
				new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, 
					LinearLayout.LayoutParams.WrapContent);
			handleMealInfoLayout (buttonCont, 25, 100, bcll, count, json);
			buttonCont.Visibility = Android.Views.ViewStates.Visible;
			MealButton button = new MealButton (this, null, 
				Resource.Style.generalButtonStyle); 

			LinearLayout.LayoutParams lp = 
				new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, 
					LinearLayout.LayoutParams.MatchParent);

			handleMealButtonInButtonContainer (button, "Mealname", "Mealid", 
				"Mealsize", 150, json, lp, "Mealname");
			buttonCont.AddView (button);
			return buttonCont;
		}
		/// <summary>
		/// Creates a button view to be added to a meal to start the walkthrough
		/// </summary>
		/// <returns>The view (LinearLayout) containing buttons and 
		/// 			other fields for a meal button.</returns>
		/// <param name="json">Json for a meal.</param>
		/// <param name="recipeResult">Recipe result in Json for a given meal.</param>
		/// <param name="count">Count for unique ids.</param>
		private LinearLayout ButtonView (JsonValue json, JsonValue recipeResult, int count)
		{
			LinearLayout walkthroughButton = new LinearLayout (this);
			walkthroughButton.Orientation = Orientation.Vertical;
			LinearLayout.LayoutParams wtll = 
				new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, 
					LinearLayout.LayoutParams.WrapContent);
			walkthroughButton.LayoutParameters = wtll;
			walkthroughButton.AddView (CreateMealInfo (json, recipeResult, count));
			MealButton button = new MealButton (this);
			button.mealName = json ["Mealname"];
			button.mealId = json ["Mealid"];
			button.mealSize = json ["Mealsize"];
			button.Text = "Start Walkthrough";
			button.SetHeight (150);
			button.Click += (object sender, EventArgs e) => {
				Intent i = new Intent (this, typeof(StepsActivity));
				// System.Diagnostics.Debug.WriteLine (button.mealId);
				i.PutExtra ("mealId", button.mealId);
				// requestCode of walkthrough is 1
				StartActivityForResult (i, 1);
			};
			button.Gravity = GravityFlags.Center;
			LinearLayout.LayoutParams bll = 
				new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, 
					LinearLayout.LayoutParams.WrapContent);
			bll.SetMargins (10, 10, 10, 10);
			button.LayoutParameters = bll;
			button.SetPadding (0, 0, 0, 10);
			walkthroughButton.AddView (button);
			return walkthroughButton;
		}
		public void handleMealButtonCreation(MealButton button, String name, String id, 
			String mealSize, String text, int height, JsonValue json) {
			button.mealName = json [name];
			button.mealId = json [id];
			button.mealSize = json [mealSize];
			button.Text = text;
			button.SetHeight (height);
		}
示例#5
0
		/// <summary>
		/// Creates the button container. Used to clean up code and with button for desiging meal/
		/// </summary>
		/// <returns>The button container object.</returns>
		/// <param name="json">Json to be parsed.</param>
		/// <param name="count">Count used to create unique ids.</param>
		private LinearLayout CreateButtonContainer (JsonValue json, int count)
		{
			LinearLayout buttonCont = new LinearLayout (this);
			//buttonCont.SetBackgroundColor (Android.Graphics.Color.White);
			buttonCont.Orientation = Orientation.Horizontal;
			buttonCont.SetMinimumWidth (25);
			buttonCont.SetMinimumHeight (100);
			LinearLayout.LayoutParams bcll = 
				new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, 
					LinearLayout.LayoutParams.WrapContent);
			bcll.SetMargins (5, 5, 5, 5);
			buttonCont.LayoutParameters = bcll;
			buttonCont.Visibility = Android.Views.ViewStates.Visible;
			buttonCont.Id = count * 20 + 6;
			// Used to hold more values
			MealButton button = new MealButton (this, null, 
				                    Resource.Style.generalButtonStyle); 
			button.mealName = json ["Mealname"];
			button.mealSize = (json ["Mealsize"]);
			button.SetHeight (150);
			button.mealId = (json ["Mealid"]);
			button.Click += (object sender, EventArgs e) => {
				Intent intent = new Intent (this, typeof(MealDesign));
				LinearLayout mealDisplay = FindViewById<LinearLayout> (Resource.Id.MealDisplay);
				// PRINTS
				mealDisplay.RemoveAllViews ();
				intent.PutExtra ("Name", button.mealName);
				intent.PutExtra ("Mealsize", button.mealSize);
				intent.PutExtra ("mealId", button.mealId);
				StartActivityForResult (intent, 3);
				// requestCode for Design page 3

			};
			LinearLayout.LayoutParams lp = 
				new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, 
					LinearLayout.LayoutParams.MatchParent);
			button.LayoutParameters = lp;
			button.Text = json ["Mealname"];

			button.Visibility = Android.Views.ViewStates.Visible;
			button.SetBackgroundColor (Resources.GetColor (Resource.Color.orange_header));
			button.Gravity = GravityFlags.Center;
			buttonCont.AddView (button);
			return buttonCont;
		}