private void AddCompulsaryRoutingCodeRow(Location loc, string keySuffix) { string locationKey = loc.Id + keySuffix; Log.Trace(CultureInfo.CurrentCulture, Resources.LogMessage_AddRoutingRow, locationKey); if (!Locations.Any(l => l.LocationKey == locationKey)) { Locations.AddSorted(new LocationDisplayModel { LocationKey = locationKey, LocationId = loc.Id, AlwaysDisplay = true, ArrivalDepartureLabel = string.Empty, EditorDisplayName = string.Empty, ExportDisplayName = string.Empty, Mileage = loc.Mileage, FontType = loc.FontType, IsRoutingCodeRow = true, DisplaySeparatorAbove = loc.DisplaySeparatorAbove, DisplaySeparatorBelow = loc.DisplaySeparatorBelow, ParentDisplaySeparatorAbove = loc.DisplaySeparatorAbove, ParentDisplaySeparatorBelow = loc.DisplaySeparatorBelow, }, _locationDisplayModelComparer); } }
public CustomMap CreateMap() { Position centre = new Position(57.1499749, -2.1950675); if (Locations.Any()) { var midPoint = Locations.Midpoint(); centre = new Position(midPoint.Latitude, midPoint.Longitude); } map = new CustomMap(MapSpan.FromCenterAndRadius(centre, Distance.FromMiles(.5)), isReadOnly); map.IsShowingUser = false; map.SetBinding(Map.MapTypeProperty, nameof(MapType), BindingMode.TwoWay); map.InputTransparent = isReadOnly; map.MapClicked += (s, e) => { if (!goToMapPageOnClick) { MapTapped?.Invoke(null, e); } }; CreatePolylinesFromLocations(); return(map); }
private void AddCompulsaryLocation(Location loc, string locationKeySuffix) { string locationKey = loc.Id + locationKeySuffix; Log.Trace(CultureInfo.CurrentCulture, Resources.LogMessage_AddArrivalDepartureRow, locationKey); if (!Locations.Any(l => l.LocationKey == locationKey)) { Locations.AddSorted(new LocationDisplayModel { LocationKey = locationKey, LocationId = loc.Id, AlwaysDisplay = true, ArrivalDepartureLabel = locationKey.Substring(locationKey.Length - 1), EditorDisplayName = loc.EditorDisplayName, ExportDisplayName = loc.TimetableDisplayName, Mileage = loc.Mileage, FontType = loc.FontType, IsRoutingCodeRow = false, DisplaySeparatorAbove = loc.DisplaySeparatorAbove, DisplaySeparatorBelow = loc.DisplaySeparatorBelow, ParentDisplaySeparatorAbove = loc.DisplaySeparatorAbove, ParentDisplaySeparatorBelow = loc.DisplaySeparatorBelow, }, _locationDisplayModelComparer); } }
protected override void UpdateData() { var geometry = (PathGeometry)Data; geometry.Figures.Clear(); if (ParentMap != null && Locations != null && Locations.Any()) { var points = Locations.Select(l => ParentMap.MapTransform.Transform(l)); var figure = new PathFigure { StartPoint = points.First(), IsClosed = IsClosed, IsFilled = IsClosed }; var segment = new PolyLineSegment(); foreach (var point in points.Skip(1)) { segment.Points.Add(point); } figure.Segments.Add(segment); geometry.Figures.Add(figure); geometry.Transform = ParentMap.ViewportTransform; } else { geometry.ClearValue(Geometry.TransformProperty); } }
protected override void UpdateData() { var geometry = (PathGeometry)Data; geometry.Figures.Clear(); if (ParentMap != null && Locations != null && Locations.Any()) { var points = Locations.Select(l => ParentMap.MapProjection.LocationToPoint(l)); var figure = new PathFigure { StartPoint = points.First(), IsClosed = IsClosed, IsFilled = IsClosed }; var segment = new PolyLineSegment(); foreach (var point in points.Skip(1)) { segment.Points.Add(point); } figure.Segments.Add(segment); geometry.Figures.Add(figure); } }
/// <summary> /// Gets the data store from Icarus, you can optionally speicify the location tag to use. /// If the location tag is left blank, the default tag will be used. /// The isNew out flag will be true if teh data store had to be created, false otherwise. /// </summary> /// <param name="dataStoreName">Name of the data store.</param> /// <param name="isNew">if set to <c>true</c> then the data store was created as a part of this call.</param> /// <param name="locationTag">The location tag, if left blank will be the default tag.</param> /// <param name="isAccessEveryone">if set to <c>true</c> the Icarus datastore is accessible by everyone.</param> /// <returns> /// The data store. /// </returns> public IIcarusDataStore GetDataStore(string dataStoreName, out bool isNew, string locationTag = "", bool isAccessEveryone = false) { isNew = false; if (!Locations.Any()) { return(default(IIcarusDataStore)); } if (string.IsNullOrEmpty(locationTag)) { locationTag = Locations.ContainsKey(DefaultTag) ? DefaultTag : Locations.Keys.First(); } var storeTagKey = string.Format("{0}|{1}", locationTag, dataStoreName); if (!_dataStores.ContainsKey(storeTagKey)) { var path = string.Empty; isNew = !IcarusDataStore.Exists(Locations[locationTag], dataStoreName, out path); _dataStores.Add(storeTagKey, new IcarusDataStore( Locations[locationTag], dataStoreName, (IsAccessEveryone || isAccessEveryone))); } return(_dataStores[storeTagKey]); }
public override async void Update(TimeSpan delta) { if (Locations.Any(x => x.Equals(new TileLocation(_player.EnemyTrackingPosition)))) { World.NavigateToScene("GameOver"); } }
public bool Load(string imageFilePath) { Bitmap = (Bitmap)System.Drawing.Image.FromFile(imageFilePath); ImageFilePath = imageFilePath; try { //Image = FaceRecognition.LoadImage(Bitmap); Image = FaceRecognition.LoadImageFile(imageFilePath); } catch (Exception e) { return(false); } Locations = FaceRecognition.FaceLocations(Image).ToList(); if (Locations.Any()) { Encodings = FaceRecognition.FaceEncodings(Image, Locations).ToList(); } IsLoaded = true; return(true); }
void RemoveLocation() { if (Locations.Any()) { Locations.Remove(Locations.First()); } }
protected override void OnCompleteType( ICompletionContext context, DirectiveTypeDefinition definition) { base.OnCompleteType(context, definition); _converter = context.Services.GetTypeConversion(); MiddlewareComponents = definition.MiddlewareComponents.ToList().AsReadOnly(); SyntaxNode = definition.SyntaxNode; Locations = definition.Locations.ToList().AsReadOnly(); Arguments = new FieldCollection <Argument>( definition.Arguments.Select(t => new Argument(t))); IsExecutable = MiddlewareComponents.Count > 0; if (!Locations.Any()) { context.ReportError(SchemaErrorBuilder.New() .SetMessage(string.Format( CultureInfo.InvariantCulture, TypeResources.DirectiveType_NoLocations, Name)) .SetCode(ErrorCodes.Schema.MissingType) .SetTypeSystemObject(context.Type) .AddSyntaxNode(definition.SyntaxNode) .Build()); } FieldInitHelper.CompleteFields(context, definition, Arguments); }
protected override void OnCompleteType( ICompletionContext context, DirectiveTypeDefinition definition) { base.OnCompleteType(context, definition); _converter = context.Services.GetTypeConversion(); MiddlewareComponents = definition.MiddlewareComponents.ToList().AsReadOnly(); SyntaxNode = definition.SyntaxNode; ClrType = definition.ClrType == GetType() ? typeof(object) : definition.ClrType; IsRepeatable = definition.IsRepeatable; Locations = definition.Locations.ToList().AsReadOnly(); Arguments = new FieldCollection <Argument>( definition.Arguments.Select(t => new Argument(t))); IsExecutable = MiddlewareComponents.Count > 0; if (!Locations.Any()) { // TODO : resources context.ReportError(SchemaErrorBuilder.New() .SetMessage( $"The `{Name}` directive does not declare any " + "location on which it is valid.") .SetCode(TypeErrorCodes.MissingType) .SetTypeSystemObject(context.Type) .AddSyntaxNode(definition.SyntaxNode) .Build()); } FieldInitHelper.CompleteFields(context, definition, Arguments); }
private void FavAddressSearch_OnSelectedAction(object sender, EventArgs e) { if (sender is AddressesSearch asS) { if (asS.SelectedAddress == null) { return; } var currPin = Pins?.FirstOrDefault(); if (currPin != null) { Pins.Clear(); currPin.Location = new Location(asS.SelectedAddress.Lat, asS.SelectedAddress.Lon); Pins.Add(currPin); } else { if (!Locations.Any(p => p.Address == asS.SelectedAddress)) { Pins.Clear(); Pins.Add(new Pushpin() { Location = new Location(asS.SelectedAddress.Lat, asS.SelectedAddress.Lon), Content = Tools.CreateIcon((Editing == null) ? PackIconKind.Plus : PackIconKind.Edit) }); } } if (!(currPin != null && (Math.Abs(currPin.Location.Latitude - asS.SelectedAddress.Lat) < 1 || Math.Abs(currPin.Location.Longitude - asS.SelectedAddress.Lon) < 1))) { FavMap.Center = new Location(asS.SelectedAddress.Lat, asS.SelectedAddress.Lon); } } }
void ReplaceLocation() { if (!Locations.Any()) { return; } Locations[Locations.Count - 1] = NewLocation(); }
public override void Update(TimeSpan delta) { var playerLoc = new TileLocation(_player.EnemyTrackingPosition); if (Locations.Any(x => x.Equals(playerLoc))) { World.NavigateToScene(ConnectedRoom); } }
/// <summary> /// Renders line graph. /// </summary> public override void Render() { if (Locations?.Any() ?? false) { _lineGraph.Points = Locations; _lineGraph.Visibility = Visibility.Visible; } else { _lineGraph.Points = null; _lineGraph.Visibility = Visibility.Collapsed; } }
public void TryAddLocation(Location location) { var locationCode = location.GetCode(); if (Locations.Any(loc => loc.Code.Equals(locationCode))) { return; } dbContext.Locations.Add(location); dbContext.SaveChanges(); Helpers.Util.SaveLocationData(dbContext.Locations); }
private void DetectLocations(object param = null) { var locations = GetLocationsList(); TroveLocation.DetectLocations(locations); var ic = StringComparison.OrdinalIgnoreCase; foreach (var loc in locations) { // Add any locations detected that are not already present if (!Locations.Any(l => l.DataObject.LocationPath.Equals(loc.LocationPath, ic))) { Locations.Add(new TroveLocationViewModel(loc)); } } }
/// <summary> /// Add a column to the table. /// </summary> /// <param name="segment">The data in the column to be added.</param> public void Add(TrainSegmentModel segment) { if (segment is null) { throw new ArgumentNullException(nameof(segment)); } foreach (string locationKey in TrainSegments.SelectMany(t => t.TimingsIndex).Select(t => t.Key).Union(segment.TimingsIndex.Select(t => t.Key))) { if (!Locations.Any(l => l.LocationKey == locationKey)) { string strippedKey = locationKey.StripArrivalDepartureSuffix(); Location loc = LocationDict[strippedKey]; LocationDisplayModel ldm = new LocationDisplayModel { LocationKey = locationKey, LocationId = loc.Id, Mileage = loc.Mileage, FontType = loc.FontType, DisplaySeparatorAbove = loc.DisplaySeparatorAbove, DisplaySeparatorBelow = loc.DisplaySeparatorBelow, ParentDisplaySeparatorBelow = loc.DisplaySeparatorBelow, ParentDisplaySeparatorAbove = loc.DisplaySeparatorAbove, }; if (locationKey.EndsWith(LocationIdSuffixes.Arrival, StringComparison.InvariantCulture) || locationKey.EndsWith(LocationIdSuffixes.Departure, StringComparison.InvariantCulture)) { ldm.ArrivalDepartureLabel = locationKey.Substring(locationKey.Length - 1); ldm.EditorDisplayName = loc.EditorDisplayName; ldm.ExportDisplayName = loc.TimetableDisplayName; } else { ldm.EditorDisplayName = string.Empty; ldm.ExportDisplayName = string.Empty; ldm.IsRoutingCodeRow = true; if (locationKey.EndsWith(LocationIdSuffixes.Platform, StringComparison.InvariantCulture)) { ldm.ArrivalDepartureLabel = Resources.LocationRow_Abbreviation_Platform; } } Locations.AddSorted(ldm, _locationDisplayModelComparer); } } TrainSegments.AddSorted(segment, new TrainSegmentModelComparer(Locations)); }
void UpdateLocations() { if (!Locations.Any()) { return; } double lastLatitude = Locations.Last().Position.Latitude; foreach (Pin location in Locations) { var newposted = new Pin() { Position = new Position(lastLatitude, location.Position.Longitude), Label = lastLatitude + ", " + location.Position.Longitude.ToString() }; Locations.Add(newposted); } }
protected override void UpdateData() { var geometry = (StreamGeometry)Data; if (ParentMap != null && Locations != null && Locations.Any()) { using (var context = geometry.Open()) { var points = Locations.Select(l => ParentMap.MapTransform.Transform(l)); context.BeginFigure(points.First(), IsClosed, IsClosed); context.PolyLineTo(points.Skip(1).ToList(), true, false); } } else { geometry.Clear(); } }
/// <summary> /// Получение всех сотрудников. /// </summary> private void GetAllLocations() { if (GetAll != null) { GetAll(); } Locations = Filters(); if (Locations.Any()) { btnNext.Enabled = true; btnPrev.Enabled = true; } else { btnNext.Enabled = false; btnPrev.Enabled = false; } }
public void Can_prepare_mock_data() { Assert.That(StartLocation != null); Assert.That(Locations != null && Locations.Any(), "Mock Locations not ready"); Assert.That(Drivers != null && Drivers.Any(), "Mock Drivers not ready"); Assert.That(Jobs != null && Jobs.Any(), "Mock Jobs not ready"); var hazmatJobs = Jobs.Where(p => p.IsHazmat); var shortHaulJobs = Jobs.Where(p => p.IsShortHaul); var longHaulJobs = Jobs.Where(p => p.IsLongHaul); var type1Jobs = Jobs.Where(p => p.OrderType == 1); var type2Jobs = Jobs.Where(p => p.OrderType == 2); var type3Jobs = Jobs.Where(p => p.OrderType == 3); var p1Jobs = Jobs.Where(p => p.Priority == 1); var p2Jobs = Jobs.Where(p => p.Priority == 2); var p3Jobs = Jobs.Where(p => p.Priority == 3); Assert.That(hazmatJobs != null && hazmatJobs.Any()); Assert.That(shortHaulJobs != null && shortHaulJobs.Any()); Assert.That(longHaulJobs != null && longHaulJobs.Any()); Assert.That(type1Jobs != null && type1Jobs.Any()); Assert.That(type2Jobs != null && type2Jobs.Any()); Assert.That(type3Jobs != null && type3Jobs.Any()); Assert.That(p1Jobs != null && p1Jobs.Any()); Assert.That(p2Jobs != null && p2Jobs.Any()); Assert.That(p3Jobs != null && p3Jobs.Any()); var hazmatDrivers = Drivers.Where(p => p.IsHazmatEligible); var shortHaulDrivers = Drivers.Where(p => p.IsShortHaulEligible); var longHaulDrivers = Drivers.Where(p => p.IsLongHaulEligible); var type1Drivers = Drivers.Where(p => p.OrderType == 1); var type2Drivers = Drivers.Where(p => p.OrderType == 2); var type3Drivers = Drivers.Where(p => p.OrderType == 3); Assert.That(hazmatDrivers != null && hazmatDrivers.Any()); Assert.That(shortHaulDrivers != null && shortHaulDrivers.Any()); Assert.That(longHaulDrivers != null && longHaulDrivers.Any()); Assert.That(type1Drivers != null && type1Drivers.Any()); Assert.That(type2Drivers != null && type2Drivers.Any()); Assert.That(type3Drivers != null && type3Drivers.Any()); }
public bool Load(Bitmap bitmap) { Bitmap = bitmap; try { Image = FaceRecognition.LoadImage(Bitmap); } catch (Exception e) { return(false); } Locations = FaceRecognition.FaceLocations(Image).ToList(); if (Locations.Any()) { Encodings = FaceRecognition.FaceEncodings(Image, Locations).ToList(); } IsLoaded = true; return(true); }
/// <summary> /// Returns true if this statement surrounds the given source location. /// </summary> /// <param name="loc">The source location to look for.</param> /// <returns>True if this is a container for the given location, False otherwise.</returns> public virtual bool ContainsLocation(SourceLocation loc) { return(Locations.Any(l => l.Contains(loc))); }
public void Save() { var context = DataEntitiesProvider.Provide(); var id = OlympiadId; Olympiad_Info o; if (id == 0) { o = new Olympiad_Info() { YearOf = int.Parse(this.YearOf), Number = this.Number, Title = this.Title, Venue = this.Venue, StartDate = this.StartDate, FinishDate = this.FinishDate, MaxFee = decimal.Parse(this.MaxFee), MaxCon = decimal.Parse(this.MaxCon), AgeDate = this.AgeDate, JnrAge = int.Parse(this.JnrAge), SnrAge = int.Parse(this.SnrAge), PentaLong = int.Parse(this.PentaLong), PentaTotal = int.Parse(this.PentaTotal), Events = new List <Event>(), Current = false, // will be sorted out later }; context.Olympiad_Infoes.Add(o); context.SaveChanges(); // So we don't have to do a full refresh of the combo Olympiads.RemoveAt(0); Olympiads.Insert(0, new OlympiadVm() { Text = o.FullTitle(), Id = o.Id }); id = o.Id; } else { o = context.Olympiad_Infoes.FirstOrDefault(x => x.Id == id); o.YearOf = int.Parse(this.YearOf); o.Number = this.Number; o.Title = this.Title; o.Venue = this.Venue; o.StartDate = this.StartDate; o.FinishDate = this.FinishDate; o.MaxFee = decimal.Parse(this.MaxFee); o.MaxCon = decimal.Parse(this.MaxCon); o.AgeDate = this.AgeDate; o.JnrAge = int.Parse(this.JnrAge); o.SnrAge = int.Parse(this.SnrAge); o.PentaLong = int.Parse(this.PentaLong); o.PentaTotal = int.Parse(this.PentaTotal); o.Current = false; // will be sorted out later } context.SaveChanges(); // Now update the events and locations. Need to do here to have the reference back to the Olympiad foreach (var existingEvent in o.Events.ToList()) { if (!Events.Any(x => x.Id == existingEvent.EIN)) { o.Events.Remove(existingEvent); context.Events.Remove(existingEvent); } } foreach (var existingLocation in o.Locations.ToList()) { if (!Locations.Any(x => x.Id == existingLocation.Id)) { o.Locations.Remove(existingLocation); context.Locations.Remove(existingLocation); } } foreach (var evm in Events) { if (evm.Id == 0) { var game = context.Games.FirstOrDefault(x => evm.Code.StartsWith(x.Code)); if (game == null) { throw new ArgumentOutOfRangeException("No Game for code " + evm.Code); } var evt = new Event() { Mind_Sport = evm.Name, Code = evm.Code, Olympiad_Info = o, Game = game, MAX_Number = 70, ConsistentWithBoardability = true, PentamindFactor = 1.0f // TODO more stuff here }; o.Events.Add(evt); } else { var evt = context.Events.Find(evm.Id); // We're not doing any update here? } } foreach (var loc in Locations) { if (loc.Id == 0) { o.Locations.Add(new Location() { Location1 = loc.Name, Olympiad_Info = o, YEAR = o.YearOf }); } // Not doing updates here } context.SaveChanges(); // Make sure Current is set properly var oldCurrents = context.Olympiad_Infoes.Where(x => x.Current).ToList(); oldCurrents.ForEach(ol => ol.Current = false); var newCurrent = context.Olympiad_Infoes.OrderByDescending(x => x.StartDate).First(); newCurrent.Current = true; context.SaveChanges(); var eventIndexer = new EventIndexer(); eventIndexer.IndexEvents(id); IsDirty = false; OlympiadId = id; }
public bool ShouldSerializeLocations() { return(Locations.Any()); }
/// <summary> /// Returns true if this statement contains the given XPath. A statement contains /// an xpath if <see cref="SrcMLLocation.XPath"/> is a prefix for <paramref name="xpath"/> /// </summary> /// <param name="xpath">The xpath to look for.</param> /// <returns>True if this statement contains the given xpath. False, otherwise.</returns> public virtual bool ContainsLocation(string xpath) { return(Locations.Any(l => xpath.StartsWith(l.XPath))); }
/// <summary> /// Initializes a new instance of the <c>__Directive</c> introspection type. /// </summary> /// <param name="allowAppliedDirectives">Allows 'appliedDirectives' field for this type. It is an experimental feature.</param> /// <param name="allowRepeatable">Allows 'isRepeatable' field for this type. This feature is from a working draft of the specification.</param> public __Directive(bool allowAppliedDirectives = false, bool allowRepeatable = false) { Name = nameof(__Directive); Description = "A Directive provides a way to describe alternate runtime execution and " + "type validation behavior in a GraphQL document." + @" " + "In some cases, you need to provide options to alter GraphQL's " + "execution behavior in ways field arguments will not suffice, such as " + "conditionally including or skipping a field. Directives provide this by " + "describing additional information to the executor."; Field <NonNullGraphType <StringGraphType> >("name", resolve: context => context.Source !.Name); Field <StringGraphType>("description", resolve: context => context.Source !.Description); Field <NonNullGraphType <ListGraphType <NonNullGraphType <__DirectiveLocation> > > >("locations"); Field <NonNullGraphType <ListGraphType <NonNullGraphType <__InputValue> > > >("args", resolve: context => context.Source !.Arguments?.List ?? Enumerable.Empty <QueryArgument>() ); if (allowRepeatable) { Field <NonNullGraphType <BooleanGraphType> >("isRepeatable", resolve: context => context.Source !.Repeatable); } Field <NonNullGraphType <BooleanGraphType> >("onOperation", deprecationReason: "Use 'locations'.", resolve: context => context.Source !.Locations.Any(l => l == DirectiveLocation.Query || l == DirectiveLocation.Mutation || l == DirectiveLocation.Subscription)); Field <NonNullGraphType <BooleanGraphType> >("onFragment", deprecationReason: "Use 'locations'.", resolve: context => context.Source !.Locations.Any(l => l == DirectiveLocation.FragmentSpread || l == DirectiveLocation.InlineFragment || l == DirectiveLocation.FragmentDefinition)); Field <NonNullGraphType <BooleanGraphType> >("onField", deprecationReason: "Use 'locations'.", resolve: context => context.Source !.Locations.Any(l => l == DirectiveLocation.Field)); if (allowAppliedDirectives) { this.AddAppliedDirectivesField("directive"); } }
/// <summary> /// Returns true if this variable scope contains the given XPath. A variable scope contains /// an xpath if <see cref="SrcMLLocation.XPath"/> is a prefix for /// <paramref name="xpath"/></summary> /// <param name="xpath">The xpath to look for.</param> /// <returns>True if this is a container for the given xpath. False, otherwise.</returns> public virtual bool IsScopeFor(string xpath) { return(Locations.Any(l => xpath.StartsWith(l.XPath))); }
/// <summary> /// Returns true if this scope surrounds the given source location. /// </summary> /// <param name="loc">The source location to look for.</param> /// <returns>True if this is a container for the given location, False otherwise.</returns> public virtual bool IsScopeFor(SourceLocation loc) { return(Locations.Any(l => l.Contains(loc))); }