protected override void OnModelCanDrop(ModelDropEventArgs args)
        {
            base.OnModelCanDrop(args);

            if (args.Handled)
            {
                return;
            }

            args.Effect = DragDropEffects.Move;

            // Don't allow drops from other list, if that's what's configured
            if (!this.AcceptExternal && args.SourceListView != this.ListView)
            {
                args.Effect             = DragDropEffects.None;
                args.DropTargetLocation = DropTargetLocation.None;
                args.InfoMessage        = "This list doesn't accept drops from other lists";
            }

            // If we are rearranging a list, don't allow drops on the background
            if (args.DropTargetLocation == DropTargetLocation.Background && args.SourceListView == this.ListView)
            {
                args.Effect             = DragDropEffects.None;
                args.DropTargetLocation = DropTargetLocation.None;
            }
        }
 protected virtual void OnModelCanDrop(ModelDropEventArgs args)
 {
     if (this.ModelCanDrop != null)
     {
         this.ModelCanDrop(this, args);
     }
 }
        /// <summary>
        /// Do the work of processing the dropped items
        /// </summary>
        /// <param name="args"></param>
        public virtual void RearrangeModels(ModelDropEventArgs args)
        {
            switch (args.DropTargetLocation)
            {
            case DropTargetLocation.AboveItem:
                this.ListView.MoveObjects(args.DropTargetIndex, args.SourceModels);
                break;

            case DropTargetLocation.BelowItem:
                this.ListView.MoveObjects(args.DropTargetIndex + 1, args.SourceModels);
                break;

            case DropTargetLocation.Background:
                this.ListView.AddObjects(args.SourceModels);
                break;

            default:
                return;
            }

            if (args.SourceListView != this.ListView)
            {
                args.SourceListView.RemoveObjects(args.SourceModels);
            }
        }
        public virtual void RearrangeModels(ModelDropEventArgs args)
        {
            DropTargetLocation dropTargetLocation = args.DropTargetLocation;

            if (dropTargetLocation == DropTargetLocation.Background)
            {
                this.ListView.AddObjects(args.SourceModels);
            }
            else if (dropTargetLocation != DropTargetLocation.AboveItem)
            {
                if (dropTargetLocation != DropTargetLocation.BelowItem)
                {
                    return;
                }
                this.ListView.MoveObjects(args.DropTargetIndex + 1, args.SourceModels);
            }
            else
            {
                this.ListView.MoveObjects(args.DropTargetIndex, args.SourceModels);
            }
            if (args.SourceListView != this.ListView)
            {
                args.SourceListView.RemoveObjects(args.SourceModels);
            }
        }
 protected virtual void OnModelDropped(ModelDropEventArgs args)
 {
     if (this.ModelDropped != null)
     {
         this.ModelDropped(this, args);
     }
 }
        private void objectListView_ModelDropped(object sender, ModelDropEventArgs e)
        {
            var copy = new List<Combatant>(e.SourceModels.OfType<Combatant>());
            if (copy.Count == 0) {
                return;
            }

            this.dirty = true;
            this.Text = String.Concat("* ", this.Text);

            //var handles = this.encounter.Handles;
            //var combatants = this.encounter.Combatants;
            //foreach (var combatant in copy) {
            //    int count;
            //    if (!handles.TryGetValue(combatant.Handle, out count)) {
            //        combatants.Add(combatant.Handle, combatant);
            //    }
            //    else if (combatant is Character) {
            //        continue; // only one copy of a character allowed
            //    }
            //    else {
            //        this.encounter.IncrementCombatant(combatant.Handle);
            //    }
            //}
        }
Beispiel #7
0
        /// <summary>
        /// A drag has entered this control.
        /// </summary>
        /// <remarks>Implementators should set args.Effect to the appropriate DragDropEffects.</remarks>
        /// <param name="args"></param>
        public override void Enter(DragEventArgs args)
        {
            //System.Diagnostics.Debug.WriteLine("Enter");

            /*
             * When FullRowSelect is true, we have two problems:
             * 1) GetItemRect(ItemOnly) returns the whole row rather than just the icon/text, which messes
             *    up our calculation of the drop rectangle.
             * 2) during the drag, the Timer events will not fire! This is the major problem, since without
             *    those events we can't autoscroll.
             *
             * The first problem we can solve through coding, but the second is more difficult.
             * We avoid both problems by turning off FullRowSelect during the drop operation.
             */
            originalFullRowSelect  = ListView.FullRowSelect;
            ListView.FullRowSelect = false;

            // Setup our drop event args block
            dropEventArgs            = new ModelDropEventArgs();
            dropEventArgs.DropSink   = this;
            dropEventArgs.ListView   = ListView;
            dropEventArgs.DataObject = args.Data;
            var olvData = args.Data as OLVDataObject;

            if (olvData != null)
            {
                dropEventArgs.SourceListView = olvData.ListView;
                dropEventArgs.SourceModels   = olvData.ModelObjects;
            }

            Over(args);
        }
 protected override void OnModelDropped(ModelDropEventArgs args)
 {
     base.OnModelDropped(args);
     if (!args.Handled)
     {
         this.RearrangeModels(args);
     }
 }
 public void HandleEvent_ModelDropped(object sender, ModelDropEventArgs e)
 {
     var dropTarget = e.TargetModel as ConnectionInfo;
     if (dropTarget == null) return;
     var dropSource = (ConnectionInfo)e.SourceModels[0];
     DropModel(dropSource, dropTarget, e.DropTargetLocation);
     e.Handled = true;
     Runtime.SaveConnectionsAsync();
 }
        private void objectListView_ModelCanDrop(object sender, ModelDropEventArgs e)
        {
            if (!e.SourceModels.OfType<Combatant>().Any()) {
                e.Effect = DragDropEffects.None;
                return;
            }

            e.Effect = DragDropEffects.Copy;
        }
