Esempio n. 1
0
 public void TestClear()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     test.Add("a");
     test.Add("b");
     test.Clear();
     CollectionAssert.IsEmpty(test);
 }
Esempio n. 2
0
 public void TestAdd()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     test.Add("a");
     Utilities.TestSequenceEqual(test, "a");
     test.Add("b");
     Utilities.TestSequenceEqual(test, "a", "b");
     Assert.Throws<ArgumentNullException>(delegate() { test.Add(null); });
 }
Esempio n. 3
0
        public void TestClear()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            test.Add("a");
            test.Add("b");
            test.Clear();
            CollectionAssert.IsEmpty(test);
        }
Esempio n. 4
0
 public void TestIEnumerable()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     CollectionAssert.IsEmpty(test);
     test.Add("a");
     Utilities.TestSequenceEqual(test, "a");
     test.Add("b");
     Utilities.TestSequenceEqual(test, "a", "b");
 }
Esempio n. 5
0
 public void TestContains()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     Assert.False(test.Contains("a"));
     test.Add("a");
     Assert.True(test.Contains("a"));
     test.Add("b");
     Assert.True(test.Contains("b"));
 }
Esempio n. 6
0
 public void TestCount()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     Assert.True(test.Count == 0);
     test.Add("a");
     Assert.True(test.Count == 1);
     test.Add("b");
     Assert.True(test.Count == 2);
 }
Esempio n. 7
0
        public void TestAsIEnumerable()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            CollectionAssert.IsEmpty(test.AsIEnumerable <object>());
            test.Add("a");
            test.Add(this);
            Utilities.TestSequenceEqual(test.AsIEnumerable <string>(), "a");
            Utilities.TestSequenceEqual(test.AsIEnumerable <object>(), "a", this);
        }
Esempio n. 8
0
        public void TestCount()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            Assert.True(test.Count == 0);
            test.Add("a");
            Assert.True(test.Count == 1);
            test.Add("b");
            Assert.True(test.Count == 2);
        }
Esempio n. 9
0
        public void TestAdd()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            test.Add("a");
            Utilities.TestSequenceEqual(test, "a");
            test.Add("b");
            Utilities.TestSequenceEqual(test, "a", "b");
            Assert.Throws <ArgumentNullException>(delegate() { test.Add(null); });
        }
Esempio n. 10
0
        public void TestGetSnapshotGeneric()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            CollectionAssert.IsEmpty(test.GetSnapshot());
            test.Add("a");
            test.Add(this);
            Assert.AreEqual(test.GetSnapshot <object>(), new object[] { "a", this });
            Assert.AreEqual(test.GetSnapshot <string>(), new string[] { "a" });
        }
Esempio n. 11
0
        public void TestContains()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            Assert.False(test.Contains("a"));
            test.Add("a");
            Assert.True(test.Contains("a"));
            test.Add("b");
            Assert.True(test.Contains("b"));
        }
Esempio n. 12
0
        public void TestIEnumerable()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            CollectionAssert.IsEmpty(test);
            test.Add("a");
            Utilities.TestSequenceEqual(test, "a");
            test.Add("b");
            Utilities.TestSequenceEqual(test, "a", "b");
        }
Esempio n. 13
0
 public void TestRemove()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     test.Add("a");
     test.Add("b");
     Assert.False(test.Remove("c"));
     Assert.True(test.Remove("a"));
     Utilities.TestSequenceEqual(test, "b");
     Assert.False(test.Remove("a"));
     Assert.True(test.Remove("b"));
     CollectionAssert.IsEmpty(test);
 }
Esempio n. 14
0
        public void TestActiveItem()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            Assert.Null(test.ActiveItem);
            test.Add("a");
            Assert.AreSame(test.ActiveItem, "a");
            test.Add("b");
            Assert.AreSame(test.ActiveItem, "b");
            test.Remove("b");
            Assert.AreSame(test.ActiveItem, "a");
        }
