Exemple #1
0
        protected override void RenderContent(HtmlTextWriter writer)
        {
            foreach (ToolBarItem item in _items)
            {
                if (!item.Visible)
                {
                    continue;
                }

                writer.RenderBeginTag(HtmlTextWriterTag.Dt);

                if (!item.IsEmpty())
                {
                    this.RenderItem(writer, item);
                }

                writer.RenderEndTag();

                if (!string.IsNullOrWhiteSpace(item.Description))
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Dd);
                    writer.WriteEncodedText(BindingUtility.FormatBindingValue(item.Description, this.GetBindingSource()));
                    writer.RenderEndTag();
                }
            }
        }
Exemple #2
0
        public static string GetDataValue(object dataItem, string names)
        {
            if (dataItem == null)
            {
                return(string.Empty);
            }

            if (string.IsNullOrWhiteSpace(names))
            {
                return(string.Empty);
            }

            string result = string.Empty;

            string[] keys = names.Split(',');

            foreach (string key in keys)
            {
                if (string.IsNullOrWhiteSpace(key))
                {
                    continue;
                }

                result += string.Format("{0},", BindingUtility.GetBindingValue(key.Trim(), dataItem, null));
            }

            if (string.IsNullOrWhiteSpace(result))
            {
                return(string.Empty);
            }
            else
            {
                return(result.TrimEnd(','));
            }
        }
Exemple #3
0
        protected override void RenderContent(HtmlTextWriter writer)
        {
            foreach (var child in this.Controls)
            {
                var literalControl = child as LiteralControl;

                if (literalControl != null)
                {
                    literalControl.Text = BindingUtility.FormatBindingValue(literalControl.Text, BindingUtility.GetBindingSource(literalControl));
                }
            }

            if (!string.IsNullOrWhiteSpace(this.Text))
            {
                if (this.TextEncoded)
                {
                    writer.WriteEncodedText(this.Text);
                }
                else
                {
                    writer.Write(this.Text);
                }
            }

            //调用基类同名方法(生成子控件集)
            base.RenderContent(writer);
        }
        protected override void OnRender(HtmlTextWriter writer, object dataItem, int index)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Name, _commandType.ToString());
            writer.AddAttribute(HtmlTextWriterAttribute.Href, BindingUtility.FormatBindingValue(_arguments, dataItem, true));
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.WriteEncodedText(BindingUtility.FormatBindingValue(_text, dataItem, true));
            writer.RenderEndTag();

            //调用基类同名方法
            base.OnRender(writer, dataItem, index);
        }
Exemple #5
0
        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();
            }
        }
Exemple #7
0
        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();
        }
Exemple #8
0
        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();
            }
        }
Exemple #9
0
        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);
        }
Exemple #10
0
 internal protected object GetBindingSource()
 {
     return(BindingUtility.GetBindingSource(this));
 }
Exemple #11
0
        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(),
                    });
                }
            }
        }
Exemple #12
0
        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);
        }
Exemple #13
0
        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("&nbsp;");
                }
                else
                {
                    writer.WriteEncodedText(text);
                }
            }

            if (!string.IsNullOrWhiteSpace(_navigateUrl))
            {
                writer.RenderEndTag();
            }

            //调用基类同名方法
            base.OnRender(writer, dataItem, index);
        }