Ejemplo n.º 1
0
 void RaisePostBackEvent(string eventArgument)
 {
     if (eventArgument == "Upload")
     {
         HttpPostedFile uploadedFile = Page.Request.Files [ClientID + "_Upload"];
         if (uploadedFile != null && uploadedFile.ContentLength > 0)
         {
             FileManagerItemInfo dir = GetCurrentDirectory();
             Controller.ProcessFileUpload(dir, uploadedFile);
         }
     }
     else if (eventArgument.StartsWith("Toolbar:", StringComparison.Ordinal))
     {
         int i = int.Parse(eventArgument.Substring(8));
         CustomToolbarButton button = CustomToolbarButtons [i];
         OnToolbarCommand(new CommandEventArgs(button.CommandName, button.CommandArgument));
     }
 }
 public void Remove(CustomToolbarButton button)
 {
     ((IList) this).Remove (button);
 }
 public void Insert(int index, CustomToolbarButton button)
 {
     ((IList) this).Insert (index, button);
 }
 public int IndexOf(CustomToolbarButton button)
 {
     return ((IList) this).IndexOf (button);
 }
 public void CopyTo(CustomToolbarButton [] buttonArray, int index)
 {
     base.CopyTo (buttonArray, index);
 }
 public bool Contains(CustomToolbarButton button)
 {
     return ((IList) this).Contains (button);
 }
 public int Add(CustomToolbarButton button)
 {
     return ((IList) this).Add (button);
 }
 public void Remove(CustomToolbarButton button)
 {
     ((IList)this).Remove(button);
 }
 public void Insert(int index, CustomToolbarButton button)
 {
     ((IList)this).Insert(index, button);
 }
 public int IndexOf(CustomToolbarButton button)
 {
     return(((IList)this).IndexOf(button));
 }
 public bool Contains(CustomToolbarButton button)
 {
     return(((IList)this).Contains(button));
 }
 public int Add(CustomToolbarButton button)
 {
     return(((IList)this).Add(button));
 }
