예제 #1
0
 private void RenderDropdownButton(BocAutoCompleteReferenceValueRenderingContext renderingContext)
 {
     renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, GetDropDownButtonName(renderingContext));
     renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClassButton);
     renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
     IconInfo.CreateSpacer(ResourceUrlFactory).Render(renderingContext.Writer, renderingContext.Control);
     renderingContext.Writer.RenderEndTag();
 }
예제 #2
0
        private void AssertDropDownButton(XmlNode titleDiv, bool hasTitle)
        {
            var span = titleDiv.GetAssertedChildElement("a", hasTitle ? 1 : 0);

            var image = span.GetAssertedChildElement("img", 0);

            image.AssertAttributeValueEquals("src", IconInfo.CreateSpacer(_resourceUrlFactory).Url);
            image.AssertAttributeValueEquals("alt", "");
        }
예제 #3
0
        private void RegisterInitializationScript(BocRenderingContext <TControl> renderingContext)
        {
            string key = typeof(BocReferenceValueRendererBase <>).FullName + "_InitializeGlobals";

            if (renderingContext.Control.Page.ClientScript.IsClientScriptBlockRegistered(typeof(BocReferenceValueRendererBase <>), key))
            {
                return;
            }

            var nullIcon = IconInfo.CreateSpacer(ResourceUrlFactory);

            var script = new StringBuilder(1000);

            script.Append("BocReferenceValueBase.InitializeGlobals(");
            script.AppendFormat("'{0}'", nullIcon.Url);
            script.Append(");");

            renderingContext.Control.Page.ClientScript.RegisterStartupScriptBlock(
                renderingContext.Control, typeof(BocReferenceValueRendererBase <>), key, script.ToString());
        }
예제 #4
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);
        }
        private void AssertDropDownListSpan(XmlNode contentSpan, AutoPostBack autoPostBack)
        {
            var inputSpan = contentSpan.GetAssertedChildElement("span", 0);

            inputSpan.AssertChildElementCount(0);
            inputSpan.AssertTextNode("TextBox", 0);

            int hiddenFieldIndex = 1;

            if (Control.Enabled)
            {
                var dropDownButton = contentSpan.GetAssertedChildElement("span", 1);
                dropDownButton.AssertAttributeValueEquals("class", "bocAutoCompleteReferenceValueButton");
                dropDownButton.AssertChildElementCount(1);

                var dropDownSpacer = dropDownButton.GetAssertedChildElement("img", 0);
                dropDownSpacer.AssertAttributeValueEquals("src", IconInfo.CreateSpacer(_resourceUrlFactory).Url);
                dropDownSpacer.AssertChildElementCount(0);

                hiddenFieldIndex++;
            }

            var hiddenField = contentSpan.GetAssertedChildElement("input", hiddenFieldIndex);

            hiddenField.AssertAttributeValueEquals("id", c_keyValueName);
            hiddenField.AssertAttributeValueEquals("name", c_keyValueName);
            hiddenField.AssertAttributeValueEquals("type", "hidden");
            if (autoPostBack == AutoPostBack.Enabled)
            {
                hiddenField.AssertAttributeValueEquals("onchange", "PostBackEventReference");
            }
            else
            {
                hiddenField.AssertNoAttribute("onchange");
            }
            hiddenField.AssertChildElementCount(0);
        }
        private void RenderDropdownButton(DropDownMenuRenderingContext renderingContext)
        {
            renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClassDropDownButton);
            if (!HasDefaultTitle(renderingContext) || HasCustomTitle(renderingContext))
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, renderingContext.Control.ClientID + "_DropDownMenuButton");
                if (renderingContext.Control.Enabled)
                {
                    renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Href, "#");
                    renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "return false;");
                }
            }

            if (HasCustomTitle(renderingContext) && HasTitleText(renderingContext))
            {
                renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Title, renderingContext.Control.TitleText);
            }

            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A);

            IconInfo.CreateSpacer(ResourceUrlFactory).Render(renderingContext.Writer, renderingContext.Control);

            renderingContext.Writer.RenderEndTag();
        }
예제 #7
0
        public BusinessObjectWithIdentityProxy[] Search(
            string searchString,
            int?completionSetCount,
            string businessObjectClass,
            string businessObjectProperty,
            string businessObject,
            string args)
        {
            if (searchString.Equals("throw", StringComparison.OrdinalIgnoreCase))
            {
                throw new Exception("Test Exception");
            }

            if (!string.IsNullOrEmpty(args))
            {
                var delay = int.Parse(args);
                Thread.Sleep(delay);
            }

            List <BusinessObjectWithIdentityProxy> persons = new List <BusinessObjectWithIdentityProxy>();

            foreach (Person person in XmlReflectionBusinessObjectStorageProvider.Current.GetObjects(typeof(Person)))
            {
                persons.Add(
                    new BusinessObjectWithIdentityProxy((IBusinessObjectWithIdentity)person)
                {
                    IconUrl = GetUrl(GetIcon((IBusinessObject)person))
                });
            }

            foreach (string value in s_values)
            {
                persons.Add(new BusinessObjectWithIdentityProxy {
                    UniqueIdentifier = "invalid", DisplayName = value, IconUrl = GetUrl(IconInfo.CreateSpacer(ResourceUrlFactory))
                });
            }

            var filteredPersons = persons.FindAll(person => person.DisplayName.StartsWith(searchString, StringComparison.OrdinalIgnoreCase));

            if (filteredPersons.Count == 0)
            {
                filteredPersons = persons.FindAll(person => person.DisplayName.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) != -1);
            }

            filteredPersons.Sort((left, right) => string.Compare(left.DisplayName, right.DisplayName, StringComparison.OrdinalIgnoreCase));

            return(filteredPersons.ToArray());
        }