private void RenderItem(HtmlTextWriter writer, object dataItem, int index) { if (_binding == null) { return; } var item = new SliderItem() { Url = BindingUtility.FormatBindingValue(_binding.Url, dataItem), ImageUrl = BindingUtility.FormatBindingValue(_binding.ImageUrl, dataItem), Title = BindingUtility.FormatBindingValue(_binding.Title, dataItem), Description = BindingUtility.FormatBindingValue(_binding.Description, dataItem), }; writer.RenderBeginTag(HtmlTextWriterTag.Dt); this.RenderItem(writer, item, index); writer.RenderEndTag(); }
protected virtual void OnRender(HtmlTextWriter writer, object dataItem, int index) { if (!string.IsNullOrWhiteSpace(this.Value)) { if (!string.IsNullOrWhiteSpace(this.Name)) { writer.AddAttribute(HtmlTextWriterAttribute.Name, this.Name); } writer.AddAttribute(HtmlTextWriterAttribute.Type, "hidden"); writer.AddAttribute(HtmlTextWriterAttribute.Value, BindingUtility.FormatBindingValue(this.Value, dataItem, true)); if (!string.IsNullOrWhiteSpace(this.ToolTip)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, BindingUtility.FormatBindingValue(this.ToolTip, dataItem, true)); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); } }
private void RenderItem(HtmlTextWriter writer, ToolBarItem item) { if (item.Content != null) { item.Content.InstantiateIn(this); this.RenderChildren(writer); this.Controls.Clear(); return; } if (!string.IsNullOrWhiteSpace(item.Icon)) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "icon icon-" + item.Icon.Trim()); writer.RenderBeginTag(HtmlTextWriterTag.I); writer.RenderEndTag(); } if (!string.IsNullOrWhiteSpace(item.Name)) { writer.AddAttribute(HtmlTextWriterAttribute.Name, item.Name); } if (!string.IsNullOrWhiteSpace(item.ToolTip)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, BindingUtility.FormatBindingValue(item.ToolTip, this.GetBindingSource())); } writer.AddAttribute(HtmlTextWriterAttribute.Class, "toolbar-button"); writer.AddAttribute(HtmlTextWriterAttribute.Href, string.IsNullOrWhiteSpace(item.Url) ? Utility.EmptyLink : BindingUtility.FormatBindingValue(item.Url, this.GetBindingSource())); writer.RenderBeginTag(HtmlTextWriterTag.A); if (!string.IsNullOrEmpty(item.Text)) { writer.WriteEncodedText(item.Text); } writer.RenderEndTag(); }
protected override void RenderEndTag(HtmlTextWriter writer) { //调用基类同名方法 base.RenderEndTag(writer); if (!string.IsNullOrWhiteSpace(this.Icon)) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "icon " + this.Icon.Trim().ToLowerInvariant()); writer.RenderBeginTag(HtmlTextWriterTag.I); writer.RenderEndTag(); } if (_button != null) { if (!string.IsNullOrWhiteSpace(_button.Id)) { writer.AddAttribute(HtmlTextWriterAttribute.Id, _button.Id); } if (string.IsNullOrWhiteSpace(_button.Url)) { writer.AddAttribute(HtmlTextWriterAttribute.Href, Utility.EmptyLink); } else { var url = BindingUtility.FormatBindingValue(_button.Url, this.GetBindingSource()); if (string.IsNullOrWhiteSpace(url)) { url = Utility.EmptyLink; } else { writer.AddAttribute(HtmlTextWriterAttribute.Target, url); } writer.AddAttribute(HtmlTextWriterAttribute.Href, url); } var cssClass = "ui icon basic button"; if (!string.IsNullOrWhiteSpace(_button.CssClass)) { cssClass = Utility.ResolveCssClass(_button.CssClass, () => cssClass); } writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass); writer.RenderBeginTag(HtmlTextWriterTag.A); if (!string.IsNullOrWhiteSpace(_button.Icon)) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "icon " + _button.Icon.ToString().ToLowerInvariant()); writer.RenderBeginTag(HtmlTextWriterTag.I); writer.RenderEndTag(); } if (!string.IsNullOrWhiteSpace(_button.Text)) { writer.WriteEncodedText(_button.Text); } writer.RenderEndTag(); } }
protected override void Render(HtmlTextWriter writer) { if (_panels.Count < 1) { return; } if (!string.IsNullOrWhiteSpace(this.ID)) { writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ID); } writer.AddAttribute(HtmlTextWriterAttribute.Class, "tabStrip"); writer.RenderBeginTag(HtmlTextWriterTag.Div); //生成头部元素(开始) writer.RenderBeginTag(HtmlTextWriterTag.Dl); //获取所有可见的面板 var visiblePanels = _panels.GetVisiblePanels(); foreach (var panel in visiblePanels) { if (string.Equals(panel.Name, this.SelectedPanel, StringComparison.OrdinalIgnoreCase)) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "active"); } writer.RenderBeginTag(HtmlTextWriterTag.Dt); writer.AddAttribute(HtmlTextWriterAttribute.Href, "#" + panel.Name); if (!string.IsNullOrEmpty(panel.ToolTip)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, BindingUtility.FormatBindingValue(panel.ToolTip, this.GetBindingSource())); } //生成选项面板的头部标签的开始部分 writer.RenderBeginTag(HtmlTextWriterTag.A); if (!string.IsNullOrEmpty(panel.Title)) { writer.WriteEncodedText(BindingUtility.FormatBindingValue(panel.Title, this.GetBindingSource())); } //生成选项面板的头部标签的结束部分 writer.RenderEndTag(); writer.RenderEndTag(); //生成选项面板的注释内容 if (!string.IsNullOrWhiteSpace(panel.Description)) { writer.RenderBeginTag(HtmlTextWriterTag.Dd); writer.WriteEncodedText(BindingUtility.FormatBindingValue(panel.Description, this.GetBindingSource())); writer.RenderEndTag(); } } //生成头部元素(结束) writer.RenderEndTag(); foreach (var panel in visiblePanels) { if (string.Equals(panel.Name, this.SelectedPanel, StringComparison.OrdinalIgnoreCase)) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "active"); } writer.AddAttribute(HtmlTextWriterAttribute.Id, panel.Name); writer.RenderBeginTag(HtmlTextWriterTag.Div); if (panel.Content != null) { panel.Content.InstantiateIn(this); this.RenderChildren(writer); this.Controls.Clear(); } writer.RenderEndTag(); } writer.RenderEndTag(); //调用基类同名方法 base.Render(writer); }
private void SetBinding() { if (_binding == null || this.DataSource == null) { return; } IEnumerable dataSource = this.DataSource as IEnumerable; if (dataSource == null) { return; } if (this.Type == ChartType.Pie) { foreach (var dataItem in dataSource) { this.Points.Add(new ChartPoint() { Title = BindingUtility.FormatBindingValue(_binding.TitleMember, dataItem), Value = Zongsoft.Common.Convert.ConvertValue <decimal>(BindingUtility.GetBindingValue(_binding.ValueMember, dataItem)), }); } } else { Dictionary <string, List <decimal> > lines = new Dictionary <string, List <decimal> >(StringComparer.OrdinalIgnoreCase); foreach (var dataItem in dataSource) { string key = BindingUtility.FormatBindingValue(_binding.TitleMember, dataItem); List <decimal> values; decimal v = Zongsoft.Common.Convert.ConvertValue <decimal>(BindingUtility.GetBindingValue(_binding.ValueMember, dataItem)); if (lines.TryGetValue(key, out values)) { values.Add(v); } else { values = new List <decimal>(); values.Add(v); lines[key] = values; } if (!string.IsNullOrWhiteSpace(_binding.SerieMember)) { string serie = BindingUtility.FormatBindingValue(_binding.SerieMember, dataItem); if (!this.Series.Contains(serie)) { this.Series.Add(new ChartSerie() { Name = serie, Title = serie, }); } } } foreach (var entry in lines) { this.Lines.Add(new ChartLine() { Name = entry.Key, Title = entry.Key, Values = entry.Value.ToArray(), }); } } }
private int RenderDataItems(HtmlTextWriter writer, int index) { if (this.DataSource == null) { return(index); } var dataSource = this.DataSource as IEnumerable; if (dataSource == null) { var item = new ComboBoxItem() { Value = BindingUtility.FormatBindingValue(_binding != null ? _binding.ValueMember : string.Empty, this.DataSource, true), Text = BindingUtility.FormatBindingValue(_binding != null ? _binding.TextMember : string.Empty, this.DataSource, true), Description = BindingUtility.FormatBindingValue(_binding != null ? _binding.DescriptionMember : string.Empty, this.DataSource, true), Icon = BindingUtility.FormatBindingValue(_binding != null ? _binding.IconMember : string.Empty, this.DataSource, true), }; var isSelected = this.IsSelected(index, item.Value); if (isSelected) { _selectedItem = item; } if (_itemTemplate == null) { item.ToHtmlString(writer, this.RenderMode, isSelected); } else { this.RenderItemTemplate(writer, item.Value, this.DataSource, index, isSelected); } } else { foreach (object dataItem in dataSource) { var item = new ComboBoxItem() { Value = BindingUtility.FormatBindingValue(_binding != null ? _binding.ValueMember : string.Empty, dataItem, true), Text = BindingUtility.FormatBindingValue(_binding != null ? _binding.TextMember : string.Empty, dataItem, true), Description = BindingUtility.FormatBindingValue(_binding != null ? _binding.DescriptionMember : string.Empty, dataItem, true), Icon = BindingUtility.FormatBindingValue(_binding != null ? _binding.IconMember : string.Empty, dataItem, true), }; var isSelected = this.IsSelected(index, item.Value); if (isSelected) { _selectedItem = item; } if (_itemTemplate == null) { item.ToHtmlString(writer, this.RenderMode, isSelected); } else { this.RenderItemTemplate(writer, item.Value, dataItem, index, isSelected); } } } return(++index); }
protected override void OnRender(HtmlTextWriter writer, object dataItem, int index) { if (!string.IsNullOrWhiteSpace(_navigateUrl)) { string navigateUrl = BindingUtility.FormatBindingValue(_navigateUrl, dataItem, true); string navigateTitle = BindingUtility.FormatBindingValue(_navigateTitle, dataItem, true); string navigateCssClass = BindingUtility.FormatBindingValue(_navigateCssClass, dataItem, true); if (navigateUrl == null) { writer.AddAttribute(HtmlTextWriterAttribute.Href, Utility.EmptyLink); } else { writer.AddAttribute(HtmlTextWriterAttribute.Href, navigateUrl); } if (!string.IsNullOrWhiteSpace(navigateTitle)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, navigateTitle); } if (!string.IsNullOrWhiteSpace(navigateCssClass)) { writer.AddAttribute(HtmlTextWriterAttribute.Class, navigateCssClass); } writer.RenderBeginTag(HtmlTextWriterTag.A); } if (!string.IsNullOrWhiteSpace(_imageUrl)) { string imageUrl = BindingUtility.FormatBindingValue(_imageUrl, dataItem, true); if (!string.IsNullOrWhiteSpace(imageUrl)) { writer.AddAttribute(HtmlTextWriterAttribute.Src, imageUrl); string imageTitle = BindingUtility.FormatBindingValue(_imageTitle, dataItem, true); if (!string.IsNullOrWhiteSpace(imageTitle)) { writer.AddAttribute(HtmlTextWriterAttribute.Alt, imageTitle); } writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); } } string text = BindingUtility.FormatBindingValue(_text ?? this.Name, dataItem, true); if (string.IsNullOrEmpty(text)) { text = this.NullText; } if (string.Equals(text, "true", StringComparison.OrdinalIgnoreCase) || string.Equals(text, "false", StringComparison.OrdinalIgnoreCase)) { writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox"); writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); if (string.Equals(text, "true", StringComparison.OrdinalIgnoreCase)) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); } else { if (string.IsNullOrEmpty(text)) { writer.Write(" "); } else { writer.WriteEncodedText(text); } } if (!string.IsNullOrWhiteSpace(_navigateUrl)) { writer.RenderEndTag(); } //调用基类同名方法 base.OnRender(writer, dataItem, index); }