Exemplo n.º 1
0
        /// <summary>
        /// Returns the position where an item should be inserted in the queue.
        /// </summary>
        /// <param name="item">Item which requires inserting.</param>
        /// <returns>Position where the item should be inserted.</returns>
        private int GetInsertPosition(QSetItemBase item)
        {
            int insertPos = 0;

            if (base.Count == 1)
            {
                if (((QSetItemBase)base.BaseGet(0)).Name.CompareTo(item.Name) < 0)
                {
                    insertPos = 1;
                }
            }
            else if (base.Count >= 1)
            {
                for (int checkPos = 0; checkPos <= base.Count - 1; checkPos++)
                {
                    if (((QSetItemBase)base.BaseGet(checkPos)).Name.CompareTo(item.Name) == 0)
                    {
                        insertPos = checkPos;
                        break;
                    }
                    else if ((((QSetItemBase)base.BaseGet(checkPos)).Name.CompareTo(item.Name) < 0) &&
                             (checkPos + 1 > base.Count - 1 || (((QSetItemBase)base.BaseGet(checkPos + 1)).Name.CompareTo(item.Name) > 0)))
                    {
                        insertPos = checkPos + 1;
                        break;
                    }
                }
            }

            return(insertPos);
        }
Exemplo n.º 2
0
		/// <summary>
		/// Constructs object.
		/// </summary>
		/// <param name="item">Item associated with the event.</param>
		protected AssociateItemEventArgs(QSetItemBase item)
			: base()
		{
			if (item == null) throw new ArgumentNullException("item");

			_item = item;
		}