Esempio n. 15
0
        public void TestUniqueness()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            test.Add("a");
            test.Add("a");
            Utilities.TestSequenceEqual(test, "a");
            object b = new object();

            test.Add("b");
            Utilities.TestSequenceEqual(test, "a", "b");
        }
Esempio n. 16
0
        public void TestGetSnapshot()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            CollectionAssert.IsEmpty(test.GetSnapshot());
            test.Add("a");
            object[] snapshot = test.GetSnapshot();
            Assert.AreEqual(snapshot, new object[] { "a" });
            test.Add("b");
            snapshot = test.GetSnapshot();
            Assert.AreEqual(snapshot, new object[] { "a", "b" });
        }
Esempio n. 17
0
        public void TestCopyTo()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            test.Add("a");
            test.Add("b");
            object[] array1 = new object[2];
            test.CopyTo(array1, 0);
            Assert.AreEqual(array1, new object[] { "a", "b" });
            object[] array2 = new object[3];
            test.CopyTo(array2, 1);
            Assert.AreEqual(array2, new object[] { null, "a", "b" });
        }
Esempio n. 18
0
        public void TestGetActiveItem()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            Assert.Null(test.GetActiveItem <string>());
            test.Add("a");
            Assert.AreSame(test.GetActiveItem <string>(), "a");
            test.Add("b");
            Assert.AreSame(test.GetActiveItem <string>(), "b");
            test.Add(this); // any non-string
            Assert.AreSame(test.GetActiveItem <string>(), "b");
            Assert.AreSame(test.GetActiveItem <TestActiveCollection>(), this);
        }
Esempio n. 19
0
        public void TestRemove()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            test.Add("a");
            test.Add("b");
            Assert.False(test.Remove("c"));
            Assert.True(test.Remove("a"));
            Utilities.TestSequenceEqual(test, "b");
            Assert.False(test.Remove("a"));
            Assert.True(test.Remove("b"));
            CollectionAssert.IsEmpty(test);
        }
Esempio n. 20
0
        /// <summary>
        /// Begins dragging any selected items managed by the adapter. May be called
        /// by another adapter when it begins dragging.</summary>
        /// <param name="initiator">Control adapter that is initiating the drag</param>
        void IItemDragAdapter.BeginDrag(ControlAdapter initiator)
        {
            // drag all selected nodes, and any edges impinging on them
            var draggingNodes = new ActiveCollection <Element>();

            foreach (var node in m_selectionContext.GetSelection <Element>())
            {
                draggingNodes.Add(node);
            }

            m_draggingNodes.AddRange(draggingNodes.GetSnapshot());

            var draggingGrpPins = new ActiveCollection <GroupPin>();

            // add the selected floating pins
            foreach (var grpin in m_selectionContext.GetSelection <GroupPin>())
            {
                draggingGrpPins.Add(grpin);
            }
            m_draggingGroupPins.AddRange(draggingGrpPins.GetSnapshot());

            if (m_draggingGroupPins.Any())
            {
                m_originalPinY = new int[m_draggingGroupPins.Count];
                for (int i = 0; i < m_originalPinY.Length; i++)
                {
                    m_originalPinY[i] = m_draggingGroupPins[i].Bounds.Location.Y;
                }
            }
        }
        public void TestChangeEvents()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            test.ActiveItemChanging += test_ActiveItemChanging;
            test.ActiveItemChanged  += test_ActiveItemChanged;
            object a = new object();

            test.Add(a);
            Assert.True(m_changingEvents == 1);
            Assert.True(m_changedEvents == 1);
            test.Add(a);
            Assert.True(m_changingEvents == 1); // no change!
            Assert.True(m_changedEvents == 1);  // no change!
            object b = new object();

            test.Add(b);
            Assert.True(m_changingEvents == 2);
            Assert.True(m_changedEvents == 2);
            test.Remove(a);
            Assert.True(m_changingEvents == 2); // no change!
            Assert.True(m_changedEvents == 2);  // no change!
            test.Remove(b);
            Assert.True(m_changingEvents == 3);
            Assert.True(m_changedEvents == 3);
            test.ActiveItem = a;
            Assert.True(m_changingEvents == 4);
            Assert.True(m_changedEvents == 4);
            test.Clear();
            Assert.True(m_changingEvents == 5);
            Assert.True(m_changedEvents == 5);
            test.Clear();
            Assert.True(m_changingEvents == 5); // no change!
            Assert.True(m_changedEvents == 5);  // no change!
            test.Add(b);
            Assert.True(m_changingEvents == 6);
            Assert.True(m_changedEvents == 6);
            test.Set(new[] { a, b });           //'b' becomes ActiveItem, so no change
            Assert.True(m_changingEvents == 6); // no change!
            Assert.True(m_changedEvents == 6);  // no change!
            test.Set(new[] { b, a });           //'a' becomes ActiveItem, so we have a change
            Assert.True(m_changingEvents == 7);
            Assert.True(m_changedEvents == 7);
            test.Set(new object[] { });
            Assert.True(m_changingEvents == 8);
            Assert.True(m_changedEvents == 8);
        }
