Beispiel #1
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;
                }
            }
        }
Beispiel #2
0
        public ControlHostService(Form mainForm)
        {
            m_controls = new ActiveCollection<ControlInfo>();
            m_controls.ActiveItemChanged += controls_ActiveItemChanged;
            m_controls.ActiveItemChanging += controls_ActiveItemChanging;
            m_controls.ItemAdded += controls_ItemAdded;
            m_controls.ItemRemoved += controls_ItemRemoved;

            m_mainForm = mainForm;

            m_dockPanel = new DockPanel();
            m_dockPanel.Dock = DockStyle.Fill;
            m_dockPanel.DockBackColor = mainForm.BackColor;
            m_dockPanel.ShowDocumentIcon = true;
            m_dockPanel.ActiveContentChanged += dockPanel_ActiveContentChanged;
            m_dockPanel.ContentAdded += DockPanelContentAdded;
            m_dockPanel.ContentRemoved += DockPanelContentRemoved;

            // default behavior - when double clicking a float window's title it will
            // maximize the floating window instead of docking the floating window
            DoubleClickFloatWindowTitleMaximizes = true;

            // try a default delay (in milliseconds!)
            MouseOverTabSwitchDelay = 250;

            m_uiLockImage = ResourceUtil.GetImage24(Resources.LockUIImage);
            m_uiUnlockImage = ResourceUtil.GetImage24(Resources.UnlockUIImage);
        }
Beispiel #3
0
 public void TestClear()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     test.Add("a");
     test.Add("b");
     test.Clear();
     CollectionAssert.IsEmpty(test);
 }
Beispiel #4
0
 /**
  * Adds a clip to the active collections
  */
 public void AddClipToActiveCollection(AudioMateClip clip, bool noEvent = false)
 {
     ActiveCollection?.Add(clip);
     if (!noEvent)
     {
         OnActiveCollectionUpdated.Invoke();
     }
 }
Beispiel #5
0
        public void TestClear()
        {
            ActiveCollection <object> test = new ActiveCollection <object>();

            test.Add("a");
            test.Add("b");
            test.Clear();
            CollectionAssert.IsEmpty(test);
        }
Beispiel #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);
 }
Beispiel #7
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");
 }
Beispiel #8
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); });
 }
Beispiel #9
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"));
 }
Beispiel #10
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");
        }
Beispiel #11
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" });
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }
Beispiel #14
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); });
        }
Beispiel #15
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"));
        }
Beispiel #16
0
 public void PlayRandomClipAction(string collectionName = null)
 {
     if (collectionName == null)
     {
         ActiveCollection?.PlayRandomClip();
     }
     else
     {
         PlayRandomClipInCollection(collectionName);
     }
 }
Beispiel #17
0
 public void QueueRandomClipAction(string collectionName = null)
 {
     if (collectionName == null)
     {
         ActiveCollection?.QueueRandomClip();
     }
     else
     {
         QueueRandomClipInCollection(collectionName);
     }
 }
Beispiel #18
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" });
        }
Beispiel #19
0
        /// <summary>
        /// End the measuring
        /// </summary>
        internal override void EndMeasuring()
        {
            base.EndMeasuring();

            ActiveCollection.FinalizeElements();
            CreateFeatureGeometry();

            var newCollection = new DimElementCollection();

            newCollection.OnCSUnitsPerPixelChanged(this.CSUnitsPerPixel);
            _elements.Add(newCollection);
        }
        /// <summary>
        /// End the measuring
        /// </summary>
        internal override void EndMeasuring()
        {
            base.EndMeasuring();

            ActiveCollection.FinalizeElements();
            CreateFeatureGeometry();

            var element = new FreeElement();

            element.OnCSUnitsPerPixelChanged(this.CSUnitsPerPixel);
            _elements.Add(element);
        }
Beispiel #21
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");
        }
Beispiel #22
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");
        }
