private void ListVars_ItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data as object;

            if (droppedItem != null)
            {
                VariableBase droppedAtVar = DragDrop2.GetRepositoryItemHit(ListView) as VariableBase;

                VariableBase varDropped = droppedItem as VariableBase;

                VariableBase instance = (VariableBase)varDropped.CreateInstance(true);

                if (droppedAtVar != null)
                {
                    int targetIndex = GetVariablesList().IndexOf(droppedAtVar);

                    GetVariablesList().Insert(targetIndex, instance);
                    ListView.xListView.SelectedItem = instance;
                }
                else
                {
                    GetVariablesList().Add(instance);

                    int selectedActIndex = -1;
                    if (GetVariablesList().CurrentItem != null)
                    {
                        selectedActIndex = GetVariablesList().IndexOf((VariableBase)GetVariablesList().CurrentItem);
                    }
                    if (selectedActIndex >= 0)
                    {
                        GetVariablesList().Move(GetVariablesList().Count - 1, selectedActIndex + 1);
                    }
                }
            }
        }
Пример #2
0
        private void ActivitiesListView_ItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data as object;

            if (droppedItem != null)
            {
                if (droppedItem is Activity)
                {
                    string   activityGroupID   = null;
                    int      activityIndex     = -1;
                    Activity activityDroppedOn = DragDrop2.GetRepositoryItemHit(ListView) as Activity;

                    if (activityDroppedOn != null)
                    {
                        activityGroupID = activityDroppedOn.ActivitiesGroupID;
                        activityIndex   = ListView.xListView.Items.IndexOf(activityDroppedOn);
                    }

                    List <Activity> list = new List <Activity>();
                    list.Add((Activity)droppedItem);
                    ActionsFactory.AddActivitiesFromSRHandler(list, mContext.BusinessFlow, activityGroupID, activityIndex);
                    if (activityIndex != -1)
                    {
                        ListView.xListView.SelectedIndex = activityIndex;
                    }
                }
                else if (droppedItem is ActivitiesGroup)
                {
                    List <ActivitiesGroup> list = new List <ActivitiesGroup>();
                    list.Add((ActivitiesGroup)droppedItem);
                    ActionsFactory.AddActivitiesGroupsFromSRHandler(list, mContext.BusinessFlow);
                }
            }
        }
Пример #3
0
        private void ActivitiesListView_SameFrameItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data as object;

            if (droppedItem != null)
            {
                if (droppedItem is Activity)
                {
                    Activity draggedActivity   = droppedItem as Activity;
                    Activity activityDroppedOn = DragDrop2.GetRepositoryItemHit(ListView) as Activity;

                    if (activityDroppedOn != null)
                    {
                        if (activityDroppedOn.ActivitiesGroupID != draggedActivity.ActivitiesGroupID)
                        {
                            //need to shift groups
                            try
                            {
                                mContext.BusinessFlow.MoveActivityBetweenGroups(draggedActivity, mContext.BusinessFlow.GetActivitiesGroupByName(activityDroppedOn.ActivitiesGroupID), mContext.BusinessFlow.Activities.IndexOf(activityDroppedOn));
                            }
                            catch (Exception ex)
                            {
                                Reporter.ToLog(eLogLevel.DEBUG, "Error occurred while dragging Activity to other group", ex);
                            }
                            ListView.UpdateGrouping();
                        }
                        else
                        {
                            //need to move in group
                            mContext.BusinessFlow.MoveActivityInGroup(draggedActivity, mContext.BusinessFlow.Activities.IndexOf(activityDroppedOn));
                        }
                    }
                }
            }
        }
Пример #4
0
        private void listActions_ItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data as object;

            if (droppedItem != null)
            {
                int mouseIndex     = -1;
                int lastAddedIndex = -1;
                Act actDroppedOn   = DragDrop2.GetRepositoryItemHit(ListView) as Act;

                if (actDroppedOn != null)
                {
                    mouseIndex = ListView.DataSourceList.IndexOf(actDroppedOn);
                }

                lastAddedIndex = ActionsFactory.AddActionsHandler(droppedItem, mContext, mouseIndex);

                if (lastAddedIndex > mouseIndex)
                {
                    ListView.xListView.SelectedItems.Clear();
                    for (int itemIndex = mouseIndex; itemIndex < lastAddedIndex; itemIndex++)
                    {
                        RepositoryItemBase repoBaseItem = ListView.DataSourceList[itemIndex] as RepositoryItemBase;
                        if (repoBaseItem != null)
                        {
                            ListView.xListView.SelectedItems.Add(repoBaseItem);
                        }
                    }
                }
            }
        }
Пример #5
0
        private void listActions_ItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data as object;

            if (droppedItem != null)
            {
                int mouseIndex   = -1;
                Act actDroppedOn = DragDrop2.GetRepositoryItemHit(ListView) as Act;

                if (actDroppedOn != null)
                {
                    mouseIndex = ListView.DataSourceList.IndexOf(actDroppedOn);
                }
                DroppedItemHandler(droppedItem, mouseIndex);
            }
        }
Пример #6
0
        void IDragDrop.Drop(DragInfo Info)
        {
            // first check if we did drag and drop on the same ListView then it is a move - reorder
            if (Info.DragSource == this)
            {
                EventHandler mHandler = SameFrameItemDropped;
                if (mHandler != null)
                {
                    mHandler(Info, new EventArgs());
                }
                else
                {
                    RepositoryItemBase draggedItem = Info.Data as RepositoryItemBase;

                    if (draggedItem != null)
                    {
                        RepositoryItemBase draggedOnItem = DragDrop2.GetRepositoryItemHit(this) as RepositoryItemBase;
                        if (draggedOnItem != null)
                        {
                            DragDrop2.ShuffleControlsItems(draggedItem, draggedOnItem, this);
                        }
                    }
                }
                //if (!(xMoveUpBtn.Visibility == System.Windows.Visibility.Visible)) return;  // Do nothing if reorder up/down arrow are not allowed
                return;
            }

            // OK this is a dropped from external
            EventHandler handler = ItemDropped;

            if (handler != null)
            {
                handler(Info, new EventArgs());
            }
            // TODO: if in same grid then do move,
        }