예제 #1
0
        /// <summary>
        /// Constructor</summary>
        public ObjectSelectionContext()
        {
            m_selection = new AdaptableSelection <object>();

            m_selection.Changing += selection_Changing;
            m_selection.Changed  += selection_Changed;
        }
 /// <summary>
 /// Constructor</summary>
 /// <param name="treeView">Data context of ITreeView to apply a filter</param>
 /// <param name="filterFunc">Callback to determine if an item in the tree is filtered in (return true) or out</param>
 public IndependentFilteredTreeView(ITreeView treeView, Predicate <object> filterFunc)
     : base(treeView, filterFunc)
 {
     m_selection           = new AdaptableSelection <object>();
     m_selection.Changing += (s, e) => SelectionChanging.Raise(this, e);
     m_selection.Changed  += (s, e) => SelectionChanged.Raise(this, e);;
 }
예제 #3
0
 /// <summary>
 /// Constructor</summary>
 /// <param name="root">Root of the tree view. Should implement IItemView, too.</param>
 public TreeViewWithSelection(ITreeView root)
 {
     m_treeView            = root;
     m_itemView            = root as IItemView;
     m_selection           = new AdaptableSelection <object>();
     m_selection.Changed  += (s, e) => SelectionChanged.Raise(this, e);
     m_selection.Changing += (s, e) => SelectionChanging.Raise(this, e);
 }
예제 #4
0
        public void TestAdaptation()
        {
            AdaptableSelection<object> test = new AdaptableSelection<object>();

            var a1 = new UnitTests.Atf.Adaptation.SimpleAdaptable();
            object o1 = new object();

            test.Add(a1);
            test.Add(o1);

            Utilities.TestSequenceEqual(test.AsIEnumerable<object>(), a1, o1);
            Utilities.TestSequenceEqual(test.AsIEnumerable<string>(), a1.As<string>());
            CollectionAssert.IsEmpty(test.AsIEnumerable<TestAdaptableSelection>());

            CollectionAssert.AreEqual(test.GetSnapshot<object>(), new object[] { a1, o1 });
            CollectionAssert.AreEqual(test.GetSnapshot<string>(), new string[] { a1.As<string>() });
            CollectionAssert.IsEmpty(test.GetSnapshot<TestAdaptableSelection>());

            Assert.AreSame(test.GetLastSelected<string>(), a1.As<string>());
            Assert.AreSame(test.GetLastSelected<object>(), o1);
            Assert.Null(test.GetLastSelected<TestAdaptableSelection>());
        }
예제 #5
0
        public void TestAdaptation()
        {
            AdaptableSelection <object> test = new AdaptableSelection <object>();

            var    a1 = new UnitTests.Atf.Adaptation.SimpleAdaptable();
            object o1 = new object();

            test.Add(a1);
            test.Add(o1);

            Utilities.TestSequenceEqual(test.AsIEnumerable <object>(), a1, o1);
            Utilities.TestSequenceEqual(test.AsIEnumerable <string>(), a1.As <string>());
            CollectionAssert.IsEmpty(test.AsIEnumerable <TestAdaptableSelection>());

            CollectionAssert.AreEqual(test.GetSnapshot <object>(), new object[] { a1, o1 });
            CollectionAssert.AreEqual(test.GetSnapshot <string>(), new string[] { a1.As <string>() });
            CollectionAssert.IsEmpty(test.GetSnapshot <TestAdaptableSelection>());

            Assert.AreSame(test.GetLastSelected <string>(), a1.As <string>());
            Assert.AreSame(test.GetLastSelected <object>(), o1);
            Assert.Null(test.GetLastSelected <TestAdaptableSelection>());
        }