Inheritance: MonoBehaviour
        public MapItem[,] createMapItemList(String[,] map)
        {
            int size = map.GetLength(0);
            MapItem[,] itList = new MapItem[size, size];
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    itList[j, i] = new MapItem();
                    /*if (new String[] { MapItem.BLANK, MapItem.COIN, MapItem.LIFEPACK }.Contains(map[j, i], StringComparer.Ordinal))
                        itList[j, i].Contain = MapItem.BLANK;
                    else
                        itList[j, i].Contain = MapItem.STONE;*/
                    itList[j, i].Contain = map[j, i];
                    if (DecodeOperations.playerDir.Contains(map[j, i],StringComparer.Ordinal))
                    {
                        itList[j, i].Dir = Array.FindIndex(DecodeOperations.playerDir, pl => pl.Contains(map[j, i]));
                    }

                    itList[j, i].Name = i.ToString() + "," + j.ToString();
                    itList[j, i].Pre = null;
                    itList[j, i].Dis = Int32.MaxValue - 1;
                }
            }
            return itList;
        }
Example #2
0
 public PlayMenu()
 {
     map = new MapItem(this);
     components.Add(new BackGround(this, "Images//BackGround//background-test2"));
     components.Add(map);
     this.BlocksUpdate = true;
     this.BlocksDraw = true;
 }
Example #3
0
    public void Add(MapItem item)
    {
        items.Add(item);

        if(item is StartPosMI)
        {
            startPoses.Add(item as StartPosMI);
        }
    }
        protected override List<StatementSyntax> BuildAllBodyStatements(MapItem source, MapItem target)
        {
            var allStatements = new List<StatementSyntax>();

            var mappingStatements = BuildSourceToTargetMappingStatements(source, target);
            allStatements.AddRange(mappingStatements);

            return allStatements;
        }
Example #5
0
        protected BlockSyntax BuildMethodBody(MapItem source, MapItem target)
        {
            var allStatements = BuildAllBodyStatements(source, target);

            var methodBody = SyntaxFactory.Block()
                .WithStatements(SyntaxFactory.List<StatementSyntax>(allStatements));

            return methodBody;
        }
        /// <summary>
        /// Adds the specified map item to the set.
        /// </summary>
        /// <param name="item">The map item.</param>
        /// <returns>
        /// True if the element is added to the set; false if the element is already present.
        /// </returns>
        public override bool Add(MapItem item)
        {
            if (!_Items.Contains(item))
            {
                _Items.Add(item);
                return true;
            }

            return false;
        }
        protected override List<StatementSyntax> BuildAllBodyStatements(MapItem source, MapItem target)
        {
            var allStatements = new List<StatementSyntax>();

            var targetDeclaration = BuildVariableDeclarationStatement(target.Syntax, target.Name);
            allStatements.Add(targetDeclaration);

            var mappingStatements = BuildSourceToTargetMappingStatements(source, target);
            allStatements.AddRange(mappingStatements);

            var returnStatement = BuildReturnStatement(target.Name);
            allStatements.Add(returnStatement);
            return allStatements;
        }
        public void BuildItemArray()
        {
            int size = 0;

            foreach (MapItem item in RawItems)
                if (item.Position.HasValue) size++;

            Items = new MapItem[size];

            int pos = 0;
            foreach (MapItem item in RawItems)
                if (item.Position.HasValue)
                    Items[pos++] = item;
        }
        internal static Expression MapCollectionExpression(this TypeMapRegistry typeMapRegistry,
           IConfigurationProvider configurationProvider, PropertyMap propertyMap, Expression sourceExpression,
           Expression destExpression, Expression contextExpression, Func<Expression, Expression> conditionalExpression, Type ifInterfaceType, MapItem mapItem)
        {
            var passedDestination = Variable(destExpression.Type, "passedDestination");
            var condition = conditionalExpression(passedDestination);
            var newExpression = Variable(passedDestination.Type, "collectionDestination");
            var sourceElementType = TypeHelper.GetElementType(sourceExpression.Type);
            var itemParam = Parameter(sourceElementType, "item");

            var itemExpr = mapItem(typeMapRegistry, configurationProvider, propertyMap, sourceExpression.Type, passedDestination.Type, itemParam, contextExpression);

            var destinationElementType = TypeHelper.GetElementType(destExpression.Type);
            var destinationCollectionType = typeof(ICollection<>).MakeGenericType(destinationElementType);
            var clearMethod = destinationCollectionType.GetDeclaredMethod("Clear");
            var cast = typeof(Enumerable).GetDeclaredMethod("Cast").MakeGenericMethod(itemParam.Type);
            var addMethod = destinationCollectionType.GetDeclaredMethod("Add");
            var genericSource = sourceExpression.Type.IsGenericType() ? sourceExpression : Call(null, cast, sourceExpression);
            var destination = propertyMap?.UseDestinationValue == true ? passedDestination : newExpression;
            var addItems = ForEach(genericSource, itemParam, Call(destination, addMethod, itemExpr));

            var mapExpr = Block(addItems, destination);

            var ifNullExpr = configurationProvider.Configuration.AllowNullCollections ? Constant(null, passedDestination.Type) : (Expression) newExpression;
            var checkNull =  
                Block(new[] { newExpression, passedDestination },
                    Assign(passedDestination, destExpression),
                    IfThenElse(condition ?? Constant(false),
                                    Block(Assign(newExpression, passedDestination), Call(newExpression, clearMethod)),
                                    Assign(newExpression, passedDestination.Type.NewExpr(ifInterfaceType))),
                    Condition(Equal(sourceExpression, Constant(null)), ToType(ifNullExpr, passedDestination.Type), ToType(mapExpr, passedDestination.Type))
                );
            if(propertyMap != null)
            {
                return checkNull;
            }
            var elementTypeMap = configurationProvider.ResolveTypeMap(sourceElementType, destinationElementType);
            if(elementTypeMap == null)
            {
                return checkNull;
            }
            var checkContext = TypeMapPlanBuilder.CheckContext(elementTypeMap, contextExpression);
            if(checkContext == null)
            {
                return checkNull;
            }
            return Block(checkContext, checkNull);
        }
        protected override async Task<Solution> MapAsync(Document document, MethodDeclarationSyntax methodDeclaration, CancellationToken cancellationToken)
        {
            ParameterSyntax firstParameterSyntax = methodDeclaration.ParameterList.Parameters.First();
            TypeSyntax returnTypeSyntax = methodDeclaration.ReturnType;

            SemanticModel model = await document.GetSemanticModelAsync(cancellationToken);
            INamedTypeSymbol firstParameter = model.GetDeclaredSymbol(firstParameterSyntax).ToNamedTypeSymbol();
            INamedTypeSymbol returnTypeSymbol = model.GetSymbolInfo(returnTypeSyntax).ToNamedTypeSymbol();

            var sourceItem = new MapItem() {Name = firstParameterSyntax.Identifier.ValueText, Syntax = firstParameterSyntax.Type, Symbol = firstParameter};
            var targetItem = new MapItem() {Name = "target", Syntax = returnTypeSyntax, Symbol = returnTypeSymbol};

            var methodBody = BuildMethodBody(sourceItem, targetItem);
            var newSolution = await BuildSolutionWithNewMethodBody(document, methodDeclaration, cancellationToken, methodBody);

            // Return the new solution with the method containing the mapping code.
            return newSolution;
        }
