예제 #1
0
파일: HButton.cs 프로젝트: undyings/Commune
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      {
        DefaultExtensionContainer defaults = new DefaultExtensionContainer(this);
        defaults.Display("inline-block");
        defaults.Cursor(CursorStyle.Pointer);
        CssExt.CssAttribute(defaults, "white-space", "nowrap");
        defaults.OnClick(";");
      }

      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);

      foreach (HStyle pseudo in pseudoClasses)
        HtmlHlp.AddStyleToCss(css, cssClassName, pseudo);
       
      List<object> elements = new List<object>(3);
      {
        elements.Add(h.Span(caption));

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

      return new HEventElement("div", HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray())
      );

      //return h.Div(HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray())
      //);
    }
예제 #2
0
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);

      foreach (HStyle pseudo in pseudoClasses)
        HtmlHlp.AddStyleToCss(css, cssClassName, pseudo);

      List<object> elements = new List<object>();

      elements.Add(h.type("button"));
      elements.Add(h.value(caption));

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

      DefaultExtensionContainer defaults = new DefaultExtensionContainer(this);
      defaults.OnClick(";");
      defaults.Cursor(CursorStyle.Pointer);

      return new HEventElement("input", HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray())
      );

      //return h.Input(HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray())
      //);
    }
예제 #3
0
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      string checkClassName = string.Format("{0}_check", Name);
      string frameClassName = string.Format("{0}_frame", Name);

      HTone innerStyle = new HTone().Display("none");
      HtmlHlp.AddClassToCss(css, checkClassName, innerStyle.CssExtensions);

      HtmlHlp.AddClassToCss(css, frameClassName, frameStyle.CssExtensions);

      HtmlHlp.AddExtensionsToCss(css,
        markStyle.CssExtensions,
        ".{0} input[type=checkbox]:checked ~ .{1}::before ",
        cssClassName, frameClassName
      );

      {
        DefaultExtensionContainer defaults = new DefaultExtensionContainer(this);
        defaults.Display("inline-block");
        defaults.OnClick(string.Format(
          "e.preventDefault(); $('.{0}').is(':checked') ? $('.{0}').prop('checked', false) : $('.{0}').prop('checked', true);",
          checkClassName)
        );
      }

      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);
      foreach (HStyle pseudo in pseudoClasses)
        HtmlHlp.AddStyleToCss(css, cssClassName, pseudo);

      List<object> checkElements = new List<object>();
      checkElements.Add(h.@class(checkClassName));
      checkElements.Add(h.type("checkbox"));
      checkElements.Add(h.data("name", Name));
      checkElements.Add(h.data("id", checkClassName));
      if (value)
        checkElements.Add(h.@checked());

      return h.Div(HtmlHlp.ContentForHElement(this, cssClassName,
        h.Input(checkElements.ToArray()),
        h.Div(h.@class(frameClassName))
      ));
    }
예제 #4
0
    public HElement ToHtml(string cssClassName, StringBuilder css)
    {
      {
        DefaultExtensionContainer defaults = new DefaultExtensionContainer(this);
        defaults.Display("inline-block");
        defaults.OnClick(";");
      }

      HtmlHlp.AddClassToCss(css, cssClassName, CssExtensions);
      foreach (HStyle pseudo in pseudoClasses)
        HtmlHlp.AddStyleToCss(css, cssClassName, pseudo);

      List<object> elements = new List<object>();
      elements.Add(h.type("radio"));
      elements.Add(new HAttribute("name", groupName));
      elements.Add(h.data("name", Name));
      elements.Add(h.data("id", Name));
      if (isChecked)
        elements.Add(h.@checked());

      if (eventHandler != null)
      {
        hevent onevent = HtmlExt.InnerEvent(groupName, "", eventHandler, objectId);
        elements.Add(onevent);

        return new HEventElement("input", HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray()));
      }

      //elements.Add(h.value(objectId));
      //hevent onevent = GetExtended("onevent") as hevent;
      //if (onevent != null)
      //{
      //  elements.Add(onevent);

      //  return new HEventElement("input", HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray()));
      //}

      return h.Input(HtmlHlp.ContentForHElement(this, cssClassName, elements.ToArray()));
    }
예제 #5
0
파일: HButton.cs 프로젝트: undyings/Commune
    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())
      );
    }