Esempio n. 22
0
 /**
  * Adds a clip to the active collections
  */
 public void AddClipToActiveCollection(AudioMateClip clip, bool noEvent = false)
 {
     ActiveCollection?.Add(clip);
     if (!noEvent)
     {
         OnActiveCollectionUpdated.Invoke();
     }
 }
Esempio n. 23
0
        public void TestChangeEvents()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            test.ActiveItemChanging += test_ActiveItemChanging;
            test.ActiveItemChanged  += test_ActiveItemChanged;
            object a = new object();

            test.Add(a);
            Assert.True(m_changedEvents == 1);
            test.Add(a);
            Assert.True(m_changedEvents == 1); // no change!
            object b = new object();

            test.Add(b);
            Assert.True(m_changedEvents == 2);
        }
Esempio n. 24
0
        private void AddDragNode(TNode node, ActiveCollection <TNode> draggingNodes, HashSet <TNode> nodes)
        {
            draggingNodes.Add(node);
            if (!nodes.Contains(node))
            {
                nodes.Add(node);
            }

            if (DraggingSubNodes)
            {
                var hierarchicalNode = node.As <IHierarchicalGraphNode <TNode, TEdge, TEdgeRoute> >();
                if (hierarchicalNode != null)
                {
                    foreach (TNode subNode in hierarchicalNode.SubNodes)
                    {
                        AddDragNode(subNode, draggingNodes, nodes);
                    }
                }
            }
        }
        private void AddDragNode(TNode node, ActiveCollection <TNode> draggingNodes, HashSet <TNode> nodes)
        {
            draggingNodes.Add(node);
            if (!nodes.Contains(node))
            {
                nodes.Add(node);
                m_graphAdapter.SetStyle(node, DiagramDrawingStyle.Ghosted);
            }

            IHierarchicalGraphNode <TNode, TEdge, TEdgeRoute> hierarchicalNode =
                node.As <IHierarchicalGraphNode <TNode, TEdge, TEdgeRoute> >();

            if (hierarchicalNode != null)
            {
                foreach (TNode subNode in hierarchicalNode.SubNodes)
                {
                    AddDragNode(subNode, draggingNodes, nodes);
                }
            }
        }
Esempio n. 26
0
 /**
  * Adds a range of clips to the active collections
  */
 public void AddClipRangeToActiveCollection(int fromIndex, int toIndex, bool noEvent = false)
 {
     if (ActiveCollection == null)
     {
         return;
     }
     for (var i = fromIndex; i <= toIndex; i++)
     {
         var clip = _ui.clipLibrary.Clips.ElementAtOrDefault(i);
         if (clip == null)
         {
             continue;
         }
         ActiveCollection.Add(clip);
         _controller.ui.clipLibrary.SetCursorIndex(i);
     }
     if (!noEvent)
     {
         OnActiveCollectionUpdated.Invoke();
     }
 }
