void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                if (TagKey == HtmlTextWriterTag.Button)
                {
                    Attributes.Add("name", EwfPage.ButtonElementName);
                    Attributes.Add("value", "v");
                    Attributes.Add("type", usesSubmitBehavior ? "submit" : "button");
                }

                FormAction action = postBackAction;
                action.AddToPageIfNecessary();

                if (ConfirmationWindowContentControl != null)
                {
                    if (usesSubmitBehavior)
                    {
                        throw new ApplicationException("PostBackButton cannot be the submit button and also have a confirmation message.");
                    }
                    confirmationWindow = new ModalWindow(this, ConfirmationWindowContentControl, title: "Confirmation", postBack: postBackAction.PostBack);
                }
                else if (!usesSubmitBehavior)
                {
                    PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, action.GetJsStatements() + " return false"); }
                }
                ;

                CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
                ActionControlStyle.SetUpControl(this, "");
            });
        }
예제 #2
0
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace(CheckBoxListCssElementCreator.CssClass);

            var table = new DynamicTable {
                Caption = caption
            };

            if (includeSelectAndDeselectAllButtons)
            {
                table.AddActionLink(new ActionButtonSetup("Select All", new CustomButton(() => string.Format(@"toggleCheckBoxes( '{0}', true )", ClientID))));
                table.AddActionLink(new ActionButtonSetup("Deselect All", new CustomButton(() => string.Format(@"toggleCheckBoxes( '{0}', false )", ClientID))));
            }

            var itemsPerColumn = (int)Math.Ceiling((decimal)items.Count() / numberOfColumns);
            var cells          = new List <EwfTableCell>();

            for (byte i = 0; i < numberOfColumns; i += 1)
            {
                var maxIndex = Math.Min((i + 1) * itemsPerColumn, items.Count());
                var place    = new PlaceHolder();
                for (var j = i * itemsPerColumn; j < maxIndex; j += 1)
                {
                    var item     = items.ElementAt(j);
                    var checkBox = new BlockCheckBox(selectedItemIds.Contains(item.Id), label: item.Label, highlightWhenChecked: true, postBack: postBack);
                    place.Controls.Add(checkBox);
                    checkBoxesByItem.Add(item, checkBox);
                }
                cells.Add(place);
            }
            table.AddRow(cells.ToArray());
            Controls.Add(table);
        }
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);

                textBox = new EwfTextBox(
                    value.HasValue ? value.Value.ToMonthDayYearString() + " " + value.Value.ToHourAndMinuteString() : "",
                    disableBrowserAutoComplete: true,
                    autoPostBack: autoPostBack);
                Controls.Add(new ControlLine(textBox, getIconButton()));

                min = DateTime.MinValue;
                max = DateTime.MaxValue;
                if (constrainToSqlSmallDateTimeRange)
                {
                    min = Validator.SqlSmallDateTimeMinValue;
                    max = Validator.SqlSmallDateTimeMaxValue;
                }
                if (minDate.HasValue && minDate.Value > min)
                {
                    min = minDate.Value;
                }
                if (maxDate.HasValue && maxDate.Value < max)
                {
                    max = maxDate.Value;
                }

                if (ToolTip != null || ToolTipControl != null)
                {
                    new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
                }
            });
        }
예제 #4
0
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);

            if (minuteInterval < 30)
            {
                textBox = new EwfTextBox(value.HasValue ? value.Value.ToTimeOfDayHourAndMinuteString() : "", disableBrowserAutoComplete: true, autoPostBack: autoPostBack);
                Controls.Add(new ControlLine(textBox, getIconButton()));
            }
            else
            {
                var minuteValues = new List <int>();
                for (var i = 0; i < 60; i += minuteInterval)
                {
                    minuteValues.Add(i);
                }
                selectList = SelectList.CreateDropDown(
                    from hour in Enumerable.Range(0, 24)
                    from minute in minuteValues
                    let timeSpan = new TimeSpan(hour, minute, 0)
                                   select SelectListItem.Create <TimeSpan?>(timeSpan, timeSpan.ToTimeOfDayHourAndMinuteString()),
                    value,
                    width: Unit.Percentage(100),
                    placeholderIsValid: true,
                    placeholderText: "",
                    autoPostBack: autoPostBack);
                Controls.Add(selectList);
            }

            if (ToolTip != null || ToolTipControl != null)
            {
                new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
            }
        }
