Exemple #1
0
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);

      List<object> elements = new List<object>();
 
      string container = GetExtended("container") as string;
      if (!StringHlp.IsEmpty(container))
        elements.Add(h.data("name", container));

      int index = -1;
      foreach (IHtmlControl control in controls)
      {
        index++;

        if (control is IEditExtension)
        {
          DefaultExtensionContainer defaults = new DefaultExtensionContainer((IEditExtension)control);
          defaults.Display("table-cell");
          defaults.VAlign(true);
        }

        string childCssClassName = control.Name;
        if (StringHlp.IsEmpty(childCssClassName))
          childCssClassName = string.Format("{0}_{1}", cssClassName, index + 1);

        HElement element = control.ToHtml(childCssClassName, css);

        bool isHide = (control.GetExtended("hide") as bool?) ?? false;
        if (!isHide)
          elements.Add(element);
      }

      return h.Div(HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray()));
    }
Exemple #2
0
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      DefaultExtensionContainer defaults = new DefaultExtensionContainer(this);
      defaults.VAlign(null);
      defaults.Padding("4px 8px");
      defaults.Display("inline-block");

      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);
      HtmlHlp.AddHoverToCss(css, cssClassName, this);

      return h.Div(HtmlHlp.ContentForHElement(this, cssClassName, caption));
    }
Exemple #3
0
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      {
        DefaultExtensionContainer defaults = new DefaultExtensionContainer(this);
        defaults.Align(null, null);
        defaults.Padding("6px 12px");
        defaults.Display("inline-block");
        defaults.Border("1px", "solid", Color.FromArgb(187, 187, 187), "2px");
        defaults.LinearGradient("to top right", Color.FromArgb(221, 221, 221), Color.FromArgb(241, 241, 241));
        defaults.Cursor(CursorStyle.Pointer);

        defaults.OnClick(";");
      }

      {
        PseudoCssClass hover = GetExtended("hover") as PseudoCssClass;
        if (hover == null)
        {
          hover = new PseudoCssClass(".{0}:hover");
          this.Hover(hover);
        }

        DefaultExtensionContainer defaults = new DefaultExtensionContainer(hover);
        //defaults.Border("1px", "solid", Color.FromArgb(60, 127, 177), "2px");
        //defaults.LinearGradient("to top right", Color.FromArgb(167, 217, 177), Color.FromArgb(232, 246, 253));
        defaults.Border("1px", "solid", Color.FromArgb(170, 170, 170), "2px");
        defaults.LinearGradient("to top right", Color.FromArgb(204, 204, 204), Color.FromArgb(234, 234, 234));
      }

      {
        PseudoCssClass active = GetExtended("active") as PseudoCssClass;
        if (active == null)
        {
          active = new PseudoCssClass(".{0}:active");
          this.WithExtension(new ExtensionAttribute("active", active));
        }

        DefaultExtensionContainer defaults = new DefaultExtensionContainer(active);
        defaults.Border("2px", "double", Color.FromArgb(44, 98, 139), "2px");
        defaults.Padding("5px", "12px", "5px", "10px");
        defaults.LinearGradient("to top right", Color.FromArgb(104, 179, 219), Color.FromArgb(229, 244, 252));
      }


      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);
      HtmlHlp.AddHoverToCss(css, cssClassName, this);
      HtmlHlp.AddPseudoClassToCss(css, "active", cssClassName, this);

      List<object> elements = new List<object>();
      {
        HImage image = GetExtended("innerImage") as HImage;
        if (image != null)
        {
          DefaultExtensionContainer defaults = new DefaultExtensionContainer(image);
          defaults.VAlign(null);
          defaults.Margin("0px", "0px", "2px", "0px");
          defaults.Display("inline");
          //defaults.Align(true);

          elements.Add(image.ToHtml(string.Format("{0}_image", cssClassName), css));

          elements.Add(h.Span(caption));

          //string captionClassName = string.Format("{0}_caption", cssClassName);
          //elements.Add(h.Span(caption, h.@class(captionClassName))
          //);
          //HtmlHlp.AddClassToCss(css, captionClassName,
          //  new CssExtensionAttribute[] { new CssExtensionAttribute("display", "table-cell") });
        }
        else
          elements.Add(caption);

        hevent onevent = GetExtended("onevent") as hevent;
        if (onevent != null)
          elements.Add(onevent);
      }

      return h.Div(HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray())
      );
    }
Exemple #4
0
    /// <summary>
    /// Создает HXPanel
    /// Оборачивает дочерние контролы не являющиеся панелями в HPanel
    /// По умолчанию выставляет всем дочерним панелям VAlign(null)
    /// </summary>
    public static HXPanel RowPanel(params IHtmlControl[] controls)
    {
      IHtmlControl[] panelControls = ArrayHlp.Convert(controls, delegate(IHtmlControl control)
      {
        if (!(control is HPanel || control is HXPanel))
          control = new HPanel(control);
        DefaultExtensionContainer defaults = new DefaultExtensionContainer(control);
        defaults.VAlign(null);
        return control;
      });

      return new HXPanel(panelControls); //.NoWrap();
    }
Exemple #5
0
    public static HXPanel SimpleHeader(params IHtmlControl[] cells)
    {
      foreach (IHtmlControl cell in cells)
      {
        DefaultExtensionContainer defaults = new DefaultExtensionContainer(cell);
        defaults.Align(null);
        defaults.VAlign(null);
        defaults.FontBold();
      }

      return new HXPanel(cells);
    }