ObservableCollection <Resource> GetResources()
        {
            Resource grr = new Resource(0, 0, "Some group", "This is the group for my tools", 0, false, 0, null, true, "13/15/13", this);

            grr.AddResource(new Resource(0, 0, "Laceses", "This is the laces I will be using for Abbot work", 80, false, 0, null, false, "13/13/13", this));
            grr.AddResource(new Resource(0, 0, "Miscal", "This is the laces I will be using for Abbot work", 34, true, 0, null, false, "13/13/13", this));
            Resource re = new Resource(0, 0, "Done good with this", "This one's got transactions!", 100, false, 0, null, false, "9:11, 9 November, 2016", this);

            re.AddTransaction(new Transaction(0, 0, true, 20, re, "Took these for your dad..", "13/12/11", "hahahah"));
            re.AddTransaction(new Transaction(0, 0, false, 5, re, "Took these for your mum..", "15/12/11", "hahahah"));
            re.AddTransaction(new Transaction(0, 0, true, 10, re, "Took these for your brother..", "13/12/11", "hahahah"));
            re.AddTransaction(new Transaction(0, 0, false, 8, re, "Took these for your sister..", "13/12/11", "hahahah"));
            ObservableCollection <Resource> resourcess = new ObservableCollection <Resource>
            {
                new Resource(0, 0, "Laces", "This is the laces I will be using for Abbot work", 100, false, 0, null, false, "13/13/13", this),
                grr,
                new Resource(0, 0, "Threads", "This is for sewing", 100, false, 0, null, false, "13/13/13", this),
                re
            };
            DatabaseHandler db = new DatabaseHandler(this);

            resources = db.GetResources();
            db.Close();
            topResources = resources;
            if (resources.Count == 0)
            {
                NoResources(true);
            }
            else
            {
                NoResources(false);
            }
            return(resources);
        }
        public void CreateGroup(string name, string description)
        {
            ObservableCollection <Resource> reses = selected.Count > 0 ? selected : new ObservableCollection <Resource> {
                lastSelected
            };
            DatabaseHandler db = new DatabaseHandler(this);

            db.Open();
            Resource group = db.AddGroup(name, description, parent, reses);

            if (parent == null)
            {
                resources.Add(group);
            }
            else
            {
                parent.AddResource(group);
            }
            if (selected.Count > 0)
            {
                foreach (Resource res in selected)
                {
                    if (res.Group == null)
                    {
                        resources.Remove(res);
                    }
                    else
                    {
                        res.Group.RemoveResource(res, false);
                    }
                    group.AddResource(res);
                    res.Group = group;
                }
            }
            else
            {
                if (lastSelected.Group == null)
                {
                    resources.Remove(lastSelected);
                }
                else
                {
                    lastSelected.Group.RemoveResource(lastSelected, false);
                }
                group.AddResource(lastSelected);
                lastSelected.Group = group;
            }
            InMultiSelectMode = false;
            Select(group);
        }
Exemplo n.º 3
0
        public IEnumerable <Resource> Create(IEnumerable <Match> matches, string gameId, string teamIdOnTop, out int numberOfMatches)
        {
            numberOfMatches = 0;

            var matchMapper = new MatchMapper(_uriHelper);
            var teamMapper  = new TeamMapper(_uriHelper);

            var matchesGroupedByCompetitionId = matches.ToLookup(m => m.CompetitionId);
            var competitionResources          = new List <Resource>();

            foreach (var group in matchesGroupedByCompetitionId)
            {
                bool teamIdFound = false;

                var matchesForOneCompetitionResource = new Resource(new Link(_uriHelper.GetHomeUri()));

                var matchResources = new List <Resource>();

                bool first = true;
                foreach (var match in group)
                {
                    if (first)
                    {
                        matchesForOneCompetitionResource.AddProperty("competition-name", match.Round.CompetitionName);
                        matchesForOneCompetitionResource.AddProperty("round-name", match.Round.Name);
                    }

                    if (match.HomeTeamId.Equals(teamIdOnTop, StringComparison.OrdinalIgnoreCase) ||
                        match.AwayTeamId.Equals(teamIdOnTop, StringComparison.OrdinalIgnoreCase))
                    {
                        teamIdFound = true;
                    }

                    var matchResource = matchMapper.Map(match, MatchMapper.HomeScore, MatchMapper.AwayScore, MatchMapper.Played, MatchMapper.HomePenaltyScore, MatchMapper.AwayPenaltyScore, MatchMapper.PenaltiesTaken);
                    matchResource.AddResource("home-team", teamMapper.Map(match.HomeTeam, TeamMapper.TeamName));
                    matchResource.AddResource("away-team", teamMapper.Map(match.AwayTeam, TeamMapper.TeamName));
                    matchResources.Add(matchResource);

                    numberOfMatches++;

                    first = false;
                }

                matchesForOneCompetitionResource.AddResource("rel:matches", matchResources);

                if (teamIdFound)
                {
                    competitionResources.Insert(0, matchesForOneCompetitionResource);
                }
                else
                {
                    competitionResources.Add(matchesForOneCompetitionResource);
                }
            }

            return(competitionResources);
        }
