Exemplo n.º 1
0
 override public string ToString() => $"{{id: {IMDB_ID}, " +
 $"title: {Title}, " +
 $"language: {Lang}, " +
 $"director: {Director.ToString()}, " +
 $"rate: {Rate / 10.0}," +
 $"actors: { (Actors == null ? 0 : Actors.Count()) }," +
 $"tags: {(Tags == null ? "" : string.Join(",", Tags))} }}";
Exemplo n.º 2
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            if (ActualWidth <= 0 || ActualHeight <= 0 || Actors == null || Actors.Count() < 1)
            {
                return;
            }

            using (var bitmap = new Bitmap((int)ActualWidth, (int)ActualHeight))
            {
                using (var g = Graphics.FromImage(bitmap))
                {
                    PrepareFrame(g);

                    if (IsGridVisible)
                    {
                        DrawGrid(g);
                        DrawPoints(g);
                    }
                }

                // Copy GDI bitmap to WPF bitmap
                var hBitmap = bitmap.GetHbitmap();
                var image   = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                image.Freeze();
                dc.DrawImage(image, new Rect(RenderSize));

                DeleteObject(hBitmap);
            }
        }
        void PopulateActorListView(List <ActorModel> actors)
        {
            var position = Actors.Count();

            actors.ForEach(actor =>
            {
                position       = position + 1;
                actor.Position = position;
                Actors.Add(actor);
            });
        }
Exemplo n.º 4
0
        public Task <bool> SaveChangesAsync()
        {
            return(Task.Run(() =>
            {
                if (FilmsToAdd.Count() <= 0 && ActorsToAdd.Count() <= 0 &&
                    DirectorsToAdd.Count() <= 0 && FilmsToDelete.Count() <= 0 &&
                    ActorsToDelete.Count() <= 0 && DirectorsToDelete.Count() <= 0)
                {
                    return false;
                }

                foreach (var film in FilmsToAdd)
                {
                    film.Id = Films.Count() + 1;
                    Films.Add(film);
                }
                foreach (var actor in ActorsToAdd)
                {
                    actor.Id = Actors.Count() + 1;
                    Actors.Add(actor);
                }
                foreach (var director in DirectorsToAdd)
                {
                    director.Id = Directors.Count() + 1;
                    Directors.Add(director);
                }

                foreach (var film in FilmsToDelete)
                {
                    var filmInList = Films.Where(f => f.Id == film.Id).FirstOrDefault();
                    Films.Remove(filmInList);
                }
                foreach (var actor in ActorsToDelete)
                {
                    var actorInList = Actors.Where(f => f.Id == actor.Id).FirstOrDefault();
                    Actors.Remove(actorInList);
                }
                foreach (var director in DirectorsToDelete)
                {
                    var directorInList = Directors.Where(f => f.Id == director.Id).FirstOrDefault();
                    Directors.Remove(directorInList);
                }

                Initialize();
                return true;
            }));
        }
Exemplo n.º 5
0
        private void TestCollisions(Func <ActorBase, ActorBase, bool> collisionTest)
        {
            for (int i = 0; i < Actors.Count(); i++)
            {
                if (Actors[i].Collided)
                {
                    continue;
                }

                for (int j = 0; j < Actors.Count(); j++)
                {
                    if (j <= i)
                    {
                        continue;
                    }

                    if (collisionTest(Actors[i], Actors[j]))
                    {
                        Actors[i].RegisterCollision(Actors[j]);
                        Actors[j].RegisterCollision(Actors[i]);
                    }
                }
            }
        }