예제 #5
0
        void ControlTreeDataLoader.LoadData()
        {
            EwfPage.Instance.AddDisplayLink(this);

            // NOTE: Currently this hidden field will always be persisted in page state whether the page cares about that or not. We should put this decision into the
            // hands of the page, maybe by making ToggleButton sort of like a form control such that it takes a boolean value in its constructor and allows access to
            // its post back value.
            var controlsToggled = false;

            EwfHiddenField.Create(
                this,
                EwfPage.Instance.PageState.GetValue(this, pageStateKey, false).ToString(),
                postBackValue => controlsToggled = getControlsToggled(postBackValue),
                EwfPage.Instance.DataUpdate,
                out controlsToggledHiddenFieldValueGetter,
                out controlsToggledHiddenFieldClientIdGetter);
            EwfPage.Instance.DataUpdate.AddModificationMethod(
                () => AppRequestState.AddNonTransactionalModificationMethod(() => EwfPage.Instance.PageState.SetValue(this, pageStateKey, controlsToggled)));

            if (TagKey == HtmlTextWriterTag.Button)
            {
                PostBackButton.AddButtonAttributes(this);
            }
            this.AddJavaScriptEventScript(JsWritingMethods.onclick, handlerName + "()");
            CssClass    = CssClass.ConcatenateWithSpace("ewfClickable");
            textControl = ActionControlStyle.SetUpControl(this, "", width, height, w => base.Width = w);
        }
예제 #6
0
        void ControlTreeDataLoader.LoadData()
        {
            if (TagKey == HtmlTextWriterTag.Button)
            {
                Attributes.Add("name", EwfPage.ButtonElementName);
                Attributes.Add("value", "v");
                Attributes.Add("type", usesSubmitBehavior ? "submit" : "button");
            }

            EwfPage.Instance.AddPostBack(postBack);

            if (ConfirmationWindowContentControl != null)
            {
                if (usesSubmitBehavior)
                {
                    throw new ApplicationException("PostBackButton cannot be the submit button and also have a confirmation message.");
                }
                confirmationWindow = new ModalWindow(ConfirmationWindowContentControl, title: "Confirmation", postBack: postBack);
            }
            else if (!usesSubmitBehavior)
            {
                PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, GetPostBackScript(postBack)); }
            }
            ;

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            ActionControlStyle.SetUpControl(this, "", width, height, setWidth);
        }
 void ControlTreeDataLoader.LoadData()
 {
     CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);
     Controls.Add(new Literal {
         Text = html
     });
 }
예제 #8
0
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace(!expanded.HasValue || expanded.Value ? expandedClass : closedClass);

            var contentBlock = new Block(childControls)
            {
                CssClass = headingAndContentClass
            };

            if (heading.Length > 0)
            {
                var headingControl = new Heading(heading.GetLiteralControl())
                {
                    Level = headingLevel, CssClass = headingAndContentClass, ExcludesBuiltInCssClass = true
                };
                this.AddControlsReturnThis(expanded.HasValue
                                                                ? new ToggleButton(this.ToSingleElementArray(),
                                                                                   new CustomActionControlStyle(
                                                                                       c =>
                                                                                       c.AddControlsReturnThis(new EwfLabel {
                    Text = "Click to Expand", CssClass = closedClass
                },
                                                                                                               new EwfLabel {
                    Text = "Click to Close", CssClass = expandedClass
                },
                                                                                                               headingControl)),
                                                                                   toggleClasses: new[] { closedClass, expandedClass }) as Control
                                                                : new Block(headingControl));
            }
            this.AddControlsReturnThis(contentBlock);
        }
예제 #9
0
 void ControlTreeDataLoader.LoadData()
 {
     if (!ExcludesBuiltInCssClass)
     {
         CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);
     }
     this.AddControlsReturnThis(markupControls.Concat(codeControls));
 }