Example #11
0
        /// <summary>
        /// Adds the specified item to the tree.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <returns>true if the element is added to the set; false if the element is already present.</returns>
        public bool Add(MapItem item)
        {
            Debug.Assert(_NodesToVisit.Count == 0);

            _NodesToVisit.Push(_RootNode);

            int numNodesVisited = 0;

            for (; _NodesToVisit.Count > 0; numNodesVisited++)
            {
                MapItemQuadTreeNode node = _NodesToVisit.Pop();
                Debug.Assert(node.ZoomLevel <= item.MaxZoomLevel);
                Debug.Assert(item.BoundingRectAtZoomLevel(node.ZoomLevel).Intersects(node.Rect));

                if (node.ZoomLevel >= item.MinZoomLevel)
                {
                    if (!node.AddMapItem(item))
                    {
                        Debug.Assert(numNodesVisited == 0);

                        // If the item's present at this node, it will be present in all others in its
                        // [MinZoomLevel, MaxZoomLevel] range, so return early, indicating it's already in
                        // the tree.
                        return false;
                    }
                }

                if (node.ZoomLevel < item.MaxZoomLevel)
                {
                    for (int childIdx = 0; childIdx < 4; childIdx++)
                    {
                        Rect childRect = node.GetChildRect(childIdx);
                        NormalizedMercatorRect itemRect = item.BoundingRectAtZoomLevel(node.ZoomLevel + 1);

                        if (itemRect.Intersects(childRect))
                        {
                            _NodesToVisit.Push(node.EnsureChild(childIdx));
                        }
                    }
                }
            }

            return true;
        }
Example #12
0
        internal WorldPart(MapItem data, MapInfo mapDataList, SencePart sencePart, int collusionLayer, MapManager.MapLoadingData loadingData)
        {
            m_data = loadingData;
            int count = data.List.Count;
            m_manager = WorldManager.GetInstance();
            m_mapData = sencePart;
            m_collusionLayer = collusionLayer;

            //m_filepath = new string[count];
            m_layers = new MapDrawer[count +1];
            string path = "Maps/" + mapDataList.Name + "/";
            m_locate = new Vector2(data.X * ImageSize, data.Y * ImageSize);

            foreach( var textureInfo in data.List)
            {
                DataReader.LoadAsync<Texture2D>( path + textureInfo.Texture, LoadingItemCallback, textureInfo.Layer );
                m_data.LoadingLeft++;
            }
        }
        public DynamicDataMap(ObservableCollection<RegisterSettings> registers)
        {
            bool positionsFound = false;

            Items = null;
            RawItems = new List<MapItem>();

            foreach (RegisterSettings reg in registers)
            {
                MapItem item = new MapItem();

                item.templateRegisterSettings = reg;
                item.Position = reg.Position;
                positionsFound |= item.Position.HasValue;
                RawItems.Add(item);
            }
            if (positionsFound)
                BuildItemArray();
        }
