예제 #1
0
 private static void RenderSmallGalleryButton(HtmlTextWriter output, Item button, CommandContext commandContext,
     Ribbon ribbon, string title, string overrideIcon, NameValueCollection parameters)
 {
     Assert.ArgumentNotNull(output, "output");
     Assert.ArgumentNotNull(button, "button");
     var enabled = CommandState.Enabled;
     var fieldValue = GetFieldValue(button, "Header");
     var icon = string.IsNullOrEmpty(overrideIcon) ? GetFieldValue(button, "Icon") : overrideIcon;
     var click = GetFieldValue(button, "Command");
     var str4 = GetFieldValue(button, "ID");
     var keyCode = GetFieldValue(button, "KeyCode");
     var str6 = GetFieldValue(button, "Access Key");
     var str7 = GetFieldValue(button, "Tooltip");
     if (click.Length > 0)
     {
         var command = CommandManager.GetCommand(GetClick(click));
         if (command != null)
         {
             fieldValue = command.GetHeader(commandContext, fieldValue);
             icon = command.GetIcon(commandContext, icon);
             click = command.GetClick(commandContext, click);
             enabled = CommandManager.QueryState(command, commandContext);
         }
     }
     if (enabled == CommandState.Hidden)
     {
         return;
     }
     var itemArray = (commandContext == null) ? new Item[0] : commandContext.Items;
     var item = (itemArray.Length > 0) ? itemArray[0] : null;
     var itemUrl = GetItemUrl(item, (commandContext != null) ? commandContext.Parameters : null);
     var smallButton = new SmallGalleryButton
     {
         ID = "B" + button.ID.ToShortID()
     };
     itemUrl.Parameters["id"] = smallButton.ID;
     if (str4.Length > 0)
     {
         smallButton.ID = str4;
     }
     click = GetClick(click, commandContext);
     var width = GetFieldValue(button, "Gallery Width");
     var height = GetFieldValue(button, "Gallery Height");
     GalleryManager.GetGallerySize(smallButton.ID + "_frame", ref width, ref height);
     smallButton.Header = string.IsNullOrEmpty(title) ? fieldValue : title;
     smallButton.Icon = icon;
     smallButton.Command = click;
     smallButton.Gallery = GetFieldValue(button, "Gallery");
     smallButton.GalleryHeight = height;
     smallButton.GalleryWidth = width;
     smallButton.GalleryUrl = itemUrl.ToString();
     smallButton.Enabled = enabled != CommandState.Disabled;
     smallButton.AccessKey = str6;
     smallButton.ToolTip = str7;
     smallButton.KeyCode = keyCode;
     ribbon.RenderSmallButton(output, smallButton);
     if (enabled != CommandState.Disabled)
     {
         Context.ClientPage.RegisterKey(keyCode, click, ribbon.ID);
     }
 }
예제 #2
0
        private static void RenderSmallGalleryButton(HtmlTextWriter output, Item button, CommandContext commandContext,
                                                     Ribbon ribbon, string title, string overrideIcon)
        {
            Assert.ArgumentNotNull(output, "output");
            Assert.ArgumentNotNull(button, "button");
            var enabled    = CommandState.Enabled;
            var fieldValue = GetFieldValue(button, "Header");
            var icon       = string.IsNullOrEmpty(overrideIcon) ? GetFieldValue(button, "Icon") : overrideIcon;
            var click      = GetFieldValue(button, "Command");
            var str4       = GetFieldValue(button, "ID");
            var keyCode    = GetFieldValue(button, "KeyCode");
            var str6       = GetFieldValue(button, "Access Key");
            var str7       = GetFieldValue(button, "Tooltip");

            if (click.Length > 0)
            {
                var command = CommandManager.GetCommand(GetClick(click));
                if (command != null)
                {
                    fieldValue = command.GetHeader(commandContext, fieldValue);
                    icon       = command.GetIcon(commandContext, icon);
                    click      = command.GetClick(commandContext, click);
                    enabled    = CommandManager.QueryState(command, commandContext);
                }
            }
            if (enabled == CommandState.Hidden)
            {
                return;
            }
            var itemArray   = (commandContext == null) ? new Item[0] : commandContext.Items;
            var item        = (itemArray.Length > 0) ? itemArray[0] : null;
            var itemUrl     = GetItemUrl(item, (commandContext != null) ? commandContext.Parameters : null);
            var smallButton = new SmallGalleryButton
            {
                ID = "B" + button.ID.ToShortID()
            };

            itemUrl.Parameters["id"] = smallButton.ID;
            if (str4.Length > 0)
            {
                smallButton.ID = str4;
            }
            click = GetClick(click, commandContext);
            var width  = GetFieldValue(button, "Gallery Width");
            var height = GetFieldValue(button, "Gallery Height");

            GalleryManager.GetGallerySize(smallButton.ID + "_frame", ref width, ref height);
            smallButton.Header        = string.IsNullOrEmpty(title) ? fieldValue : title;
            smallButton.Icon          = icon;
            smallButton.Command       = click;
            smallButton.Gallery       = GetFieldValue(button, "Gallery");
            smallButton.GalleryHeight = height;
            smallButton.GalleryWidth  = width;
            smallButton.GalleryUrl    = itemUrl.ToString();
            smallButton.Enabled       = enabled != CommandState.Disabled;
            smallButton.AccessKey     = str6;
            smallButton.ToolTip       = str7;
            smallButton.KeyCode       = keyCode;
            ribbon.RenderSmallButton(output, smallButton);
            if (enabled != CommandState.Disabled)
            {
                Context.ClientPage.RegisterKey(keyCode, click, ribbon.ID);
            }
        }