Пример #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 == "Select")
     {
         if (SelectCommand != null)
             SelectCommand.Invoke(this, EventArgs.Empty);
     }
     else if (eventArgument == "Cancel")
     {
         if (CancelCommand != null)
             CancelCommand.Invoke(this, EventArgs.Empty);
     }
     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));
     }
 }
Пример #2
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);

			_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 (CommandOptions.Copy)
            {
				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 (CommandOptions.Move)
            {
				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 (CommandOptions.Delete)
            {
				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 (CommandOptions.Rename)
            {
				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 (CommandOptions.NewFolder)
            {
				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 (CommandOptions.FolderUp)
            {
				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 (CommandOptions.View)
            {
				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 (CommandOptions.Refresh)
            {
				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 (_customToolbarButtons != null) {
                for (int i = 0; i < _customToolbarButtons.Count; i++)
                {
                    CustomToolbarButton button = _customToolbarButtons[i];
					string postBackStatement = null;
					if (button.PerformPostBack) {
						postBackStatement = Page.ClientScript.GetPostBackEventReference (this, "Toolbar:" + i);
					}
					MenuItem item = new MenuItem ();
                    item.Text = button.Text;
                    item.ImageUrl = button.ImageUrl.ToString();
                    item.NavigateUrl = "javascript:" + button.OnClientClick + ";" + postBackStatement + ";return false;";
					_toolBar.Items.Add (item);
				}
			}
		}