Example #14
0
 private void btnProcess_Click(object sender, EventArgs e)
 {
     var dlg = new OpenFileDialog
                   {
                       CheckFileExists = true,
                       Multiselect = false,
                       Filter = "png|*.png|gif|*.gif|jpg|*.jpg|images|*.png;*.jpg;*.gif",
                       DefaultExt = "images|*.png;*.jpg;*.gif"
                   };
     dlg.ShowDialog();
     Point size = new Point();
     Image img = Image.FromStream( dlg.OpenFile() );
     size.X = ( img.Width + 511 ) / 512;
     size.Y = ( img.Height + 511 ) / 512;
     Bitmap output = new Bitmap( 512, 512 );
     Graphics g = Graphics.FromImage( output );
     var list = new MapInfo();
     MapItem item;
     var dlg1 = new FolderBrowserDialog();
     dlg1.ShowDialog();
     string path = dlg1.SelectedPath;
     for( int i = 0; i < size.X; i++ )
     {
         for( int j = 0; j < size.Y; j++ )
         {
             item = new MapItem();// i, j, txtDir.Text + "\\" + txtPrefix.Text + "_" + j + "_" + i );
             list.Add( item );
             g.Clear( Color.Transparent );
             g.DrawImage(img, new Rectangle(-512 * i, -512 * j, img.Width, img.Height));
             //output.Save( path + "\\" + txtPrefix.Text + "_" + j + "_" + i + ".png", ImageFormat.Png );
         }
     }
     var xmlSerializer = new XmlSerializer( typeof( MapInfo ) );
     Stream stream = new FileStream( path + "\\" + ".xml", FileMode.Create );
     xmlSerializer.Serialize( stream, list );
     stream.Close();
 }
		private void _dropItem(int characterAmount, byte weight, byte maxWeight, MapItem item)
		{
			World.Instance.ActiveMapRenderer.AddMapItem(item);
			if (characterAmount >= 0) //will be -1 when another player drops
			{
				World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(item.id, characterAmount, weight, maxWeight);

				ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.id);
				m_game.Hud.AddChat(ChatTabs.System, "",
						string.Format("{0} {1} {2}", World.GetString(DATCONST2.STATUS_LABEL_ITEM_DROP_YOU_DROPPED), item.amount, rec.Name),
						ChatType.DownArrow);
				m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_DROP_YOU_DROPPED,
						string.Format(" {0} {1}", item.amount, rec.Name));
			}
		}
Example #16
0
        private void _handleItemDrop(Packet pkt)
        {
            if (OnDropItem == null) return;
            short _id = pkt.GetShort();
            int _amount = pkt.GetThree();
            int characterAmount = pkt.GetInt(); //amount remaining for the character
            MapItem item = new MapItem
            {
                id = _id,
                amount = _amount,
                uid = pkt.GetShort(),
                x = pkt.GetChar(),
                y = pkt.GetChar(),
                //turn off drop protection since main player dropped it
                time = DateTime.Now.AddSeconds(-5),
                npcDrop = false,
                playerID = 0 //id of 0 means the currently logged in player owns it
            };
            byte characterWeight = pkt.GetChar(), characterMaxWeight = pkt.GetChar(); //character adjusted weights

            OnDropItem(characterAmount, characterWeight, characterMaxWeight, item);
        }
Example #17
0
 private void _handleItemAdd(Packet pkt)
 {
     if (OnDropItem == null) return;
     MapItem item = new MapItem
     {
         id = pkt.GetShort(),
         uid = pkt.GetShort(),
         amount = pkt.GetThree(),
         x = pkt.GetChar(),
         y = pkt.GetChar(),
         time = DateTime.Now,
         npcDrop = false,
         playerID = -1 //another player dropped. drop protection says "Item protected" w/o player name
     };
     OnDropItem(-1, 0, 0, item);
 }
Example #18
0
		public void UpdateMapItemAmount(short uid, int amountTaken)
		{
			List<Point> pts = MapItems.Keys.Where(_key => MapItems[_key].Find(_mi => _mi.uid == uid).uid == uid).ToList();
			if(pts.Count > 1)
				throw new AmbiguousMatchException("Multiple MapItems shared that uid. Something is wrong.");

			List<MapItem> res = MapItems[pts[0]];
			MapItem toRemove = res.Find(_mi => _mi.uid == uid);
			res.Remove(toRemove);
			toRemove = new MapItem
			{
				amount = toRemove.amount - amountTaken,
				id = toRemove.id,
				npcDrop = toRemove.npcDrop,
				playerID = toRemove.playerID,
				time = toRemove.time,
				uid = toRemove.uid,
				x = toRemove.x,
				y = toRemove.y
			};
			//still some left. add it back.
			if(toRemove.amount > 0)
				res.Add(toRemove);
		}
Example #19
0
		private void RemoveMapItem(MapItem oldItem)
		{
			Point key = new Point(oldItem.x, oldItem.y);
			if (!MapItems.ContainsKey(key))
				return;
			MapItems[key].Remove(oldItem);
			if (MapItems[key].Count == 0)
				MapItems.Remove(key);
		}
Example #20
0
		public void AddMapItem(MapItem newItem)
		{
			if (newItem.npcDrop && newItem.id > 0)
			{
				ItemRecord rec = World.Instance.EIF.GetItemRecordByID(newItem.id);
				EOGame.Instance.Hud.AddChat(ChatTabs.System, "",
					string.Format("{0} {1} {2}", World.GetString(DATCONST2.STATUS_LABEL_THE_NPC_DROPPED), newItem.amount, rec.Name),
					ChatType.DownArrow);
			}

			Point key = new Point(newItem.x, newItem.y);
			if(!MapItems.ContainsKey(key))
				MapItems.Add(key, new List<MapItem>());

			int index = MapItems[key].FindIndex(_mi => _mi.uid == newItem.uid);
			if (index < 0)
				MapItems[key].Add(newItem);
		}
