/// <summary>
        /// Renders a command control as link with an icon, a text or both.
        /// </summary>
        /// <param name="renderingContext">The <see cref="BocColumnRenderingContext{BocColumnDefinition}"/>.</param>
        /// <param name="originalRowIndex">The zero-based index of the current row in <see cref="IBocList"/></param>
        /// <param name="businessObject">The <see cref="IBusinessObject"/> associated with the current row.</param>
        /// <param name="command">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.RowEditModeCommand"/> that is issued
        /// when the control is clicked. Must not be <see langword="null" />.</param>
        /// <param name="alternateText">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.ResourceIdentifier"/>
        /// specifying which resource to load as alternate text to the icon.</param>
        /// <param name="icon">The icon to render; must not be <see langword="null"/>.
        /// To skip the icon, set <see cref="IconInfo.Url"/> to <see langword="null" />.</param>
        /// <param name="text">The text to render after the icon. May be <see langword="null"/>, in which case no text is rendered.</param>
        protected virtual void RenderCommandControl(
            BocColumnRenderingContext <BocRowEditModeColumnDefinition> renderingContext,
            int originalRowIndex,
            IBusinessObject businessObject,
            BocList.RowEditModeCommand command,
            BocList.ResourceIdentifier alternateText,
            IconInfo icon,
            string text)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);
            ArgumentUtility.CheckNotNull("icon", icon);

            if (!renderingContext.Control.IsReadOnly && renderingContext.Control.HasClientScript)
            {
                string argument      = renderingContext.Control.GetRowEditCommandArgument(new BocListRow(originalRowIndex, businessObject), command);
                string postBackEvent = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(renderingContext.Control, argument) + ";";
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Href, "#");
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, postBackEvent + c_onCommandClickScript);
            }
            var commandID = renderingContext.Control.ClientID + "_Column_" + renderingContext.ColumnIndex + "_RowEditCommand_" + command + "_Row_" + originalRowIndex;

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, commandID);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);

            bool hasIcon = icon.HasRenderingInformation;
            bool hasText = !string.IsNullOrEmpty(text);

            if (hasIcon && hasText)
            {
                icon.Render(renderingContext.Writer, renderingContext.Control);
                renderingContext.Writer.Write(c_whiteSpace);
            }
            else if (hasIcon)
            {
                bool hasAlternateText = !string.IsNullOrEmpty(icon.AlternateText);
                if (!hasAlternateText)
                {
                    icon.AlternateText = renderingContext.Control.GetResourceManager().GetString(alternateText);
                }

                icon.Render(renderingContext.Writer, renderingContext.Control);
            }
            if (hasText)
            {
                renderingContext.Writer.Write(text); // Do not HTML encode.
            }
            renderingContext.Writer.RenderEndTag();
        }
        private void RenderNavigationIcon(BocListRenderingContext renderingContext, bool isInactive, GoToOption command, int pageIndex)
        {
            var navigateCommandID = renderingContext.Control.ClientID + "_Navigation_" + command;

            if (isInactive)
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, navigateCommandID);
                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);

                var imageUrl = GetResolvedImageUrl(s_inactiveIcons[command]);
                new IconInfo(imageUrl.GetUrl()).Render(renderingContext.Writer, renderingContext.Control);

                renderingContext.Writer.RenderEndTag();
            }
            else
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, navigateCommandID);

                var currentPageControlClientID = GetCurrentPageIndexControlID(renderingContext);
                var postBackEvent = string.Format("$('#{0}').val({1}).trigger('change');", currentPageControlClientID, pageIndex);
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, postBackEvent);

                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Href, "#");

                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);

                var imageUrl = GetResolvedImageUrl(s_activeIcons[command]);
                var icon     = new IconInfo(imageUrl.GetUrl());
                icon.AlternateText = GetResourceManager(renderingContext).GetString(s_alternateTexts[command]);
                icon.Render(renderingContext.Writer, renderingContext.Control);

                renderingContext.Writer.RenderEndTag();
            }
        }
