/// <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); }
public IDockContent FindOpenDocumentForItem(QSetItemBase item) { foreach (IDockContent dockControl in _dockPanel.Documents) { var messageBrowserForm = dockControl as MessageBrowserForm; var webServiceForm = dockControl as WebServiceClientForm; if (messageBrowserForm != null) { if (messageBrowserForm.MessageBrowser.QSetItem == item) { return(dockControl); } } else if (webServiceForm != null) { if (webServiceForm.WebServiceClientControl.QSetItem == item) { return(dockControl); } } } return(null); }
/// <summary> /// Starts drag and drop. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _qsetTreeView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) { QSetItemBase item = ((QSetItemTreeNode)e.Item).QSetItem; if (!(item.ParentItem is QSetMachineItem) && !(item is QSetModel)) { _qsetTreeView.DoDragDrop(((QSetItemTreeNode)e.Item).QSetItem, DragDropEffects.Move); } }
/// <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; }
/// <summary> /// Brings a document to the front. /// </summary> /// <param name="item">Item which we want to activate.</param> public void BringDocumentToFront(QSetItemBase item) { IDockContent dockControl = FindDocument(item); if (dockControl != null) { dockControl.DockHandler.Activate(); } }
/// <summary> /// Searches for a node which contains a particular QSetItemBase object. /// </summary> /// <param name="item">QSetItemBase to search for.</param> /// <returns>The node hosting the item if found, else null.</returns> private QSetItemTreeNode FindNode(QSetItemBase item) { QSetItemTreeNode result = null; foreach (TreeNode node in _queueSetTreeView.Nodes) { if (((QSetItemTreeNode)node).QSetItem == item) { result = (QSetItemTreeNode)node; break; } } return(result); }
/// <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.OpenIcon; this.Text = queueSetItem.Name; _queueSetItem = queueSetItem; QSetFolderItem folderItem = _queueSetItem as QSetFolderItem; if (folderItem != null) { folderItem.ChildItems.ItemAdded += new Mulholland.Applications.QSet.QSetItemCollection.ItemAddedEvent(ChildItems_ItemAdded); folderItem.ChildItems.ItemRemoved += new Mulholland.Applications.QSet.QSetItemCollection.ItemRemovedEvent(ChildItems_ItemRemoved); } }
/// <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); }
/// <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); }
/// <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); } } }
/// <summary> /// Handles the drag enter/over to provide visual feedback to the user. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _qsetTreeView_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { //get the item being dragged over QSetItemBase dragOverItem = _qsetTreeView.GetNodeAt(_qsetTreeView.PointToClient(new Point(e.X, e.Y))) == null ? null : ((QSetItemTreeNode)_qsetTreeView.GetNodeAt(_qsetTreeView.PointToClient(new Point(e.X, e.Y)))).QSetItem; e.Effect = DragDropEffects.None; //is this a Q Set item being dragged QSetItemBase qSetDragItem = QSetItemBase.GetFromDataObject(e.Data); if (qSetDragItem != null) { //handle a Q Set item drag if (qSetDragItem != null && dragOverItem != null && dragOverItem is QSetFolderItem && !(IsAncestorOf(qSetDragItem, dragOverItem)) && qSetDragItem.ParentItem != dragOverItem && !(dragOverItem is QSetMachineItem) && qSetDragItem != dragOverItem) { e.Effect = DragDropEffects.Move; } } else { //is this a message(s) drag? MessageDragContainer messageDragContainer = (MessageDragContainer)e.Data.GetData(typeof(MessageDragContainer)); if (messageDragContainer != null) { if (dragOverItem is QSetQueueItem) { e.Effect = DragDropEffects.Move; } } } }
/// <summary> /// Handles the drag drop. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _qsetTreeView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //get the item which was dragged on to QSetItemBase dragOverItem = _qsetTreeView.GetNodeAt(_qsetTreeView.PointToClient(new Point(e.X, e.Y))) == null ? null : ((QSetItemTreeNode)_qsetTreeView.GetNodeAt(_qsetTreeView.PointToClient(new Point(e.X, e.Y)))).QSetItem; //was a Q Set item dragged? QSetItemBase droppedItem = QSetItemBase.GetFromDataObject(e.Data); if (droppedItem != null) { //handle Q Set item drag QSetFolderItem dragOverFolder = dragOverItem as QSetFolderItem; if (dragOverFolder != null && droppedItem.ParentItem != dragOverFolder) { if (!dragOverFolder.ChildItems.Exists(droppedItem.Name)) { ((QSetFolderItem)droppedItem.ParentItem).ChildItems.Remove(droppedItem.Name); dragOverFolder.ChildItems.Add(droppedItem); } else { MessageBox.Show(Locale.UserMessages.CannotAddItemAsAlreadyExists, System.Windows.Forms.Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { //is this a message(s) drag? MessageDragContainer messageDragContainer = (MessageDragContainer)e.Data.GetData(typeof(MessageDragContainer)); if (messageDragContainer != null) { OnMessagesDragDrop(new MessagesDragDropEventArgs(messageDragContainer.OwnerQueueItem, (QSetQueueItem)dragOverItem, messageDragContainer.Messages)); } } }
/// <summary> /// Constructs object. /// </summary> /// <param name="item">Q Set which was deactivated.</param> public QSetDeactivatedEventArgs(QSetItemBase item) : base(item) { }
public void SetPropertyGridObject(QSetItemBase item) { _propertyGridForm.PropertyGrid.SelectedObject = item; }
/// <summary> /// Searches for a node which contains a particular QSetItemBase object. /// </summary> /// <param name="item">QSetItemBase to search for.</param> /// <returns>The node hosting the item if found, else null.</returns> private QSetItemTreeNode FindNode(QSetItemBase item) { QSetItemTreeNode result = null; foreach(TreeNode node in _queueSetTreeView.Nodes) { if (((QSetItemTreeNode)node).QSetItem == item) { result = (QSetItemTreeNode)node; break; } } return result; }
/// <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())); }
/// <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 IDockContent FindDocument(QSetItemBase item) { return(_primaryControls.FindOpenDocumentForItem(item)); }
/// <summary> /// Constructs object. /// </summary> /// <param name="item">Item which was double clicked.</param> public QSetItemDoubleClickEventArgs(QSetItemBase item) : base(item) { }
/// <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; }