private List<View> CreateSortObjects(Context context, Text2Speech tts) { var result = new List<View>(); var x = ParseXml(context); //var p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); //p.SetMargins(5, 5, 5, 5); //for (int i = 1; i < 15; ++i) //{ // var s = new TextView(context); // s.Text = ("View " + i.ToString()); // s.LayoutParameters = (p); // result.Add(s); //} var s = new ShapeView(context, ShapeView.ShapeEnum.RectangleShape, 100, 100, Color.DKGRAY); //var d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("1") }; //s.SetOnDragListener(d); //s.SetOnLongClickListener(d); //s.SetOnTouchListener(d); //s.LayoutParameters = (p); //result.Add(s); //s = new ShapeView(context, ShapeView.ShapeEnum.OvalShape, 100, 75, Color.WHITE); //d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("2") }; //s.SetOnDragListener(d); //s.SetOnLongClickListener(d); //s.SetOnTouchListener(d); //s.LayoutParameters = (p); //result.Add(s); //s = new ShapeView(context, ShapeView.ShapeEnum.TriangleShape, 100, 100, Color.MAGENTA); //d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("1") }; //s.SetOnDragListener(d); //s.SetOnLongClickListener(d); //s.SetOnTouchListener(d); //s.LayoutParameters = (p); //result.Add(s); //s = new ShapeView(context, ShapeView.ShapeEnum.RoundedRectShape, 100, 100, Color.YELLOW); //d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("2") }; //s.SetOnDragListener(d); //s.SetOnLongClickListener(d); //s.SetOnTouchListener(d); //s.LayoutParameters = (p); //result.Add(s); var p = new LinearLayout.LayoutParams(120, 120); p.SetMargins(5, 5, 5, 5); var i = new ImageView(context); i.SetScaleType(Android.Widget.ImageView.ScaleType.CENTER_INSIDE); i.SetImageResource(R.Drawable.Laura); //- i.SetImageDrawable(Drawable.CreateFromPath("res/drawable/laura.png")); i.LayoutParameters = (p); var d = new MoveDragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("1") }; var t = new SpeechDropHandler { Tts = tts, Text = "This is Laura" }; d.Successor = t; i.SetOnDragListener(d); i.SetOnTouchListener(d); result.Add(i); i = new ImageView(context); i.SetScaleType(Android.Widget.ImageView.ScaleType.CENTER_INSIDE); i.SetImageResource(R.Drawable.Inge); //- i.SetImageDrawable(Drawable.CreateFromPath("res/drawable/laura.png")); i.LayoutParameters = (p); d = new MoveDragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("1") }; t = new SpeechDropHandler { Tts = tts, Text = "This is Inge" }; d.Successor = t; i.SetOnDragListener(d); i.SetOnTouchListener(d); result.Add(i); i = new ImageView(context); i.SetScaleType(Android.Widget.ImageView.ScaleType.CENTER_INSIDE); i.SetImageResource(R.Drawable.Emma); //- i.SetImageDrawable(Drawable.CreateFromPath("res/drawable/laura.png")); i.LayoutParameters = (p); d = new MoveDragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("2") }; t = new SpeechDropHandler { Tts = tts, Text = "This is Emma" }; d.Successor = t; i.SetOnDragListener(d); i.SetOnTouchListener(d); result.Add(i); i = new ImageView(context); i.SetScaleType(Android.Widget.ImageView.ScaleType.CENTER_INSIDE); i.SetImageResource(R.Drawable.Thor); //- i.SetImageDrawable(Drawable.CreateFromPath("res/drawable/laura.png")); i.LayoutParameters = (p); d = new MoveDragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("2") }; t = new SpeechDropHandler { Tts = tts, Text = "This is Thor" }; d.Successor = t; i.SetOnDragListener(d); i.SetOnTouchListener(d); result.Add(i); sortObjects.ResultChecker.NrAccepts = result.Count(); return result; }
private List<ShapeView> ParseXml(Context context) { var s = new ShapeView(context, ShapeView.ShapeEnum.RectangleShape, 100, 100, Color.DKGRAY); //var d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("1") }; //s.SetOnDragListener(d); //s.SetOnLongClickListener(d); //s.SetOnTouchListener(d); //s.LayoutParameters = (p); //result.Add(s); //List<ShapeView> shapeList = new List<ShapeView>(); List<ShapeView> shapeList = ( from e in XDocument.Parse(strXml).Root.Elements("Shape") select new ShapeView(context) { Shape = (ShapeView.ShapeEnum)Enum.Parse(typeof(ShapeView.ShapeEnum), (string)e.Element("shapeType").ToString()), Color = int.Parse(e.Element("color").ToString()), ShapeWidth = int.Parse(e.Element("width").ToString()), ShapeHeight = int.Parse(e.Element("heigth").ToString()) //EmployeeID = (int)e.Element("id"), //EmployeeName = (string)e.Element("name"), //EmployeePosition = (string)e.Element("position"), //EmployeeCountry = (string)e.Element("country"), //Projects = //( // from p in e.Elements("projects").Elements("project") // select new Project // { // ProjectCode = (string)p.Element("code"), // ProjectBudget = (int)p.Element("budget") // }).ToArray() }).ToList(); return shapeList; }