public static async Task<MagicList> CreateFromParseObject(ParseObject parseObject)
        {
            return await Task.Run<MagicList>(() =>
            {
                var mlist = new MagicList();

                mlist.CountryName = parseObject.ObjectId;
                mlist.CountryObjectId = parseObject.ObjectId;
                if (parseObject.ContainsKey("languageID"))
                {
                    mlist.CountryName = (string)parseObject["languageID"];
                }
                if (parseObject.ContainsKey("objectId"))
                {
                    mlist.CountryObjectId = (string) parseObject["objectId"];
                }

                if (parseObject.ContainsKey("name"))
                {
                    mlist.CountryDescription = (string)parseObject["name"];
                }
                return mlist;
            });
        }
        public void LoadFromParse(ParseObject parseObj)
        {
            var thisType = this.GetType ();

            foreach (PropertyInfo prop in thisType.GetRuntimeProperties ()) {
                if (!prop.Name.Equals (Const.OBJECT_ID, StringComparison.OrdinalIgnoreCase)) {
                    object value = null;
                    if (parseObj.ContainsKey (prop.Name)) {
                        value = parseObj.Get<object> (prop.Name);
                    }
                    prop.SetValue (this, value);
                }
            }

            this.objectId = parseObj.ObjectId;
        }
Exemple #3
0
    public static bool SetParsePropertyFromFsmVar(ParseObject _object,string property,Fsm fsm,FsmVar fsmVar)
    {
        if (_object==null )
        {
            Debug.Log("Parse Object null");
            return false;
        }

        if (string.IsNullOrEmpty(property) )
        {
            Debug.Log("property null");
            return false;
        }

        if (! _object.ContainsKey(property))
        {
        //	return false;
        }

        PlayMakerUtils.RefreshValueFromFsmVar(fsm,fsmVar);

        if (fsmVar.Type == VariableType.Bool)
        {
            _object[property] = fsmVar.boolValue;

        }else if (fsmVar.Type == VariableType.Float)
        {
            _object[property] = fsmVar.floatValue;

        }else if (fsmVar.Type == VariableType.Int)
        {
            _object[property] = fsmVar.intValue;

        }else if (fsmVar.Type == VariableType.String)
        {
            _object[property] = fsmVar.stringValue;

        }else if (fsmVar.Type == VariableType.Color)
        {
            _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.colorValue);
        }else if (fsmVar.Type == VariableType.GameObject)
        {
            _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.gameObjectValue);
        }else if (fsmVar.Type == VariableType.Material)
        {
            _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.materialValue);
        }else if (fsmVar.Type == VariableType.Quaternion)
        {
            _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.quaternionValue);
        }else if (fsmVar.Type == VariableType.Rect)
        {
            _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.rectValue);
        }else if (fsmVar.Type == VariableType.Texture)
        {
            _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.textureValue);
        }else if (fsmVar.Type == VariableType.Vector2)
        {
            _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.vector2Value);
        }
        else if (fsmVar.Type == VariableType.Vector3)
        {
            _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.vector3Value);
        }

        return true;
    }