Esempio n. 27
0
        /// <summary>
        /// Begins dragging any selected items managed by the adapter. May be called
        /// by another adapter when it begins dragging.</summary>
        /// <param name="initiator">Control adapter that is initiating the drag</param>
        void IItemDragAdapter.BeginDrag(ControlAdapter initiator)
        {
           
            // drag all selected nodes, and any edges impinging on them
            var draggingNodes = new ActiveCollection<Element>();
         
            foreach (var node in m_selectionContext.GetSelection<Element>())
                draggingNodes.Add(node);
                 
            m_draggingNodes.AddRange(draggingNodes.GetSnapshot());

            var draggingGrpPins= new ActiveCollection<GroupPin>();
            // add the selected floating pins
            foreach (var grpin in m_selectionContext.GetSelection<GroupPin>())         
                draggingGrpPins.Add(grpin);
            m_draggingGroupPins.AddRange(draggingGrpPins.GetSnapshot());

            if (m_draggingGroupPins.Any())
            {
                m_originalPinY = new int[m_draggingGroupPins.Count];
                for (int i = 0; i < m_originalPinY.Length; i++)
                    m_originalPinY[i] = m_draggingGroupPins[i].Bounds.Location.Y;
            }
        }
Esempio n. 28
0
 public void TestChangeEvents()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     test.ActiveItemChanging += test_ActiveItemChanging;
     test.ActiveItemChanged += test_ActiveItemChanged;
     object a = new object();
     test.Add(a);
     Assert.True(m_changingEvents == 1);
     Assert.True(m_changedEvents == 1);
     test.Add(a);
     Assert.True(m_changingEvents == 1); // no change!
     Assert.True(m_changedEvents == 1); // no change!
     object b = new object();
     test.Add(b);
     Assert.True(m_changingEvents == 2);
     Assert.True(m_changedEvents == 2);
     test.Remove(a);
     Assert.True(m_changingEvents == 2); // no change!
     Assert.True(m_changedEvents == 2); // no change!
     test.Remove(b);
     Assert.True(m_changingEvents == 3);
     Assert.True(m_changedEvents == 3);
     test.ActiveItem = a;
     Assert.True(m_changingEvents == 4);
     Assert.True(m_changedEvents == 4);
     test.Clear();
     Assert.True(m_changingEvents == 5);
     Assert.True(m_changedEvents == 5);
     test.Clear();
     Assert.True(m_changingEvents == 5); // no change!
     Assert.True(m_changedEvents == 5); // no change!
     test.Add(b);
     Assert.True(m_changingEvents == 6);
     Assert.True(m_changedEvents == 6);
     test.Set(new[] { a, b }); //'b' becomes ActiveItem, so no change
     Assert.True(m_changingEvents == 6); // no change!
     Assert.True(m_changedEvents == 6); // no change!
     test.Set(new[] { b, a }); //'a' becomes ActiveItem, so we have a change
     Assert.True(m_changingEvents == 7);
     Assert.True(m_changedEvents == 7);
     test.Set(new object[] { });
     Assert.True(m_changingEvents == 8);
     Assert.True(m_changedEvents == 8);
 }
Esempio n. 29
0
 public void TestUniqueness()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     test.Add("a");
     test.Add("a");
     Utilities.TestSequenceEqual(test, "a");
     object b = new object();
     test.Add("b");
     Utilities.TestSequenceEqual(test, "a", "b");
 }
Esempio n. 30
0
 public void TestActiveItem()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     Assert.Null(test.ActiveItem);
     test.Add("a");
     Assert.AreSame(test.ActiveItem, "a");
     test.Add("b");
     Assert.AreSame(test.ActiveItem, "b");
     test.Remove("b");
     Assert.AreSame(test.ActiveItem, "a");
 }
