Esempio n. 1
0
 public static HElement[] Desktop_Scripts(this HBuilder h, bool isDebug = false)
 {
     return(HDesktopSynchronizer.Scripts(isDebug: isDebug));
 }
Esempio n. 2
0
        HElement HView(List <PinValue <double> > values)
        {
            var s = DateTime.Now.Minute * 60 + DateTime.Now.Second + DateTime.Now.Millisecond / 1000.0;

            var svgNs = "http://www.w3.org/2000/svg";

            return(new HElement("html",
                                new HElement("head",
                                             HDesktopSynchronizer.Scripts(),
                                             new HElement("link",
                                                          new HAttribute("type", "text/css"),
                                                          new HAttribute("rel", "stylesheet"),
                                                          new HAttribute("href", "http://cdnjs.cloudflare.com/ajax/libs/rickshaw/1.3.0/rickshaw.css")
                                                          ),
                                             new HElement("script", new HAttribute("src", "http://cdnjs.cloudflare.com/ajax/libs/d3/3.2.2/d3.js"), ""),
                                             new HElement("script", new HAttribute("src", "http://cdnjs.cloudflare.com/ajax/libs/rickshaw/1.3.0/rickshaw.js"), ""),
                                             h.Css(
                                                 @"
            h1 {font-size:100%;}
            "
                                                 )
                                             ),
                                new HElement("body",
                                             h.Div(
                                                 h.Element("h1", "click"),
                                                 h.style("display:inline-block;"),
                                                 new HElement("div", new HAttribute("onclick", ";"), new HAttribute("data-command", "tt"), "onclick")
                                                 ),
                                             h.Div(
                                                 h.style("display:inline-block;margin:10px;"),
                                                 h.Element("h1", "использование js-init"),
                                                 new HElement("div",
                                                              new HAttribute("js-update", "$(_this).html(new Date())"),
                                                              11
                                                              )
                                                 ),
                                             h.Div
                                             (
                                                 h.Element("h1", "container"),
                                                 h.Div(
                                                     h.data("name", "book"),
                                                     h.data("book-id", "1"),
                                                     h.Input(h.type("text"), h.data("name", "author"), h.value("Голдратт")),
                                                     h.Input(h.type("text"), h.data("name", "title"), h.value("Цель")),
                                                     h.Input(h.type("checkbox"), h.@checked(), h.data("name", "is-readed")),
                                                     h.Select(h.data("name", "category"),
                                                              h.Option(h.value(""), "-"),
                                                              h.Option(h.value("managment"), "управление"),
                                                              h.Option(h.value("sci-fi"), "фантастика"),
                                                              h.Option(h.value("detective"), "детектив")
                                                              ),
                                                     h.Input(h.type("button"), h.onclick(";"), h.data("container", "book"), h.data("command", "new-book"), h.value("добавить"))
                                                     ),
                                                 h.Div(h.style("font-size:85%;color:#505050;"), "<div data-name='bla-bla'><input type='button' data-container='bla-bla'/><input type='text' data-name='age' /> </div>")
                                             ),
                                             h.Div(h.Element("h1", "drag & drop"),
                                                   new HElement("div",
                                                                new HAttribute("style", "border:1px solid black;width:50px;height:50px;padding:10px;display:inline-block;"),
                                                                new HAttribute("js-init", "$(_this).draggable({ opacity: 0.8, helper: 'clone'  });"),
                                                                new HAttribute("data-r", 1),
                                                                "draggable"
                                                                ),
                                                   new HElement("div",
                                                                new HAttribute("style", "border:1px solid black;width:100px;height:100px;padding:10px;display:inline-block;"),
                                                                new HAttribute("js-init", "$(_this).droppable({drop: function() {server_element_event(this, 'drop');}  });"),
                                                                new HAttribute("data-s", 1),
                                                                //new HAttribute("onclick", "alert(12)"),
                                                                "droppable"
                                                                ),
                                                   h.Span("todo: добавить свойство, которое указывает какие data-свойства не надо передавать")
                                                   ),
                                             //h.Div
                                             //(
                                             //  h.Span(((DateTime.UtcNow.Second / 2) % 2 == 0) ? (object)"T" : h.Span("t")),
                                             //  h.Span(" - "),
                                             //  h.Span((DateTime.UtcNow.Second / 2) % 2)
                                             //)//,
                                             h.Div
                                             (
                                                 h.style("display:inline-block;"),
                                                 h.Element("h1", "svg"),
                                                 h.Element(new HName(svgNs, "svg"),
                                                           h.Element(new HName(svgNs, "circle"), h.Attribute("cx", 100), h.Attribute("cy", 94), h.Attribute("r", 10 + DateTime.UtcNow.Second)),
                                                           h.Element(new HName(svgNs, "polygon"), h.Attribute("points", "100,10 40,180 190,60 10,60 160,180"), h.style("fill:orange;stroke:purple;stroke-width:5;fill-rule:evenodd;"))
                                                           )
                                             ),
                                             h.Div
                                             (
                                                 h.style("display:inline-block;"),
                                                 h.Element("h1", "Изображения из ресурсов"),
                                                 new HElement("image", new HAttribute("src", @"nres://gold_star.jpg"), new HAttribute("style", "width:100px")),
                                                 new HElement("image", new HAttribute("src", @"nres://gold_star2.jpg"), new HAttribute("style", "width:100px")),
                                                 new HElement("image", new HAttribute("src", @"nres://gold_metal_star.jpg"), new HAttribute("style", "width:100px")),
                                                 new HElement("image", new HAttribute("src", @"nres2://gold_metal_star.jpg"), new HAttribute("style", "width:100px")),
                                                 new HElement("image", new HAttribute("src", @"nres2://not-found.jpg"), new HAttribute("style", "width:100px"), h.title("проверка работы отсутствующего изображения")),
                                                 new HElement("image", new HAttribute("src", @"avatar://avatar.png"), h.style("style", "width:80px;", "border:1px solid green;"))
                                             ),
                                             h.Element("h1", "chart"),
                                             new HElement("p",
                                                          new HAttribute("style", "padding:40px;margin:20px;border:1px solid black;"),
                                                          new HAttribute("js-init",
                                                                         @"
var palette = new Rickshaw.Color.Palette( { scheme: 'spectrum14' } );

var graph = new Rickshaw.Graph( {
	element: $(_this)[0],
	width: 900,
	height: 500,
	renderer: 'line',
	stroke: true,
	preserve: true,
	series: [
		{
			color: palette.color(),
			data: [{x:1, y:1}],
			name: 'Moscow'
		},
//		{
//			color: palette.color(),
//			data: [{x:1, y:1}],
//			name: 'Moscow'
//		},
//    {
//			color: palette.color(),
//			data: [{x:1, y:1}],
//			name: 'Shanghai'
//		}, 
	]
} );

graph.render();

jQuery.data(_this[0], 'graph', graph);
jQuery.data(_this[0], 'x1', '15');


"),
                                                          new HAttribute("js-update", @"
var _graph = jQuery.data(_this[0], 'graph');
//_this.css('background-color', 'red');
//alert(jQuery.data(_this[0], 'x1'));
//alert(_this[0]);
  _graph.series[0].data = [__data__];
  _graph.render();

".Replace("__data__",
          //Shift(F(s, s + 14, 0.3), -s, 4).Select(p => string.Format(System.Globalization.CultureInfo.InvariantCulture, "{{x:{0}, y:{1}}}", p.X, p.Y)).JoinToString(", ")
          values.Select(p => string.Format(System.Globalization.CultureInfo.InvariantCulture, "{{x:{0}, y:{1}}}", (p.Time - new DateTime(2013, 1, 1)).TotalHours, p.Value)).JoinToString(", ")
          )
                                                                         //new HAttribute("style", ((DateTime.Now.Second / 3) % 2) == 0 ? "background-color:green": "background-color:red")
                                                                         )
                                                          )
                                             )
                                ));
        }