Exemple #4
0
    public static bool GetParsePropertyToFsmVar(ParseObject _object,string property,Fsm fsm,FsmVar fsmVar)
    {
        if (_object==null || string.IsNullOrEmpty(property) )
        {
            return false;
        }

        if (! _object.ContainsKey(property))
        {
            return false;
        }

        if (fsmVar.Type == VariableType.Bool)
        {
            PlayMakerUtils.ApplyValueToFsmVar(fsm,fsmVar,_object[property]);

        }else if (fsmVar.Type == VariableType.Float)
        {
            PlayMakerUtils.ApplyValueToFsmVar(fsm,fsmVar,_object[property]);

        }else if (fsmVar.Type == VariableType.Int)
        {
            PlayMakerUtils.ApplyValueToFsmVar(fsm,fsmVar,_object[property]);

        }else if (fsmVar.Type == VariableType.String)
        {
            PlayMakerUtils.ApplyValueToFsmVar(fsm,fsmVar,_object[property]);

        }else if (fsmVar.Type == VariableType.Color)
        {
            fsmVar.colorValue = (Color) PlayMakerUtils.ParseValueFromString( (string)_object[property] );
        }else if (fsmVar.Type == VariableType.GameObject)
        {
            fsmVar.gameObjectValue = (GameObject) PlayMakerUtils.ParseValueFromString( (string)_object[property] );
        }else if (fsmVar.Type == VariableType.Material)
        {
            fsmVar.materialValue = (Material)PlayMakerUtils.ParseValueFromString( (string)_object[property] );
        }else if (fsmVar.Type == VariableType.Quaternion)
        {
            fsmVar.quaternionValue = (Quaternion)PlayMakerUtils.ParseValueFromString( (string)_object[property] );
        }else if (fsmVar.Type == VariableType.Rect)
        {
            fsmVar.rectValue = (Rect)PlayMakerUtils.ParseValueFromString( (string)_object[property] );
        }else if (fsmVar.Type == VariableType.Texture)
        {
            fsmVar.textureValue = (Texture2D)PlayMakerUtils.ParseValueFromString( (string)_object[property] );
        }else if (fsmVar.Type == VariableType.Vector2)
        {
            fsmVar.vector2Value = (Vector2)PlayMakerUtils.ParseValueFromString( (string)_object[property] );
        }else if (fsmVar.Type == VariableType.Vector3)
        {
            fsmVar.vector3Value = (Vector3)PlayMakerUtils.ParseValueFromString( (string)_object[property] );
        }

        return true;
    }
            public static async Task<MagicListHotline> CreateHotlineFromParseObject(ParseObject parseObject)
            {
                return await Task.Run<MagicListHotline>(async () =>
                {
                    var mlist = new MagicListHotline();
              

                    if (parseObject.ContainsKey("languageID"))
                    {
                        var rel = parseObject.Get<ParseObject>("languageID");
                        String rel2 = rel.ObjectId;
                        var query = from language in ParseObject.GetQuery("Language")
                            where language.Get<string>("objectId") == rel2
                            select language;


                        ParseObject obj = await query.FirstAsync();
                        mlist.HotlineLanguage = (string)obj["name"];
                        

                    }

                    if (parseObject.ContainsKey("email"))
                    {
                        mlist.HotlineEmail = (string)parseObject["email"];
                    }
                    if (parseObject.ContainsKey("fax"))
                    {
                        mlist.HotlineFax = (string)parseObject["fax"];
                    }
                    if (parseObject.ContainsKey("phone"))
                    {
                        mlist.HotlinePhone = (string)parseObject["phone"];
                    }
                    return mlist;
                });
            }
