Exemplo n.º 1
0
        void CreateToolbarButton(Control control)
        {
            MenuItemTemplateContainer container = (MenuItemTemplateContainer)control;
            MenuItem      menuItem = (MenuItem)container.DataItem;
            BorderedPanel panel    = new BorderedPanel();

            panel.ControlStyle.CopyFrom(DefaultToolbarButtonStyle);
            if (ToolbarButtonStyleCreated)
            {
                panel.ControlStyle.CopyFrom(ToolbarButtonStyle);
            }
            panel.Style [HtmlTextWriterStyle.Cursor] = "default";
            if (menuItem.Enabled)
            {
                panel.HoverSyle.CopyFrom(DefaultToolbarButtonHoverStyle);
                if (ToolbarButtonHoverStyleCreated)
                {
                    panel.HoverSyle.CopyFrom(ToolbarButtonHoverStyle);
                }
                panel.PressedSyle.CopyFrom(DefaultToolbarButtonPressedStyle);
                if (ToolbarButtonPressedStyleCreated)
                {
                    panel.PressedSyle.CopyFrom(ToolbarButtonPressedStyle);
                }
                panel.Attributes ["onclick"] = menuItem.NavigateUrl;
            }
            else
            {
                panel.Style ["color"] = "gray";
            }
            container.Controls.Add(panel);
            Table t = new Table();

            t.CellPadding = 0;
            t.CellSpacing = 0;
            t.BorderWidth = 0;
            panel.Controls.Add(t);
            TableRow r = new TableRow();

            t.Rows.Add(r);
            TableCell c1 = new TableCell();

            r.Cells.Add(c1);
            System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
            img.ImageUrl = ((MenuItem)container.DataItem).ImageUrl;
            c1.Controls.Add(img);
            TableCell c2 = new TableCell();

            c2.Style [HtmlTextWriterStyle.PaddingLeft]  = "2px";
            c2.Style [HtmlTextWriterStyle.PaddingRight] = "2px";
            c2.Text = " " + menuItem.Text;
            r.Cells.Add(c2);
        }
Exemplo n.º 2
0
        private void RenderToolBar(HtmlTextWriter writer)
        {
            BorderedPanel p = new BorderedPanel();

            p.Page = Page;
            p.ControlStyle.CopyFrom(DefaultToolbarStyle);
            if (ToolbarStyleCreated)
            {
                p.ControlStyle.CopyFrom(ToolbarStyle);
            }

            writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "relative");
            writer.AddStyleAttribute(HtmlTextWriterStyle.ZIndex, "100");
            writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_ToolBar");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            p.RenderBeginTag(writer);
            _toolBar.RenderControl(writer);
            p.RenderEndTag(writer);
            writer.RenderEndTag();
        }
Exemplo n.º 3
0
        private void CreateToolbar()
        {
            _toolBar = new ToolbarMenu(
                ClientID + "tb",
                Controller.CurrentUICulture.TextInfo.IsRightToLeft,
                RenderToolbarItem,
                RenderToolbarPopupItem,
                Controller.DynamicMenuStyle,
                Controller.DynamicMenuItemStyle,
                Controller.DynamicHoverStyle);

            Controls.Add(enabledToolbarButton = CreateToolbarButton(true));
            Controls.Add(disabledToolbarButton = CreateToolbarButton(false));

            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);

                // 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);
                }
            }
        }
Exemplo n.º 4
0
        private void RenderToolBar(HtmlTextWriter writer)
        {
            var p = new BorderedPanel();
            p.Page = Page;
            p.ControlStyle.CopyFrom(DefaultToolbarStyle);
            if (ToolbarStyleCreated)
                p.ControlStyle.CopyFrom(ToolbarStyle);

            writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "relative");
            writer.AddStyleAttribute(HtmlTextWriterStyle.ZIndex, "100");
            writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_ToolBar");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            p.RenderBeginTag(writer);
            _toolBar.Render(writer);
            p.RenderEndTag(writer);
            writer.RenderEndTag();
        }