Example #21
0
 public bool Condition(MapItem item)
 {
     return((item.ItemInstance !.Item !.ItemType != ItemType.Map) && (item.VNum != 1046));
 }
        public IQueryable<MapItem> GetMapInfo( int groupId )
        {
            // Enable proxy creation since security is being checked and need to navigate parent authorities
            SetProxyCreation( true );

            var group = ( (GroupService)Service ).Queryable( "GroupLocations.Location" )
                .Where( g => g.Id == groupId )
                .FirstOrDefault();

            if ( group != null )
            {
                var person = GetPerson();

                if ( group.IsAuthorized( Rock.Security.Authorization.VIEW, person ) )
                {
                    var mapItems = new List<MapItem>();
                    foreach ( var location in group.GroupLocations
                        .Where( l => l.Location.GeoPoint != null || l.Location.GeoFence != null )
                        .Select( l => l.Location ) )
                    {
                        var mapItem = new MapItem( location );
                        mapItem.EntityTypeId = EntityTypeCache.Read( "Rock.Model.Group" ).Id;
                        mapItem.EntityId = group.Id;
                        mapItem.Name = group.Name;
                        if ( mapItem.Point != null || mapItem.PolygonPoints.Any() )
                        {
                            mapItems.Add( mapItem );
                        }
                    }

                    return mapItems.AsQueryable();
                }
                else
                {
                    throw new HttpResponseException( HttpStatusCode.Unauthorized );
                }
            }
            else
            {
                throw new HttpResponseException( HttpStatusCode.BadRequest );
            }
        }
        public IQueryable<MapItem> GetChildMapInfo( int groupId, string groupTypeIds = null, bool includeDescendants = false )
        {
            var person = GetPerson();

            var mapItems = new List<MapItem>();

            // Enable proxy creation since security is being checked and need to navigate parent authorities
            SetProxyCreation( true );

            var groupService = (GroupService)Service;
            var groupLocationService = new GroupLocationService( groupService.Context as RockContext );
            IEnumerable<Group> childGroups;

            if ( !includeDescendants )
            {
                childGroups = groupService.Queryable().Where( g => g.ParentGroupId == groupId );
            }
            else
            {
                childGroups = groupService.GetAllDescendents( groupId );
            }

            if ( !string.IsNullOrWhiteSpace( groupTypeIds ) )
            {
                var groupTypeIdList = groupTypeIds.Split( ',' ).AsIntegerList();
                if ( groupTypeIdList.Any() )
                {
                    childGroups = childGroups.Where( a => groupTypeIdList.Contains( a.GroupTypeId ) );
                }
            }

            var childGroupIds = childGroups.Select( a => a.Id ).ToList();

            // fetch all the groupLocations for all the groups we are going to show (to reduce SQL traffic)
            var groupsLocationList = groupLocationService.Queryable().Where( a => childGroupIds.Contains( a.GroupId ) && a.Location.GeoPoint != null || a.Location.GeoFence != null ).Select( a => new
            {
                a.GroupId,
                a.Location
            } ).ToList();

            foreach ( var group in childGroups )
            {
                if ( group != null && group.IsAuthorized( Rock.Security.Authorization.VIEW, person ) )
                {
                    var groupLocations = groupsLocationList.Where( a => a.GroupId == group.Id ).Select( a => a.Location );
                    foreach ( var location in groupLocations )
                    {
                        var mapItem = new MapItem( location );
                        mapItem.EntityTypeId = EntityTypeCache.Read( "Rock.Model.Group" ).Id;
                        mapItem.EntityId = group.Id;
                        mapItem.Name = group.Name;
                        if ( mapItem.Point != null || mapItem.PolygonPoints.Any() )
                        {
                            mapItems.Add( mapItem );
                        }
                    }
                }
            }

            return mapItems.AsQueryable();
        }