Exemple #6
0
            public static async Task<curoLists> CreateFromParseObject(ParseObject parseObject)
            {
                return await Task.Run<curoLists>(() =>
                {
                    var mlist = new curoLists();

                    mlist.Title = parseObject.ObjectId;
                    if (parseObject.ContainsKey("title"))
                    {
                        mlist.Title = (string)parseObject["title"];
                    }


                    if (parseObject.ContainsKey("description"))
                    {
                        mlist.Description = (string)parseObject["description"];
                    }
                    if (parseObject.ContainsKey("image"))
                    {
                        mlist.ImagePath = (string)parseObject["image"];


               //         Image src = new Image();
                      //  mlist.curoImage = ImagePath;
                    }


                    if (parseObject.ContainsKey("unread"))


                    {

                        Color currentAccentColorHex = (Color)Application.Current.Resources["PhoneAccentColor"];

                        Boolean isUnread = (bool) parseObject["unread"];
                        if (isUnread == true)
                        {
                            mlist.MessageColour =currentAccentColorHex;
                        }
                        else
                        {
                            mlist.MessageColour = currentAccentColorHex;
                        }
                            mlist.Unread = isUnread;
                      

                    }


                    if (parseObject.ContainsKey("type"))
                    {
                        string mtype = (string)parseObject["type"];

                        if (mtype == "N")
                        {
                            mlist.Type = "Notes";
                            mlist.ViewToUse = "Notes.Xaml";
                        }
                    }
                    return mlist;
                });
            }
    public void TestAddUniqueToList() {
      ParseObject obj = new ParseObject("Corgi");
      obj.AddUniqueToList("emptyList", "gogo");
      obj["existingList"] = new List<string>() { "gogo" };

      Assert.True(obj.ContainsKey("emptyList"));
      Assert.AreEqual(1, obj.Get<List<object>>("emptyList").Count);

      obj.AddUniqueToList("existingList", "gogo");
      Assert.True(obj.ContainsKey("existingList"));
      Assert.AreEqual(1, obj.Get<List<object>>("existingList").Count);

      obj.AddUniqueToList("existingList", 1);
      Assert.AreEqual(2, obj.Get<List<object>>("existingList").Count);

      obj.AddRangeUniqueToList("newRange", new List<string>() { "anti", "anti" });
      Assert.AreEqual(1, obj.Get<List<object>>("newRange").Count);
    }
		public AddPitTeam (ParseObject teamData)
		{
			Grid grid = new Grid () {
				//Padding = new Thickness(0,20,0,0), 
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand,

				RowDefinitions = {
					new RowDefinition{ Height = new GridLength(160, GridUnitType.Absolute) },
					new RowDefinition{ Height = GridLength.Auto }
				},
				ColumnDefinitions = {
					new ColumnDefinition{ Width = new GridLength(160, GridUnitType.Absolute) },
					new ColumnDefinition{ Width = GridLength.Auto }
				}
			};

			var imageTap = new TapGestureRecognizer ();
			imageTap.Tapped += (s, e) => {
				Console.WriteLine("Tapped");
				OpenPicker();
			};
				
			Image robotImage = new Image();
			try {
				if (teamData ["robotImage"].ToString() != null) {
					ParseFile robotImageURL = (ParseFile)teamData ["robotImage"];
					//Gets the image from parse and converts it to ParseFile
					//robotImage.Source = "I"+teamData["teamNumber"]+".jpg"; //Must scale down images manually before upload, & all images must be .jpg
					//How to write this so caching actually works?

					robotImage.Source = new UriImageSource{
						Uri = robotImageURL.Url,
						CachingEnabled = true,
						CacheValidity = new TimeSpan(7,0,0,0) //Caches Images onto your device for a week
					};
				} else {}
			}
			catch {
				robotImage.Source = "Placeholder_image_placeholder.png";
				robotImage.GestureRecognizers.Add (imageTap);
			}
			//robotImage.Aspect = Aspect.AspectFit; //Need better way to scale an image while keeping aspect ratio, but not overflowing everything else
			//robotImage.GestureRecognizers.Add (imageTap);

			Label teamNumberLabel = new Label(){
				Text = "Team Number:"
			};
	
			Entry teamNumber = new Entry (){
				Keyboard = Keyboard.Numeric
			};
			try {
				if (teamData ["teamNumber"] != null) {
					teamNumber.Text = teamData ["teamNumber"].ToString();
				} else {}
			}
			catch {
				teamNumber.Placeholder = "[Enter Team Number]";
			}

			Label teamNameLabel = new Label () {
				Text = "Team Name:"
			};

			Entry teamName = new Entry ();
			try {
				if (teamData ["teamName"] != null) {
					teamName.Text = teamData ["teamName"].ToString();
				} else {} 
			} catch {
				teamName.Placeholder = "[Enter Team Name]";
			}

			Label robotWeightLabel = new Label(){
				Text = "RobotWeight:"
			};

			Entry robotWeight = new Entry (){
				Keyboard = Keyboard.Numeric
			};
			try {
				if (teamData ["robotWeight"] != null) {
					robotWeight.Text = teamData ["robotWeight"].ToString();
				} else {}
			}
			catch {
				robotWeight.Text = "0";
			}

			Label rampLabel = new Label () {
				Text = "Do you need a ramp?:"
			};

			Picker rampPicker = new Picker ();
			try {
				if (teamData ["ramp"] != null) {
					rampPicker.Title = teamData ["ramp"].ToString();
				} else {} 
			} catch {
				rampPicker.Title = "[Select an Option]";
			}
			for(Choice type=Choice.No; type<=Choice.Yes; type++){
				string stringValue = type.ToString();
				rampPicker.Items.Add(stringValue);
			}

			rampPicker.SelectedIndexChanged += (sender, args) => {
				Choice type = (Choice)rampPicker.SelectedIndex;
				string stringValue = type.ToString();
				rampPicker.Title = stringValue;

			};
				
			Label driveTypeLabel = new Label () {
				Text = "Drive Type:"
			};

			Picker drivePicker = new Picker ();
			try {
				if (teamData ["driveType"] != null) {
					drivePicker.Title = teamData ["driveType"].ToString();
				} else {} 
			} catch {
				drivePicker.Title = "[Select Drive Type]";
			}

			for(DriveType type=DriveType.None; type<=DriveType.Other; type++){
				string stringValue = type.ToString();
				drivePicker.Items.Add(stringValue);
			}

			drivePicker.SelectedIndexChanged += (sender, args) => {
				DriveType type = (DriveType)drivePicker.SelectedIndex;
				string stringValue = type.ToString();
				drivePicker.Title = stringValue;
			};
					
			Label totePickupOrientationLabel = new Label () {
				Text = "Tote Pickup Orentation:"
			};

			Picker toteOrientationPicker = new Picker ();
			try {
				if (teamData ["toteOrientation"] != null) {
					toteOrientationPicker.Title = teamData ["toteOrientation"].ToString();
				} else {} 
			} catch {
				toteOrientationPicker.Title = "[Select Tote Orientation]";
			}

			for(ToteOrientation type=ToteOrientation.None; type<=ToteOrientation.Both; type++){
				string stringValue = type.ToString();
				toteOrientationPicker.Items.Add(stringValue);
			}

			toteOrientationPicker.SelectedIndexChanged += (sender, args) => {
				ToteOrientation type = (ToteOrientation)toteOrientationPicker.SelectedIndex;
				string stringValue = type.ToString();
				toteOrientationPicker.Title = stringValue;
			};

			Label canPickupOrientationLabel = new Label () {
				Text = "Can Pickup Orentation:"
			};

			Picker canOrientationPicker = new Picker ();
			try {
				if (teamData ["canOrientation"] != null) {
					canOrientationPicker.Title = teamData ["canOrientation"].ToString();
				} else {} 
			} catch {
				canOrientationPicker.Title = "[Select Can Orientation]";
			}

			for(CanOrientation type=CanOrientation.None; type<=CanOrientation.Both; type++){
				string stringValue = type.ToString();
				canOrientationPicker.Items.Add(stringValue);
			}

			canOrientationPicker.SelectedIndexChanged += (sender, args) => {
				CanOrientation type = (CanOrientation)canOrientationPicker.SelectedIndex;
				string stringValue = type.ToString();
				canOrientationPicker.Title = stringValue;
			};

			Label autoStrategyLabel = new Label () {
				Text = "Auto Strategy:"
			};

			Entry autoStrategy = new Entry ();
			try {
				if (teamData ["autoStrategy"] != null) {
					autoStrategy.Text = teamData ["autoStrategy"].ToString();
				} else {} 
			} catch {
				autoStrategy.Placeholder = "[Enter Auto Strategy]";
			}

			Label teleOpStrategyLabel = new Label () {
				Text = "TeleOp Strategy:"
			};

			Entry teleOpStrategy = new Entry ();
			try {
				if (teamData ["teleOpStrategy"] != null) {
					teleOpStrategy.Text = teamData ["teleOpStrategy"].ToString();
				} else {} 
			} catch {
				teleOpStrategy.Placeholder = "[Enter TeleOp Strategy]";
			}
				
			Label autoToteLabel = new Label () {
				Text = "Can you push a tote in Auto?:"
			};

			Picker autoTotePicker = new Picker ();
			try {
				if (teamData ["autoTote"] != null) {
					autoTotePicker.Title = teamData ["autoTote"].ToString();
				} else {} 
			} catch {
				autoTotePicker.Title = "[Select Option]";
			}

			for(Choice type=Choice.No; type<=Choice.Yes; type++){
				string stringValue = type.ToString();
				autoTotePicker.Items.Add(stringValue);
			}

			autoTotePicker.SelectedIndexChanged += (sender, args) => {
				Choice type = (Choice)autoTotePicker.SelectedIndex;
				string stringValue = type.ToString();
				autoTotePicker.Title = stringValue;
			};

			Label coopertitionTotesLabel= new Label () {
				Text = "Possible Co-Op Tote Stack:"
			}; 

			Entry coopertitionTotes = new Entry ();
			try {
				if (teamData ["coopertitionTotes"] != null) {
					coopertitionTotes.Text = teamData ["coopertitionTotes"].ToString();
				} else {} 
			} catch {
				coopertitionTotes.Text = "0";
			}
			coopertitionTotes.Keyboard = Keyboard.Numeric;

			Label notesLabel = new Label () {
				Text = "Additional Notes:"
			};

			//int test = teamData["pitScoutStatus"].ToString();

			Editor notes = new Editor ();
			try {
				if (teamData ["notes"] != null) {
					notes.Text = teamData ["notes"].ToString();
				} else {} 
			} catch {
				//notes.Text = test.ToString();
				notes.Text = "[Add notes]";
			}
			notes.HeightRequest = 100;
			
			data = teamData;

			Button backBtn = new Button (){
				Text = "Back"
			};
			backBtn.Clicked += (object sender, EventArgs e) => {
				Navigation.PushModalAsync(new PitScoutingPage());
			};

			Button updateBtn = new Button(){Text = "Update"};
			updateBtn.Clicked += (object sender, EventArgs e) => {
				//data ["robotImage"] = new ParseFile(robotImage);
				//data ["teamNumber"] = int.Parse(teamNumber.Text);

				data ["teamName"] = teamName.Text;
				data ["robotWeight"] = Convert.ToInt32(robotWeight.Text);

				if(rampPicker.Title != "[Select an Option]"){
					data ["ramp"] = rampPicker.Title;
				}
				if(drivePicker.Title != "[Select Drive Type]"){
					data ["driveType"] = drivePicker.Title;
				}
				if(toteOrientationPicker.Title != "[Select Tote Orientation]"){
					data ["toteOrientation"] = toteOrientationPicker.Title;
				}
				if(canOrientationPicker.Title != "[Select Can Orientation]"){
					data ["canOrientation"] = canOrientationPicker.Title;
				}
				if(autoStrategy.Text != "[Enter Auto Strategy]"){
					data ["autoStrategy"] = autoStrategy.Text;
				}
				if(teleOpStrategy.Text != "[Enter TeleOp Strategy]"){
					data ["teleOpStrategy"] = teleOpStrategy.Text;
				}
				if(autoTotePicker.Title != "[Select Option]"){
					data ["autoTote"] = autoTotePicker.Title;
				}
				data ["coopertitionTotes"] = Convert.ToInt32(coopertitionTotes.Text);
				data ["notes"] = notes.Text;

				SaveData (); 

				if( data.ContainsKey("ramp") == 
					data.ContainsKey("driveType") == 
					data.ContainsKey("toteOrientation") == 
					data.ContainsKey("canOrientation") ==
					data.ContainsKey("autoStrategy") ==
					data.ContainsKey("teleOpStrategy") ==
					data.ContainsKey("autoTote") ==
					true) 
				{
					data["pitScoutStatus"]=0;
				} else {
					data["pitScoutStatus"]=255;
				}
				SaveData();
			};

			Label keyboardPadding = new Label ();
			keyboardPadding.HeightRequest = 300;

			StackLayout side = new StackLayout () {
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand,

				Children = {
					teamNumberLabel,
					teamNumber,
					teamNameLabel,
					teamName
				}
			};

			StackLayout bottom = new StackLayout () {
				HorizontalOptions = LayoutOptions.FillAndExpand,

				Children = {
					robotWeightLabel,
					robotWeight,
					rampLabel,
					rampPicker,
					driveTypeLabel,
					drivePicker,
					totePickupOrientationLabel,
					toteOrientationPicker,
					canPickupOrientationLabel,
					canOrientationPicker,
					autoStrategyLabel,
					autoStrategy,
					autoToteLabel,
					autoTotePicker,
					teleOpStrategyLabel,
					teleOpStrategy,
					coopertitionTotesLabel,
					coopertitionTotes,
					notesLabel,
					notes,
					backBtn,
					updateBtn,
					keyboardPadding
				}
			};

			grid.Children.Add (robotImage, 0, 0);
			grid.Children.Add (side, 1, 0);
			grid.Children.Add (bottom, 0, 2, 1, 2);

			this.Content = new ScrollView {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,

				Content = grid
			};
		}
