コード例 #1
0
        public void Materialize_Should_Create_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null);
            var result = containers.OfType<TextBlock>().Select(x => x.Text).ToList();

            Assert.Equal(items, result);
        }
コード例 #2
0
        public void Dematerialize_Should_Return_Removed_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null);
            var expected = target.Containers.Take(2).ToList();
            var result = target.Dematerialize(0, 2);

            Assert.Equal(expected, result);
        }
コード例 #3
0
        public void IndexFromContainer_Should_Return_Index()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null).ToList();

            Assert.Equal(0, target.IndexFromContainer(containers[0].ContainerControl));
            Assert.Equal(1, target.IndexFromContainer(containers[1].ContainerControl));
            Assert.Equal(2, target.IndexFromContainer(containers[2].ContainerControl));
        }
コード例 #4
0
        public void ContainerFromIndex_Should_Return_Materialized_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null).ToList();

            Assert.Equal(containers[0].ContainerControl, target.ContainerFromIndex(0));
            Assert.Equal(containers[1].ContainerControl, target.ContainerFromIndex(1));
            Assert.Equal(containers[2].ContainerControl, target.ContainerFromIndex(2));
        }
コード例 #5
0
        public void RemoveRange_Should_Alter_Successive_Container_Indexes()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null).ToList();

            var removed = target.RemoveRange(1, 1).Single();

            Assert.Equal(containers[0], target.ContainerFromIndex(0));
            Assert.Equal(containers[2], target.ContainerFromIndex(1));
            Assert.Equal(containers[1], removed);
        }
コード例 #6
0
        public void Dematerialize_Should_Remove_Container()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null).ToList();

            target.Dematerialize(1, 1);

            Assert.Equal(containers[0], target.ContainerFromIndex(0));
            Assert.Equal(null, target.ContainerFromIndex(1));
            Assert.Equal(containers[2], target.ContainerFromIndex(2));
        }
コード例 #7
0
        public void Materialize_Should_Create_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator<ListBoxItem>(owner, ListBoxItem.ContentProperty);
            var containers = target.Materialize(0, items, null);
            var result = containers
                .Select(x => x.ContainerControl)
                .OfType<ListBoxItem>()
                .Select(x => x.Content)
                .ToList();

            Assert.Equal(items, result);
        }
コード例 #8
0
ファイル: TabStrip.cs プロジェクト: hacklex/Perspex
        protected override IItemContainerGenerator CreateItemContainerGenerator()
        {
            TabControl tabControl = TemplatedParent as TabControl;
            IItemContainerGenerator result;

            if (tabControl != null)
            {
                result = tabControl.ItemContainerGenerator;
            }
            else
            {
                result = new ItemContainerGenerator<TabItem>(this);
            }

            return result;
        }
コード例 #9
0
ファイル: TabStrip.cs プロジェクト: Robertofon/Perspex
        protected override IItemContainerGenerator CreateItemContainerGenerator()
        {
            TabControl tabControl = this.TemplatedParent as TabControl;
            IItemContainerGenerator result;

            if (tabControl != null)
            {
                result = tabControl.ItemContainerGenerator;
            }
            else
            {
                result = new ItemContainerGenerator<TabItem>(this);
            }

            ////result.StateChanged += this.ItemsContainerGeneratorStateChanged;

            return result;
        }