public void AddSelectionToBetslip(SelectionRequest selectionRequest) { using (Logger.BeginScope(LoggerHelper.GetCaller())) { try { var horse = FindBet(selectionRequest); Logger.LogDebug("horse was found:\n" + horse.GetDump()); var selection = new Selection(horse.Id, selectionRequest) { Data = horse, Odds = (double)horse.Odds, Stake = 0, EW = false }; CurrentBetslip.AddSelection(selection); GenerateMultiple(); } catch (Exception ex) { Logger.LogError(ex, $"{ LoggerHelper.GetCaller() } failed"); throw ex.PreserveStackTrace(); } } }
public void WaitSelection(CancellationToken cancellation) { waitOne = true; SelectionRequest?.Invoke(this, new EventArgs()); while (waitOne) { cancellation.ThrowIfCancellationRequested(); Thread.Sleep(100); } }
/***************************************************/ public static IEnumerable <ElementId> ElementIds(this SelectionRequest request, Document document, IEnumerable <ElementId> ids = null) { if (document.IsLinked) { BH.Engine.Reflection.Compute.RecordError("It is not allowed to combine selection requests with link requests - Revit selection does not work with links."); return(null); } return(new UIDocument(document).ElementIdsBySelection(ids)); }
/***************************************************/ public IEnumerable <IBHoMObject> Read(SelectionRequest request, ActionConfig actionConfig = null) { List <IBHoMObject> results = new List <IBHoMObject>(); foreach (KeyValuePair <Type, List <string> > keyVal in SelectedElements()) { results.AddRange(IRead(keyVal.Key, keyVal.Value, actionConfig)); } return(results); }
public void RemoveSelectionFromBetslip(SelectionRequest selectionQuery) { using (Logger.BeginScope(LoggerHelper.GetCaller())) { try { var selection = CurrentBetslip.GetSelectionByQuery(selectionQuery); CurrentBetslip.RemoveSelection(selection, true); GenerateMultiple(); } catch (Exception ex) { Logger.LogError(ex, $"{ LoggerHelper.GetCaller()} failed"); throw ex.PreserveStackTrace(); } } }
public void SetRequested(SelectionRequest selectionRequest, double?stake, bool?ew) { using (Logger.BeginScope(LoggerHelper.GetCaller())) { try { if ((stake.HasValue ^ ew.HasValue) == false) { throw new Exception($"Stake or ew must have value, stake: {stake} ew: {ew}"); } var selection = CurrentBetslip.GetSelectionByQuery(selectionRequest); CurrentBetslip.SetRequested(selection, stake, ew); if (stake.HasValue) { CurrentBetslip.UpdateSelection( selection.Key, selection.Odds, stake.Value, selection.EW, selection.Data, selection.MinStake ?? _minStake ?? 0.1, selection.MaxStake); } if (ew.HasValue) { CurrentBetslip.UpdateSelection( selection.Key, selection.Odds, selection.Stake, (bool)ew, selection.Data, selection.MinStake ?? _minStake ?? 0.1, selection.MaxStake); } } catch (Exception ex) { Logger.LogError(ex, $"{ LoggerHelper.GetCaller()} failed"); UpdateBetslip(); throw ex.PreserveStackTrace(); } } }
private HorseInfo FindBet(SelectionRequest selection) { HorseInfo horse = null; using (Logger.BeginScope(LoggerHelper.GetCaller())) { try { JToken allRacesJData = _web.GetHorseRacing(); var racesAtTime = GetAllRacesAtTime(allRacesJData, selection.RaceStartTime); var firstRace = SortRacesBySimilarity(racesAtTime, selection.EventName).FirstOrDefault(); JToken raceHorsesJData = _web.GetBetoffer(firstRace.Id); var horses = ExtractHorses(raceHorsesJData); horse = FindHorseByName(horses, selection.Name); horse.Race = firstRace; return(horse); } catch (Exception ex) { throw new Exception($"Horse racing or betoffer are not found!\n{ex.Message}"); } } }
/// <summary> /// Wait until user select point on image by mouse click. /// </summary> /// <returns> /// Coordinates of selected point. /// </returns> public Vector2D SelectPoint() { this.Cursor = Cursors.Cross; SelectionRequest req = new SelectionRequest(); _selectionQueue.Enqueue(req); req.waitEvent.WaitOne(); req.waitEvent.Close(); return req.position; }
public void AcceptChanges(SelectionRequest selectionRequest) { var selection = CurrentBetslip.GetSelectionByQuery(selectionRequest); CurrentBetslip.AcceptBetOffer(selection); }
/***************************************************/ public static IEnumerable <ElementId> ElementIds(this SelectionRequest request, UIDocument uIDocument, IEnumerable <ElementId> ids = null) { return(uIDocument.ElementIdsBySelection(ids)); }