Exemplo n.º 3
0
        /// <summary>
        /// Adds a QSetItemBase object to the collection.
        /// </summary>
        /// <param name="qSetItem">QSetItemBase object to add.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if any arguments are set to null.</exception>
        public void Add(QSetItemBase qSetItem)
        {
            if (qSetItem == null)
            {
                throw new ArgumentNullException("QSetItem");
            }
            else if (qSetItem is QSetModel)
            {
                throw new ArgumentOutOfRangeException("queueSetItem", "QSet cannot belong to a collection.");
            }
            else if (base.BaseGet(qSetItem.Name) != null)
            {
                throw new ArgumentOutOfRangeException("queueSetItem", "An item with the supplied name already exists in the collection.");
            }

            if (OwnerItem != null)
            {
                qSetItem.ParentItem = OwnerItem;
            }

            int insertedAt;

            InsertItemOrdered(qSetItem, out insertedAt);

            qSetItem.ItemRenamed += new ItemRenamedEvent(qSetItem_ItemRenamed);

            OnAfterItemAdded(new AfterItemAddedEventArgs(qSetItem, insertedAt));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Alphabetically inserts a new item into the collection.
        /// </summary>
        /// <param name="qSetItem">Item to insert.</param>
        /// <param name="insertedAt">Returns the index of where the item was inserted.</param>
        private void InsertItemOrdered(QSetItemBase qSetItem, out int insertedAt)
        {
            //ascertain where the item should be inserted
            int insertPos = GetInsertPosition(qSetItem);

            //insert the item at the desired position
            if (insertPos == base.Count)
            {
                base.BaseAdd(qSetItem.Name, qSetItem);
            }
            else
            {
                //we need to shunt all items at the insert pos and
                //after up one space, so temporarily put them onto a stack
                Stack shuntItemsStack = new Stack();
                int   currentCount    = base.Count;
                for (int counter = insertPos; counter <= currentCount - 1; counter++)
                {
                    shuntItemsStack.Push(base.BaseGet(base.Count - 1));
                    base.BaseRemoveAt(base.Count - 1);
                }

                //insert the new item
                base.BaseAdd(qSetItem.Name, qSetItem);

                //put everything from the stack backinto the collection
                while (shuntItemsStack.Count > 0)
                {
                    QSetItemBase replaceItem = (QSetItemBase)shuntItemsStack.Pop();
                    base.BaseAdd(replaceItem.Name, replaceItem);
                }
            }

            insertedAt = insertPos;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructs object.
        /// </summary>
        /// <param name="item">Item associated with the event.</param>
        protected AssociateItemEventArgs(QSetItemBase item)
            : base()
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            _item = item;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Removes the QSetItemBase object at the specified index.
 /// </summary>
 /// <param name="index">Index to remove at.</param>
 public void RemoveAt(int index)
 {
     lock (this)
     {
         QSetItemBase item = (QSetItemBase)base.BaseGet(index);
         if (item != null)
         {
             OnBeforeItemRemoved(new BeforeItemRemovedEventArgs(item, index));
             item.ParentItem   = null;
             item.ItemRenamed -= new ItemRenamedEvent(qSetItem_ItemRenamed);
             base.BaseRemoveAt(index);
         }
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Removes the QSetItemBase object with the specified key.
 /// </summary>
 /// <param name="key">Key of QSetItemBase object to remove.</param>
 public void Remove(string key)
 {
     lock (this)
     {
         QSetItemBase item = (QSetItemBase)base.BaseGet(key);
         if (item != null)
         {
             OnBeforeItemRemoved(new BeforeItemRemovedEventArgs(item, GetIndexOfKey(item.Name)));
             item.ParentItem   = null;
             item.ItemRenamed -= new ItemRenamedEvent(qSetItem_ItemRenamed);
             base.BaseRemove(key);
         }
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Attempts to extract a QSetItemBase object from a DataObject.
        /// </summary>
        /// <param name="data">DataObject.</param>
        /// <returns>QSetItemBase object if extract was succesful, else null.</returns>
        public static QSetItemBase GetFromDataObject(IDataObject data)
        {
            QSetItemBase item = null;

            item = (QSetItemBase)data.GetData(typeof(QSetItemBase));
            if (item == null)
            {
                item = (QSetQueueItem)data.GetData(typeof(QSetQueueItem));
            }
            if (item == null)
            {
                item = (QSetFolderItem)data.GetData(typeof(QSetFolderItem));
            }
            if (item == null)
            {
                item = (QSetMachineItem)data.GetData(typeof(QSetMachineItem));
            }
            if (item == null)
            {
                item = (QSetModel)data.GetData(typeof(QSetModel));
            }

            return(item);
        }
Exemplo n.º 9
0
		/// <summary>
		/// Searches for a node which contains a particular QSetItemBase object.
		/// </summary>
		/// <param name="item">QSetItemBase to search for.</param>
		/// <param name="searchRootNode">Tree node to start search from.</param>
		/// <returns>The node hosting the item if found, else null.</returns>
		private QSetItemTreeNode FindNode(QSetItemBase item, QSetItemTreeNode searchRootNode)
		{
			QSetItemTreeNode result = null;
			
			foreach(TreeNode node in searchRootNode.Nodes)
			{
				QSetItemTreeNode checkQSetNode = ((QSetItemTreeNode)node);

				if (checkQSetNode.QSetItem == item)
				{
					result = checkQSetNode;
					break;
				}
				else if (checkQSetNode.QSetItem is QSetFolderItem)
				{
					result = FindNode(item, checkQSetNode);
					if (result != null)
						break;
				}
			}

			return result;
		}
Exemplo n.º 10
0
 /// <summary>
 /// Constructs the object with the minum requirements.
 /// </summary>
 /// <param name="item">Item that was added or removed.</param>
 /// <param name="removedAt">Gets the index from which the item was removed.</param>
 public BeforeItemRemovedEventArgs(QSetItemBase item, int removedAt)
     : base(item)
 {
     _removedAt = removedAt;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Constructs object.
 /// </summary>
 /// <param name="item">Item which was renamed.</param>
 /// <param name="previousName">The previous name of the item.</param>
 public ItemRenamedEventArgs(QSetItemBase item, string previousName)
     : base(item)
 {
     _previousName = previousName;
 }
Exemplo n.º 12
0
		/// <summary>
		/// Constructs the object with the minum requirements.
		/// </summary>
		/// <param name="item">Item that was added or removed.</param>
		/// <param name="removedAt">Gets the index from which the item was removed.</param>
		public BeforeItemRemovedEventArgs(QSetItemBase item, int removedAt)
			: base(item)
		{
			_removedAt = removedAt;
		}
Exemplo n.º 13
0
		/// <summary>
		/// Constructs object.
		/// </summary>
		/// <param name="item">Item which was renamed.</param>
		/// <param name="previousName">The previous name of the item.</param>
		public ItemRenamedEventArgs(QSetItemBase item, string previousName)
			: base(item)
		{			
			_previousName = previousName;
		}
Exemplo n.º 14
0
		/// <summary>
		/// Returns the position where an item should be inserted in the queue.
		/// </summary>
		/// <param name="item">Item which requires inserting.</param>
		/// <returns>Position where the item should be inserted.</returns>
		private int GetInsertPosition(QSetItemBase item)
		{
			int insertPos = 0;
						
			if (base.Count == 1)
			{
				if (((QSetItemBase)base.BaseGet(0)).Name.CompareTo(item.Name) < 0)					
				{
					insertPos = 1;
				}
			}					
			else if (base.Count >= 1)
			{
				for (int checkPos = 0; checkPos <= base.Count - 1; checkPos ++)
				{					
					if (((QSetItemBase)base.BaseGet(checkPos)).Name.CompareTo(item.Name) == 0)
					{
						insertPos = checkPos;
						break;
					}
					else if ((((QSetItemBase)base.BaseGet(checkPos)).Name.CompareTo(item.Name) < 0) 
						&& (checkPos + 1 > base.Count - 1 || (((QSetItemBase)base.BaseGet(checkPos + 1)).Name.CompareTo(item.Name) > 0)))					
					{
						insertPos = checkPos + 1;					
						break;
					}
				}
			}
			
			return insertPos;
		}
Exemplo n.º 15
0
		/// <summary>
		/// Constructs the object a QSetItemBase object.
		/// </summary>
		/// <param name="queueSetItem">QSetItemBase object on which the tree node is based.</param>
		public QSetItemTreeNode(QSetItemBase queueSetItem) : base() 
		{			
			this.ImageIndex = (int)queueSetItem.Icon;
			this.SelectedImageIndex = (int)queueSetItem.Icon;
			this.Text = queueSetItem.Name;						
			
			_queueSetItem = queueSetItem;			
			QSetFolderItem folderItem = _queueSetItem as QSetFolderItem;
			if (folderItem != null)
			{	
				_afterItemAddedEventDelegate = new AfterItemAddedEvent(ChildItems_AfterItemAdded);
				_beforeItemRemovedEventDelegate = new BeforeItemRemovedEvent(ChildItems_BeforeItemRemoved);
				_itemRepositionedEventDelegate = new ItemRepositionedEvent(ChildItems_ItemRepositioned);

				folderItem.ChildItems.AfterItemAdded += _afterItemAddedEventDelegate;
				folderItem.ChildItems.BeforeItemRemoved += _beforeItemRemovedEventDelegate;
				folderItem.ChildItems.ItemRepositioned += _itemRepositionedEventDelegate;
			}			

			_queueSetItem.ItemRenamed += new ItemRenamedEvent(_queueSetItem_ItemRenamed);
		}		
Exemplo n.º 16
0
		/// <summary>
		/// Alphabetically inserts a new item into the collection.
		/// </summary>
		/// <param name="qSetItem">Item to insert.</param>
		/// <param name="insertedAt">Returns the index of where the item was inserted.</param>
		private void InsertItemOrdered(QSetItemBase qSetItem, out int insertedAt)
		{			
			//ascertain where the item should be inserted
			int insertPos = GetInsertPosition(qSetItem);			

			//insert the item at the desired position
			if (insertPos == base.Count)
				base.BaseAdd(qSetItem.Name, qSetItem);
			else
			{
				//we need to shunt all items at the insert pos and 
				//after up one space, so temporarily put them onto a stack
				Stack shuntItemsStack = new Stack();				
				int currentCount = base.Count;
				for (int counter = insertPos; counter <= currentCount - 1; counter ++)
				{
					shuntItemsStack.Push(base.BaseGet(base.Count - 1));
					base.BaseRemoveAt(base.Count - 1);
				}

				//insert the new item
				base.BaseAdd(qSetItem.Name, qSetItem);

				//put everything from the stack backinto the collection
				while (shuntItemsStack.Count > 0)
				{					
					QSetItemBase replaceItem = (QSetItemBase)shuntItemsStack.Pop();
					base.BaseAdd(replaceItem.Name, replaceItem);
				}
			}

			insertedAt = insertPos;
		}
Exemplo n.º 17
0
        /// <summary>
        /// Recursively creates all of the child items of a Q Set item.
        /// </summary>
        /// <param name="parentItem">Parent item.</param>
        /// <param name="parentNodeIterator">XPathNodeIterator positioned at the parent item. </param>
        private static void CreateChildItems(QSetFolderItem parentItem, XPathNodeIterator parentNodeIterator)
        {
            //iterate through all child items
            XPathNodeIterator childNodeIterator = parentNodeIterator.Current.Select("*");

            while (childNodeIterator.MoveNext())
            {
                //get the item details
                string itemName = childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Name, "");
                Guid   itemGuid = Guid.Empty;
                if (childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, "") != string.Empty)
                {
                    itemGuid = new Guid(childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.ItemAttributes.Guid, ""));
                }

                //create a new item of the required type, specifying the guid if available
                QSetItemBase newItem = null;
                if (childNodeIterator.Current.Name == QSetFolderItem.TypeName)
                {
                    //create folder
                    if (itemGuid == Guid.Empty)
                    {
                        newItem = new QSetFolderItem(itemName);
                    }
                    else
                    {
                        newItem = new QSetFolderItem(itemGuid, itemName);
                    }
                }
                else if (childNodeIterator.Current.Name == QSetMachineItem.TypeName)
                {
                    //create machine
                    if (itemGuid == Guid.Empty)
                    {
                        newItem = new QSetMachineItem(itemName);
                    }
                    else
                    {
                        newItem = new QSetMachineItem(itemGuid, itemName);
                    }
                }
                else if (childNodeIterator.Current.Name == QSetQueueItem.TypeName)
                {
                    //create queue
                    if (itemGuid == Guid.Empty)
                    {
                        newItem = new QSetQueueItem(itemName);
                    }
                    else
                    {
                        newItem = new QSetQueueItem(itemGuid, itemName);
                    }
                    if (childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.QueueElement.Attributes.MessageViewerXslt, "") != string.Empty)
                    {
                        ((QSetQueueItem)newItem).MessageViewerXslt = childNodeIterator.Current.GetAttribute(QSetXmlFileFormat.QueueElement.Attributes.MessageViewerXslt, "");
                    }
                }
                else if (childNodeIterator.Current.Name == QSetWebServiceItem.TypeName)
                {
                    //web service item
                    if (itemGuid == Guid.Empty)
                    {
                        newItem = new QSetWebServiceItem(itemName);
                    }
                    else
                    {
                        newItem = new QSetWebServiceItem(itemGuid, itemName);
                    }
                }

                //apply finaly settings and actions to new item
                if (newItem != null)
                {
                    //finish type specific setup
                    if (newItem is QSetFolderItem)
                    {
                        //create child items
                        CreateChildItems((QSetFolderItem)newItem, childNodeIterator);
                    }

                    //final setup common to all item types
                    parentItem.ChildItems.Add(newItem);
                    newItem.IsDirty = false;
                }
            }
        }
Exemplo n.º 18
0
		/// <summary>
		/// Constructs the object with the minum requirements.
		/// </summary>
		/// <param name="item">Item that was added.</param>
		/// <param name="insertedAt">Gets the index at which the item as added.</param>
		public AfterItemAddedEventArgs(QSetItemBase item, int insertedAt)
			: base(item)
		{			
			_insertedAt = insertedAt;
		}
Exemplo n.º 19
0
		/// <summary>
		/// Checks to see if an item is currently open.
		/// </summary>
		/// <param name="item">Item to search for.</param>
		/// <returns>true if item is open, else false.</returns>
		public bool IsItemOpen(QSetItemBase item)
		{
			return _primaryControls.MessageBrowserCollection.Exists(item.ID.ToString()) || _primaryControls.WebServiceClientControlCollection.Exists(item.ID.ToString());
		}
Exemplo n.º 20
0
		/// <summary>
		/// Constructs the object with the minum requirements.
		/// </summary>
		/// <param name="item">Item that was repositioned.</param>
		/// <param name="previousPosition">The previous index of the item in the collection.</param>
		/// <param name="newPosition">The new index of the item in the collection.</param>
		public ItemRepositionedEventArgs(QSetItemBase item, int previousPosition, int newPosition)
			: base(item)							
		{
			_previousPosition = previousPosition;
			_newPosition = newPosition;
		}
Exemplo n.º 21
0
		/// <summary>
		/// Brings a document to the front.
		/// </summary>
		/// <param name="item">Item which we want to activate.</param>
		public void BringDocumentToFront(QSetItemBase item)
		{
			DockControl dockControl = FindDocument(item);
			if (dockControl != null)
				dockControl.Activate();
		}
Exemplo n.º 22
0
		/// <summary>
		/// COnstructs event arguments class.
		/// </summary>
		/// <param name="item">Item which has become dirty.</param>
		public ItemDirtiedEventArgs(QSetItemBase item)
			: base(item) {}
Exemplo n.º 23
0
		/// <summary>
		/// Finds the docuemtn relating to a particular item.
		/// </summary>
		/// <param name="item">Item for which document we are looking for.</param>
		/// <returns>DockControl if found, else null.</returns>
		public DockControl FindDocument(QSetItemBase item)
		{
			DockControl result = null;

			foreach(DockControl dockControl in _primaryControls.DocumentContainer.Manager.Documents)				
			{
				IQSetItemControl itemControl = dockControl.Controls[0] as IQSetItemControl;
				if (itemControl != null && itemControl.QSetItem == item)
				{					
					result = dockControl;					
					break;
				}
			}

			return result;
		}
Exemplo n.º 24
0
 /// <summary>
 /// Constructs the object with the minum requirements.
 /// </summary>
 /// <param name="item">Item that was added.</param>
 /// <param name="insertedAt">Gets the index at which the item as added.</param>
 public AfterItemAddedEventArgs(QSetItemBase item, int insertedAt)
     : base(item)
 {
     _insertedAt = insertedAt;
 }
Exemplo n.º 25
0
		/// <summary>
		/// Constructs object.
		/// </summary>
		/// <param name="item">Item associated with the event.</param>
		protected QSetControlItemAffectedEventArgs(QSetItemBase item)
		{
			if (item == null) throw new ArgumentNullException("item");

			_item = item;
		}
Exemplo n.º 26
0
 /// <summary>
 /// Constructs the object with the minum requirements.
 /// </summary>
 /// <param name="item">Item that was repositioned.</param>
 /// <param name="previousPosition">The previous index of the item in the collection.</param>
 /// <param name="newPosition">The new index of the item in the collection.</param>
 public ItemRepositionedEventArgs(QSetItemBase item, int previousPosition, int newPosition)
     : base(item)
 {
     _previousPosition = previousPosition;
     _newPosition      = newPosition;
 }
Exemplo n.º 27
0
		/// <summary>
		/// Constructs object.
		/// </summary>
		/// <param name="item">Item which was double clicked.</param>
		public QSetItemDoubleClickEventArgs(QSetItemBase item) 
			: base (item) {}
Exemplo n.º 28
0
 /// <summary>
 /// COnstructs event arguments class.
 /// </summary>
 /// <param name="item">Item which has become dirty.</param>
 public ItemDirtiedEventArgs(QSetItemBase item)
     : base(item)
 {
 }
Exemplo n.º 29
0
		/// <summary>
		/// Constructs object.
		/// </summary>
		/// <param name="item">Q Set which was deactivated.</param>
		public QSetDeactivatedEventArgs(QSetItemBase item) 
			: base (item) {}
Exemplo n.º 30
0
		/// <summary>
		/// Checks to see if an item is an ancestor of another.
		/// </summary>
		/// <param name="ancestor">Item to be checked whether is an ancestor.</param>
		/// <param name="ancestorOf">Item to be checked against.</param>
		/// <returns>True if the first item is an ancestor of the second, else false.</returns>
		private bool IsAncestorOf(QSetItemBase ancestor, QSetItemBase ancestorOf)
		{
			bool result = false;

			QSetItemBase check = ancestorOf;

			while (check.ParentItem != null)
			{
				if (check.ParentItem == ancestor)
				{
					result = true;
					break;
				}

				check = check.ParentItem;
			}

			return result;
		}
Exemplo n.º 31
0
		/// <summary>
		/// Constructs the event arguments class.
		/// </summary>
		/// <param name="process">Process which can be visualized.</param>
		/// <param name="item">Item associated with the event.</param>
		public VisualizableProcessItemAffectedEventArgs(VisualizableProcess process, QSetItemBase item)
			: base(process)
		{
			_item = item;
		}
Exemplo n.º 32
0
			/// <summary>
			/// Given a QSetItemBase, marks the corresponding QueueItemListViewItemPair for deletion,
			/// and repeats for any children of the QSetItemBase object.
			/// </summary>
			/// <param name="item">QSetItemBase to delete.</param>
			private void RecursivelyMarkListItemsForDeletion(QSetItemBase item)
			{
				//if we have a queue, remove it
				QSetQueueItem queueItem = item as QSetQueueItem;
				if (queueItem != null)
				{
					if (_itemPairHashTable.ContainsKey(queueItem.ID))
					{						
						_deleteItemPairQueue.Enqueue(_itemPairHashTable[queueItem.ID]);
					}
				}
				
				//if we have a folder, check children
				QSetFolderItem folderItem = item as QSetFolderItem;
				if (folderItem != null)
					foreach (QSetItemBase childItem in folderItem.ChildItems)
						RecursivelyMarkListItemsForDeletion(childItem);

			}
Exemplo n.º 33
0
		/// <summary>
		/// Adds a QSetItemBase object to the collection.
		/// </summary>
		/// <param name="qSetItem">QSetItemBase object to add.</param>
		/// <exception cref="System.ArgumentNullException">Thrown if any arguments are set to null.</exception>
		public void Add(QSetItemBase qSetItem)
		{
			if (qSetItem == null) 
				throw new ArgumentNullException("QSetItem");
			else if (qSetItem is QSetModel) 
				throw new ArgumentOutOfRangeException("queueSetItem", "QSet cannot belong to a collection.");
			else if (base.BaseGet(qSetItem.Name) != null)
				throw new ArgumentOutOfRangeException("queueSetItem", "An item with the supplied name already exists in the collection.");
			
			if (OwnerItem != null)
				qSetItem.ParentItem = OwnerItem;

			int insertedAt;
			InsertItemOrdered(qSetItem, out insertedAt);			
			
			qSetItem.ItemRenamed += new ItemRenamedEvent(qSetItem_ItemRenamed);

			OnAfterItemAdded(new AfterItemAddedEventArgs(qSetItem, insertedAt));
		}