Beispiel #11
0
        private void BonesTreeViews_ModelDropped(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
        {
            void UnlinkBone(BoneLinkNode node)
            {
                node.ParentID = string.Empty;
                var parentBone = BoneNodes.FirstOrDefault(x => x.ChildBones.Contains(node));

                if (parentBone != null)
                {
                    parentBone.ChildBones.Remove(node);
                    HierarchyTreeView.RefreshObject(parentBone);
                }
            }

            var draggedBones = e.SourceModels.OfType <BoneLinkNode>().ToList();

            if (sender == UnassignedTreeView)
            {
                var allBones = draggedBones.SelectMany(x => x.GetHierarchy(true)).Distinct().ToList();

                foreach (BoneLinkNode node in allBones)
                {
                    //node.ParentID = string.Empty;
                    node.UnlinkChildrens();
                }

                foreach (BoneLinkNode node in draggedBones)
                {
                    UnlinkBone(node);
                }

                UnassignedTreeView.AddObjects(allBones);
            }
            else if (sender == HierarchyTreeView)
            {
                if (RootBone == null)
                {
                    RootBone = e.SourceModels[0] as BoneLinkNode;
                    HierarchyTreeView.AddObject(RootBone);
                }
                else if (e.TargetModel is BoneLinkNode targetBone)
                {
                    foreach (BoneLinkNode node in draggedBones)
                    {
                        if (string.IsNullOrEmpty(node.ParentID))
                        {
                            UnassignedTreeView.RemoveObject(node);
                        }

                        UnlinkBone(node);
                        targetBone.ChildBones.Add(node);
                        node.ParentID = targetBone.ID;
                    }
                    HierarchyTreeView.RefreshObject(targetBone);
                }
            }
        }
        public static Klasse GetDragTargetKlasse(ModelDropEventArgs e)
        {
            Klasse targetKlasse = e.TargetModel as Klasse;
              if (targetKlasse == null)
              {
            Schueler targetSchueler = e.TargetModel as Schueler;
            if (targetSchueler != null)
            {
              targetKlasse = targetSchueler.getKlasse;
            }
              }

              return targetKlasse;
        }
        public void HandleEvent_ModelCanDrop(object sender, ModelDropEventArgs e)
        {
            _enableFeedback = true;
            _currentFeedbackColor = DropDeniedFeedbackColor;
            _infoMessage = null;
            var dropSource = e.SourceModels.Cast<ConnectionInfo>().First();
            var dropTarget = e.TargetModel as ConnectionInfo;

            e.Effect = CanModelDrop(dropSource, dropTarget, e.DropTargetLocation);
            e.InfoMessage = _infoMessage;
            e.DropSink.EnableFeedback = _enableFeedback;
            e.DropSink.FeedbackColor = _currentFeedbackColor;
            e.Handled = true;
        }
        private void navigatorListView_ModelCanDrop(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
        {
            e.Effect = DragDropEffects.None;
            object rowObjectUnderMouse = navigatorListView.OlvHitTest(e.MouseLocation.X, e.MouseLocation.Y).RowObject;

            if (e.SourceModels[0] is NavigatorCollection collection)
            {
                if (!collection.Permanent)
                {
                    if (rowObjectUnderMouse is NavigatorGroup group)
                    {
                        navigatorListView.SelectedObject = group;
                        e.Effect      = DragDropEffects.Copy;
                        e.InfoMessage = $"Move {collection.Name} to {group.Name} group";
                    }
                    else
                    {
                        navigatorListView.SelectedObject = null;
                        e.Effect = DragDropEffects.None;
                    }
                }
            }
            else if (!(e.SourceModels[0] is InventoryTotalsItem) && rowObjectUnderMouse is NavigatorCollection navigatorCollection)
            {
                string DocumentName = navigatorCollection.CardCollection.CollectionName;
                e.Effect = DragDropEffects.Move;
                if (e.SourceModels[0] is OLVCardItem)
                {
                    e.InfoMessage = $"Add {e.SourceModels.Count} card{(e.SourceModels.Count == 1 ? "" : "s")} to {DocumentName}";
                }
                else if (e.SourceModels[0] is OLVSetItem setItem)
                {
                    e.InfoMessage = $"Add set [{setItem.Name}] to {DocumentName}";
                }
                else if (e.SourceModels[0] is OLVRarityItem rarityItem)
                {
                    e.InfoMessage = $"Add {rarityItem.Rarity}s from [{(rarityItem.Parent as OLVSetItem).Name}] to {DocumentName}";
                }
                else if (e.SourceModels[0] is FullInventoryCard fullInventoryCard)
                {
                    var parentForm = Globals.Forms.OpenCollectionForms.FirstOrDefault(x => x.cardListView == e.SourceListView);
                    if (parentForm != null && parentForm.Collection.Id != navigatorCollection.Id)
                    {
                        e.InfoMessage = $"Move {e.SourceModels.Count} card{(e.SourceModels.Count == 1 ? "" : "s")} to {DocumentName}";
                    }
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// Trigger ModelCanDrop
        /// </summary>
        /// <param name="args"></param>
        protected virtual void OnModelCanDrop(ModelDropEventArgs args)
        {
            // Don't allow drops from other list, if that's what's configured
            if (!AcceptExternal && args.SourceListView != null && args.SourceListView != ListView)
            {
                args.Effect             = DragDropEffects.None;
                args.DropTargetLocation = DropTargetLocation.None;
                args.InfoMessage        = "This list doesn't accept drops from other lists";
                return;
            }

            if (ModelCanDrop != null)
            {
                ModelCanDrop(this, args);
            }
        }
        public override void Enter(DragEventArgs args)
        {
            this.originalFullRowSelect    = this.ListView.FullRowSelect;
            this.ListView.FullRowSelect   = false;
            this.dropEventArgs            = new ModelDropEventArgs();
            this.dropEventArgs.DropSink   = this;
            this.dropEventArgs.ListView   = this.ListView;
            this.dropEventArgs.DataObject = args.Data;
            OLVDataObject data = args.Data as OLVDataObject;

            if (data != null)
            {
                this.dropEventArgs.SourceListView = data.ListView;
                this.dropEventArgs.SourceModels   = data.ModelObjects;
            }
            this.Over(args);
        }
Beispiel #17
0
        private void BonesTreeViews_ModelCanDrop(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
        {
            var draggedBones = e.SourceModels.OfType <BoneLinkNode>().ToList();
            var allBones     = draggedBones.SelectMany(x => x.GetHierarchy(true)).Distinct().ToList();
            var targetBone   = e.TargetModel as BoneLinkNode;

            if (e.SourceListView == HierarchyTreeView &&
                sender == HierarchyTreeView && RootBone != null)
            {
                if (e.SourceModels.Contains(RootBone))
                {
                    e.Effect = DragDropEffects.None;
                    return;
                }
            }

            if (e.SourceListView == UnassignedTreeView && sender == UnassignedTreeView)
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            if (targetBone != null && allBones.Contains(targetBone))
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            if (e.DropTargetLocation == DropTargetLocation.Item)
            {
                e.Effect = DragDropEffects.Move;
            }
            else if (e.DropTargetLocation == DropTargetLocation.Background ||
                     e.DropTargetLocation == DropTargetLocation.None)
            {
                if (sender == UnassignedTreeView)
                {
                    e.Effect = DragDropEffects.Move;
                }
                else if (RootBone == null && e.SourceModels.Count == 1)
                {
                    e.Effect = DragDropEffects.Move;
                }
            }
        }
Beispiel #18
0
        private void HandleModelDropped(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
        {
            e.Handled = true;
            switch (e.DropTargetLocation)
            {
            case DropTargetLocation.AboveItem:
                MoveObjectsToSibling(
                    e.ListView as TreeListView,
                    e.SourceListView as TreeListView,
                    (ModelWithChildren)e.TargetModel,
                    e.SourceModels,
                    0);
                break;

            case DropTargetLocation.BelowItem:
                MoveObjectsToSibling(
                    e.ListView as TreeListView,
                    e.SourceListView as TreeListView,
                    (ModelWithChildren)e.TargetModel,
                    e.SourceModels,
                    1);
                break;

            case DropTargetLocation.Background:
                MoveObjectsToRoots(
                    e.ListView as TreeListView,
                    e.SourceListView as TreeListView,
                    e.SourceModels);
                break;

            case DropTargetLocation.Item:
                MoveObjectsToChildren(
                    e.ListView as TreeListView,
                    e.SourceListView as TreeListView,
                    (ModelWithChildren)e.TargetModel,
                    e.SourceModels);
                break;

            default:
                return;
            }

            e.RefreshObjects();
        }
 protected override void OnModelCanDrop(ModelDropEventArgs args)
 {
     base.OnModelCanDrop(args);
     if (!args.Handled)
     {
         args.Effect = DragDropEffects.Move;
         if (!(this.AcceptExternal || (args.SourceListView == this.ListView)))
         {
             args.Effect             = DragDropEffects.None;
             args.DropTargetLocation = DropTargetLocation.None;
             args.InfoMessage        = "This list doesn't accept drops from other lists";
         }
         if ((args.DropTargetLocation == DropTargetLocation.Background) && (args.SourceListView == this.ListView))
         {
             args.Effect             = DragDropEffects.None;
             args.DropTargetLocation = DropTargetLocation.None;
         }
     }
 }
Beispiel #20
0
        private void olvSelectedDescriptionColumns_ModelCanDrop(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
        {
            if (e.SourceModels.Count == 1)
            {
                if (e.SourceModels[0] is ColumnInfo)
                {
                    var c = e.SourceModels[0] as ColumnInfo;

                    //it's already in it
                    if (olvSelectedDescriptionColumns.IndexOf(c) != -1)
                    {
                        e.InfoMessage = "ColumnInfo is already selected as a Description";
                        return;
                    }

                    e.Effect = DragDropEffects.Copy;
                }
            }
        }
        private void navigatorListView_ModelDropped(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
        {
            object rowObjectUnderMouse = navigatorListView.OlvHitTest(e.MouseLocation.X, e.MouseLocation.Y).RowObject;

            if (e.SourceModels[0] is NavigatorCollection collection)
            {
                if (!collection.Permanent && rowObjectUnderMouse is NavigatorGroup group)
                {
                    using (var context = new MyDbContext())
                    {
                        try
                        {
                            collection.CardCollection.GroupId = group.Id;
                            if (collection.CardCollection.GroupName == "Wish Lists" || group.Name == "Wish Lists")
                            {
                                collection.CardCollection.Virtual = group.Virtual;
                            }
                            context.Update(collection.CardCollection);
                            context.SaveChanges();
                            collection.RemoveFromParent();
                            group.AddCollection(collection);
                            navigatorListView.RebuildAll(true);
                        }
                        catch (Exception ex)
                        {
                            DebugOutput.WriteLine(ex.ToString());
                            context.Entry(collection.CardCollection).Reload();
                        }
                    }
                }
            }
            else if (rowObjectUnderMouse is NavigatorCollection navigatorCollection)
            {
                OnCardsDropped(new CardsDroppedEventArgs
                {
                    Items            = e.SourceModels as ArrayList,
                    SourceForm       = Globals.Forms.OpenCollectionForms.FirstOrDefault(x => x.cardListView == e.SourceListView),
                    TargetCollection = navigatorCollection.CardCollection
                });
            }
        }
Beispiel #22
0
        private void olvSelected_ModelCanDrop(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
        {
            e.Effect = DragDropEffects.None;

            //dragging within our own control
            if (e.SourceListView == olvSelected)
            {
                //only allow drag of one object
                if (e.SourceModels == null || e.SourceModels.Count != 1)
                {
                    return;
                }

                e.Effect = DragDropEffects.Move;
            }

            //allow dragging multiple from the left hand side though
            if (e.SourceListView == olvAvailable)
            {
                e.Effect = DragDropEffects.Move;
            }
        }
Beispiel #23
0
 private void HandleModelCanDrop(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
 {
     e.Handled = true;
     e.Effect  = DragDropEffects.None;
     if (e.SourceModels.Contains(e.TargetModel))
     {
         e.InfoMessage = "Cannot drop on self";
     }
     else
     {
         IEnumerable <ModelWithChildren> sourceModels = e.SourceModels.Cast <ModelWithChildren>();
         if (e.DropTargetLocation == DropTargetLocation.Background)
         {
             if (e.SourceListView == e.ListView && sourceModels.All(x => x.Parent == null))
             {
                 e.InfoMessage = "Dragged objects are already roots";
             }
             else
             {
                 e.Effect      = DragDropEffects.Move;
                 e.InfoMessage = "Drop on background to promote to roots";
             }
         }
         else
         {
             ModelWithChildren target = (ModelWithChildren)e.TargetModel;
             if (sourceModels.Any(x => target.IsAncestor(x)))
             {
                 e.InfoMessage = "Cannot drop on descendant (think of the temporal paradoxes!)";
             }
             else
             {
                 e.Effect = DragDropEffects.Move;
             }
         }
     }
 }
        public void treeListView1_ModelCanDrop(object sender, ModelDropEventArgs e)
        {
            e.Handled = true;
              e.Effect = DragDropEffects.None;

              Klasse targetKlasse = GetDragTargetKlasse(e);

              if (targetKlasse == null)
              {
            e.InfoMessage = "Ziel konnte nicht erkannt werden.";
            return;
              }

              Schueler derSchueler = GetDraggedSchueler(e.SourceModels);
              if (derSchueler == null)
              {
            e.InfoMessage = "Nur Schülerzeilen können in eine andere Klasse verschoben werden.";
            return;
              }
              else
              {
            e.Effect = DragDropEffects.Move;
              }
        }
Beispiel #25
0
 private void dropSink_ModelDropped(object sender, ModelDropEventArgs e)
 {
     OnModelDropped(e);
 }
Beispiel #26
0
            protected override void OnModelCanDrop(ModelDropEventArgs args)
            {
                base.OnModelCanDrop(args);

                if (args.Handled)
                    return;

                args.Effect = DragDropEffects.Move;

                if (args.SourceListView != this.ListView)
                {
                    args.Effect = DragDropEffects.None;
                    args.DropTargetLocation = DropTargetLocation.None;
                    args.InfoMessage = "Cannot drop here.";
                }

                // If we are rearranging a list, don't allow drops on the background
                if (args.DropTargetLocation == DropTargetLocation.Background && args.SourceListView == this.ListView)
                {
                    args.Effect = DragDropEffects.None;
                    args.DropTargetLocation = DropTargetLocation.None;
                }
            }
Beispiel #27
0
 protected override void OnModelDropped(ModelDropEventArgs args)
 {
     base.OnModelDropped(args);
 }
Beispiel #28
0
 protected override void OnModelDropped(ModelDropEventArgs args)
 {
     base.OnModelDropped(args);
     if (!args.Handled)
     {
         _form.HostModelDropped(args);
     }
     args.Handled = true;
 }
 private void filterTree_ModelDropped(object sender, ModelDropEventArgs e)
 {
     // throw new NotImplementedException();
 }
Beispiel #30
0
        protected override void OnModelDropped(ModelDropEventArgs args)
        {
            base.OnModelDropped(args);

            if (!args.Handled)
                this.RearrangeModels(args);
        }
Beispiel #31
0
        /// <summary>
        /// Do the work of processing the dropped items
        /// </summary>
        /// <param name="args"></param>
        public virtual void RearrangeModels(ModelDropEventArgs args)
        {
            switch (args.DropTargetLocation) {
                case DropTargetLocation.AboveItem:
                    this.ListView.MoveObjects(args.DropTargetIndex, args.SourceModels);
                    break;
                case DropTargetLocation.BelowItem:
                    this.ListView.MoveObjects(args.DropTargetIndex + 1, args.SourceModels);
                    break;
                case DropTargetLocation.Background:
                    this.ListView.AddObjects(args.SourceModels);
                    break;
                default:
                    return;
            }

            if (args.SourceListView != this.ListView) {
                args.SourceListView.RemoveObjects(args.SourceModels);
            }
        }
Beispiel #32
0
 private void dataListViewSceneCMDs_ModelCanDrop(object sender, ModelDropEventArgs e)
 {
     if (e.SourceModels[0].GetType().Equals(typeof(device)))
     {
         e.Effect = DragDropEffects.Copy;
         e.InfoMessage = "Create new action for this device";
     }
     else if (e.SourceModels[0].GetType().Equals(typeof(scene_commands)))
     {
         e.Effect = DragDropEffects.Move;
         e.InfoMessage = "Rearrage Order";
     }
     else
     {
         e.Effect = DragDropEffects.None;
         e.InfoMessage = "Can not drop this here.";
     }
 }
 public void treeListView1_ModelDropped(object sender, ModelDropEventArgs e)
 {
     Schueler derSchueler = GetDraggedSchueler(e.SourceModels);
       Klasse targetKlasse = GetDragTargetKlasse(e);
       var questionResult = MessageBox.Show("Soll der Schüler " + derSchueler.NameVorname + " von der " + derSchueler.getKlasse.Bezeichnung + " in die " + targetKlasse.Bezeichnung + " verschoben werden?", "Nachfrage", MessageBoxButtons.YesNo);
       if (questionResult == DialogResult.Yes)
       {
     derSchueler.WechsleKlasse(targetKlasse);
     if (this.refreshFunc != null)
     {
       this.refreshFunc();
     }
       }
       else
       {
     e.Effect = DragDropEffects.None;
       }
 }
Beispiel #34
0
        private void dataListViewSceneCMDs_ModelDropped(object sender, ModelDropEventArgs e)
        {
            int TargetIndex = 0;

            //Handle if dropped into empty Action box
            if (e.TargetModel == null)
                TargetIndex = 0;
            else
                TargetIndex = e.DropTargetIndex;

            // Handle Device Drop
            if (e.SourceModels[0].GetType().Equals(typeof(device)))
            {
                scene scene = (scene)dataListViewScenes.SelectedObject;
                using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                {
                    scene selected_scene = db.scenes.FirstOrDefault(c => c.id == scene.id);
                    if (selected_scene != null)
                    {
                        if (selected_scene.is_running)
                        {
                            MessageBox.Show("Cannot modify scene when it is running.", ProgramName);
                            return;
                        }

                        foreach (device selected_device in e.SourceModels)
                        {
                            if (selected_device != null)
                            {
                                int pos = TargetIndex;
                                switch (e.DropTargetLocation)
                                {
                                    case DropTargetLocation.BelowItem:
                                        pos += 1;
                                        break;
                                }

                                AddEditSceneDeviceCMD addCMDform = new AddEditSceneDeviceCMD(null, selected_device.id, selected_scene.id, pos);
                                addCMDform.ShowDialog();

                            }
                        }
                    }
                }
            }
            else if (e.SourceModels[0].GetType().Equals(typeof(scene_commands)))
            {
                //Rearrage Actions
                scene scene = (scene)dataListViewScenes.SelectedObject;
                using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                {
                    scene selected_scene = db.scenes.FirstOrDefault(c => c.id == scene.id);
                    if (selected_scene != null)
                    {
                        if (selected_scene.is_running)
                        {
                            MessageBox.Show("Cannot modify scene when it is running.", ProgramName);
                            return;
                        }

                        switch (e.DropTargetLocation)
                        {
                            case DropTargetLocation.AboveItem:
                                //offset = 0
                                dataListViewSceneCMDs.MoveObjects(TargetIndex, e.SourceModels);
                                dataListViewSceneCMDs.SelectedObjects = e.SourceModels;
                                break;
                            case DropTargetLocation.BelowItem:
                                //offset = 1
                                dataListViewSceneCMDs.MoveObjects(TargetIndex + 1, e.SourceModels);
                                dataListViewSceneCMDs.SelectedObjects = e.SourceModels;
                                break;
                        }

                        //SAve the sort order to the DB
                        foreach (scene_commands cmd in dataListViewSceneCMDs.Objects)
                        {
                            scene_commands scene_cmd = db.scene_commands.FirstOrDefault(s => s.id == cmd.id);
                            if (scene_cmd != null)
                            {
                                scene_cmd.sort_order = dataListViewSceneCMDs.IndexOf(cmd);
                            }
                            db.SaveChanges();
                        }
                    }
                }
            }
        }
Beispiel #35
0
        private void dataListViewScenes_ModelCanDrop_1(object sender, ModelDropEventArgs e)
        {
            e.Effect = DragDropEffects.None;
            e.InfoMessage = "Can not drop this here.";

            if (e.SourceModels[0].GetType().Equals(typeof(scene)) && e.TargetModel != null && e.TargetModel.GetType().Equals(typeof(scene)))
            {
                e.Effect = DragDropEffects.Move;
                e.InfoMessage = "Rearrage Order";
            }
        }
Beispiel #36
0
        private void dataListViewScenes_ModelDropped_1(object sender, ModelDropEventArgs e)
        {
            int TargetIndex = 0;

            //Handle if dropped into empty Action box
            if (e.TargetModel == null)
                TargetIndex = 0;
            else
                TargetIndex = e.DropTargetIndex;

            if (e.SourceModels[0].GetType().Equals(typeof(scene)))
            {
                switch (e.DropTargetLocation)
                {
                    case DropTargetLocation.AboveItem:
                        //offset = 0
                        dataListViewScenes.MoveObjects(TargetIndex, e.SourceModels);
                        dataListViewScenes.SelectedObjects = e.SourceModels;
                        break;
                    case DropTargetLocation.BelowItem:
                        //offset = 1
                        dataListViewScenes.MoveObjects(TargetIndex +1, e.SourceModels);
                        dataListViewScenes.SelectedObjects = e.SourceModels;
                        break;
                }
            }

            //SAve the sort order to the DB
            foreach (scene scene_in_list in dataListViewScenes.Objects)
            {
                using (zvsEntities2 db = new zvsEntities2(zvsEntityControl.GetzvsConnectionString))
                {
                    scene scene = db.scenes.FirstOrDefault(s => s.id == scene_in_list.id);
                    if (scene != null)
                    {
                        scene.sort_order = dataListViewScenes.IndexOf(scene_in_list);
                    }
                    db.SaveChanges();
                }
            }
        }
Beispiel #37
0
            protected override void OnModelCanDrop(ModelDropEventArgs args)
            {
                base.OnModelCanDrop(args);

                args.Effect = DragDropEffects.None;

                //args.Handled = true; // OnCanDrop is not being called anymore

                if (args.Handled)
                    return;

                args.Effect = CalculateStandardDropActionFromKeys();

                // Don't allow drops from other list, if that's what's configured
                if (!AcceptExternal)
                {
                    args.Effect = DragDropEffects.None;
                    args.DropTargetLocation = DropTargetLocation.None;
                }
                else
                {
                    _form.HostModelCanDrop(args);
                }
                args.Handled = true;
            }
Beispiel #38
0
 //process the dropped
 private void tree_ModelDropped(object sender, ModelDropEventArgs e)
 {
     switch (e.DropTargetLocation) {
     case DropTargetLocation.AboveItem:
       moveTag(e.SourceModels, (TagItem)e.TargetModel);
       break;
     case DropTargetLocation.BelowItem:
       moveTag(e.SourceModels, (TagItem)e.TargetModel, 1);
       break;
     case DropTargetLocation.Item:
       moveNote(e.SourceModels, (TagItem)e.TargetModel, e.StandardDropActionFromKeys);
       e.RefreshObjects();
       break;
       }
       //OLV drops renderer/sort when Roots assigned
       cName.Renderer = fancyRenderer;
       tree.Sort(cSort, SortOrder.Ascending);
 }
Beispiel #39
0
 void DropSinkModelCanDrop(object sender, ModelDropEventArgs e) { this.OnModelCanDrop(e); }
Beispiel #40
0
        /// <summary>
        /// Trigger ModelCanDrop
        /// </summary>
        /// <param name="args"></param>
        protected virtual void OnModelCanDrop(ModelDropEventArgs args) {

            // Don't allow drops from other list, if that's what's configured
            if (!this.AcceptExternal && args.SourceListView != null && args.SourceListView != this.ListView) {
                args.Effect = DragDropEffects.None;
                args.DropTargetLocation = DropTargetLocation.None;
                args.InfoMessage = "This list doesn't accept drops from other lists";
                return;
            }

            if (this.ModelCanDrop != null)
                this.ModelCanDrop(this, args);
        }
Beispiel #41
0
        private void PluginTree_ModelCanDrop(object sender, ModelDropEventArgs e)
        {
            e.Effect = DragDropEffects.None;
            if (e.DropTargetLocation == DropTargetLocation.Background)
            {
                return;
            }

            if (e.SourceModels.OfType<Plugin>().Any())
            {
                e.InfoMessage = "Cannot drag plugins";
                return;
            }

            if (e.TargetModel != null)
            {
                var rec = e.TargetModel as BaseRecord;
                var targetPlugin = this.GetPluginFromNode(rec);
                var targetParent = rec.Parent;
                if (e.SourceModels.Contains(e.TargetModel))
                {
                    // e.InfoMessage = "Cannot drop on self";
                }
                else
                {
                    var parents = e.SourceModels.OfType<BaseRecord>().Select(x => x.Parent).Distinct();
                    if (parents.Count() != 1)
                    {
                        e.InfoMessage = Resources.CannotDragNodesWithDifferentParents;
                        return;
                    }

                    var srcParent = parents.FirstOrDefault();
                    if (e.DropTargetLocation == DropTargetLocation.Item && srcParent.Equals(targetParent))
                    {
                        return;
                    }

                    Plugin srcPlugin = this.GetPluginFromNode(srcParent);
                    foreach (BaseRecord r in e.SourceModels)
                    {
                        foreach (var r2 in r.Enumerate(x => x is IGroupRecord || x.Equals(rec)))
                        {
                            if (r2.Equals(rec))
                            {
                                e.InfoMessage = Resources.CannotDropOnDescendent;
                                return;
                            }
                        }
                    }

                    if (e.DropTargetLocation == DropTargetLocation.Item && !(e.TargetModel is IGroupRecord))
                    {
                        // e.InfoMessage = "Can only drop on groups or plugins";
                    }
                    else
                    {
                        if (srcPlugin.Equals(targetPlugin))
                        {
                            // same plugin defaults to move unless ctrl down
                            e.Effect = e.DropSink.IsControlDown ? DragDropEffects.Copy : DragDropEffects.Move;
                        }
                        else
                        {
                            // same plugin defaults to copy unless shift down
                            e.Effect = (!e.DropSink.IsControlDown && e.DropSink.IsShiftDown) ? DragDropEffects.Move : DragDropEffects.Copy;
                        }
                    }
                }
            }
        }
Beispiel #42
0
        protected override void OnModelCanDrop(ModelDropEventArgs args)
        {
            base.OnModelCanDrop(args);

            if (args.Handled)
                return;

            args.Effect = DragDropEffects.Move;

            // Don't allow drops from other list, if that's what's configured
            if (!this.AcceptExternal && args.SourceListView != this.ListView) {
                args.Effect = DragDropEffects.None;
                args.DropTargetLocation = DropTargetLocation.None;
                args.InfoMessage = "This list doesn't accept drops from other lists";
            }

            // If we are rearranging a list, don't allow drops on the background
            if (args.DropTargetLocation == DropTargetLocation.Background && args.SourceListView == this.ListView) {
                args.Effect = DragDropEffects.None;
                args.DropTargetLocation = DropTargetLocation.None;
            }
        }
Beispiel #43
0
        private void PluginTree_ModelDropped(object sender, ModelDropEventArgs e)
        {
            if (e.DropTargetLocation == DropTargetLocation.Item)
            {
                var group = e.TargetModel as IGroupRecord;
                if (group == null)
                {
                    return;
                }

                var objects = new List<BaseRecord>();
                foreach (IRecord record in e.SourceModels)
                {
                    if (e.Effect == DragDropEffects.Copy)
                    {
                        var r = record.Clone() as BaseRecord;
                        group.AddRecord(r);
                        objects.Add(r);
                    }
                    else if (e.Effect == DragDropEffects.Move)
                    {
                        var r = record as BaseRecord;
                        if (r != null && r.Parent.DeleteRecord(r))
                        {
                            group.AddRecord(r);
                            objects.Add(r);
                        }
                    }
                }

                e.RefreshObjects();
                this.PluginTree.SelectObject(objects);
                this.PluginTree.RefreshObject(group);
                this.PluginTree.RefreshObjects(objects);
            }
            else if (e.DropTargetLocation == DropTargetLocation.AboveItem || e.DropTargetLocation == DropTargetLocation.BelowItem)
            {
                int offset = e.DropTargetLocation == DropTargetLocation.BelowItem ? +1 : 0;
                var rec = e.TargetModel as IRecord;
                if (rec == null)
                {
                    return;
                }

                var group = rec.Parent as IGroupRecord;
                if (group == null)
                {
                    return;
                }

                int idx = group.IndexOf(rec as BaseRecord) + offset;
                var refreshObjects = new List<BaseRecord>();
                var selObjects = new List<BaseRecord>();
                IEnumerable<IRecord> itr = e.SourceModels.OfType<IRecord>();
                if (e.DropTargetLocation == DropTargetLocation.BelowItem)
                {
                    itr = itr.Reverse();
                }

                foreach (IRecord record in itr)
                {
                    if (e.Effect == DragDropEffects.Copy)
                    {
                        var r = record.Clone() as BaseRecord;
                        group.InsertRecord(idx, r);
                        selObjects.Add(r);
                    }
                    else if (e.Effect == DragDropEffects.Move)
                    {
                        var r = record as BaseRecord;
                        var p = r.Parent;
                        if (r.Parent.DeleteRecord(r))
                        {
                            idx = group.IndexOf(rec as BaseRecord) + offset;
                            group.InsertRecord(idx, r);
                            selObjects.Add(r);
                        }
                    }
                }

                e.RefreshObjects();
                this.PluginTree.SelectObject(selObjects);
                this.PluginTree.RefreshObject(group);
                this.PluginTree.RefreshObjects(selObjects);
            }
        }
Beispiel #44
0
        /// <summary>
        /// A drag has entered this control.
        /// </summary>
        /// <remarks>Implementators should set args.Effect to the appropriate DragDropEffects.</remarks>
        /// <param name="args"></param>
        public override void Enter(DragEventArgs args)
        {
            //System.Diagnostics.Debug.WriteLine("Enter");

            /*
             * When FullRowSelect is true, we have two problems:
             * 1) GetItemRect(ItemOnly) returns the whole row rather than just the icon/text, which messes
             *    up our calculation of the drop rectangle.
             * 2) during the drag, the Timer events will not fire! This is the major problem, since without
             *    those events we can't autoscroll.
             *
             * The first problem we can solve through coding, but the second is more difficult.
             * We avoid both problems by turning off FullRowSelect during the drop operation.
             */
            this.originalFullRowSelect = this.ListView.FullRowSelect;
            this.ListView.FullRowSelect = false;

            // Setup our drop event args block
            this.dropEventArgs = new ModelDropEventArgs();
            this.dropEventArgs.DropSink = this;
            this.dropEventArgs.ListView = this.ListView;
            this.dropEventArgs.DataObject = args.Data;
            OLVDataObject olvData = args.Data as OLVDataObject;
            if (olvData != null) {
                this.dropEventArgs.SourceListView = olvData.ListView;
                this.dropEventArgs.SourceModels = olvData.ModelObjects;
            }

            this.Over(args);
        }
Beispiel #45
0
        private void olvSelectedDescriptionColumns_ModelDropped(object sender, BrightIdeasSoftware.ModelDropEventArgs e)
        {
            olvSelectedDescriptionColumns.AddObject(e.SourceModels[0]);

            UpdateValidityAssesment();
        }
Beispiel #46
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnModelCanDrop(ModelDropEventArgs args) {
     if (this.ModelCanDrop != null)
         this.ModelCanDrop(this, args);
 }
Beispiel #47
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnModelDropped(ModelDropEventArgs args) {
     if (this.ModelDropped != null)
         this.ModelDropped(this, args);
 }
Beispiel #48
0
 void dropSink_ModelDropped(object sender, ModelDropEventArgs e)
 {
     this.OnModelDropped(e);
 }
Beispiel #49
0
 //check if can drop here
 private void tree_ModelCanDrop(object sender, ModelDropEventArgs e)
 {
     e.Handled = true;
       e.Effect = DragDropEffects.None;
       if(e.TargetModel == null || e.SourceModels.Contains(e.TargetModel)) return; //drop to self
       var tag = e.TargetModel as TagItem;
       if (tag != null) {
     //what is dropped?
     var containNotes = false;
     var containTags = false;
     foreach (var i in e.SourceModels) {
       if (i is NoteItem) containNotes = true;
       else containTags = true;
     }
     if (!containNotes && e.DropTargetLocation != DropTargetLocation.Item && tag != tagDeleted ) e.Effect = DragDropEffects.Move; //can rearrange tags
     if (!containTags) {
       if ((e.DragEventArgs.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy; //Ctrl pressed - add tag
       else e.Effect = DragDropEffects.Move; //can drop notes to tags
     }
       }
 }