Beispiel #23
0
 /**
  * Removes a clip from a collection
  */
 public bool RemoveClipFromActiveCollection(AudioMateClip clip, bool noEvent = false)
 {
     if (ActiveCollection == null || !ActiveCollection.Remove(clip))
     {
         return(false);
     }
     if (!noEvent)
     {
         OnActiveCollectionUpdated.Invoke();
     }
     return(true);
 }
Beispiel #24
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);
 }
Beispiel #25
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);
        }
Beispiel #26
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" });
        }
Beispiel #27
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);
        }
        public ControlHostService(Form mainForm)
        {
            m_controls = new ActiveCollection <ControlInfo>();
            m_controls.ActiveItemChanged  += new EventHandler(controls_ActiveItemChanged);
            m_controls.ActiveItemChanging += new EventHandler(controls_ActiveItemChanging);
            m_controls.ItemAdded          += new EventHandler <ItemInsertedEventArgs <ControlInfo> >(controls_ItemAdded);
            m_controls.ItemRemoved        += new EventHandler <ItemRemovedEventArgs <ControlInfo> >(controls_ItemRemoved);

            m_mainForm = mainForm;

            m_dockPanel                       = new DockPanel();
            m_dockPanel.Dock                  = DockStyle.Fill;
            m_dockPanel.DockBackColor         = SystemColors.AppWorkspace;
            m_dockPanel.ShowDocumentIcon      = true;
            m_dockPanel.ActiveContentChanged += new EventHandler(dockPanel_ActiveContentChanged);
        }
        public ControlHostService(Form mainForm)
        {
            m_controls = new ActiveCollection<ControlInfo>();
            m_controls.ActiveItemChanged += new EventHandler(controls_ActiveItemChanged);
            m_controls.ActiveItemChanging += new EventHandler(controls_ActiveItemChanging);
            m_controls.ItemAdded += new EventHandler<ItemInsertedEventArgs<ControlInfo>>(controls_ItemAdded);
            m_controls.ItemRemoved += new EventHandler<ItemRemovedEventArgs<ControlInfo>>(controls_ItemRemoved);

            m_mainForm = mainForm;

            m_dockPanel = new DockPanel();
            m_dockPanel.Dock = DockStyle.Fill;
            m_dockPanel.DockBackColor = SystemColors.AppWorkspace;
            m_dockPanel.ShowDocumentIcon = true;
            m_dockPanel.ActiveContentChanged += new EventHandler(dockPanel_ActiveContentChanged);
        }
        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);
        }
        /// <summary>
        /// Deletes the last coordinate
        /// </summary>
        internal override void DeleteLastCoordinate()
        {
            if (!ActiveCollection.IsFinalized && LastCoordinate != null)
            {
                var coordinates = Coordinates;
                if (coordinates.Count > 0)
                {
                    Coordinate last = LastMouseCoordinate;

                    coordinates.RemoveAt(coordinates.Count - 1);

                    ActiveCollection.DeletedCoordinate(coordinates, last);

                    CreateFeatureGeometry();
                }
            }
        }
Beispiel #32
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);
        }
        /// <summary>
        /// Move the coordinate
        /// </summary>
        internal override void MoveAll(double divX, double divY)
        {
            if (ActiveCollection.CanAddCoordinate() && !ActiveCollection.IsFinalized)
            {
                if (ActiveCollection != null && Coordinates.Count > 0)
                {
                    ActiveCollection.Transform = this.PixelToWorldTransform;

                    for (int nr = 0; nr < Coordinates.Count; nr++)
                    {
                        var cd = Coordinates[nr];
                        Coordinates[nr] = new Coordinate(cd.X + divX, cd.Y + divY);
                    }

                    ActiveCollection.MovedAll(Coordinates, LastMouseCoordinate);
                    CreateFeatureGeometry();
                }
            }
        }
        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);
                }
            }
        }
Beispiel #35
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);
                    }
                }
            }
        }