예제 #10
0
        void ControlTreeDataLoader.LoadData()
        {
            CssClass =
                CssClass.ConcatenateWithSpace(
                    allStylesBothStatesClass + " " +
                    (style == SectionStyle.Normal ? getSectionClass(normalClosedClass, normalExpandedClass) : getSectionClass(boxClosedClass, boxExpandedClass)));

            if (heading.Any())
            {
                var headingControls =
                    new WebControl(HtmlTextWriterTag.H1)
                {
                    CssClass = headingClass
                }.AddControlsReturnThis(heading.GetLiteralControl())
                .ToSingleElementArray()
                .Concat(postHeadingControls);
                if (expanded.HasValue)
                {
                    var toggleClasses = style == SectionStyle.Normal ? new[] { normalClosedClass, normalExpandedClass } : new[] { boxClosedClass, boxExpandedClass };

                    var headingContainer =
                        new Block(
                            new[] { new EwfLabel {
                                        Text = "Click to Expand", CssClass = closeClass
                                    }, new EwfLabel {
                                        Text = "Click to Close", CssClass = expandClass
                                    } }.Concat(
                                headingControls).ToArray())
                    {
                        CssClass = headingClass
                    };
                    var actionControlStyle = new CustomActionControlStyle(c => c.AddControlsReturnThis(headingContainer));

                    this.AddControlsReturnThis(
                        disableStatePersistence
                                                        ? new CustomButton(() => "$( '#" + ClientID + "' ).toggleClass( '" + StringTools.ConcatenateWithDelimiter(" ", toggleClasses) + "', 200 )")
                    {
                        ActionControlStyle = actionControlStyle
                    }
                                                        : new ToggleButton(this.ToSingleElementArray(), actionControlStyle, toggleClasses: toggleClasses) as Control);
                }
                else
                {
                    var headingContainer = new Block(headingControls.ToArray())
                    {
                        CssClass = headingClass
                    };
                    this.AddControlsReturnThis(new Block(headingContainer));
                }
            }
            if (contentControls.Any())
            {
                this.AddControlsReturnThis(new Block(contentControls.ToArray())
                {
                    CssClass = contentClass
                });
            }
        }
예제 #11
0
 /// <summary>
 /// Renders this control after applying the appropriate CSS classes.
 /// </summary>
 protected override void Render(HtmlTextWriter writer)
 {
     if (isStandard)
     {
         CssClass       = CssClass.ConcatenateWithSpace("ewfStandardDynamicTable");
         table.CssClass = table.CssClass.ConcatenateWithSpace("ewfStandard");
     }
     base.Render(writer);
 }
예제 #12
0
 /// <summary>
 /// Renders this control after applying the appropriate CSS classes.
 /// </summary>
 protected override void Render(HtmlTextWriter writer)
 {
     CssClass = CssClass.ConcatenateWithSpace("textBoxWrapper");
     if (Width.Type == UnitType.Pixel && Width.Value > 0)              // Only modify width if it has been explicitly set in pixels.
     {
         Width = (int)Width.Value - 6;
     }
     base.Render(writer);
 }
예제 #13
0
 void ControlTreeDataLoader.LoadData()
 {
     if (TagKey == HtmlTextWriterTag.Button)
     {
         PostBackButton.AddButtonAttributes(this);
     }
     CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
     ActionControlStyle.SetUpControl(this, "", Unit.Empty, Unit.Empty, width => { });
 }
예제 #14
0
 /// <summary>
 /// Renders this control after applying the appropriate CSS classes.
 /// </summary>
 protected override void Render(HtmlTextWriter writer)
 {
     CssClass = CssClass.ConcatenateWithSpace("ewfControlList");
     if (IsStandard)
     {
         CssClass = CssClass.ConcatenateWithSpace("ewfStandard");
     }
     base.Render(writer);
 }
        void ControlTreeDataLoader.LoadData()
        {
            EwfPage.Instance.AddDisplayLink(this);

            if (TagKey == HtmlTextWriterTag.Button)
            {
                PostBackButton.AddButtonAttributes(this);
            }
            this.AddJavaScriptEventScript(JsWritingMethods.onclick, handlerName + "()");
            CssClass    = CssClass.ConcatenateWithSpace("ewfClickable");
            textControl = ActionControlStyle.SetUpControl(this, "");
        }
예제 #16
0
        /// <summary>
        /// Checks that WindowToLaunch has been set and applies the attributes for this LaunchWindowLink.
        /// </summary>
        void ControlTreeDataLoader.LoadData()
        {
            if (TagKey == HtmlTextWriterTag.Button)
            {
                PostBackButton.AddButtonAttributes(this);
            }
            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            ActionControlStyle.SetUpControl(this, "");

            if (ToolTip != null || ToolTipControl != null)
            {
                new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
            }
        }
        void ControlTreeDataLoader.LoadData()
        {
            if (hideIfEmpty && !formItems.Any())
            {
                Visible = false;
                return;
            }

            CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);

            var theButton = button;