Exemple #3
0
        private void RenderTenantHierarchyIcon(HtmlTextWriter writer, IControl container)
        {
            string url;
            string text;

            switch (_accessControlEntry.TenantHierarchyCondition)
            {
            case TenantHierarchyCondition.Undefined:
                throw new InvalidOperationException();

            case TenantHierarchyCondition.This:
                url  = "HierarchyThis.gif";
                text = ResourceManager.GetString(ResourceIdentifier.TenantHierarchyCondition_This);
                break;

            case TenantHierarchyCondition.Parent:
                throw new InvalidOperationException();

            case TenantHierarchyCondition.ThisAndParent:
                url  = "HierarchyThisAndParent.gif";
                text = ResourceManager.GetString(ResourceIdentifier.TenantHierarchyCondition_ThisAndParent);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var icon = new IconInfo(GetIconUrl(url).GetUrl())
            {
                AlternateText = text
            };

            icon.Render(writer, container);
        }
        protected void RenderCellIcon(BocColumnRenderingContext <TBocColumnDefinition> renderingContext, IBusinessObject businessObject)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);

            IconInfo icon = BusinessObjectBoundWebControl.GetIcon(businessObject, businessObject.BusinessObjectClass.BusinessObjectProvider);

            if (icon != null)
            {
                icon.Render(renderingContext.Writer, renderingContext.Control);
                renderingContext.Writer.Write(c_whiteSpace);
            }
        }
        public void Render_WidthInPercent()
        {
            IconInfo iconInfo = new IconInfo("/image.gif")
            {
                Width = Unit.Percentage(10)
            };

            iconInfo.Render(_html.Writer, _controlStub);

            var document = _html.GetResultDocument();
            var imgTag   = _html.GetAssertedChildElement(document, "img", 0);

            _html.AssertStyleAttribute(imgTag, "width", "10%");
        }
        public void Render_HeightInPixels()
        {
            IconInfo iconInfo = new IconInfo("/image.gif")
            {
                Height = Unit.Pixel(20)
            };

            iconInfo.Render(_html.Writer, _controlStub);

            var document = _html.GetResultDocument();
            var imgTag   = _html.GetAssertedChildElement(document, "img", 0);

            _html.AssertStyleAttribute(imgTag, "height", "20px");
        }
        private void RenderTitleCellSortingButton(
            BocColumnRenderingContext <TBocColumnDefinition> renderingContext,
            SortingDirection sortingDirection,
            int orderIndex)
        {
            if (sortingDirection == SortingDirection.None)
            {
                return;
            }

            //  WhiteSpace before icon
            renderingContext.Writer.Write(c_whiteSpace);
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.SortingOrder);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);

            BocList.ResourceIdentifier alternateTextID;
            if (sortingDirection == SortingDirection.Ascending)
            {
                alternateTextID = BocList.ResourceIdentifier.SortAscendingAlternateText;
            }
            else
            {
                alternateTextID = BocList.ResourceIdentifier.SortDescendingAlternateText;
            }

            var imageUrl = GetImageUrl(sortingDirection);

            Assertion.IsNotNull(imageUrl);

            var icon = new IconInfo(imageUrl.GetUrl());

            icon.AlternateText = renderingContext.Control.GetResourceManager().GetString(alternateTextID);
            icon.Render(renderingContext.Writer, renderingContext.Control);

            if (renderingContext.Control.IsShowSortingOrderEnabled && orderIndex >= 0)
            {
                renderingContext.Writer.Write(c_whiteSpace + (orderIndex + 1));
            }
            renderingContext.Writer.RenderEndTag();
        }
Exemple #8
0
        private void RenderSeparateIcon(BocRenderingContext <TControl> renderingContext, string postBackEvent, string onClick, string objectID)
        {
            IconInfo icon          = null;
            var      isIconEnabled = renderingContext.Control.IsIconEnabled();

            if (isIconEnabled)
            {
                icon = GetIcon(renderingContext);
            }

            var anchorClass = CssClassCommand;

            if (icon != null)
            {
                anchorClass += " " + CssClassHasIcon;
            }
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, anchorClass);

            var isCommandEnabled = isIconEnabled && IsCommandEnabled(renderingContext);
            var command          = GetCommand(renderingContext, isCommandEnabled);

            command.RenderBegin(renderingContext.Writer, RenderingFeatures, postBackEvent, onClick, objectID, null);

            if (isIconEnabled)
            {
                icon = icon ?? IconInfo.CreateSpacer(ResourceUrlFactory);
            }

            if (icon != null)
            {
                if (!string.IsNullOrEmpty(command.ToolTip))
                {
                    icon.ToolTip = renderingContext.Control.Command.ToolTip;
                }
                icon.Render(renderingContext.Writer, renderingContext.Control);
            }

            renderingContext.Control.Command.RenderEnd(renderingContext.Writer);
        }
Exemple #9
0
        private void RenderNavigationIcon(BocListRenderingContext renderingContext, bool isInactive, GoToOption command, int pageIndex)
        {
            if (isInactive || renderingContext.Control.EditModeController.IsRowEditModeActive)
            {
                string imageUrl = GetResolvedImageUrl(s_inactiveIcons[command]);
                new IconInfo(imageUrl).Render(renderingContext.Writer, renderingContext.Control);
            }
            else
            {
                var navigateCommandID = renderingContext.Control.ClientID + "_Navigation_" + command;
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, navigateCommandID);

                var postBackEvent = new StringBuilder(200);
                postBackEvent.AppendFormat(
                    "document.getElementById ('{0}').value = {1};",
                    renderingContext.Control.GetCurrentPageControlName().Replace('$', '_'),
                    pageIndex);
                var postBackOptions = new PostBackOptions(new Control {
                    ID = renderingContext.Control.GetCurrentPageControlName()
                }, "");
                postBackEvent.Append(renderingContext.Control.Page.ClientScript.GetPostBackEventReference(postBackOptions));
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, postBackEvent.ToString());

                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Href, "#");

                renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);

                string imageUrl = GetResolvedImageUrl(s_activeIcons[command]);
                var    icon     = new IconInfo(imageUrl);
                icon.AlternateText = GetResourceManager(renderingContext).GetString(s_alternateTexts[command]);
                icon.Render(renderingContext.Writer, renderingContext.Control);

                renderingContext.Writer.RenderEndTag();
            }

            renderingContext.Writer.Write(c_whiteSpace + c_whiteSpace + c_whiteSpace);
        }
