예제 #1
0
 /// <summary>
 /// Gets called when an item is draged over the treeview.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">More information about the event.</param>
 private void trvTree_DragOver(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(TreeNodeAdv[])) && trvTree.DropPosition.Node != null)
     {
         TreeNodeAdv[] nodes  = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
         TreeNodeAdv   parent = trvTree.DropPosition.Node;
         if (nodes != null && nodes.Length == 1 && parent != null && Editable)
         {
             ObjectField draggedField = nodes[0].Tag as ObjectField;
             ObjectField destField    = parent.Tag as ObjectField;
             if (draggedField != null && destField != null && trvTree.DropPosition.Position != NodePosition.Inside)
             {
                 bool ownNode = trvTree.FindNodeByTag(draggedField) != null;
                 if (ownNode && draggedField.Parent == destField.Parent)
                 {
                     e.Effect = DragDropEffects.Move;
                     return;
                 }
                 if (!ownNode)
                 {
                     ObjectFieldCollection parentDraggedCollection = draggedField.Parent as ObjectFieldCollection;
                     ObjectFieldCollection parentDestCollection    = destField.Parent as ObjectFieldCollection;
                     if (parentDraggedCollection != null && parentDestCollection != null && parentDraggedCollection.ItemType == parentDestCollection.ItemType)
                     {
                         e.Effect = DragDropEffects.Copy;
                         return;
                     }
                 }
             }
             e.Effect = DragDropEffects.None;
         }
     }
 }
        private void expectedObjectTree_Expanded(object sender, ObjectFieldEventArgs e)
        {
            ObjectField otherField = currentObjectTree.GetEquivalentField(e.ObjectField);

            if (toolStripButtonSynchronizeTrees.Checked)
            {
                // Synchronize with the other tree view
                currentObjectTree.Expand(otherField);
            }
            bool openOther = true;

            if (otherField != null)
            {
                ObjectFieldCollection otherCollection = otherField as ObjectFieldCollection;
                if (otherCollection != null && otherCollection.Count > 1)
                {
                    openOther = false;
                }
            }
            ObjectFieldCollection collection = e.ObjectField as ObjectFieldCollection;

            if (collection != null && collection.Count == 1 && (openOther || !toolStripButtonSynchronizeTrees.Checked))
            {
                expectedObjectTree.Expand(collection.Childs.First());
            }
        }
예제 #3
0
        // ========================================================================
        // Properties

        #region === Properties

        #endregion

        // ========================================================================
        // Event-Handling

        #region === Event-Handling

        private void objectTree_Expanded(object sender, ObjectTree.ObjectFieldEventArgs e)
        {
            ObjectFieldCollection collection = e.ObjectField as ObjectFieldCollection;

            if (collection != null && collection.Count == 1)
            {
                objectTree.Expand(collection.Childs.First());
            }
        }
예제 #4
0
        /// <summary>
        /// Gets called after a new item was added to a collection.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="args">Informations about the event.</param>
        private void field_ItemAdded(object sender, ObjectFieldEventArgs args)
        {
            ObjectFieldCollection collection = args.ObjectField.Parent as ObjectFieldCollection;

            if (collection != null)
            {
                Dirty = true;
                TreePath        parentPath = GetPath(collection);
                ObjectFieldList listField  = collection as ObjectFieldList;
                int             index      = collection.Count;
                if (listField != null)
                {
                    index = listField.Items.IndexOf(args.ObjectField);
                }
                OnNodesInserted(new TreeModelEventArgs(parentPath, new[] { index }, new object[] { args.ObjectField }));
                treeView.FindNode(parentPath).Expand();
                OnItemAdded(args);
            }
        }