Exemplo n.º 4
0
        public MouseCursorTestOverlay(MouseInputService windowInputService, GameContainer container)
        {
            Container         = container;
            MouseInputService = windowInputService;
            MouseInputService.IsRendertimeUpdate = true;

            Resource.AddResource("ForegroundBrush", new SolidColorBrushResource(new RawColor4(1, 1, 1, .9f)));
            format = new TextFormat(Container.DWFactory, "MS Gothic", FontWeight.Bold, FontStyle.Normal, 32);
        }
Exemplo n.º 5
0
        public Resource Map(SeasonStatistics seasonStatistics, params string[] properties)
        {
            bool applyAllProperties = !properties.Any();

            var teamMapper = new TeamMapper(_uriHelper);

            var resource = new Resource(new Link(_uriHelper.GetSeasonUri(seasonStatistics.GameId, seasonStatistics.Id)));

            if (applyAllProperties || properties.Contains(SeasonShortName))
            {
                resource.AddProperty(SeasonShortName, seasonStatistics.Season.ShortName);
            }

            if (applyAllProperties || properties.Contains(SeasonLongName))
            {
                resource.AddProperty(SeasonLongName, seasonStatistics.Season.LongName);
            }

            if (applyAllProperties || properties.Contains(NationalChampion) && seasonStatistics.NationalChampion != null)
            {
                var team = teamMapper.Map(seasonStatistics.NationalChampion, TeamMapper.TeamName);
                resource.AddResource(NationalChampion, team);
            }

            if (applyAllProperties || properties.Contains(NationalChampionRunnerUp) && seasonStatistics.NationalChampionRunnerUp != null)
            {
                var team = teamMapper.Map(seasonStatistics.NationalChampionRunnerUp, TeamMapper.TeamName);
                resource.AddResource(NationalChampionRunnerUp, team);
            }

            if (applyAllProperties || properties.Contains(NationalCupWinner) && seasonStatistics.CupWinner != null)
            {
                var team = teamMapper.Map(seasonStatistics.CupWinner, TeamMapper.TeamName);
                resource.AddResource(NationalCupWinner, team);
            }

            if (applyAllProperties || properties.Contains(NationalCupRunnerUp) && seasonStatistics.CupRunnerUp != null)
            {
                var team = teamMapper.Map(seasonStatistics.CupRunnerUp, TeamMapper.TeamName);
                resource.AddResource(NationalCupRunnerUp, team);
            }

            return(resource);
        }
Exemplo n.º 6
0
        public DebugOverlay(GameContainer container, MouseInputService mouseInputService)
        {
            Container         = container;
            MouseInputService = mouseInputService;

            Resource.AddResource("ForegroundBrush", new SolidColorBrushResource(new RawColor4(1, 1, 1, .9f)));
            format = new TextFormat(Container.DWFactory, "Consolas", FontWeight.Normal, FontStyle.Normal, 16);

            UpdateTimeQueue.Enqueue(0);            //dummy
        }
        public void AddResource(string title, string description, int stock, string image)
        {
            DatabaseHandler db = new DatabaseHandler(this);

            db.Open();
            Resource res = db.AddResource(title, description, stock, image, parent);

            db.Close();
            if (parent != null)
            {
                parent.AddResource(res);
            }
            else
            {
                resources.Add(res);
            }
            CurrentGroupStock = parent == null ? "" : "(" + parent.Size + "/" + parent.InitialSize + ")";
            if (resources.Count == 1)
            {
                NoResources(false);
            }
        }