Exemple #10
0
        private void RenderReadOnlyValue(BocRenderingContext <TControl> renderingContext, string postBackEvent, string onClick, string objectID)
        {
            Label    label         = GetLabel(renderingContext);
            IconInfo icon          = null;
            var      isIconEnabled = renderingContext.Control.IsIconEnabled();

            if (isIconEnabled)
            {
                icon = GetIcon(renderingContext);
            }

            var anchorClass = CssClassCommand;

            if (icon != null)
            {
                anchorClass += " " + CssClassHasIcon;
            }
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, anchorClass);

            var isCommandEnabled = IsCommandEnabled(renderingContext);
            var command          = GetCommand(renderingContext, isCommandEnabled);

            command.RenderBegin(renderingContext.Writer, RenderingFeatures, postBackEvent, onClick, objectID, null);

            if (icon != null)
            {
                icon.Render(renderingContext.Writer, renderingContext.Control);
            }

            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, GetCssClassInnerContent(renderingContext));
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
            label.RenderControl(renderingContext.Writer);
            renderingContext.Writer.RenderEndTag();

            renderingContext.Control.Command.RenderEnd(renderingContext.Writer);
        }
        /// <summary>
        /// Renders a command control as link with an icon, a text or both.
        /// </summary>
        /// <param name="renderingContext">The <see cref="BocColumnRenderingContext{BocColumnDefinition}"/>.</param>
        /// <param name="originalRowIndex">The zero-based index of the current row in <see cref="IBocList"/></param>
        /// <param name="businessObject">The <see cref="IBusinessObject"/> associated with the current row.</param>
        /// <param name="command">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.RowEditModeCommand"/> that is issued
        /// when the control is clicked. Must not be <see langword="null" />.</param>
        /// <param name="alternateText">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.ResourceIdentifier"/>
        /// specifying which resource to load as alternate text to the icon.</param>
        /// <param name="icon">The icon to render; must not be <see langword="null"/>.
        /// To skip the icon, set <see cref="IconInfo.Url"/> to <see langword="null" />.</param>
        /// <param name="text">The text to render after the icon. May be <see langword="null"/>, in which case no text is rendered.</param>
        protected virtual void RenderCommandControl(
            BocColumnRenderingContext <BocRowEditModeColumnDefinition> renderingContext,
            int originalRowIndex,
            IBusinessObject businessObject,
            BocList.RowEditModeCommand command,
            BocList.ResourceIdentifier alternateText,
            IconInfo icon,
            string text)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);
            ArgumentUtility.CheckNotNull("icon", icon);

            string argument      = renderingContext.Control.GetRowEditCommandArgument(new BocListRow(originalRowIndex, businessObject), command);
            string postBackEvent = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(renderingContext.Control, argument) + ";";
            var    commandItemID = "Column_" + renderingContext.ColumnIndex + "_RowEditCommand_" + command + "_Row_" + originalRowIndex;

            Command c;

            if (!renderingContext.Control.IsReadOnly && renderingContext.Control.HasClientScript)
            {
                c = new Command(CommandType.Event)
                {
                    EventCommand = new Command.EventCommandInfo()
                }
            }
            ;
            else
            {
                c = new Command(CommandType.None);
            }

            c.ItemID       = commandItemID;
            c.OwnerControl = renderingContext.Control;

            c.RenderBegin(renderingContext.Writer, RenderingFeatures, postBackEvent, new string[0], c_onCommandClickScript, null);

            bool hasIcon = icon.HasRenderingInformation;
            bool hasText = !string.IsNullOrEmpty(text);

            if (hasIcon && hasText)
            {
                icon.Render(renderingContext.Writer, renderingContext.Control);
                renderingContext.Writer.Write(c_whiteSpace);
            }
            else if (hasIcon)
            {
                bool hasAlternateText = !string.IsNullOrEmpty(icon.AlternateText);
                if (!hasAlternateText)
                {
                    icon.AlternateText = renderingContext.Control.GetResourceManager().GetString(alternateText);
                }

                icon.Render(renderingContext.Writer, renderingContext.Control);
            }
            if (hasText)
            {
                renderingContext.Writer.Write(text); // Do not HTML encode.
            }
            c.RenderEnd(renderingContext.Writer);
        }