void Roles_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up && loaded) { //map this touch against roles in bootlegger: var touch = new System.Drawing.PointF(e.Event.GetX() / View.FindViewById <ImageView>(Resource.Id.image).Width, e.Event.GetY() / View.FindViewById <ImageView>(Resource.Id.image).Height); //find closest one from the given roles: List <Role> roles; if (CurrentEvent.CurrentPhase != null && CurrentEvent.CurrentPhase.roles != null && CurrentEvent.CurrentPhase.roles.Count() > 0) { roles = (from n in CurrentEvent.roles where CurrentEvent.CurrentPhase.roles.Contains(n.id) orderby(n.Position.DistanceTo(touch)) select n).ToList(); } else { roles = (from n in CurrentEvent.roles orderby(n.Position.DistanceTo(touch)) select n).ToList(); } if (roles.Count() > 0) { var selected = roles.First(); OnRoleSelected?.Invoke(selected); } } }
public GhostRolesEntry(string name, string description, IEnumerable <GhostRoleInfo> roles) { RobustXamlLoader.Load(this); Title.Text = name; Description.SetMessage(description); foreach (var role in roles) { var button = new GhostRoleEntryButtons(); button.RequestButton.OnPressed += _ => OnRoleSelected?.Invoke(role); button.FollowButton.OnPressed += _ => OnRoleFollow?.Invoke(role); Buttons.AddChild(button); } }
private void ListAdapter_OnChosen(Role obj) { OnRoleSelected?.Invoke(obj); }