private void OnAddPage(object obj)
        {
            var page = new HostedLayoutPageViewModel(new HostedLayoutPage(ModelAs <HostedLayout>())
            {
                Name         = $"New Page {_pages.Count + 1}",
                CanvasWidth  = 3840,
                CanvasHeight = 2160
            });

            _pages.Add(page);
            SelectedPage = page;
        }
 public void Add_ShouldWork()
 {
     bool isChangeTriggered = false, isAddTriggered = false, isAllTriggered = false;
     var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel));
     c.Bind("change", e => isChangeTriggered = true);
     c.Bind("add", e => isAddTriggered = true);
     c.Bind("all", e => isAllTriggered = true);
     c.Add(new SimpleModel {Id = 3});
     Assert.AreEqual(c.Count, 1);
     Assert.AreEqual(c.ElementAt(0).Id, 3);
     Assert.AreEqual(isChangeTriggered, true, "change event should have been triggered");
     Assert.AreEqual(isAddTriggered, true, "add event should have been triggered");
     Assert.AreEqual(isAllTriggered, true, "all event should have been triggered");
 }
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="SelectCollaborators" /> class.
        /// </summary>
        /// <param name="collaborators">The collaborators.</param>
        public SelectCollaborators(IEnumerable<Collaborator> collaborators)
        {
            InitializeComponent();

            TheList = new ViewModelCollection<Collab>();

            foreach (var co in collaborators.Where(c => c.Status == "online"))
            {
                var collab = new Collab() { Collaborator = co };
                TheList.Add(collab);
            }

            lvCollabs.ItemsSource = TheList;
        }
Example #4
0
        public EditorLevel(int screenWidth, int screenHeight)
        {
            _environment = new EnvironmentContainer();

            LevelWidth  = Common.Settings.GlobalSettings.LevelWidth;
            LevelHeight = Common.Settings.GlobalSettings.LevelHeight;

            PickableObjects  = new ObservableCollection <IInstancePrototype>();
            ActivePrototypes = new ObservableCollection <IInstancePrototype>();
            ((ObservableCollection <IInstancePrototype>)ActivePrototypes).Insert(0, ActivePrototype);

            ///// TODO: Replace it with special editor environment container
            LevelObjects = new ViewModelCollection <IInstance>();
            //LevelItems = EnvironmentContainer.Items;
            // Add Terrain 4 test
            var wall1 = new StaticObjectBehavior(new DungeonStoneWall(new Point(2400, 2600), _environment));
            var wall2 = new StaticObjectBehavior(new DungeonStoneWall(new Point(2900, 2900), _environment));

            LevelObjects.Add(wall1);
            LevelObjects.Add(wall2);


            //Replace with invisible actor with ignoring collision resolver
            Player   = new Player(new BrokenHeart(new Point(2700, 2700), _environment), null);
            ViewPort = new ViewPort(screenWidth, screenHeight, (IInstance)Player);


            // Load available pickable objects
            foreach (Type t in System.Reflection.Assembly.GetAssembly(typeof(IInstancePrototype)).GetTypes()
                     .Where(x => x.GetInterface(typeof(IInstancePrototype).Name) != null && !x.IsInterface && !x.IsAbstract))
            {
                ((ObservableCollection <IInstancePrototype>)PickableObjects).Insert(0, (IInstancePrototype)Activator.CreateInstance(t));
            }

            _environment.AddInstance((IInstance)Player);
            _environment.Run();
        }
Example #5
0
        protected override void OnModelChanged(IDeck OldValue, IDeck NewValue)
        {
            base.OnModelChanged(OldValue, NewValue);

            if (Model == null)
            {
                Cards = null;
            }
            else
            {
                Cards = new ViewModelCollection <CardViewModel>();
                foreach (Card tile in Model.Cards)
                {
                    Cards.Add(new CardViewModel(tile));
                }
            }
        }
        public void SortInsertOnRightSpot()
        {
            CompositeCollection <int> collection = new CompositeCollection <int>(true);


            ViewModelCollection <int> a = new ViewModelCollection <int>(new List <int>());
            ViewModelCollection <int> b = new ViewModelCollection <int>(new List <int>());

            collection.Add(a);
            collection.Add(b);

            Random r = new Random();

            for (int i = 0; i < 200; i++)
            {
                if ((i % 2) == 1)
                {
                    a.Add(r.Next());
                }
                else
                {
                    b.Add(r.Next());
                }
            }

            int prv = collection[0];

            for (int i = 1; i < collection.Count; i++)
            {
                if (collection[i] < prv)
                {
                    throw new Exception($"{i}");
                }
                else
                {
                    prv = collection[i];
                }
            }
        }
 public void Clear_ShouldWork()
 {
     bool isClearTriggered = false, isAllTriggered = false;
     var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel));
     var m = new SimpleModel {Id = 3};
     c.Add(m);
     Assert.AreEqual(c.Count, 1);
     c.Bind("all", e => isAllTriggered = true);
     c.Bind("clear", e => isClearTriggered = true);
     c.Clear();
     Assert.AreEqual(c.Count, 0);
     Assert.AreEqual(isClearTriggered, true, "clear event should have been triggered");
     Assert.AreEqual(isAllTriggered, true, "all event should have been triggered");
 }
 public void Remove_WithSilent_ShouldNotTriggerChangeEvent()
 {
     bool isChangeTriggered = false, isRemoveTriggered = false, isAllTriggered = false;
     var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel));
     var m = new SimpleModel {Id = 3};
     c.Add(m);
     Assert.AreEqual(c.Count, 1);
     c.Bind("all", e => isAllTriggered = true);
     c.Bind("change", e => isChangeTriggered = true);
     c.Bind("remove", e => isRemoveTriggered = true);
     c.Remove(m);
     Assert.AreEqual(c.Count, 0);
     Assert.AreEqual(isChangeTriggered, true, "change event should not have been triggered");
     Assert.AreEqual(isRemoveTriggered, true, "remove event should not have been triggered");
     Assert.AreEqual(isAllTriggered, true, "all event should not have been triggered");
 }
 public void GetById_ShouldWork()
 {
     var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel));
     var model = new SimpleModel {Id = 3};
     c.Add(model);
     Assert.AreEqual(c.Count, 1);
     var a = c.GetById(model.Id);
     Assert.AreEqual(a.Id, model.Id);
     Assert.AreEqual(a, model);
 }
 public void ElementAt_ShouldWork()
 {
     var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel));
     var m = new SimpleModel {Id = 3};
     c.Add(m);
     Assert.AreEqual(c.Count, 1);
     Assert.AreEqual(c.ElementAt(0).Id, m.Id);
 }
 public void Contains_ShouldWork()
 {
     var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel));
     var m = new SimpleModel {Id = 3};
     c.Add(m);
     Assert.AreEqual(c.Count, 1);
     Assert.IsTrue(c.Contains(m));
 }