Exemplo n.º 8
0
        public IEnumerable <Resource> Create(IEnumerable <TeamRoundMatch> matches, string gameId, string seasonId, string teamId)
        {
            var teamMapper = new TeamMapper(_uriHelper);

            var matchResources = new List <Resource>();

            foreach (var match in matches)
            {
                var matchResource = new Resource(new Link(_uriHelper.GetMatchUri(match.GameId, match.MatchId)));

                matchResource.AddProperty("date", match.MatchDate.ToString("dd-MMM"));
                matchResource.AddProperty("competition-name", match.CompetitionName);
                matchResource.AddProperty("round", match.RoundName);
                matchResource.AddProperty("home-score", match.HomeScore);
                matchResource.AddProperty("away-score", match.AwayScore);
                matchResource.AddProperty("penalties-taken", match.PenaltiesTaken);
                matchResource.AddProperty("home-penalty-score", match.HomePenaltyScore);
                matchResource.AddProperty("away-penalty-score", match.AwayPenaltyScore);
                matchResource.AddProperty("played", match.Played);

                if (match.HomeTeam != null)
                {
                    var homeTeamResource = teamMapper.Map(match.HomeTeam, TeamMapper.TeamName, TeamMapper.LeagueName, TeamMapper.CurrentLeaguePosition);
                    matchResource.AddResource("home-team", homeTeamResource);
                }

                if (match.AwayTeam != null)
                {
                    var awayTeamResource = teamMapper.Map(match.AwayTeam, TeamMapper.TeamName, TeamMapper.LeagueName, TeamMapper.CurrentLeaguePosition);
                    matchResource.AddResource("away-team", awayTeamResource);
                }

                matchResources.Add(matchResource);
            }

            return(matchResources);
        }
Exemplo n.º 9
0
        public LoadingOverlay(GameContainer container)
        {
            Resource.AddResource("Fore", new SolidColorBrushResource(new RawColor4(1, 0.64705882352941176470588235294118f, 0, 1)));
            Resource.AddResource("Back", new SolidColorBrushResource(new RawColor4(1, 1, 1, .3f)));
            format = new TextFormat(container.DWFactory, "Consolas", 32);

            Container = container;

            LoopAnimation = new Animation(Container);
            FadeAnimation = new Animation(Container);

            parameter = new LayerParameters()
            {
                ContentBounds = RectangleF.Infinite,
            };
        }
Exemplo n.º 10
0
    void OnPickUp(InputAction.CallbackContext context)
    {
        if (pickableItem != null)
        {
            player.Inventory.AddItem(pickableItem);
            pickableItem.gameObject.SetActive(false);
            pickableItem = null;
            PickUpEvent();
        }

        if (pickableResource != null)
        {
            pickableResource.AddResource(player.Resources);
            Destroy(pickableResource.gameObject);
            pickableResource = null;
            PickUpEvent();
        }
    }
Exemplo n.º 11
0
            public SampleScene(GameContainer container, FadeTransitionScene tscene)
            {
                Container       = container;
                TransitionScene = tscene;

                position = 10;
                Resource.AddSolidColorBrushResource("MainBrush", new RawColor4(1, 1, 1, 1));
                Resource.AddPngImageResource("Image", Container.ImagingFactory, @"D:\ingen\Desktop\saikoro_145.png");
                Resource.AddPngImageSprite("Saikoro", Container.ImagingFactory, @"D:\ingen\Desktop\saikoro_145.png");
                var atlas = Resource.AddSpriteAtlas("ImageAtlas", Resource.Get <ImageResource>("Image"));

                Resource.AddResource("Sprite", atlas.MakeSprite(new RawRectangle(100, 50, 200, 100)));


                SpriteBatch = new Framework.Sprite.SpriteBatch(container);

                System.Threading.Thread.Sleep(1000);
            }
Exemplo n.º 12
0
        public Resource Map(LeagueTable leagueTable, params string[] properties)
        {
            var teamMapper = new TeamMapper(_uriHelper);

            var leagueTableLink = new Link(_uriHelper.GetCompetitionLeagueTableUri(leagueTable.GameId, leagueTable.SeasonCompetition.SeasonId, leagueTable.SeasonCompetition.CompetitionId));
            var resource        = new Resource(leagueTableLink);

            resource.AddProperty("competition-name", leagueTable.CompetitionName);

            var positions = new List <Resource>();

            foreach (var leagueTablePosition in leagueTable.LeagueTablePositions)
            {
                var position = new Resource(leagueTableLink);

                position.AddResource("team", teamMapper.Map(leagueTablePosition.Team, TeamMapper.TeamName, TeamMapper.LeagueName, TeamMapper.CurrentLeaguePosition));
                position.AddProperty("position", leagueTablePosition.Position);
                position.AddProperty("played", leagueTablePosition.Matches);
                position.AddProperty("points", leagueTablePosition.Points);

                if (properties.Contains(FullDetails))
                {
                    position.AddProperty("wins", leagueTablePosition.Wins);
                    position.AddProperty("draws", leagueTablePosition.Draws);
                    position.AddProperty("losses", leagueTablePosition.Losses);
                    position.AddProperty("goals-scored", leagueTablePosition.GoalsScored);
                    position.AddProperty("goals-conceded", leagueTablePosition.GoalsConceded);

                    string goalDifference = leagueTablePosition.GoalDifference.ToString();
                    if (leagueTablePosition.GoalDifference > 0)
                    {
                        goalDifference = $"+{goalDifference}";
                    }

                    position.AddProperty("goal-difference", goalDifference);
                }

                positions.Add(position);
            }

            resource.AddResource("positions", positions.ToArray());

            return(resource);
        }