Example #24
0
 /// <summary>
 /// Convert <see cref="MapItem"/> to <see langword="char"/>
 /// </summary>
 public static char ConvertToChar(MapItem value) => value switch
 {
Example #25
0
 protected override void InitializeItem(MapItem item, object obj) {
     CityWeather cityWeather = obj as CityWeather;
     MapCustomElement element = item as MapCustomElement;
     if(element == null || cityWeather == null)
         return;
     element.ImageUri = new Uri(cityWeather.WeatherIconPath);
 }      
Example #26
0
 protected List<StatementSyntax> BuildSourceToTargetMappingStatements(MapItem source, MapItem target)
 {
     return BuildSourceToTargetMappingStatements(source.Symbol, source.Name, target.Symbol, target.Name);
 }
Example #27
0
 /// <summary>
 /// Sub classes must implement this method to build the actual statements within the method body.
 /// Depending on the method this may include things like instantiating a variable to return,
 /// the return statement, etc.
 /// </summary>
 protected abstract List<StatementSyntax> BuildAllBodyStatements(MapItem source, MapItem target);
        public IQueryable<MapItem> GetMemberMapInfo( int groupId )
        {
            // Enable proxy creation since security is being checked and need to navigate parent authorities
            SetProxyCreation( true );

            var group = ( (GroupService)Service ).Queryable( "Members" )
                .Where( g => g.Id == groupId )
                .FirstOrDefault();

            if ( group != null )
            {
                var person = GetPerson();

                if ( group.IsAuthorized( Rock.Security.Authorization.VIEW, person ) )
                {
                    var mapItems = new List<MapItem>();

                    Guid familyGuid = new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY );
                    var memberIds = group.Members.Select( m => m.PersonId ).Distinct().ToList();
                    var families = ( (GroupService)Service ).Queryable( "GroupLocations.Location" )
                        .Where( g =>
                            g.GroupType.Guid == familyGuid &&
                            g.Members.Any( m => memberIds.Contains( m.PersonId ) ) )
                        .Distinct();

                    foreach ( var family in families )
                    {
                        foreach ( var location in family.GroupLocations
                            .Where( g => g.IsMappedLocation && g.Location.GeoPoint != null )
                            .Select( g => g.Location ) )
                        {
                            var mapItem = new MapItem( location );
                            mapItem.EntityTypeId = EntityTypeCache.Read( "Rock.Model.Group" ).Id;
                            mapItem.EntityId = family.Id;
                            mapItem.Name = family.Name;
                            if ( mapItem.Point != null || mapItem.PolygonPoints.Any() )
                            {
                                mapItems.Add( mapItem );
                            }
                        }
                    }

                    return mapItems.AsQueryable();
                }
                else
                {
                    throw new HttpResponseException( HttpStatusCode.Unauthorized );
                }
            }
            else
            {
                throw new HttpResponseException( HttpStatusCode.BadRequest );
            }
        }
        public IQueryable<MapItem> GetFamiliesMapInfo( int groupId, int statusId, string campusIds)
        {
            // Enable proxy creation since security is being checked and need to navigate parent authorities
            SetProxyCreation( true );

            var group = ( (GroupService)Service ).Queryable( "GroupLocations.Location" )
                .Where( g => g.Id == groupId )
                .FirstOrDefault();

            if ( group != null )
            {
                var person = GetPerson();

                if ( group.IsAuthorized( Rock.Security.Authorization.VIEW, person ) )
                {
                    var mapItems = new List<MapItem>();

                    foreach ( var location in group.GroupLocations
                        .Where( l => l.Location.GeoFence != null )
                        .Select( l => l.Location ) )
                    {
                        var familyGroupTypeId = GroupTypeCache.GetFamilyGroupType().Id;
                        var recordStatusActiveId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;

                        var families = new GroupLocationService( (RockContext)Service.Context ).Queryable()
                            .Where( l =>
                                l.IsMappedLocation &&
                                l.Group.GroupTypeId == familyGroupTypeId &&
                                l.Location.GeoPoint.Intersects( location.GeoFence ) &&
                                l.Group.Members.Any( m =>
                                    m.Person.RecordStatusValueId.HasValue &&
                                    m.Person.RecordStatusValueId == recordStatusActiveId &&
                                    m.Person.ConnectionStatusValueId.HasValue &&
                                    m.Person.ConnectionStatusValueId.Value == statusId ) )
                            .Select( l => new
                            {
                                l.Location,
                                l.Group.Id,
                                l.Group.Name,
                                l.Group.CampusId,
                                MinStatus = l.Group.Members
                                    .Where( m =>
                                        m.Person.RecordStatusValueId.HasValue &&
                                        m.Person.RecordStatusValueId == recordStatusActiveId &&
                                        m.Person.ConnectionStatusValueId.HasValue )
                                    .OrderBy( m => m.Person.ConnectionStatusValue.Order )
                                    .Select( m => m.Person.ConnectionStatusValue.Id )
                                    .FirstOrDefault()
                            } );

                        var campusIdList = ( campusIds ?? string.Empty ).SplitDelimitedValues().AsIntegerList();
                        if ( campusIdList.Any() )
                        {
                            families = families.Where( a => a.CampusId.HasValue && campusIdList.Contains( a.CampusId.Value ) );
                        }

                        foreach ( var family in families.Where( f => f.MinStatus == statusId ) )
                        {
                            var mapItem = new MapItem( family.Location );
                            mapItem.EntityTypeId = EntityTypeCache.Read( "Rock.Model.Group" ).Id;
                            mapItem.EntityId = family.Id;
                            mapItem.Name = family.Name;
                            if ( mapItem.Point != null || mapItem.PolygonPoints.Any() )
                            {
                                mapItems.Add( mapItem );
                            }
                        }
                    }

                    return mapItems.AsQueryable();
                }
                else
                {
                    throw new HttpResponseException( HttpStatusCode.Unauthorized );
                }
            }
            else
            {
                throw new HttpResponseException( HttpStatusCode.BadRequest );
            }
        }
        public static Expression MapCollectionExpression(IConfigurationProvider configurationProvider, ProfileMap profileMap, PropertyMap propertyMap, Expression sourceExpression, Expression destExpression, Expression contextExpression, Func <Expression, Expression> conditionalExpression, Type ifInterfaceType, MapItem mapItem)
        {
            var passedDestination = Variable(destExpression.Type, "passedDestination");
            var condition         = conditionalExpression(passedDestination);
            var newExpression     = Variable(passedDestination.Type, "collectionDestination");
            var sourceElementType = ElementTypeHelper.GetElementType(sourceExpression.Type);

            var itemExpr = mapItem(configurationProvider, profileMap, propertyMap, sourceExpression.Type, passedDestination.Type,
                                   contextExpression, out ParameterExpression itemParam);

            var destinationElementType    = itemExpr.Type;
            var destinationCollectionType = typeof(ICollection <>).MakeGenericType(destinationElementType);

            if (!destinationCollectionType.IsAssignableFrom(destExpression.Type))
            {
                destinationCollectionType = typeof(IList);
            }
            var addMethod   = destinationCollectionType.GetDeclaredMethod("Add");
            var destination = propertyMap?.UseDestinationValue == true ? passedDestination : newExpression;
            var addItems    = ForEach(sourceExpression, itemParam, Call(destination, addMethod, itemExpr));

            var mapExpr = Block(addItems, destination);

            var clearMethod = destinationCollectionType.GetDeclaredMethod("Clear");
            var checkNull   =
                Block(new[] { newExpression, passedDestination },
                      Assign(passedDestination, destExpression),
                      IfThenElse(condition ?? Constant(false),
                                 Block(Assign(newExpression, passedDestination), Call(newExpression, clearMethod)),
                                 Assign(newExpression, passedDestination.Type.NewExpr(ifInterfaceType))),
                      ToType(mapExpr, passedDestination.Type)
                      );

            if (propertyMap != null)
            {
                return(checkNull);
            }
            var elementTypeMap = configurationProvider.ResolveTypeMap(sourceElementType, destinationElementType);

            if (elementTypeMap == null)
            {
                return(checkNull);
            }
            var checkContext = TypeMapPlanBuilder.CheckContext(elementTypeMap, contextExpression);

            if (checkContext == null)
            {
                return(checkNull);
            }
            return(Block(checkContext, checkNull));
        }