#pragma warning disable 618 // Disables obsolete warning
            if (IncludeButtonWithThisText != null)
            {
                theButton = new PostBackButton(EwfPage.Instance.DataUpdatePostBack, new ButtonActionControlStyle(IncludeButtonWithThisText));
            }
#pragma warning restore 618
            if (theButton != null)
            {
                theButton.ActionControlStyle = new ButtonActionControlStyle(theButton.ActionControlStyle.Text);
                theButton.Width = Unit.Percentage(50);

                // We need to do logic to get the button to be on the right of the row.
                if (useFormItemListMode && numberOfColumns.HasValue)
                {
                    var widthOfLastRowWithButton     = getFormItemRows(formItems, numberOfColumns.Value).Last().Sum(fi => getCellSpan(fi)) + defaultFormItemCellSpan;
                    var numberOfPlaceholdersRequired = 0;
                    if (widthOfLastRowWithButton < numberOfColumns.Value)
                    {
                        numberOfPlaceholdersRequired = numberOfColumns.Value - widthOfLastRowWithButton;
                    }
                    if (widthOfLastRowWithButton > numberOfColumns.Value)
                    {
                        numberOfPlaceholdersRequired = numberOfColumns.Value - ((widthOfLastRowWithButton - numberOfColumns.Value) % numberOfColumns.Value);
                    }

                    numberOfPlaceholdersRequired.Times(() => formItems.Add(getPlaceholderFormItem()));
                }
                formItems.Add(
                    FormItem.Create(
                        "",
                        theButton,
                        textAlignment: TextAlignment.Right,
                        cellSpan: defaultFormItemCellSpan));
            }
            Controls.Add(useFormItemListMode ? getTableForFormItemList() : getTableForFormItemTable());
        }
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);
            var controlStack = ControlStack.Create(false);

            if (label != null)
            {
                controlStack.AddControls(label);
            }
            if (validation != null)
            {
                controlStack.AddModificationErrorItem(validation, new ListErrorDisplayStyle());
            }
            controlStack.AddControls(new PlaceHolder().AddControlsReturnThis(wrappedControls));
            Controls.Add(controlStack);
        }