Esempio n. 31
0
 public void TestGetActiveItem()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     Assert.Null(test.GetActiveItem<string>());
     test.Add("a");
     Assert.AreSame(test.GetActiveItem<string>(), "a");
     test.Add("b");
     Assert.AreSame(test.GetActiveItem<string>(), "b");
     test.Add(this); // any non-string
     Assert.AreSame(test.GetActiveItem<string>(), "b");
     Assert.AreSame(test.GetActiveItem<TestActiveCollection>(), this);
 }
Esempio n. 32
0
 public void TestGetSnapshot()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     CollectionAssert.IsEmpty(test.GetSnapshot());
     test.Add("a");
     object[] snapshot = test.GetSnapshot();
     Assert.AreEqual(snapshot, new object[] { "a" });
     test.Add("b");
     snapshot = test.GetSnapshot();
     Assert.AreEqual(snapshot, new object[] { "a", "b" });
 }
Esempio n. 33
0
 public void TestGetSnapshotGeneric()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     CollectionAssert.IsEmpty(test.GetSnapshot());
     test.Add("a");
     test.Add(this);
     Assert.AreEqual(test.GetSnapshot<object>(), new object[] { "a", this });
     Assert.AreEqual(test.GetSnapshot<string>(), new string[] { "a" });
 }
Esempio n. 34
0
 public void TestAsIEnumerable()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     CollectionAssert.IsEmpty(test.AsIEnumerable<object>());
     test.Add("a");
     test.Add(this);
     Utilities.TestSequenceEqual(test.AsIEnumerable<string>(), "a");
     Utilities.TestSequenceEqual(test.AsIEnumerable<object>(), "a", this);
 }
Esempio n. 35
0
 public void TestChangeEvents()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     test.ActiveItemChanging += new EventHandler(test_ActiveItemChanging);
     test.ActiveItemChanged += new EventHandler(test_ActiveItemChanged);
     object a = new object();
     test.Add(a);
     Assert.True(m_changedEvents == 1);
     test.Add(a);
     Assert.True(m_changedEvents == 1); // no change!
     object b = new object();
     test.Add(b);
     Assert.True(m_changedEvents == 2);
 }
Esempio n. 36
0
 public void TestCopyTo()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     test.Add("a");
     test.Add("b");
     object[] array1 = new object[2];
     test.CopyTo(array1, 0);
     Assert.AreEqual(array1, new object[] { "a", "b" });
     object[] array2 = new object[3];
     test.CopyTo(array2, 1);
     Assert.AreEqual(array2, new object[] { null, "a", "b" });
 }
Esempio n. 37
0
        protected void GetPosts()
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            foreach (IFilter filter in this.GetFilters())
            {
                if (filter is PageNumber) pager = (PageNumber)filter;
                this.ApplyFilter(filter, parameters);
            }
            this.ApplySecurityFilter(parameters);

            ActiveCollection<Post> posts = null;
            if (parameters.ContainsKey("Slug") && parameters.ContainsKey("ControllerID"))
            {
                Post p = DataBroker.GetPost((Guid)parameters["ControllerID"], (string)parameters["Slug"]);
                posts = new ActiveCollection<Post>();
                if (
                    p == null ||
                    (parameters.ContainsKey("Status") && !p.Status.Equals(parameters["Status"])) ||
                    (parameters.ContainsKey("EndPublishDate") && p.PublishDate.CompareTo(parameters["EndPublishDate"]) > 0)
                    )
                {
                    posts.TotalResults = 0;
                }
                else if(p != null)
                {
                    posts.TotalResults = 1;
                    posts.Add(p);
                    this.Page.SetCacheDependency(this.Content);
                }
            }
            else
            {
                posts = DataBroker.GetPosts(parameters);
            }

            this.posts = posts;
            this.DataSource = this.posts;
            base.DataBind();
        }