Exemplo n.º 13
0
 void PopulateResource(Resource res)
 {
     if (res.IsGroup)
     {
         string          query  = $"select * from {RES_TABLE_NAME} where {COLUMN_PAR_ID} = {res.Id} order by {COLUMN_PINNED_DATE} desc";
         SqlCeDataReader reader = ExecuteQuery(query);
         while (reader.Read())
         {
             Resource resource = ReaderToResource(reader);
             PopulateResource(resource);
             res.AddResource(resource);
         }
     }
     else
     {
         string          query  = $"select * from {TRANS_TABLE_NAME} where {COLUMN_PAR_ID} = {res.Id}";
         SqlCeDataReader reader = ExecuteQuery(query);
         while (reader.Read())
         {
             Transaction transaction = ReaderToTransaction(reader, res);
             res.AddTransaction(transaction);
         }
     }
 }
Exemplo n.º 14
0
    /// <summary>
    /// Attempts to harvest the resource type associated with this world resource for the amount specified and drops 
    /// it into the resource container "resource"
    /// </summary>
    /// <param name="resource">The resource container</param>
    /// <param name="amount">The amount of that resource to move</param>
    private void HarvestResource(Resource resource, int amount)
    {
        if (ResourceState == global::ResourceState.Active)
        {
            if (!isInfinite)
                currentAmount = Mathf.Clamp( (currentAmount - amount) + resource.AddResource(this.resource, amount), 0, maxAmount);
            else
                resource.AddResource(this.resource, amount);

            if (currentAmount == 0 && !isInfinite)
                ResourceState = global::ResourceState.Dying;
            if (!isInfinite && !regenerates && currentAmount == 0)
            {
                ResourceState = global::ResourceState.Dying;
            }
        }
    }
