예제 #1
0
        internal MainPane(App app)
        {
            Data = app;
            TreeView.AdviseContextMenu(TreeView_ContextMenu);
            TreeView.AdviseDrag(delegate(HtmlMouseEvent e)
            {
                TreeViewHit hit = TreeView.Hit(e);
                if (hit != null)
                {
                    object node       = hit.Nodes.List[hit.Index];
                    FolderNode folder = node as FolderNode;
                    if (folder != null)
                    {
                        return(new ListItemsDragSource(new ListItem[] { folder.Item }));
                    }

                    WebNode web = node as WebNode;
                    if (web != null)
                    {
                        return(new WebNodeDragSource(web));
                    }
                }

                return(null);
            });

            TreeView.AdviseDrop(delegate(object dataObject)
            {
                IList <ListItem> listItems = dataObject as IList <ListItem>;
                if (listItems != null)
                {
                    return(new ListItemsNodeDropTarget(TreeView, listItems));
                }

                WebNode web = dataObject as WebNode;
                return(web != null ? new WebNodeDragTarget(TreeView, web) : null);
            });

            if (SupportedHtml5Features.File)
            {
                PostAdvise(
                    delegate()
                {
                    return(Element.AdviseDrop(null, null));
                });

                TreeViewFileDropTarget fileDropTarget = new TreeViewFileDropTarget(TreeView);
            }


            TreeView.AdviseKeyDown(
                delegate(HtmlKeyboardEvent e)
            {
                if (e.KeyCode == KeyCode.Delete)
                {
                    FolderNode folder = TreeView.Selection.Data as FolderNode;
                    if (folder != null)
                    {
                        NodeUtil.DeleteFolder(folder);
                    }
                }
            });
        }