예제 #19
0
        void ControlTreeDataLoader.LoadData()
        {
            var url = "";

            if (destinationResourceInfo != null && !(destinationResourceInfo.AlternativeMode is DisabledResourceMode))
            {
                url = destinationResourceInfo.GetUrl();
                Attributes.Add("href", this.GetClientUrl(url));
            }

            if (isPostBackButton && url.Any())
            {
                var postBack = GetLinkPostBack(destinationResourceInfo);
                EwfPage.Instance.AddPostBack(postBack);
                PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, PostBackButton.GetPostBackScript(postBack)); };
            }
            if (navigatesInNewWindow)
            {
                Attributes.Add("target", "_blank");
            }
            if (popUpWindowSettings != null && url.Any())
            {
                this.AddJavaScriptEventScript(JsWritingMethods.onclick, JsWritingMethods.GetPopUpWindowScript(url, this, popUpWindowSettings) + " return false");
            }
            if (navigatesInOpeningWindow && (destinationResourceInfo == null || url.Any()))
            {
                var openingWindowNavigationScript = destinationResourceInfo != null ? "opener.document.location = '" + this.GetClientUrl(url) + "'; " : "";
                this.AddJavaScriptEventScript(JsWritingMethods.onclick, openingWindowNavigationScript + "window.close(); return false");
            }

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            if (destinationResourceInfo != null && destinationResourceInfo.AlternativeMode is NewContentResourceMode)
            {
                CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.NewContentClass);
            }
            ActionControlStyle.SetUpControl(this, url, width, height, setWidth);

            if (destinationResourceInfo != null && destinationResourceInfo.AlternativeMode is DisabledResourceMode)
            {
                var message = (destinationResourceInfo.AlternativeMode as DisabledResourceMode).Message;
                new ToolTip(EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(message.Any() ? message : Translation.ThePageYouRequestedIsDisabled), this);
            }
            else if (toolTip != null || toolTipControl != null)
            {
                new ToolTip(toolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(toolTip), this);
            }
        }
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);
            var controlStack = ControlStack.Create(false);

            if (label != null)
            {
                controlStack.AddControls(label);
            }
            if (validation != null)
            {
                controlStack.AddModificationErrorItem(
                    validation,
                    errors => ErrorMessageControlListBlockStatics.CreateErrorMessageListBlock(errors).ToSingleElementArray());
            }
            controlStack.AddControls(new PlaceHolder().AddControlsReturnThis(wrappedControls));
            Controls.Add(controlStack);
        }
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);

            var cells = from i in ItemsSeparatedWithPipe?separateControls(items) : items
                            select new TableCell
            {
                CssClass = StringTools.ConcatenateWithDelimiter(
                    " ",
                    TableCssElementCreator.AllCellAlignmentsClass.ClassName,
                    tableCellVerticalAlignmentClass(VerticalAlignment),
                    CssElementCreator.ItemCssClass)
            }

            .AddControlsReturnThis(i);

            row.Cells.AddRange(cells.ToArray());
        }
        void ControlTreeDataLoader.LoadData()
        {
            CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);
            var pagePath = EwfPage.Instance.InfoAsBaseType.ResourcePath;

            foreach (var resource in pagePath.Take(pagePath.Count - 1))
            {
                Controls.Add(EwfLink.Create(resource, new ButtonActionControlStyle(resource.ResourceFullName, buttonSize: ButtonSize.ShrinkWrap)));
                Controls.Add(new PlaceHolder().AddControlsReturnThis(ResourceInfo.ResourcePathSeparator.ToComponents().GetControls()));
            }
            if (pageName != null)
            {
                Controls.Add(pageName);
            }
            else if (Controls.Count > 0)
            {
                Controls.RemoveAt(Controls.Count - 1);
            }
        }
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                if (hideIfEmpty && !formItems.Any())
                {
                    Visible = false;
                    return;
                }

                CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);
                if (IncludeButtonWithThisText != null)
                {
                    // We need to do logic to get the button to be on the right of the row.
                    if (useFormItemListMode && numberOfColumns.HasValue)
                    {
                        var widthOfLastRowWithButton     = getFormItemRows(formItems, numberOfColumns.Value).Last().Sum(getCellSpan) + defaultFormItemCellSpan;
                        var numberOfPlaceholdersRequired = 0;
                        if (widthOfLastRowWithButton < numberOfColumns.Value)
                        {
                            numberOfPlaceholdersRequired = numberOfColumns.Value - widthOfLastRowWithButton;
                        }
                        if (widthOfLastRowWithButton > numberOfColumns.Value)
                        {
                            numberOfPlaceholdersRequired = numberOfColumns.Value - ((widthOfLastRowWithButton - numberOfColumns.Value) % numberOfColumns.Value);
                        }

                        numberOfPlaceholdersRequired.Times(() => formItems.Add(getPlaceholderFormItem()));
                    }
                    formItems.Add(
                        FormItem.Create(
                            "",
                            new PostBackButton(new ButtonActionControlStyle(IncludeButtonWithThisText), postBack: EwfPage.Instance.DataUpdatePostBack)
                    {
                        Width = Unit.Percentage(50)
                    },
                            textAlignment: TextAlignment.Right,
                            cellSpan: defaultFormItemCellSpan));
                }
                Controls.Add(useFormItemListMode ? getTableForFormItemList() : getTableForFormItemTable());
            });
        }
        /// <summary>
        /// Creates a check box list.
        /// </summary>
        public EwfCheckBoxList(
            IEnumerable <SelectListItem <ItemIdType> > items, IEnumerable <ItemIdType> selectedItemIds, string caption = "", bool includeSelectAndDeselectAllButtons = false,
            byte numberOfColumns = 1, FormAction action = null)
        {
            this.items      = items.ToArray();
            selectedItemIds = selectedItemIds.ToArray();

            CssClass = CssClass.ConcatenateWithSpace(CheckBoxListCssElementCreator.CssClass);

            var table = new DynamicTable {
                Caption = caption
            };

            if (includeSelectAndDeselectAllButtons)
            {
                table.AddActionLink(new ActionButtonSetup("Select All", new CustomButton(() => string.Format(@"toggleCheckBoxes( '{0}', true )", ClientID))));
                table.AddActionLink(new ActionButtonSetup("Deselect All", new CustomButton(() => string.Format(@"toggleCheckBoxes( '{0}', false )", ClientID))));
            }

            var itemsPerColumn = (int)Math.Ceiling((decimal)this.items.Count() / numberOfColumns);
            var cells          = new List <EwfTableCell>();

            for (byte i = 0; i < numberOfColumns; i += 1)
            {
                var maxIndex = Math.Min((i + 1) * itemsPerColumn, this.items.Count());
                var place    = new PlaceHolder();
                for (var j = i * itemsPerColumn; j < maxIndex; j += 1)
                {
                    var item     = this.items.ElementAt(j);
                    var checkBox = new BlockCheckBox(
                        selectedItemIds.Contains(item.Id),
                        (postBackValue, validator) => { },
                        label: item.Label,
                        setup: new BlockCheckBoxSetup(highlightedWhenChecked: true, action: action));
                    place.Controls.Add(checkBox);
                    checkBoxesByItem.Add(item, checkBox);
                }
                cells.Add(place);
            }
            table.AddRow(cells.ToArray());
            Controls.Add(table);
        }