Beispiel #36
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();
     }
 }
        void IItemDragAdapter.BeginDrag(ControlAdapter initiator)
        {
            m_isDragging = true;

            // drag all selected nodes, and any edges impinging on them
            ActiveCollection <TNode> draggingNodes = new ActiveCollection <TNode>();
            List <TEdge>             draggingEdges = new List <TEdge>();
            HashSet <TNode>          nodes         = new HashSet <TNode>();

            foreach (TNode node in m_selectionContext.GetSelection <TNode>())
            {
                AddDragNode(node, draggingNodes, nodes);
            }

            // render all edges connected to the dragging nodes
            foreach (TEdge edge in m_graph.Edges)
            {
                if (nodes.Contains(edge.FromNode) ||
                    nodes.Contains(edge.ToNode))
                {
                    draggingEdges.Add(edge);

                    m_graphAdapter.SetStyle(edge, DiagramDrawingStyle.Ghosted);
                }
            }

            m_draggingNodes = draggingNodes.GetSnapshot <TNode>();
            m_newPositions  = new Point[m_draggingNodes.Length];
            m_oldPositions  = new Point[m_draggingNodes.Length];
            for (int i = 0; i < m_draggingNodes.Length; i++)
            {
                // Initialize m_newPositions in case the mouse up event occurs before
                //  a paint event, which can happen during rapid clicking.
                Point currentLocation = m_draggingNodes[i].Bounds.Location;
                m_newPositions[i] = currentLocation;
                m_oldPositions[i] = currentLocation;
            }

            m_draggingEdges = draggingEdges.ToArray();
        }
Beispiel #38
0
        void IItemDragAdapter.BeginDrag(ControlAdapter initiator)
        {
            // drag all selected nodes, and any edges impinging on them
            ActiveCollection <TNode> draggingNodes = new ActiveCollection <TNode>();
            HashSet <TNode>          nodes         = new HashSet <TNode>();

            foreach (TNode node in m_selectionContext.GetSelection <TNode>())
            {
                AddDragNode(node, draggingNodes, nodes);
            }
            m_draggingNodes = draggingNodes.GetSnapshot <TNode>();

            m_newPositions = new Point[m_draggingNodes.Length];
            m_oldPositions = new Point[m_draggingNodes.Length];
            for (int i = 0; i < m_draggingNodes.Length; i++)
            {
                // Initialize m_newPositions in case the mouse up event occurs before
                //  a paint event, which can happen during rapid clicking.
                Point currentLocation = m_draggingNodes[i].Bounds.Location;
                m_newPositions[i] = currentLocation;
                m_oldPositions[i] = currentLocation;
            }
        }
Beispiel #39
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;
            }
        }
Beispiel #40
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);
 }
Beispiel #41
0
 public void TestReadonly()
 {
     ActiveCollection<object> test = new ActiveCollection<object>();
     Assert.False(test.IsReadOnly);
 }
Beispiel #42
0
        protected void GetPages()
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            PageNumber pager = null;
            bool useScopeOnly = true;
            foreach(IFilter filter in this.GetFilters())
            {
                if (filter is PageNumber)
                {
                    pager = (PageNumber)filter;
                }
                else
                {
                    if (!(filter is ScopeFilter))
                    {
                        useScopeOnly = false;
                    }
                    this.ApplyFilter(filter, parameters);
                }
            }

            this.pages = (useScopeOnly) ? Content.Pages : Mubble.Models.Page.Find(parameters);

            if (pager != null)
            {
                for (int i = 0; i < this.pages.Count; i++)
                {
                    if (this.pages[i].PageNumber == pager.CurrentPageNumber)
                    {
                        this.DataSource = new Mubble.Models.Page[] { currentPage = this.pages[this.currentPageIndex = i] };
                        this.Page.SetPageTitle(currentPage.Controller.Title + ": Page " + currentPage.PageNumber);
                        break;
                    }
                }
            }
            else
            {
                this.DataSource = this.pages;
            }
            base.DataBind();
        }
Beispiel #43
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();
        }
Beispiel #44
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);
 }
Beispiel #45
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");
 }
Beispiel #46
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);
 }
Beispiel #47
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");
 }
Beispiel #48
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" });
 }
Beispiel #49
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" });
 }
Beispiel #50
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" });
 }
Beispiel #51
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);
 }