Exemple #9
0
        public static async Task<Clinics> CreateFromParseObject(ParseObject parseObject)
        {
            return await Task.Run<Clinics>(() =>
            {
                var findaPhysioList = new Clinics();

                findaPhysioList._Name = parseObject.ObjectId;
                if (parseObject.ContainsKey("BookURL"))
                {
                    findaPhysioList._Name = (string)parseObject["BookURL"];
                }

                
                if (parseObject.ContainsKey("OpeningHours"))
                {
                    findaPhysioList._OpeningHours = (string)parseObject["OpeningHours"];
                }

                if (parseObject.ContainsKey("Speciality"))
                {
                    findaPhysioList._Speciaity = (string)parseObject["Speciality"];
                }

                if (parseObject.ContainsKey("Town"))
                {
                    findaPhysioList._Town = (string)parseObject["Town"];
                }



                if (parseObject.ContainsKey("Website"))
                {
                    findaPhysioList._WebSite = (string)parseObject["Website"];
                }

                if (parseObject.ContainsKey("adress1"))
                {
                    findaPhysioList._Address1 = (string)parseObject["adress1"];
                }


              


                if (parseObject.ContainsKey("name"))
                {
                    findaPhysioList._Name = (string)parseObject["name"];
                }


                if (parseObject.ContainsKey("postcode"))
                {
                    findaPhysioList._Postcode = (string)parseObject["postcode"];
                }

                if (parseObject.ContainsKey("telephone"))
                {
                    findaPhysioList._Telephone = (string)parseObject["telephone"];
                }


                if (parseObject.ContainsKey("lat"))
                {
                    findaPhysioList._Latitude = (double)parseObject["lat"];
                }


                if (parseObject.ContainsKey("long"))
                {
                    findaPhysioList._Longitude = (double)parseObject["long"];
                }
                return findaPhysioList;
            });
        }