Exemplo n.º 15
0
        public void TestHalDocumentFromTheSpecification()
        {
            var halDocument = new Resource(new Link("/orders"));

            halDocument.AddLink("curies", new[]
            {
                new Link("http://example.com/docs/rels/{rel}")
                {
                    Name      = "ea",
                    Templated = true
                }
            });

            halDocument.AddLink("next", new Link("/orders?page=2"));

            halDocument.AddLink("ea:find", new Link("/orders{?id}")
            {
                Templated = true
            });

            halDocument.AddLink("ea:admin", new[]
            {
                new Link("/admins/2")
                {
                    Title = "Fred"
                },
                new Link("/admins/5")
                {
                    Title = "Kate"
                }
            });

            halDocument.AddProperty("currentlyProcessing", 14);
            halDocument.AddProperty("shippedToday", 20);

            var order1 = new Resource(new Link("/orders/123"));

            order1.AddLink("ea:basket", new Link("/baskets/98712"));
            order1.AddLink("ea:customer", new Link("/customers/7809"));
            order1.AddProperty("total", 30);
            order1.AddProperty("currency", "USD");
            order1.AddProperty("status", "shipped");

            var order2 = new Resource(new Link("/orders/124"));

            order2.AddLink("ea:basket", new Link("/baskets/97213"));
            order2.AddLink("ea:customer", new Link("/customers/12369"));
            order2.AddProperty("total", 20);
            order2.AddProperty("currency", "USD");
            order2.AddProperty("status", "processing");

            halDocument.AddResource("ea:order", new[] {
                order1,
                order2
            });

            var settings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting        = Formatting.Indented,
                Converters        = new List <JsonConverter>
                {
                    new DecimalJsonConverter()
                }
            };

            File.WriteAllText(@"D:\Temp\hal.json", halDocument.Json.ToString());

            // The document contains 4 properties: _links, currentlyProcessing, shippedToday and _embedded.
            Assert.AreEqual(4, halDocument.Json.Count);

            // The _links object contains 5 links.
            Assert.AreEqual(5, halDocument.Json["_links"].Count());

            // The self link only contains a href property.
            Assert.AreEqual(1, halDocument.Json["_links"]["self"].Count());
            Assert.AreEqual("/orders", halDocument.Json["_links"]["self"]["href"]);

            // The curies link array contains one link with 3 properties, name, href and templated.
            Assert.AreEqual(1, halDocument.Json["_links"]["curies"].Count());
            Assert.AreEqual(3, halDocument.Json["_links"]["curies"][0].Count());
            Assert.AreEqual("ea", halDocument.Json["_links"]["curies"][0]["name"]);
            Assert.AreEqual("http://example.com/docs/rels/{rel}", halDocument.Json["_links"]["curies"][0]["href"]);
            Assert.AreEqual(true, halDocument.Json["_links"]["curies"][0]["templated"]);

            // The next link only contains a href property.
            Assert.AreEqual(1, halDocument.Json["_links"]["next"].Count());
            Assert.AreEqual("/orders?page=2", halDocument.Json["_links"]["next"]["href"]);

            // The ea:find link contains an href and templated property.
            Assert.AreEqual(2, halDocument.Json["_links"]["ea:find"].Count());
            Assert.AreEqual("/orders{?id}", halDocument.Json["_links"]["ea:find"]["href"]);

            // The ea:admin link array contains two links, with 2 properties each: href and title.
            Assert.AreEqual(2, halDocument.Json["_links"]["ea:admin"].Count());
            Assert.AreEqual(2, halDocument.Json["_links"]["ea:admin"][0].Count());
            Assert.AreEqual("/admins/2", halDocument.Json["_links"]["ea:admin"][0]["href"]);
            Assert.AreEqual("Fred", halDocument.Json["_links"]["ea:admin"][0]["title"]);
            Assert.AreEqual(2, halDocument.Json["_links"]["ea:admin"][1].Count());
            Assert.AreEqual("/admins/5", halDocument.Json["_links"]["ea:admin"][1]["href"]);
            Assert.AreEqual("Kate", halDocument.Json["_links"]["ea:admin"][1]["title"]);

            // This resource contains two properties: currentlyProcessing and shippedToday.
            Assert.AreEqual(14, halDocument.Json["currentlyProcessing"]);
            Assert.AreEqual(20, halDocument.Json["shippedToday"]);

            // The _embedded object contains one property: ea:order, which is an array of two orders with 4 properties each.
            Assert.AreEqual(1, halDocument.Json["_embedded"].Count());
            Assert.AreEqual(2, halDocument.Json["_embedded"]["ea:order"].Count());
            Assert.AreEqual(4, halDocument.Json["_embedded"]["ea:order"][0].Count());
            Assert.AreEqual(3, halDocument.Json["_embedded"]["ea:order"][0]["_links"].Count());
            Assert.AreEqual("/orders/123", halDocument.Json["_embedded"]["ea:order"][0]["_links"]["self"]["href"]);
            Assert.AreEqual("/baskets/98712", halDocument.Json["_embedded"]["ea:order"][0]["_links"]["ea:basket"]["href"]);
            Assert.AreEqual("/customers/7809", halDocument.Json["_embedded"]["ea:order"][0]["_links"]["ea:customer"]["href"]);
            Assert.AreEqual(30, halDocument.Json["_embedded"]["ea:order"][0]["total"]);
            Assert.AreEqual("USD", halDocument.Json["_embedded"]["ea:order"][0]["currency"]);
            Assert.AreEqual("shipped", halDocument.Json["_embedded"]["ea:order"][0]["status"]);
            Assert.AreEqual(4, halDocument.Json["_embedded"]["ea:order"][1].Count());
            Assert.AreEqual(3, halDocument.Json["_embedded"]["ea:order"][1]["_links"].Count());
            Assert.AreEqual("/orders/124", halDocument.Json["_embedded"]["ea:order"][1]["_links"]["self"]["href"]);
            Assert.AreEqual("/baskets/97213", halDocument.Json["_embedded"]["ea:order"][1]["_links"]["ea:basket"]["href"]);
            Assert.AreEqual("/customers/12369", halDocument.Json["_embedded"]["ea:order"][1]["_links"]["ea:customer"]["href"]);
            Assert.AreEqual(20, halDocument.Json["_embedded"]["ea:order"][1]["total"]);
            Assert.AreEqual("USD", halDocument.Json["_embedded"]["ea:order"][1]["currency"]);
            Assert.AreEqual("processing", halDocument.Json["_embedded"]["ea:order"][1]["status"]);
        }