예제 #25
0
        void ControlTreeDataLoader.LoadData()
        {
            Attributes.Add("href",
                           "mailto:" +
                           StringTools.ConcatenateWithDelimiter("?",
                                                                ToAddress,
                                                                StringTools.ConcatenateWithDelimiter("&",
                                                                                                     CcAddress.PrependDelimiter("cc="),
                                                                                                     BccAddress.PrependDelimiter("bcc="),
                                                                                                     HttpUtility.UrlEncode(Subject).PrependDelimiter("subject="),
                                                                                                     HttpUtility.UrlEncode(Body).PrependDelimiter("body="))));

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            ActionControlStyle.SetUpControl(this, "", width, height, setWidth);

            if (ToolTip != null || ToolTipControl != null)
            {
                new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
            }
        }
        void ControlTreeDataLoader.LoadData()
        {
            if (toolTipControl == null)
            {
                throw new ApplicationException("ToolTipControl must be set on ToolTipLink");
            }

            if (TagKey == HtmlTextWriterTag.Button)
            {
                PostBackButton.AddButtonAttributes(this);
            }

            // NOTE: When this control is rendered as an anchor, the presence of an onclick attribute is necessary for it to be selected properly by our action
            // control CSS elements. This hack would not be necessary if Telerik used the onclick attribute to open the tool tip.
            this.AddJavaScriptEventScript(JsWritingMethods.onclick, "");

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            ActionControlStyle.SetUpControl(this, "", Unit.Empty, Unit.Empty, width => { });

            new ToolTip(toolTipControl, this, title: ToolTipTitle ?? "", sticky: true);
        }
예제 #27
0
        void ControlTreeDataLoader.LoadData()
        {
            if (!SizesToAvailableWidth)
            {
                Attributes.Add("src", this.GetClientUrl(imageInfo.GetUrl(true, true, false)));
                Attributes.Add("alt", AlternateText ?? "");
            }
            else
            {
                Controls.Add(new EwfImage(imageInfo)
                {
                    IsAutoSizer = true, AlternateText = AlternateText
                });
            }
            CssClass = CssClass.ConcatenateWithSpace(IsAutoSizer ? "ewfAutoSizer" : CssElementCreator.CssClass);

            if (ToolTip != null || ToolTipControl != null)
            {
                new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
            }
        }
 void ControlTreeDataLoader.LoadData()
 {
     CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);
     this.AddControlsReturnThis(wysiwygEditor = new WysiwygHtmlEditor(mod.Html, ckEditorConfiguration: ckEditorConfiguration));
 }
 void ControlTreeDataLoader.LoadData()
 {
     CssClass = CssClass.ConcatenateWithSpace("fa {0}".FormatWith(StringTools.ConcatenateWithDelimiter(" ", classes.ToArray())));
 }
