コード例 #1
0
        /// <summary>
        /// Handle Drag/Drop events for the curriculum tree
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeCurriculum_DragEnded(object sender, RadTreeViewDragEndedEventArgs e)
        {
            //Dragging a unit into a course
            if (e.DraggedItems[0].GetType().ToString() == "lbcLibrary.Unit")
            {
                if (e.TargetDropItem.FullPath == "lbcLibrary.Course")
                {
                    Course tmpCourse = (Course)e.TargetDropItem.Item;
                    Unit tmpUnit = (Unit)e.DraggedItems[0];

                    if (unitVM.MoveUnit(tmpUnit, tmpCourse) == true)
                    {
                        mainVM.InformationMessages.Insert(0, new Helper.Information(
                         "MoveUnit",
                         "Unit Moved Successfully",
                         "The unit: " + tmpUnit.UnitName + " was successfully moved into " + tmpCourse.Name));

                        //Refresh the curriculum tree
                        treeCurriculum.Items.Refresh();
                    }
                    else
                    {
                        mainVM.InformationMessages.Insert(0, new Helper.Information(
                         "Warning",
                         "Unit Move Failed",
                         "An error occured while moving the unit."));
                    }
                }
            }
            //Dragging a lesson into a unit
            else if (e.DraggedItems[0].GetType().ToString() == "lbcLibrary.Lesson")
            {
                if (e.TargetDropItem.FullPath == "lbcLibrary.Course\\lbcLibrary.Unit")
                {
                    Unit tmpUnit = (Unit)e.TargetDropItem.Item;
                    Lesson tmpLesson = (Lesson)e.DraggedItems[0];

                    if (lessonVM.MoveLesson(tmpLesson, tmpUnit) == true)
                    {
                        mainVM.InformationMessages.Insert(0, new Helper.Information(
                         "MoveLesson",
                         "Lesson Moved Successfully",
                         "The lesson: " + tmpLesson.LessonName + " was successfully moved into " + tmpUnit.UnitName));

                        //Refresh the curriculum tree
                        treeCurriculum.Items.Refresh();
                    }
                    else
                    {
                        mainVM.InformationMessages.Insert(0, new Helper.Information(
                         "Warning",
                         "Lesson Move Failed",
                         "An error occured while moving the lesson."));
                    }
                }
            }
        }
コード例 #2
0
 private void RouteTreeViewPreviewDragEnded(object sender, RadTreeViewDragEndedEventArgs e)
 {
     //Fixes issue that EntityCollection does not implement IList
     //Cancelling the default drag-drop action for the TreeView is done by handling the PreviewDragEnded event.
     //http://www.telerik.com/community/forums/silverlight/drag-and-drop/draganddrop-with-radtreeview-and-entitycollection.aspx
     e.Handled = true;
 }
コード例 #3
0
        private void XTreeView_PreviewDragEnded(object sender, RadTreeViewDragEndedEventArgs e)
        {
            if (e.DraggedItems != null && e.DraggedItems.Count > 0)
            {
                var rootMap = e.DraggedItems[0] as RootMap;
                if (rootMap != null)
                {
                    var     oldParent = _projects.FirstOrDefault(q => q.Id == rootMap.ParentId);
                    Project parent    = null;
                    RootMap target    = null;
                    if (e.DropPosition == DropPosition.Inside)
                    {
                        parent = e.TargetDropItem.DataContext as Project;
                    }
                    else if (e.DropPosition == DropPosition.Before || e.DropPosition == DropPosition.After)
                    {
                        target = e.TargetDropItem.DataContext as RootMap;
                        if (target != null)
                        {
                            parent = _projects.FirstOrDefault(q => q.Id == target.ParentId);
                        }
                    }

                    if (parent != null && oldParent != null && parent != oldParent)
                    {
                        SuperMessageBoxService.Show("Confirmation",
                                                    "Which operation do you want to do?\r\n\r\nYou can move the map to the new project\r\nor copy the map to the new project",
                                                    "Move", "Copy", "Cancel", MessageBoxType.Confirmation,
                                                    () =>
                        {
                            oldParent.RootMaps.Remove(rootMap);
                            if (rootMap.IsInherited)
                            {
                                foreach (var groups in parent.PermissionGroups)
                                {
                                    foreach (var group in groups)
                                    {
                                        rootMap.LoadValue(group.Group,
                                                          group.DefaultValue.HasValue && group.DefaultValue.Value);
                                    }
                                }
                            }

                            rootMap.Node.DomainId = parent.Id;
                            if (e.DropPosition == DropPosition.Inside)
                            {
                                parent.RootMaps.Add(rootMap);
                            }
                            else if (e.DropPosition == DropPosition.Before)
                            {
                                var index = parent.RootMaps.IndexOf(target);
                                parent.RootMaps.Insert(index, rootMap);
                            }
                            else if (e.DropPosition == DropPosition.After)
                            {
                                var index = parent.RootMaps.IndexOf(target);
                                parent.RootMaps.Insert(index + 1, rootMap);
                            }
                        },
                                                    () =>
                        {
                            MapManager.CreateRootMapCompleted.RegisterEvent(OnCopyRootMapCompleted);
                            MapManager.CreateRootMap(parent.Id, "Copy of " + rootMap.Name,
                                                     MapManager.NodeTypes["CompendiumMapNode"], string.Empty);
                        });
                    }
                }
            }
            e.Handled = true;
        }