Ejemplo n.º 13
0
        private void CreateToolbar()
        {
            _toolBar = new Menu();
            _toolBar.EnableViewState = false;
            _toolBar.StaticEnableDefaultPopOutImage  = false;
            _toolBar.DynamicEnableDefaultPopOutImage = false;
            _toolBar.Orientation         = Orientation.Horizontal;
            _toolBar.SkipLinkText        = String.Empty;
            _toolBar.StaticItemTemplate  = new CompiledTemplateBuilder(new BuildTemplateMethod(CreateToolbarButton));
            _toolBar.DynamicItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(CreateToolbarPopupItem));

            // TODO
            _toolBar.DynamicMenuStyle.BackColor         = Color.White;
            _toolBar.DynamicMenuStyle.BorderStyle       = BorderStyle.Solid;
            _toolBar.DynamicMenuStyle.BorderWidth       = Unit.Pixel(1);
            _toolBar.DynamicMenuStyle.BorderColor       = Color.FromArgb(0xACA899);
            _toolBar.DynamicMenuStyle.HorizontalPadding = Unit.Pixel(2);
            _toolBar.DynamicMenuStyle.VerticalPadding   = Unit.Pixel(2);

            // fix IE8 bug
            var ie8fix = new IE8Fix();

            if (Page.Header != null)
            {
                Page.Header.StyleSheet.RegisterStyle(ie8fix, this);
            }
            _toolBar.DynamicMenuStyle.CssClass = ie8fix.RegisteredCssClass;


            _toolBar.DynamicMenuItemStyle.ForeColor       = Color.Black;
            _toolBar.DynamicMenuItemStyle.Font.Names      = new string [] { "Tahoma", "Verdana", "Geneva", "Arial", "Helvetica", "sans-serif" };
            _toolBar.DynamicMenuItemStyle.VerticalPadding = Unit.Pixel(1);
            _toolBar.DynamicMenuItemStyle.Font.Size       = FontUnit.Parse("11px", null);

            _toolBar.DynamicHoverStyle.ForeColor = Color.White;
            _toolBar.DynamicHoverStyle.BackColor = Color.FromArgb(0x316AC5);

            Controls.Add(_toolBar);

            string clientClickFunction = "javascript:" + FileManagerController.ClientScriptObjectNamePrefix + Controller.ClientID + ".On{0}(" + FileManagerController.ClientScriptObjectNamePrefix + _fileView.ClientID + ", '{1}');return false;";

            // Copy to
            if (ToolbarOptions.ShowCopyButton)
            {
                MenuItem itemCopyTo = new MenuItem();
                itemCopyTo.Text        = Controller.GetResourceString("Copy", "Copy");
                itemCopyTo.ImageUrl    = Controller.GetToolbarImage(ToolbarImages.Copy);
                itemCopyTo.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.SelectedItemsCopyTo, "");
                itemCopyTo.Enabled     = !ReadOnly;
                _toolBar.Items.Add(itemCopyTo);
            }

            // Move to
            if (ToolbarOptions.ShowMoveButton)
            {
                MenuItem itemMoveTo = new MenuItem();
                itemMoveTo.Text        = Controller.GetResourceString("Move", "Move");
                itemMoveTo.ImageUrl    = Controller.GetToolbarImage(ToolbarImages.Move);
                itemMoveTo.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.SelectedItemsMoveTo, "");
                itemMoveTo.Enabled     = !ReadOnly && AllowDelete;
                _toolBar.Items.Add(itemMoveTo);
            }

            // Delete
            if (ToolbarOptions.ShowDeleteButton)
            {
                MenuItem itemDelete = new MenuItem();
                itemDelete.Text        = Controller.GetResourceString("Delete", "Delete");
                itemDelete.ImageUrl    = Controller.GetToolbarImage(ToolbarImages.Delete);
                itemDelete.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.SelectedItemsDelete, "");
                itemDelete.Enabled     = !ReadOnly && AllowDelete;
                _toolBar.Items.Add(itemDelete);
            }

            // Rename
            if (ToolbarOptions.ShowRenameButton)
            {
                MenuItem itemRename = new MenuItem();
                itemRename.Text        = Controller.GetResourceString("Rename", "Rename");
                itemRename.ImageUrl    = Controller.GetToolbarImage(ToolbarImages.Rename);
                itemRename.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.Rename, "");
                itemRename.Enabled     = !ReadOnly && AllowDelete;
                _toolBar.Items.Add(itemRename);
            }

            // NewFolder
            if (ToolbarOptions.ShowNewFolderButton)
            {
                MenuItem itemNewFolder = new MenuItem();
                itemNewFolder.Text        = Controller.GetResourceString("Create_New_Folder", "New Folder");
                itemNewFolder.ImageUrl    = Controller.GetToolbarImage(ToolbarImages.NewFolder);
                itemNewFolder.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.NewFolder, "");
                itemNewFolder.Enabled     = !ReadOnly;
                _toolBar.Items.Add(itemNewFolder);
            }

            // FolderUp
            if (ToolbarOptions.ShowFolderUpButton)
            {
                MenuItem itemFolderUp = new MenuItem();
                itemFolderUp.Text        = Controller.GetResourceString("Up", "Up");
                itemFolderUp.ImageUrl    = Controller.GetToolbarImage(ToolbarImages.FolderUp);
                itemFolderUp.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.FileViewNavigate, "..");
                _toolBar.Items.Add(itemFolderUp);
            }

            // View
            if (ToolbarOptions.ShowViewButton)
            {
                MenuItem itemView = new MenuItem();
                itemView.Text        = Controller.GetResourceString("View", "View");
                itemView.ImageUrl    = Controller.GetToolbarImage(ToolbarImages.View);
                itemView.NavigateUrl = "javascript: return;";
                _toolBar.Items.Add(itemView);

                // Icons
                MenuItem itemViewIcons = new MenuItem();
                itemViewIcons.Text        = Controller.GetResourceString("Icons", "Icons");
                itemViewIcons.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Icons);
                itemView.ChildItems.Add(itemViewIcons);

                // Details
                MenuItem itemViewDetails = new MenuItem();
                itemViewDetails.Text        = Controller.GetResourceString("Details", "Details");
                itemViewDetails.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Details);
                itemView.ChildItems.Add(itemViewDetails);

                if (Controller.SupportThumbnails)
                {
                    // Thumbnails
                    MenuItem itemViewThumbnails = new MenuItem();
                    itemViewThumbnails.Text        = Controller.GetResourceString("Thumbnails", "Thumbnails");
                    itemViewThumbnails.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Thumbnails);
                    itemView.ChildItems.Add(itemViewThumbnails);
                }
            }

            // Refresh
            if (ToolbarOptions.ShowRefreshButton)
            {
                MenuItem itemRefresh = new MenuItem();
                itemRefresh.Text        = Controller.GetResourceString("Refresh", "Refresh");
                itemRefresh.Value       = "Refresh";
                itemRefresh.ImageUrl    = Controller.GetToolbarImage(ToolbarImages.Refresh);
                itemRefresh.NavigateUrl = String.Format(clientClickFunction, FileManagerCommands.Refresh, "");
                _toolBar.Items.Add(itemRefresh);
            }

            // Custom Buttons
            if (_cusomToolbarButtonCollection != null)
            {
                for (int i = 0; i < _cusomToolbarButtonCollection.Count; i++)
                {
                    CustomToolbarButton button = _cusomToolbarButtonCollection [i];
                    string postBackStatement   = null;
                    if (button.PerformPostBack)
                    {
                        postBackStatement = Page.ClientScript.GetPostBackEventReference(this, "Toolbar:" + i);
                    }
                    MenuItem item = new MenuItem()
                    {
                        Text        = button.Text,
                        ImageUrl    = button.ImageUrl,
                        NavigateUrl = "javascript:" + button.OnClientClick + ";" + postBackStatement + ";return false;"
                    };
                    _toolBar.Items.Add(item);
                }
            }
        }