예제 #30
0
        /// <summary>
        /// Creates a chart displaying a supported <see cref="ChartType"/> with the given data. Includes a chart and a table, and allows exporting the data to CSV.
        /// Assuming <paramref name="seriesCollection"/> has multiple elements, draws multiple sets of Y values on the same chart.
        /// </summary>
        /// <param name="setup">The setup object for the chart.</param>
        /// <param name="seriesCollection">The data series collection.</param>
        /// <param name="colors">The colors to use for the data series collection. Pass null for default colors. If you specify your own colors, the number of
        /// colors does not need to match the number of series. If you pass fewer colors than series, the chart will use random colors for the remaining series.
        /// </param>
        public Chart(ChartSetup setup, [NotNull] IEnumerable <DataSeries> seriesCollection, IEnumerable <Color> colors = null)
        {
            seriesCollection = seriesCollection.ToArray();

            var rand = new Random();

            colors = (colors ?? getDefaultColors()).Take(seriesCollection.Count())
                     .Pad(seriesCollection.Count(), () => Color.FromArgb(rand.Next(256), rand.Next(256), rand.Next(256)));

            this.setup = setup;

            CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);

            Func <DataSeries, Color, BaseDataset> datasetSelector;
            OptionsBase options;

            switch (setup.ChartType)
            {
            case ChartType.Line:
                datasetSelector = (series, color) => new Dataset(color, series.Values.TakeLast(setup.MaxXValues));
                options         = new LineOptions {
                    bezierCurve = false
                };
                break;

            case ChartType.Bar:
                datasetSelector = (series, color) => new BaseDataset(color, series.Values.TakeLast(setup.MaxXValues));
                // ReSharper disable once RedundantEmptyObjectOrCollectionInitializer
                options = new BarOptions {
                };
                break;

            default:
                throw new UnexpectedValueException(setup.ChartType);
            }

            var chartData = new ChartData(
                setup.Labels.TakeLast(setup.MaxXValues),
                seriesCollection.Zip(colors, (series, color) => datasetSelector(series, color)).ToArray());

            var canvas = new HtmlGenericControl("canvas");

            switch (setup.ChartType)
            {
            case ChartType.Line:
            case ChartType.Bar:
                canvas.Attributes.Add("height", "400");
                break;

            default:
                throw new UnexpectedValueException(setup.ChartType);
            }
            Controls.Add(canvas);

            if (seriesCollection.Count() > 1)
            {
                this.AddControlsReturnThis(
                    new Section(
                        "Key",
                        new LineList(
                            chartData.datasets.Select(
                                (dataset, i) => (LineListItem) new TrustedHtmlString(
                                    "<div style='display: inline-block; vertical-align: middle; width: 20px; height: 20px; background-color: {0}; border: 1px solid {1};'>&nbsp;</div> {2}"
                                    .FormatWith(dataset.fillColor, dataset.strokeColor, seriesCollection.ElementAt(i).Name)).ToComponent()
                                .ToComponentListItem())).ToCollection(),
                        style: SectionStyle.Box).ToCollection()
                    .GetControls());
            }

            // Remove this when ColumnPrimaryTable supports Excel export.
            var headers   = setup.XAxisTitle.ToCollection().Concat(seriesCollection.Select(v => v.Name));
            var tableData = new List <IEnumerable <object> >(seriesCollection.First().Values.Count());

            for (var i = 0; i < tableData.Capacity; i++)
            {
                var i1 = i;
                tableData.Add(setup.Labels.ElementAt(i1).ToCollection().Concat(seriesCollection.Select(v => v.Values.ElementAt(i1).ToString())));
            }
            var exportAction = getExportAction(headers, tableData);

            var table = ColumnPrimaryTable.Create(tableActions: exportAction.ToCollection(), firstDataFieldIndex: 1)
                        .AddItems(
                EwfTableItem.Create(setup.XAxisTitle.ToCollection().Concat(setup.Labels).Select(i => i.ToCell()).Materialize())
                .ToCollection()
                .Concat(
                    from series in seriesCollection
                    select EwfTableItem.Create(series.Name.ToCell().Concat(from i in series.Values select i.ToString().ToCell()).Materialize()))
                .Materialize());

            this.AddControlsReturnThis(table.ToCollection().GetControls());

            jsInitStatementGetter = () => {
                using (var writer = new StringWriter()) {
                    writer.WriteLine("var canvas = document.getElementById( '{0}' );".FormatWith(canvas.ClientID));
                    writer.WriteLine("canvas.width = $( canvas ).parent().width();");
                    writer.WriteLine(
                        "new Chart( canvas.getContext( '2d' ) ).{0}( {1}, {2} );".FormatWith(
                            setup.ChartType,
                            JsonOps.SerializeObject(chartData),
                            JsonOps.SerializeObject(options)));
                    return(writer.ToString());
                }
            };
        }