protected void Page_Load (object sender, EventArgs e) { // create instance FileManager fileManager = new FileManager (); // set layouts fileManager.Height = 400; fileManager.Width = 600; // add root directory RootDirectory rootDirectory = new RootDirectory (); rootDirectory.DirectoryPath = DirectoryManager.GetRootDirectoryPath (Context); rootDirectory.Text = "My Documents"; fileManager.RootDirectories.Add (rootDirectory); fileManager.ExecuteCommand += FileManagerOnExecuteCommand; FileManagerCommand wyswygCmd = new FileManagerCommand(); wyswygCmd.CommandName = "WYSWYG"; wyswygCmd.Name = "Edit with WYSWYG editor"; FileManagerCommand editCmd = new FileManagerCommand(); editCmd.CommandName = "EditText"; editCmd.Name = "Edit"; FileType htmlFileType = new FileType(); htmlFileType.Extensions = "htm, html"; htmlFileType.Name = "HTML Document"; htmlFileType.LargeImageUrl = "images/32x32/html.gif"; htmlFileType.SmallImageUrl = "images/16x16/html.gif"; htmlFileType.Commands.Add(wyswygCmd); htmlFileType.Commands.Add(editCmd); fileManager.FileTypes.Add(htmlFileType); FileType txtFileType = new FileType(); txtFileType.Extensions = "txt, js, css"; txtFileType.Name = "HTML Document"; txtFileType.Commands.Add(editCmd); fileManager.FileTypes.Add(txtFileType); PlaceHolder1.Controls.Add (fileManager); }
private string ProcessCustomCommand(FileManagerItemInfo item, FileManagerCommand fileManagerCommand) { if (Page.IsCallback && fileManagerCommand.Method == FileManagerCommandMethod.PostBack) return Page.ClientScript.GetPostBackEventReference(this, "ExecuteCommand:" + EncodeURIComponent(item.FileManagerPath) + ":" + fileManagerCommand.CommandName + ":" + fileManagerCommand.CommandArgument) + ";"; return OnExecuteCommand(item, fileManagerCommand.CommandName, fileManagerCommand.CommandArgument); }
public void Remove(FileManagerCommand command) { ((IList)this).Remove(command); }
public void Insert(int index, FileManagerCommand command) { ((IList)this).Insert(index, command); }
public int IndexOf(FileManagerCommand command) { return(((IList)this).IndexOf(command)); }
public bool Contains(FileManagerCommand command) { return(((IList)this).Contains(command)); }
public int Add(FileManagerCommand command) { return(((IList)this).Add(command)); }
private string ProcessCommand(FileManagerItemInfo item, FileManagerCommand fileManagerCommand) { ExecuteCommandEventArgs arg = new ExecuteCommandEventArgs (fileManagerCommand.CommandName, fileManagerCommand.CommandArgument); arg.Items.Add (item); //arg.Command = fileManagerCommand; OnExecuteCommand (arg); return arg.ClientScript; }
public void Remove (FileManagerCommand command) { ((IList) this).Remove (command); }
public void Insert (int index, FileManagerCommand command) { ((IList) this).Insert (index, command); }
public int IndexOf (FileManagerCommand command) { return ((IList) this).IndexOf (command); }
public void CopyTo (FileManagerCommand [] commandArray, int index) { base.CopyTo (commandArray, index); }
public bool Contains (FileManagerCommand command) { return ((IList) this).Contains (command); }
public int Add (FileManagerCommand command) { return ((IList) this).Add (command); }
void CreateSelectedItemsContextMenu() { _selectedItemsContextMenu = new ContextMenu(); _selectedItemsContextMenu.EnableViewState = false; _selectedItemsContextMenu.StaticEnableDefaultPopOutImage = false; _selectedItemsContextMenu.DynamicEnableDefaultPopOutImage = false; _selectedItemsContextMenu.Orientation = Orientation.Horizontal; _selectedItemsContextMenu.SkipLinkText = String.Empty; _selectedItemsContextMenu.StaticItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(CreateContextMenuRootItem)); _selectedItemsContextMenu.DynamicItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(CreateContextMenuPopupItem)); SetContextMenuStyle(_selectedItemsContextMenu); Controls.Add(_selectedItemsContextMenu); // Root MenuItem root = new MenuItem(); root.Text = "_contextMenu"; root.NavigateUrl = "javascript: return;"; _selectedItemsContextMenu.Items.Add(root); string clientClickFunction = "javascript:" + FileManagerController.ClientScriptObjectNamePrefix + Controller.ClientID + ".On{0}(" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ", '{1}');return false;"; StringBuilder sbCommands = new StringBuilder(); for (int i = 0; i < FileTypes.Count; i++) { FileType ft = FileTypes [i]; for (int j = 0; j < ft.Commands.Count; j++) { FileManagerCommand command = ft.Commands [j]; MenuItem itemCommand = new MenuItem(); itemCommand.Text = command.Name; itemCommand.Value = i + "_" + j; itemCommand.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.ExecuteCommand, "0:" + j); itemCommand.ImageUrl = command.SmallImageUrl; root.ChildItems.Add(itemCommand); sbCommands.AppendLine(ClientID + "_SetCommandVisible('" + ClientID + "CMD" + i + "_" + j + "', (" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SelectedItems.length==1) && (" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SelectedItems[0].FileType==" + i + "));"); } } MenuItem itemOpen = new MenuItem(); itemOpen.Text = GetResourceString("Open", "Open"); itemOpen.Value = "Open"; itemOpen.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.ExecuteCommand, "0:-1"); root.ChildItems.Add(itemOpen); MenuItem itemDownload = new MenuItem(); itemDownload.Text = GetResourceString("Download", "Download"); itemDownload.Value = "Download"; itemDownload.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.ExecuteCommand, "0:-2"); root.ChildItems.Add(itemDownload); sbCommands.AppendLine(ClientID + "_SetCommandVisible('" + ClientID + "CMDDownload', (" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SelectedItems.length==1) && (" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SelectedItems[0].FileType!=-2));"); root.ChildItems.Add(new MenuItem("__separator__", "__separator__", null, "javascript: return;")); // Copy to MenuItem itemCopyTo = new MenuItem(); itemCopyTo.Text = GetResourceString("Copy", "Copy"); itemCopyTo.Value = "Copy"; itemCopyTo.ImageUrl = Controller.GetToolbarImage(ToolbarImages.Copy); itemCopyTo.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.SelectedItemsCopyTo, ""); itemCopyTo.Enabled = !ReadOnly; root.ChildItems.Add(itemCopyTo); // Move to MenuItem itemMoveTo = new MenuItem(); itemMoveTo.Text = GetResourceString("Move", "Move"); itemMoveTo.Value = "Move"; itemMoveTo.ImageUrl = Controller.GetToolbarImage(ToolbarImages.Move); itemMoveTo.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.SelectedItemsMoveTo, ""); itemMoveTo.Enabled = !ReadOnly && AllowDelete; root.ChildItems.Add(itemMoveTo); root.ChildItems.Add(new MenuItem("__separator__", "__separator__", null, "javascript: return;")); // Delete MenuItem itemDelete = new MenuItem(); itemDelete.Text = GetResourceString("Delete", "Delete"); itemDelete.Value = "Delete"; itemDelete.ImageUrl = Controller.GetToolbarImage(ToolbarImages.Delete); itemDelete.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.SelectedItemsDelete, ""); itemDelete.Enabled = !ReadOnly && AllowDelete; root.ChildItems.Add(itemDelete); // Rename MenuItem itemRename = new MenuItem(); itemRename.Text = GetResourceString("Rename", "Rename"); itemRename.Value = "Rename"; itemRename.ImageUrl = Controller.GetToolbarImage(ToolbarImages.Rename); itemRename.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.Rename, ""); itemRename.Enabled = !ReadOnly && AllowDelete; root.ChildItems.Add(itemRename); // client script StringBuilder sb = new StringBuilder(); sb.AppendLine("function " + ClientID + "_ShowSelectedItemsContextMenu(x,y) {"); sb.Append(sbCommands.ToString()); sb.AppendLine("var node = WebForm_GetElementById('" + ClientID + "_SelectedItemsContextMenu')"); sb.AppendLine("WebForm_SetElementX(node, x)"); sb.AppendLine("WebForm_SetElementY(node, y)"); sb.AppendLine("WebForm_GetElementById('" + _selectedItemsContextMenu.ClientID + "n0Items').style.height = \"auto\";"); sb.AppendLine("WebForm_GetElementById('" + _selectedItemsContextMenu.ClientID + "n0Items').physicalHeight = null;"); sb.AppendLine("Menu_HoverStatic(WebForm_GetElementById('" + _selectedItemsContextMenu.ClientID + "n0'));"); sb.AppendLine("}"); sb.AppendLine("function " + ClientID + "_SetCommandVisible(command, value) {"); sb.AppendLine("var node = WebForm_GetElementById(command);"); sb.AppendLine("var row = node.parentNode.parentNode.parentNode.parentNode.parentNode;"); sb.AppendLine("if (value) {"); sb.AppendLine("row.style.visibility = \"visible\";"); sb.AppendLine("row.style.display = \"block\";"); sb.AppendLine("row.style.position = \"static\";"); sb.AppendLine("row.parentNode.parentNode.style.height = \"auto\";"); sb.AppendLine("} else {"); sb.AppendLine("row.style.visibility = \"hidden\";"); sb.AppendLine("row.style.display = \"none\";"); sb.AppendLine("row.style.position = \"absolute\";"); sb.AppendLine("row.parentNode.parentNode.style.height = \"0px\";"); sb.AppendLine("}"); sb.AppendLine("}"); Page.ClientScript.RegisterClientScriptBlock(typeof(FileView), ClientID + "_ShowSelectedItemsContextMenu", sb.ToString(), true); }