Example #31
0
 public void ClearActiveItem(int itemSlot)
 {
     ActiveItem[itemSlot] = new MapItem(new DataManager.Maps.MapItem());
     ActiveItem[itemSlot].Num = -1;
 }
Example #32
0
 public ActionAdd(MapItem item, int layer)
 {
     items = new List<MapItem>();
     items.Add(item);
     this.layer = layer;
 }
Example #33
0
        /// <summary>
        /// Maps the specified location.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <param name="fences">The fences.</param>
        /// <param name="groups">The groups.</param>
        private void Map( MapItem location, List<MapItem> fences, List<MapItem> groups )
        {
            pnlMap.Visible = true;

            string mapStylingFormat = @"
                        <style>
                            #map_wrapper {{
                                height: {0}px;
                            }}

                            #map_canvas {{
                                width: 100%;
                                height: 100%;
                                border-radius: 8px;
                            }}
                        </style>";
            lMapStyling.Text = string.Format( mapStylingFormat, GetAttributeValue( "MapHeight" ) );

            // add styling to map
            string styleCode = "null";
            var markerColors = new List<string>();

            DefinedValueCache dvcMapStyle = DefinedValueCache.Read( GetAttributeValue( "MapStyle" ).AsInteger() );
            if ( dvcMapStyle != null )
            {
                styleCode = dvcMapStyle.GetAttributeValue( "DynamicMapStyle" );
                markerColors = dvcMapStyle.GetAttributeValue( "Colors" )
                    .Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries )
                    .ToList();
                markerColors.ForEach( c => c = c.Replace( "#", string.Empty ) );
            }
            if ( !markerColors.Any() )
            {
                markerColors.Add( "FE7569" );
            }

            string locationColor = markerColors[0].Replace( "#", string.Empty );
            var polygonColorList = GetAttributeValue( "PolygonColors" ).Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries ).ToList();
            string polygonColors = "\"" + polygonColorList.AsDelimited( "\", \"" ) + "\"";
            string groupColor = ( markerColors.Count > 1 ? markerColors[1] : markerColors[0] ).Replace( "#", string.Empty );

            string latitude = "39.8282";
            string longitude = "-98.5795";
            string zoom = "4";
            var orgLocation = GlobalAttributesCache.Read().OrganizationLocation;
            if ( orgLocation != null && orgLocation.GeoPoint != null )
            {
                latitude = orgLocation.GeoPoint.Latitude.ToString();
                longitude = orgLocation.GeoPoint.Longitude.ToString();
                zoom = "12";
            }

            // write script to page
            string mapScriptFormat = @"

            var locationData = {0};
            var fenceData = {1};
            var groupData = {2};

            var allMarkers = [];

            var map;
            var bounds = new google.maps.LatLngBounds();
            var infoWindow = new google.maps.InfoWindow();

            var mapStyle = {3};

            var pinShadow = new google.maps.MarkerImage('//chart.googleapis.com/chart?chst=d_map_pin_shadow',
            new google.maps.Size(40, 37),
            new google.maps.Point(0, 0),
            new google.maps.Point(12, 35));

            var polygonColorIndex = 0;
            var polygonColors = [{5}];

            var min = .999999;
            var max = 1.000001;

            initializeMap();

            function initializeMap() {{

            // Set default map options
            var mapOptions = {{
                 mapTypeId: 'roadmap'
                ,styles: mapStyle
                ,center: new google.maps.LatLng({7}, {8})
                ,zoom: {9}
            }};

            // Display a map on the page
            map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
            map.setTilt(45);

            if ( locationData != null )
            {{
                var items = addMapItem(0, locationData, '{4}');
                for (var j = 0; j < items.length; j++) {{
                    items[j].setMap(map);
                }}
            }}

            if ( fenceData != null ) {{
                for (var i = 0; i < fenceData.length; i++) {{
                    var items = addMapItem(i, fenceData[i] );
                    for (var j = 0; j < items.length; j++) {{
                        items[j].setMap(map);
                    }}
                }}
            }}

            if ( groupData != null ) {{
                for (var i = 0; i < groupData.length; i++) {{
                    var items = addMapItem(i, groupData[i], '{6}');
                    for (var j = 0; j < items.length; j++) {{
                        items[j].setMap(map);
                    }}
                }}
            }}

            // adjust any markers that may overlap
            adjustOverlappedMarkers();

            if (!bounds.isEmpty()) {{
                map.fitBounds(bounds);
            }}

            }}

            function addMapItem( i, mapItem, color ) {{

            var items = [];

            if (mapItem.Point) {{

                var position = new google.maps.LatLng(mapItem.Point.Latitude, mapItem.Point.Longitude);
                bounds.extend(position);

                if (!color) {{
                    color = 'FE7569'
                }}

                var pinImage = new google.maps.MarkerImage('//chart.googleapis.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|' + color,
                    new google.maps.Size(21, 34),
                    new google.maps.Point(0,0),
                    new google.maps.Point(10, 34));

                marker = new google.maps.Marker({{
                    position: position,
                    map: map,
                    title: htmlDecode(mapItem.Name),
                    icon: pinImage,
                    shadow: pinShadow
                }});

                items.push(marker);
                allMarkers.push(marker);

                if ( mapItem.InfoWindow != null ) {{
                    google.maps.event.addListener(marker, 'click', (function (marker, i) {{
                        return function () {{
                            infoWindow.setContent( $('<div/>').html(mapItem.InfoWindow).text() );
                            infoWindow.open(map, marker);
                        }}
                    }})(marker, i));
                }}

                if ( mapItem.EntityId && mapItem.EntityId > 0 ) {{
                    google.maps.event.addListener(marker, 'mouseover', (function (marker, i) {{
                        return function () {{
                            $(""tr[datakey='"" + mapItem.EntityId + ""']"").addClass('row-highlight');
                        }}
                    }})(marker, i));

                    google.maps.event.addListener(marker, 'mouseout', (function (marker, i) {{
                        return function () {{
                            $(""tr[datakey='"" + mapItem.EntityId + ""']"").removeClass('row-highlight');
                        }}
                    }})(marker, i));

                }}

            }}

            if (typeof mapItem.PolygonPoints !== 'undefined' && mapItem.PolygonPoints.length > 0) {{

                var polygon;
                var polygonPoints = [];

                $.each(mapItem.PolygonPoints, function(j, point) {{
                    var position = new google.maps.LatLng(point.Latitude, point.Longitude);
                    bounds.extend(position);
                    polygonPoints.push(position);
                }});

                var polygonColor = getNextPolygonColor();

                polygon = new google.maps.Polygon({{
                    paths: polygonPoints,
                    map: map,
                    strokeColor: polygonColor,
                    fillColor: polygonColor
                }});

                items.push(polygon);

                // Get Center
                var polyBounds = new google.maps.LatLngBounds();
                for ( j = 0; j < polygonPoints.length; j++) {{
                    polyBounds.extend(polygonPoints[j]);
                }}

                if ( mapItem.InfoWindow != null ) {{
                    google.maps.event.addListener(polygon, 'click', (function (polygon, i) {{
                        return function () {{
                            infoWindow.setContent( mapItem.InfoWindow );
                            infoWindow.setPosition(polyBounds.getCenter());
                            infoWindow.open(map);
                        }}
                    }})(polygon, i));
                }}
            }}

            return items;

            }}

            function setAllMap(markers, map) {{
            for (var i = 0; i < markers.length; i++) {{
                markers[i].setMap(map);
            }}
            }}

            function htmlDecode(input) {{
            var e = document.createElement('div');
            e.innerHTML = input;
            return e.childNodes.length === 0 ? """" : e.childNodes[0].nodeValue;
            }}

            function getNextPolygonColor() {{
            var color = 'FE7569';
            if ( polygonColors.length > polygonColorIndex ) {{
                color = polygonColors[polygonColorIndex];
                polygonColorIndex++;
            }} else {{
                color = polygonColors[0];
                polygonColorIndex = 1;
            }}
            return color;
            }}

            function adjustOverlappedMarkers() {{

            if (allMarkers.length > 1) {{
                for(i=0; i < allMarkers.length-1; i++) {{
                    var marker1 = allMarkers[i];
                    var pos1 = marker1.getPosition();
                    for(j=i+1; j < allMarkers.length; j++) {{
                        var marker2 = allMarkers[j];
                        var pos2 = marker2.getPosition();
                        if (pos1.equals(pos2)) {{
                            var newLat = pos1.lat() * (Math.random() * (max - min) + min);
                            var newLng = pos1.lng() * (Math.random() * (max - min) + min);
                            marker1.setPosition( new google.maps.LatLng(newLat,newLng) );
                        }}
                    }}
                }}
            }}

            }}
            ";

            var locationJson = location != null ?
                string.Format( "JSON.parse('{0}')", location.ToJson().Replace( Environment.NewLine, "" ).EscapeQuotes().Replace( "\x0A", "" ) ) : "null";

            var fencesJson = fences != null && fences.Any() ?
                string.Format( "JSON.parse('{0}')", fences.ToJson().Replace( Environment.NewLine, "" ).EscapeQuotes().Replace( "\x0A", "" ) ) : "null";

            var groupsJson = groups != null && groups.Any() ?
                string.Format( "JSON.parse('{0}')", groups.ToJson().Replace( Environment.NewLine, "" ).EscapeQuotes().Replace( "\x0A", "" ) ) : "null";

            string mapScript = string.Format( mapScriptFormat,
                locationJson,       // 0
                fencesJson,         // 1
                groupsJson,         // 2
                styleCode,          // 3
                locationColor,      // 4
                polygonColors,      // 5
                groupColor,         // 6
                latitude,           // 7
                longitude,          // 8
                zoom );             // 9

            ScriptManager.RegisterStartupScript( pnlMap, pnlMap.GetType(), "group-finder-map-script", mapScript, true );
        }
Example #34
0
        private void InitializeHistory()
        {
            var hasDamage      = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallDamage") > 0;
            var hasHealing     = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallHealing") > 0;
            var hasDamageTaken = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallDamageTaken") > 0;

            if (hasDamage || hasHealing || hasDamageTaken)
            {
                StatContainer  currentOverallStats = this.ParseControl.Timeline.Overall.Stats;
                var            historyItem         = new ParseHistoryItem();
                HistoryControl historyController   = historyItem.HistoryControl = new HistoryControl();
                foreach (Stat <double> stat in currentOverallStats)
                {
                    historyController.Timeline.Overall.Stats.EnsureStatValue(stat.Name, stat.Value);
                }

                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDPS", currentOverallStats.GetStatValue("DPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDOTPS", currentOverallStats.GetStatValue("DOTPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHPS", currentOverallStats.GetStatValue("HPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHOHPS", currentOverallStats.GetStatValue("HOHPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHOTPS", currentOverallStats.GetStatValue("HOTPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHMPS", currentOverallStats.GetStatValue("HMPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDTPS", currentOverallStats.GetStatValue("DTPS"));
                historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDTOTPS", currentOverallStats.GetStatValue("DTOTPS"));
                StatGroup[] playerList = this.ParseControl.Timeline.Party.ToArray();
                foreach (StatGroup player in playerList)
                {
                    HistoryGroup playerInstance = historyController.Timeline.GetSetPlayer(player.Name);
                    playerInstance.Last20DamageActions      = ((Player)player).Last20DamageActions.ToList();
                    playerInstance.Last20DamageTakenActions = ((Player)player).Last20DamageTakenActions.ToList();
                    playerInstance.Last20HealingActions     = ((Player)player).Last20HealingActions.ToList();
                    playerInstance.Last20Items = ((Player)player).Last20Items.ToList();
                    foreach (Stat <double> stat in player.Stats)
                    {
                        playerInstance.Stats.EnsureStatValue(stat.Name, stat.Value);
                    }

                    this.RabbitHoleCopy(ref playerInstance, player);
                }

                StatGroup[] monsterList = this.ParseControl.Timeline.Monster.ToArray();
                foreach (StatGroup monster in monsterList)
                {
                    HistoryGroup monsterInstance = historyController.Timeline.GetSetMonster(monster.Name);
                    monsterInstance.Last20DamageActions      = ((Monster)monster).Last20DamageActions.ToList();
                    monsterInstance.Last20DamageTakenActions = ((Monster)monster).Last20DamageTakenActions.ToList();
                    monsterInstance.Last20HealingActions     = ((Monster)monster).Last20HealingActions.ToList();
                    monsterInstance.Last20Items = ((Monster)monster).Last20Items.ToList();
                    foreach (Stat <double> stat in monster.Stats)
                    {
                        monsterInstance.Stats.EnsureStatValue(stat.Name, stat.Value);
                    }

                    this.RabbitHoleCopy(ref monsterInstance, monster);
                }

                historyItem.Start       = this.ParseControl.StartTime;
                historyItem.End         = DateTime.Now;
                historyItem.ParseLength = historyItem.End - historyItem.Start;
                var parseTimeDetails = $"{historyItem.Start} -> {historyItem.End} [{historyItem.ParseLength}]";
                var zone             = "UNKNOWN";
                if (XIVInfoViewModel.Instance.CurrentUser != null)
                {
                    var     mapIndex = XIVInfoViewModel.Instance.CurrentUser.MapIndex;
                    MapItem mapItem  = ZoneLookup.GetZoneInfo(mapIndex);
                    switch (Constants.GameLanguage)
                    {
                    case "French":
                        zone = mapItem.Name.French;
                        break;

                    case "Japanese":
                        zone = mapItem.Name.Japanese;
                        break;

                    case "German":
                        zone = mapItem.Name.German;
                        break;

                    case "Chinese":
                        zone = mapItem.Name.Chinese;
                        break;

                    case "Korean":
                        zone = mapItem.Name.Korean;
                        break;

                    default:
                        zone = mapItem.Name.English;
                        break;
                    }
                }

                var monsterName = "NULL";
                try {
                    StatGroup biggestMonster = null;
                    foreach (StatGroup monster in this.ParseControl.Timeline.Monster)
                    {
                        if (biggestMonster == null)
                        {
                            biggestMonster = monster;
                        }
                        else
                        {
                            if (monster.Stats.GetStatValue("TotalOverallDamage") > biggestMonster.Stats.GetStatValue("TotalOverallDamage"))
                            {
                                biggestMonster = monster;
                            }
                        }
                    }

                    if (biggestMonster != null)
                    {
                        monsterName = biggestMonster.Name;
                    }
                }
                catch (Exception ex) {
                    Logging.Log(Logger, new LogItem(ex, true));
                }

                foreach (Stat <double> oStat in currentOverallStats)
                {
                    historyController.Timeline.Overall.Stats.EnsureStatValue(oStat.Name, oStat.Value);
                }

                historyItem.Name = $"{zone} [{monsterName}] {parseTimeDetails}";
                DispatcherHelper.Invoke(() => MainViewModel.Instance.ParseHistory.Insert(1, historyItem));
            }
        }