public CssBoxSvgRoot(Css.BoxSpec spec, RootGraphic rootgfx, SvgElement svgElem) : base(spec, rootgfx, Css.CssDisplay.Block) { SetAsCustomCssBox(this); //create svg node this.SvgSpec = svgElem; ChangeDisplayType(this, Css.CssDisplay.Block); }
/// <summary> /// Init. /// </summary> /// <param name="parent">the parent box of this box</param> /// <param name="controller">the html tag data of this box</param> public CssBoxImage(Css.BoxSpec boxSpec, RootGraphic rootgfx, ImageBinder binder) : base(boxSpec, rootgfx) { this._imgRun = new CssImageRun(); this._imgRun.ImageBinder = binder; this._imgRun.SetOwner(this); var runlist = new List<CssRun>(1); runlist.Add(_imgRun); CssBox.UnsafeSetContentRuns(this, runlist, false); }
/// <summary>Creates a new animated property.</summary> /// <param name="animation">The animation that this property is a part of.</param> /// <param name="property">The property being animated.</param> /// <param name="targetValue">The value that this property will be when the animation is over.</param> /// <param name="constantSpeedTime">How long the animation will change the value at a constant speed for.</param> /// <param name="timeToAccelerateFor">How long the animation will accelerate for. This produces a smoother animation.</param> /// <param name="timeToDecelerateFor">How long the animation will decelerate for. This produces a smoother animation.</param> /// <param name="updateCss">True if this particular property should flush its changes to css/the screen.</param> public AnimatedProperty(UIAnimation animation,CssProperty property,int innerIndex,Css.Value targetValue,float constantSpeedTime,float timeToAccelerateFor,float timeToDecelerateFor,bool updateCss){ Animation=animation; PropertyInfo=property; InnerIndex=innerIndex; Css.ValueType type=targetValue.Type; if(!Animation.ElementStyle.Properties.TryGetValue(property,out ValueObject)){ ComputedStyle computed=Animation.ElementStyle.Computed; if(computed!=null && computed.Properties.TryGetValue(property,out ValueObject)){ // Let's derive from the computed form. ValueObject=ValueObject.Copy(); }else{ ValueObject=new Css.Value(); if(innerIndex!=-1 || type==Css.ValueType.Null){ type=Css.ValueType.Rectangle; } property.SetDefault(ValueObject,type); } Animation.ElementStyle.Properties[property]=ValueObject; } if(ValueObject.Type==Css.ValueType.Inherit){ // Special case - we need to duplicate it. Animation.ElementStyle.Properties[property]=ValueObject=ValueObject.Copy(); ValueObject.Type=type; } PropertyValueObject=ValueObject; if(innerIndex!=-1){ Css.Value innerValue=ValueObject[innerIndex]; if(innerValue==null){ ValueObject[innerIndex]=innerValue=new Css.Value(); } ValueObject=innerValue; } // Set our starting value: ActiveValue=ValueObject.ToFloat(); Animate(Animation,targetValue,constantSpeedTime,timeToAccelerateFor,timeToDecelerateFor,updateCss); }
public static CssBoxSvgRoot CreateSvgBox(CssBox parentBox, HtmlElement elementNode, Css.BoxSpec spec) { SvgFragment fragment = new SvgFragment(); SvgRootEventPortal svgRootController = new SvgRootEventPortal(elementNode); CssBoxSvgRoot svgRoot = new CssBoxSvgRoot( elementNode.Spec, parentBox.RootGfx, fragment); svgRoot.SetController(svgRootController); svgRootController.SvgRoot = svgRoot; parentBox.AppendChild(svgRoot); CreateSvgBoxContent(fragment, elementNode); return svgRoot; }
public void testParse() { string cssStr = @" #row1_column1 { background:#aaa; width:526px; margin-left:; margin-right:; margin-top:; margin-bottom :; } #row1_column2 { background:red; width:98%; margin-left:; margin-right:; margin-top:8px; margin-bottom:9px; } "; Dictionary <string, Dictionary <string, string> > dic = Css.FromAndFill(cssStr); Assert.IsNotNull(dic); Assert.AreEqual(2, dic.Count); Assert.IsTrue(dic.ContainsKey("#row1_column1")); Assert.IsTrue(dic.ContainsKey("#row1_column2")); Dictionary <string, string> css1 = dic["#row1_column1"]; Assert.IsNotNull(css1); Assert.AreEqual("#aaa", css1["background"]); Assert.AreEqual("526px", css1["width"]); Assert.AreEqual(css1["margin-left"], ""); Assert.AreEqual(css1["margin-top"], ""); Assert.AreEqual(css1["margin-right"], ""); Assert.AreEqual(css1["margin-bottom"], ""); Dictionary <string, string> css2 = dic["#row1_column2"]; Assert.IsNotNull(css2); Assert.AreEqual("red", css2["background"]); Assert.AreEqual("98%", css2["width"]); Assert.AreEqual(css2["margin-left"], ""); Assert.AreEqual(css2["margin-top"], "8px"); Assert.AreEqual(css2["margin-right"], ""); Assert.AreEqual(css2["margin-bottom"], "9px"); }
public static HtmlBuilder SelectableWrapper( this HtmlBuilder hb, string controlId, string controlWrapperCss = null, string controlCss = null, Dictionary <string, ControlData> listItemCollection = null, IEnumerable <string> selectedValueCollection = null, string action = null, string method = null, bool _using = true) { return(_using ? hb.Div( css: Css.Class("wrapper", controlWrapperCss), action: () => hb .Selectable( controlId: controlId, controlCss: Css.Class("control-selectable", controlCss), listItemCollection: listItemCollection, selectedValueCollection: selectedValueCollection, action: action, method: method)) : hb); }
public static HtmlBuilder Slider( this HtmlBuilder hb, string controlId = null, string controlCss = null, decimal value = 0, decimal min = -1, decimal max = -1, decimal step = -1, string unit = null, bool alwaysSend = false, string action = null, string method = null, bool _using = true) { return(_using ? hb .Div(attributes: new HtmlAttributes() .Id(controlId + ",ui") .Class("control-slider-ui") .DataMin(min, _using: min != -1) .DataMax(max, _using: max != -1) .DataStep(step, _using: step != -1)) .P( attributes: new HtmlAttributes() .Id(controlId).DataAction(action) .Class(Css.Class("control-slider", controlCss)) .DataAlwaysSend(alwaysSend) .DataAction(action) .DataMethod(method), action: () => hb .Span(action: () => hb .Text(value.ToString())) .Span(action: () => hb .Text(unit))) : hb); }
public static HtmlBuilder DropDown( this HtmlBuilder hb, string controlId = null, string controlCss = null, Dictionary <string, ControlData> optionCollection = null, string selectedValue = null, bool multiple = false, bool addSelectedValue = true, bool insertBlank = false, bool disabled = false, string onChange = null, string action = null, string method = null, Column column = null, bool _using = true) { return(_using ? hb.Select( attributes: new HtmlAttributes() .Id(controlId) .Class(Css.Class("control-dropdown", controlCss)) .Multiple(multiple) .Disabled(disabled) .OnChange(onChange) .DataAction(action) .DataMethod(method), action: () => hb .OptionCollection( optionCollection: optionCollection, selectedValue: selectedValue, multiple: multiple, addSelectedValue: addSelectedValue, insertBlank: insertBlank, column: column)) : hb); }
public void Add_can_handle_existing_class() { dp.AddClass("light"); Css.GetClass(dp).Should().Be("main light"); }
public void Can_toggle_existing_class() { dp.ToggleClass("light"); Css.GetClass(dp).Should().Be("main"); }
/// <summary> /// In HTML konvertieren /// </summary> /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param> /// <returns>Das Control als HTML</returns> public override IHtmlNode Render(RenderContext context) { var html = new HtmlElementTextContentDiv() { ID = ID, Class = Css.Concatenate("card", GetClasses()), Style = GetStyles(), Role = Role }; if (!string.IsNullOrWhiteSpace(Header)) { html.Elements.Add(new HtmlElementTextContentDiv(new HtmlText(Header)) { Class = "card-header" }); } if (!string.IsNullOrWhiteSpace(HeaderImage)) { html.Elements.Add(new HtmlElementMultimediaImg() { Src = HeaderImage, Class = "card-img-top" }); } if (!string.IsNullOrWhiteSpace(Headline)) { Content.Insert(0, new ControlText() { Text = Headline, Classes = new List <string>(new[] { "card-title" }), Format = TypeFormatText.H4 }); } html.Elements.Add(new HtmlElementTextContentDiv(new HtmlElementTextContentDiv(Content.Select(x => x.Render(context))) { Class = "card-text" }) { Class = "card-body" }); if (!string.IsNullOrWhiteSpace(FooterImage)) { html.Elements.Add(new HtmlElementMultimediaImg() { Src = FooterImage, Class = "card-img-top" }); } if (!string.IsNullOrWhiteSpace(Footer)) { html.Elements.Add(new HtmlElementTextContentDiv(new HtmlText(Footer)) { Class = "card-footer" }); } return(html); }
private void AnimateComposite(CssProperty property,Css.Value value){ bool isPoint=(value.Type==Css.ValueType.Point); Animate(property,0,value[0],false); Animate(property,1,value[1],isPoint); if(!isPoint){ Animate(property,2,value[2],false); Animate(property,3,value[3],true); } }
public CssFloatContainerBox(Css.BoxSpec boxSpec, RootGraphic rootgfx, Css.CssDisplay display) : base(boxSpec, rootgfx, display) { }
public CssBoxListItem(Css.BoxSpec spec, RootGraphic rootgfx) : base(spec, rootgfx) { }
public WrapperInlineCssBox(object controller, Css.BoxSpec boxSpec, RootGraphic rootgfx, RenderElement re) : base(controller, boxSpec, re.Root, CssDisplay.Inline) { int w = re.Width; int h = re.Height; ChangeDisplayType(this, CssDisplay.Inline); this.externalRun = new CssExternalRun(re); this.externalRun.SetOwner(this); var runlist = new List<CssRun>(1); runlist.Add(externalRun); CssBox.UnsafeSetContentRuns(this, runlist, false); ChangeDisplayType(this, Css.CssDisplay.Inline); //--------------------------------------------------- LayoutFarm.RenderElement.SetParentLink(re, this); }
public static HtmlBuilder MarkDown( this HtmlBuilder hb, Context context, string controlId = null, string controlCss = null, string text = null, string placeholder = null, bool readOnly = false, bool allowImage = true, bool allowBulkUpdate = false, bool mobile = false, bool alwaysSend = false, bool validateRequired = false, Column.ViewerSwitchingTypes viewerSwitchingTypes = Column.ViewerSwitchingTypes.Auto, Dictionary<string, string> attributes = null, bool preview = false, bool _using = true, int validateMaxLength = 0, string validateRegex = null, string validateRegexErrorMessage = null) { if (!_using) return hb; if (preview) controlId = Strings.NewGuid(); if (viewerSwitchingTypes != Column.ViewerSwitchingTypes.Disabled) { hb .Div(attributes: new HtmlAttributes() .Id(controlId + ".viewer") .Class("control-markup not-send") .OnDblClick($"$p.editMarkdown($('#{controlId}'));")) .Div( attributes: new HtmlAttributes() .Id(controlId + ".editor") .Class("ui-icon ui-icon-pencil button-edit-markdown") .OnClick($"$p.editMarkdown($('#{controlId}'));"), _using: !readOnly); } hb .TextArea( attributes: new HtmlAttributes() .Id(controlId) .Name(controlId) .Class(Css.Class((viewerSwitchingTypes == Column.ViewerSwitchingTypes.Disabled ? "control-textarea" : "control-markdown") + (viewerSwitchingTypes == Column.ViewerSwitchingTypes.Manual ? " manual" : string.Empty) + (CanUploadImage(context, readOnly, allowImage, preview) ? " upload-image" : string.Empty), controlCss)) .Placeholder(placeholder) .DataAlwaysSend(alwaysSend) .DataValidateMaxLength(validateMaxLength) .DataValidateRequired(validateRequired, _using: !readOnly) .DataValidateRegex(validateRegex) .DataValidateRegexErrorMessage(validateRegexErrorMessage) .DataReadOnly(readOnly) .Add(attributes), text: text) .MarkDownCommands( context: context, controlId: controlId, readOnly: readOnly, allowImage: allowImage, mobile: mobile, preview: preview); return hb; }
/// <summary> /// In HTML konvertieren /// </summary> /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param> /// <returns>Das Control als HTML</returns> public override IHtmlNode Render(RenderContextFormular context) { var renderContext = new RenderContextFormularGroup(context, this); var html = new HtmlElementTextContentDiv() { ID = ID, Class = Css.Concatenate("form-group-column", GetClasses()), Style = GetStyles(), }; var max = 100; var offset = 0; foreach (var item in Items) { var input = item as ControlFormularItemInput; var div = new HtmlElementTextContentDiv() { Style = "" }; var width = -1; if (Distribution.Count > offset) { width = Distribution.Skip(offset).Take(1).FirstOrDefault(); div.Style = $"width: { width }%"; max = max - width; offset++; } else if (Items.Count > offset) { width = max / (Items.Count - offset); div.Style = $"width: { width }%"; } if (input != null) { var icon = new ControlIcon() { Icon = input?.Icon }; var label = new ControlFormularItemLabel(!string.IsNullOrEmpty(item.ID) ? item.ID + "_label" : string.Empty); var help = new ControlFormularItemHelpText(!string.IsNullOrEmpty(item.ID) ? item.ID + "_help" : string.Empty); var fieldset = new HtmlElementFormFieldset() { Class = "form-group" }; label.Initialize(renderContext); help.Initialize(renderContext); label.Text = context.I18N(input?.Label); label.FormularItem = item; help.Text = context.I18N(input?.Help); if (icon.Icon != null) { icon.Classes.Add("mr-2 pt-1"); fieldset.Elements.Add(new HtmlElementTextSemanticsSpan(icon.Render(renderContext), label.Render(renderContext)) { Style = "display: flex;" }); } else { fieldset.Elements.Add(label.Render(renderContext)); } fieldset.Elements.Add(item.Render(renderContext)); if (!string.IsNullOrWhiteSpace(input?.Help)) { fieldset.Elements.Add(help.Render(renderContext)); } div.Elements.Add(fieldset); } else { div.Elements.Add(item.Render(context)); } html.Elements.Add(div); } return(html); }
//--------------------------------------
public void Can_remove_existing_class() { dp.RemoveClass("light"); Css.GetClass(dp).Should().Be("main"); }
public override bool Execute(params string[] args) { // { string testCss = Application.SetupDir.CombinePath("testCss/app.cb1b40f2.css").ReadString(Encoding.UTF8); Css css = CssParser.Parse(testCss); Style style = css.Styles[".gd_news_box_title_text"].Single(); Property property = style.Properties["background"].Single(); Assert.IsTrue(style.Background.Url == "/img/ico_bg.dd1a022e.png"); style.Background.Url = "../img/ico_bg.dd1a022e.png"; Assert.IsTrue(((Background)property).Url == "../img/ico_bg.dd1a022e.png"); } // { string testCss = Application.SetupDir.CombinePath("testCss/haidilao.com.css").ReadString(Encoding.UTF8); Css css = CssParser.Parse(testCss); Style style = css.Styles["@font-face"].First(); SrcValue value = style.Src.Values[0]; value.Url = "../../OpenSans-Light.ttf"; Assert.IsTrue(style.Src.Values[0].Url == "../../OpenSans-Light.ttf"); Assert.IsTrue( css.Styles.Where(i => i.Selector == ".r_share .bds_fbook").Single().BackgroundImage.Url == "../images/facebook.png"); } // { string testHtml = Application.SetupDir.CombinePath("testHtml/js.html").ReadString(Encoding.UTF8); Document doc = HtmlParser.Parse(testHtml); } // { string testStyle = "width:100px; height:100px; display:none; background:url(\"../test/test.png\")"; Style style = StyleParser.Parse(testStyle); Assert.IsTrue(style.Background.Url == "../test/test.png"); } // { string testStyle = "width:100px; height:100px; display:none; background:url(../test/test.png)"; Style style = StyleParser.Parse(testStyle); Assert.IsTrue(style.Properties.Single(i => i.Name == "display").Value == "none"); Assert.IsTrue(style.Background.Url == "../test/test.png"); } // { string testCss = Application.SetupDir.CombinePath("testCss/bibaoke.com.css").ReadString(Encoding.UTF8); Css css = CssParser.Parse(testCss); Assert.IsTrue( css.Styles.Where(i => i.Selector == ".test_background_image").Single().BackgroundImage.Url == "../images/test_background_image.png"); } // new Test1().Execute(); new Test2().Execute(); new Test3().Execute(); new Test4().Execute(); new Test5().Execute(); // { string testHtml = @"<meta name=""description"" content =""测试 <meta name=""apple-itunes-app"" content=""app-id=527806786"" />"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("meta[name='description']").attr("content") == @"测试 <meta name="); } // { string testHtml = "<head><ud /></head>"; Document document = HtmlParser.Parse(testHtml); var q = Selector.Bind(document); Assert.IsTrue(q("ud").html() == ""); Assert.IsTrue(q("ud")[0].innerHTML == ""); } // { string testHtml = "<head><base href='http://bibaoke.com/blog/'><script type='text/javascript' src='/js/jquery-1.7.2.min.js'></script></head>"; Document document = HtmlParser.Parse(testHtml); var q = Selector.Bind(document); Assert.IsTrue(q("base").href() == "http://bibaoke.com/blog/"); } // { string testHtml = "<p>段落1</p><p>段落2</p>"; Document document = HtmlParser.Parse(testHtml); Assert.IsTrue(document.getElementsByTagName("p")[1].textContent == "段落2"); } // { string testHtml = @"<a href=""http://bibaoke.com"">链接</a>"; Document document = HtmlParser.Parse(testHtml); Assert.IsTrue(document.links[0].textContent == "链接"); } // { string testHtml = Application.SetupDir.CombinePath("testHtml/265.com.html").ReadString(Encoding.UTF8); Document document = HtmlParser.Parse(testHtml); Assert.IsTrue(testHtml == document.ToString()); } // { string testHtml = Application.SetupDir.CombinePath("testHtml/youpinai.com.html").ReadString(Encoding.UTF8); var q = HtmlParser.Query(testHtml); foreach (Element i in q("a, area")) { string href = q(i).href(); } } // { string testHtml = Application.SetupDir.CombinePath("testHtml/auto.qq.com.html").ReadString(Encoding.UTF8); var q = HtmlParser.Query(testHtml); q("*").ToArray(); } // { string testHtml = "<div></div>"; var q = HtmlParser.Query(testHtml); q("div").html(1); Assert.IsTrue(q("div").html() == "1"); } // { string testHtml = "<div></div>"; var q = HtmlParser.Query(testHtml); q("div").html(null); int?i = null; q("div").html(i); q(null).html("test"); string s = null; q(s).html("test"); Assert.IsTrue(q("div").html() == ""); } // { string testHtml = Application.SetupDir.CombinePath("testHtml/auto.qq.com.html").ReadString(Encoding.UTF8); var q = HtmlParser.Query(testHtml); string title = q("title:last").html(); this.WriteLine(title); string description = q("meta[name='description']").attr("content"); this.WriteLine(description); } // { string testHtml = Application.SetupDir.CombinePath("testHtml/lrcmyanmar.org.html").ReadString(Encoding.UTF8); var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("title:last").html() == "lrc myanmar"); } // { string testHtml = Application.SetupDir.CombinePath("testHtml/wsbuluo.com.html").ReadString(Encoding.UTF8); var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("title:last").html() == "纹身图案大全图片_纹身图案大全_纹身图片 - 纹身部落"); } // { string testHtml = "<head></head>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(!q("head #icon").hasElement); } // { string testHtml = "<html><head><title></title></head></html>"; Document document = HtmlParser.Parse(testHtml); Assert.IsTrue(document.getElementsByTagName("head")[0].cloneNode().ToString() == "<head></head>"); } // { string testHtml = "deadspin-quote-carrot-aligned-w-bgr-2<\\/title><path d=\"M10,…"; Document document = HtmlParser.Parse(testHtml); Assert.IsTrue(document.childNodes.Length == 1); Assert.IsTrue(document.childNodes[0].nodeValue == "deadspin-quote-carrot-aligned-w-bgr-2<\\/title>"); } // { string testHtml = "<div style='height:100px; width:100px'></div>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("div").css("width") == "100px"); } // { string testHtml = "<td class='ip'><div style=' display:inline-bloc"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("td").text() == ""); } // { string testHtml = Application.SetupDir.CombinePath("testHtml/www.darc.de.html").ReadString(Encoding.UTF8); var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("[value='Spall']").html() == ""); } // { string testHtml = Application.SetupDir.CombinePath("testHtml/killedbypolice.net.html").ReadString(Encoding.UTF8); var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("center")[2].textContent == "St."); } // { string testHtml = "<span>0 - 1</span>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("span").text() == "0 - 1"); } // { string testHtml = "<span>0  - 1</span>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("span").text() == "0 - 1"); } // { string testHtml = "<div style='width:100px; height:100px; display:none'></div>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("div").css("display") == "none"); Assert.IsTrue(q("div").css("display", "block").css("display") == "block"); } // { string testHtml = "<select></select>"; var q = HtmlParser.Query(testHtml); var option = q("<option></option>"); Assert.IsTrue(q("select").append(option).html() == "<option></option>"); Assert.IsTrue(q("select").append(option).html() == "<option></option>"); Assert.IsTrue(q("select").append(option.clone()).html() == "<option></option>".Repeat(2)); } // { string testHtml = "<div></div>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("div").append(q("<input type='hidden' />").val(1)).html() == "<input type='hidden' value=\"1\" />"); } // { string testHtml = "<input></input>"; Document document = HtmlParser.Parse(testHtml); var q = Selector.Bind(document); q("input").text("1"); Assert.IsTrue(document.ToString() == "<input>1</input>"); } // { string testHtml = "<input />"; Document document = HtmlParser.Parse(testHtml); var q = Selector.Bind(document); q("input").text("1"); Assert.IsTrue(document.ToString() == "<input />1"); } // { string testHtml = "<input>"; Document document = HtmlParser.Parse(testHtml); var q = Selector.Bind(document); q("input").text("1"); Assert.IsTrue(document.ToString() == "<input>1"); } // { string testHtml = "<ol><li></li></ol>"; var q = HtmlParser.Query(testHtml); var li = q("li").remove(); q("ol").append(li); } // { string testHtml = "<ol><li></li><li></li></ol>"; var q = HtmlParser.Query(testHtml); var li = q("li:first").remove(); Assert.IsTrue(q("ol")[0].childNodes.Length == 1); q("ol").append(li); Assert.IsTrue(q("ol")[0].childNodes.Length == 2); } // { string testHtml = "<ol><li>0</li><li>1</li><li>2</li><li>3</li><li>4</li></ol>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("li:eq(2)").text() == "2"); Assert.IsTrue(q("li:gt(2)").text() == "34"); Assert.IsTrue(q("li:lt(2)").text() == "01"); } // { string testHtml = "<input type='checkbox' title='test' />"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q("input").attr("title", "测试").attr("title") == "测试"); Assert.IsTrue(q(":checkbox").title() == "测试"); } // { string testHtml = "<div><input type='checkbox' title='test' /></div>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q(":checkbox").title() == "test"); } // { string testHtml = "<div><input class='class1 class2 class3' type='checkbox' title='test' /></div>"; var q = HtmlParser.Query(testHtml); Assert.IsTrue(q(":checkbox").removeClass("class2").attr("class") == "class1 class3"); Assert.IsTrue(q(":checkbox").removeClass("class2 class1").attr("class") == "class3"); } return(true); }
/// <summary>Refreshes this elements css style if the given selector matches its own.</summary> /// <param name="type">The type of the given selector.</param> /// <param name="selector">The selector to match with.</param> public void RefreshSelector(Css.SelectorType type,string selector){ ComputedStyle computed=Style.Computed; switch(type){ case Css.SelectorType.Class: bool refresh=false; if(computed.ClassSelector==selector){ refresh=true; }else if(computed.ExtraClassSelectors!=null){ // Special case if we've got multiple classes on this element. for(int i=0;i<computed.ExtraClassSelectors.Length;i++){ if(computed.ExtraClassSelectors[i]==selector){ refresh=true; break; } } } if(refresh){ computed.RefreshSelector(type); } break; case Css.SelectorType.ID: if(computed.IDSelector==selector){ computed.RefreshSelector(type); } break; default: if(computed.TagSelector==selector){ computed.RefreshSelector(type); } break; } if(ChildNodes!=null){ for(int i=0;i<ChildNodes.Count;i++){ ChildNodes[i].RefreshSelector(type,selector); } } }
/// <summary>Sets the default value for this property into the given value.</summary> /// <param name="value">The value to write the default to.</param> /// <param name="type">The type of the given value. Optionally used.</param> public virtual void SetDefault(Css.Value value,ValueType type){ value.Set("",type); }
public MainWindow() { Css.Initialize(); InitializeComponent(); this.DataContext = new ViewModel.MainWindow(); }
public override bool Matches(Css.CssSelectorStack stack) { return stack.IsMatch(this); }
/// <summary> /// Constructor for DI /// </summary> public KoiCss(Dependencies dependencies) { _css = new Css(dependencies.CssDetector.AutoDetect()); }
public static string UrlFor(Control control, Css styleSheet) { var sheet = _styleSheets[styleSheet]; return control.Page.ClientScript.GetWebResourceUrl(sheet.ResourceType, sheet.ResourceName); }
/// <summary>Asks the renderer to perform a paint on the given style object next update.</summary> /// <param name="style">The style to paint.</param> public void RequestPaint(Css.ElementStyle style){ if(DoLayout||style.IsPainting){ return; } style.IsPainting=true; if(StylesToPaint==null){ StylesToPaint=style; style.Next=null; }else{ style.Next=StylesToPaint; StylesToPaint=style; } }
public CssScrollView(Css.BoxSpec boxSpec, RootGraphic rootgfx) : base(boxSpec, rootgfx) { }
public static StyleSheet Get(Css styleSheet) { return _styleSheets[styleSheet]; }
private void CreateDynamicCSS() { var dynamicCss = new Css { HtmlConfig = StepInput.HtmlConfig }; File.WriteAllText(Path.Combine(StepInput.OutputPath, "data", "dynamic.css"), dynamicCss.TransformText()); }
public override void SetDefault(Css.Value value,ValueType type){ value.Set("100% 100% 100%",ValueType.Rectangle); }
public override void SetDefault(Css.Value value,ValueType type){ value.Set("#ffffffff",ValueType.Color); }
/// <summary>Animates this property now.</summary> /// <param name="animation">The animation that this property is a part of.</param> /// <param name="targetValue">The parsed value that this property will be when the animation is over.</param> /// <param name="constantSpeedTime">How long the animation will change the value at a constant speed for.</param> /// <param name="timeToAccelerateFor">How long the animation will accelerate for. This produces a smoother animation.</param> /// <param name="timeToDecelerateFor">How long the animation will decelerate for. This produces a smoother animation.</param> /// <param name="updateCss">True if this particular property should flush its changes to css/the screen.</param> public void Animate(UIAnimation animation,Css.Value targetValue,float constantSpeedTime,float timeToAccelerateFor,float timeToDecelerateFor,bool updateCss){ Animation=animation; ValueObject.Type=targetValue.Type; Stage=0; Speed=0f; CurrentTime=0f; UpdateCss=updateCss; PropertyAfter=PropertyBefore=null; // Find the max speed. This is what we accelerate to. // Speed (y) / time (x) graph: // /| |-| |\ // A B C. A = accelerate, b=constant, c=decelerate. // Max speed = top y value. // Distance travelled = area of the graph. This should match target - current value. TargetValue=targetValue.ToFloat(); float unitsDelta=TargetValue - ActiveValue; MaxSpeed=(unitsDelta*UI.RedrawRate) / ( (0.5f*timeToAccelerateFor) + constantSpeedTime + (0.5f*timeToDecelerateFor) ); if(timeToAccelerateFor==0f){ // Skip acceleration stage. Stage=1; Speed=MaxSpeed; }else{ Acceleration=MaxSpeed*UI.RedrawRate / timeToAccelerateFor; } if(timeToDecelerateFor!=0f){ Deceleration=MaxSpeed*UI.RedrawRate / timeToDecelerateFor; } }
/// <summary>Starts animating the named property and target value. Must not be composite properties. /// (e.g. color-overlay-r instead of color-overlay)</summary> /// <param name="property">The property to update.</param> /// <param name="innerIndex">The inner index of the property to update.</param> /// <param name="value">The target value of the property.</param> /// <param name="updateCss">True if this property should update CSS/ the screen when it's progressed.</param> private void Animate(CssProperty property,int innerIndex,Css.Value value,bool updateCss){ // Check if this property is already animated - if so, interrupt it and override with our new values. // There won't be many actively animated properties, so looping through the update queue is fast anyway. AnimatedProperty animProperty=GetAnimatedProperty(Animating,property,innerIndex); if(animProperty!=null){ animProperty.Animate(this,value,ConstantSpeedTime,TimeToAccelerateFor,TimeToDecelerateFor,updateCss); }else{ // Otherwise we want to create a new AnimatedProperty and stick it into the queue: animProperty=new AnimatedProperty(this,property,innerIndex,value,ConstantSpeedTime,TimeToAccelerateFor,TimeToDecelerateFor,updateCss); animProperty.AddToQueue(); } }
/// <summary> /// Override to create the CSS class that component need. /// </summary> /// <param name="css">The instance of <see cref="T:YoiBlazor.Css" /> class.</param> protected override void CreateComponentCssClass(Css css) { css.Add("toast-container"); }
public void Initialize() { Thread.CurrentThread.SetApartmentState(ApartmentState.STA); dp = new Button(); Css.SetClass(dp, "main light"); }
/// <summary> /// Override to create the CSS class that component need. /// </summary> /// <param name="css">The instance of <see cref="T:YoiBlazor.Css" /> class.</param> protected override void CreateComponentCssClass(Css css) { css.Add("accordion"); }
public void Can_toggle_new_class() { dp.ToggleClass("dark"); Css.GetClass(dp).Should().Be("main light dark"); }
/// <summary> /// Override to create the CSS class that component need. /// </summary> /// <param name="css">The instance of <see cref="T:YoiBlazor.Css" /> class.</param> protected override void CreateComponentCssClass(Css css) { css.Add("calendar"); }
public void Can_add_new_class() { dp.AddClass("dark"); Css.GetClass(dp).Should().Be("main light dark"); }
public override string Render(string body = "") { //check security if (PathParts.Length < 2) { return(Error()); } var boardId = int.Parse(PathParts[1]); if (User.userId == 0) { return(AccessDenied <Login>()); } if (!User.CheckSecurity(boardId)) { return(AccessDenied <Login>()); } //add client-side dependencies AddScript("/js/views/board/board.js?v=" + Server.Version); AddScript("/js/dashboard.js?v=" + Server.Version); AddCSS("/css/dashboard.css?v=" + Server.Version); var view = new View("/Views/Board/board.html"); //load board details var colors = new Utility.Colors(); var board = Query.Boards.GetBoardAndLists(boardId); BoardPage page; //add custom javascript for User Settings & Board info Scripts.Append("<script language=\"javascript\">" + "S.board.id=" + board.boardId + ";" + (User.allColor ? "S.head.allColor();" : "") + "</script>"); //choose which Lists Type to render switch (board.type) { default: case Query.Models.Board.BoardType.kanban: //kanban page = new Kanban(); page.Init(Context, Parameters, Path, PathParts); break; } //dependancy injection page.board = board; //set background color of board view["color"] = "#" + board.color; view["color-dark"] = colors.ChangeHexBrightness(board.color, (float)-0.3); //transfer resources from page Scripts.Append(page.Scripts.ToString()); Css.Append(page.Css.ToString()); //render board lists view["content"] = page.Render(); //load header LoadHeader(ref view); return(base.Render(view.Render())); }
public void Remove_can_handle_notset_class() { dp.RemoveClass("dark"); Css.GetClass(dp).Should().Be("main light"); }
/// <summary> /// Handle catching DeniedOrNotExistException in case /// path looked up for is not found /// </summary> /// <param name="path"></param> /// <returns></returns> internal static Node FindNodeInSubTree(VSTSConnection vstsConn, string path, Node.TreeType type) { Node localNode = null; try { localNode = vstsConn.project.FindNodeInSubTree(path, type); } catch (DeniedOrNotExistException) { // try to create the given css path if (path.IndexOfAny(VSTSConstants.UnsupportedCSSChars) > -1) { String newPath = AreaPathRegEx.Replace(path, "_"); Logger.Write(LogSource.WorkItemTracking, TraceLevel.Warning, "Generating new CSS path from [{0}] to [{1}]", path, newPath); localNode = FindNodeInSubTree(vstsConn, newPath, type); } else { try { // try to create the CSS path if (Css == null) { Css = (ICommonStructureService)vstsConn.Tfs.GetService(typeof(ICommonStructureService)); } SetDefaultCSSUri(Css, vstsConn.projectName); if (type == Node.TreeType.Area) { CreateCSSPath(Css, path, RootAreaNodeUri); } else if (type == Node.TreeType.Iteration) { CreateCSSPath(Css, path, RootIterationNodeUri); } // after creating CSS path, sync the CSS tree if (VstsProjectInfo == null) { VstsProjectInfo = Css.GetProjectFromName(vstsConn.projectName); } WSHelper.SyncBisCSS(VstsProjectInfo); // refresh the connection vstsConn.Refresh(); // try to get the id now try { localNode = vstsConn.project.FindNodeInSubTree(path, type); } catch (DeniedOrNotExistException) { localNode = null; Logger.Write(LogSource.WorkItemTracking, TraceLevel.Warning, "Cannot find the CSS path {0} even after creating", path); } } finally { } } } return(localNode); }
/// <summary> /// 创建组件所需要的 class 类。 /// </summary> /// <param name="css">css 类名称集合。</param> protected override void CreateComponentCssClass(Css css) { css.Add("extra"); base.CreateComponentCssClass(css); }
public override async Task OnInitializing() { await base.OnInitializing(); Css.Border(bottom: 1, color: Colors.Gray); }
/// <summary> /// In HTML konvertieren /// </summary> /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param> /// <returns>Das Control als HTML</returns> public override IHtmlNode Render(RenderContextFormular context) { if (Disabled) { Classes.Add("disabled"); } switch (ValidationResult) { case TypesInputValidity.Success: Classes.Add("input-success"); break; case TypesInputValidity.Warning: Classes.Add("input-warning"); break; case TypesInputValidity.Error: Classes.Add("input-error"); break; } var html = new HtmlElementTextContentDiv() { ID = $"moveselector_{ID}", Class = Css.Concatenate("moveselector", GetClasses()), // form-control Style = GetStyles(), Role = "moveselector" }; var selectedHeader = new ControlText("selectedHeader") { Text = context.I18N("webexpress", "form.moveselector.selected"), TextColor = new PropertyColorText(TypeColorText.Muted), Format = TypeFormatText.Paragraph }; var selectedList = new ControlList("selectedOptions") { Layout = TypeLayoutList.Flush }; var leftAllButton = new ControlButton("") { Text = "<<", BackgroundColor = new PropertyColorButton(TypeColorButton.Primary), Block = TypeBlockButton.Block }; var leftButton = new ControlButton("") { Text = "<", BackgroundColor = new PropertyColorButton(TypeColorButton.Primary), Block = TypeBlockButton.Block }; var rightButton = new ControlButton("") { Text = ">", BackgroundColor = new PropertyColorButton(TypeColorButton.Primary), Block = TypeBlockButton.Block }; var rightAllButton = new ControlButton("") { Text = ">>", BackgroundColor = new PropertyColorButton(TypeColorButton.Primary), Block = TypeBlockButton.Block }; var availableHeader = new ControlText("availableHeader") { Text = context.I18N("webexpress", "form.moveselector.available"), TextColor = new PropertyColorText(TypeColorText.Muted), Format = TypeFormatText.Paragraph }; var availableList = new ControlList("availableOptions") { Layout = TypeLayoutList.Flush }; var sticky = new List <string>(new string[] { "position: sticky;" }); html.Elements.Add(new HtmlElementTextContentDiv ( selectedHeader.Render(context), selectedList.Render(context) ) { Class = "moveselector-list" }); html.Elements.Add(new HtmlElementTextContentDiv ( leftAllButton.Render(context), leftButton.Render(context), rightButton.Render(context), rightAllButton.Render(context) ) { Class = "moveselector-button" }); html.Elements.Add(new HtmlElementTextContentDiv ( availableHeader.Render(context), availableList.Render(context) ) { Class = "moveselector-list" }); return(html); }
private static string RenderColumnaCabecera(ColumnaDelGrid <TElemento> columna) { var porcentaje = columna.ZonaDeDatos.Mnt.Crud.Modo == ModoDescriptor.SeleccionarParaFiltrar || columna.ZonaDeDatos.Mnt.Crud.Modo == ModoDescriptor.Relacion || columna.ZonaDeDatos.Mnt.Crud.Modo == ModoDescriptor.Consulta ? columna.PorAnchoSel : columna.PorAnchoMnt; var atributosDelEstilo = $"text-align: {columna.AlineacionCss};"; atributosDelEstilo = $"width: {porcentaje}%; {atributosDelEstilo}"; string htmlRef = columna.ConOrdenacion ? RenderAccionOrdenar(columna) : columna.Titulo; string claseCss = columna.Visible ? Css.Render(enumCssGrid.ColumnaCabecera) : Css.Render(enumCssGrid.ColumnaOculta); string claseCssAlineacion = columna.Alineada == Aliniacion.derecha ? $"class=¨{Css.Render(enumCssGrid.ColumnaAlineadaDerecha)}¨" : ""; var htmlTh = $@"{Environment.NewLine} <th scope=¨col¨ id = ¨{columna.IdHtml}¨ class=¨{claseCss}¨ propiedad = ¨{columna.Propiedad.ToLower()}¨ modo-ordenacion=¨{(columna.cssOrdenacion == enumCssOrdenacion.SinOrden ? $"{enumModoOrdenacion.sinOrden.Render()}": $"{enumModoOrdenacion.ascendente.Render()}")}¨ style = ¨{atributosDelEstilo}¨ alineacion=¨{columna.AlineacionCss}¨ ordenar-por = ¨{columna.OrdenarPor}¨> <div {claseCssAlineacion}> {htmlRef} </div> </th>"; return(htmlTh); }
protected override void AddAttributesToRender(HtmlTextWriter writer) { if (!this.DesignMode) { Css.AddClass(this, "textbox"); if (Required) { writer.AddAttribute("data-required", "true"); } base.AddAttributesToRender(writer); StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.AppendFormat("el:this,dateFmt:'{0}'", DateFmt); if (!string.IsNullOrEmpty(ValueControl)) { string clientID = Page.FindControl(ValueControl).ClientID; sb.AppendFormat(",vel:'{0}'", clientID); } if (DoubleCalendar) { sb.Append(",doubleCalendar:true"); } if (!EnableInputMask) { sb.Append(",enableInputMask:false"); } if (WeekMethod != WeekType.ISO8601) { sb.Append(",weekMethod:'MSExcel'"); } if (Skin != SkinType.Default) { sb.Append(",skin:'whyGreen'"); } if (!string.IsNullOrEmpty(MinDate) || !string.IsNullOrEmpty(MinDateControl)) { if (!string.IsNullOrEmpty(MinDateControl)) { string clientID = Page.FindControl(MinDateControl).ClientID; sb.Append(",minDate:'#F{$dp.$D(\\'" + clientID + "\\');}'"); } else { sb.AppendFormat(",minDate:'{0}'", MinDate); } } if (!string.IsNullOrEmpty(MaxDate)) { sb.AppendFormat(",maxDate:'{0}'", MaxDate); } if (!string.IsNullOrEmpty(StartDate)) { sb.AppendFormat(",startDate:'{0}'", StartDate); } if (IsShowWeek) { sb.Append(",isShowWeek:true"); } if (!IsShowClear) { sb.Append(",isShowClear:true"); } if (DisabledDates != null && DisabledDates.Length > 0) { sb.Append(",disabledDates:["); for (int i = 0; i < DisabledDates.Length; i++) { sb.AppendFormat("'{0}'", DisabledDates[i]); if (i < DisabledDates.Length - 1) { sb.Append(","); } } sb.Append("]"); } sb.Append("}"); writer.AddAttribute("onfocus", "WdatePicker(" + sb.ToString() + ");"); writer.AddAttribute("autoComplete", "off"); } }
/// <param name="styleSheet">The CSS style sheet that is required.</param> public RequiresCustomStyleSheetAttribute(Css styleSheet) { _styleSheet = styleSheet; }
/// <summary> /// Init. /// </summary> /// <param name="parent">the parent box of this box</param> /// <param name="controller">the html tag data of this box</param> public CssBoxHr(Css.BoxSpec spec, RootGraphic rootgfx) : base(spec, rootgfx) { ChangeDisplayType(this, Css.CssDisplay.Block); }
/// <summary> /// Override to create the CSS class that component need. /// </summary> /// <param name="css">The instance of <see cref="T:YoiBlazor.Css" /> class.</param> protected override void CreateComponentCssClass(Css css) { css.Add("dimmer"); }
/// <summary> /// In HTML konvertieren /// </summary> /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param> /// <returns>Das Control als HTML</returns> public override IHtmlNode Render(RenderContextFormular context) { var renderContext = new RenderContextFormularGroup(context, this); var html = new HtmlElementTextContentDiv() { ID = ID, Class = Css.Concatenate("form-group-mix", GetClasses()), Style = GetStyles(), }; var body = new HtmlElementTextContentDiv() { }; foreach (var item in Items) { var input = item as ControlFormularItemInput; var row = new HtmlElementTextContentDiv() { }; if (input != null) { var icon = new ControlIcon() { Icon = input?.Icon }; var label = new ControlFormularItemLabel(!string.IsNullOrEmpty(item.ID) ? item.ID + "_label" : string.Empty); var help = new ControlFormularItemHelpText(!string.IsNullOrEmpty(item.ID) ? item.ID + "_help" : string.Empty); label.Initialize(renderContext); help.Initialize(renderContext); label.Text = context.I18N(input?.Label); label.FormularItem = item; label.Classes.Add("mr-2"); help.Text = context.I18N(input?.Help); if (icon.Icon != null) { icon.Classes.Add("mr-2 pt-1"); row.Elements.Add(new HtmlElementTextContentDiv(icon.Render(renderContext), label.Render(renderContext))); } else { row.Elements.Add(new HtmlElementTextContentDiv(label.Render(renderContext))); } if (!string.IsNullOrWhiteSpace(input?.Help)) { row.Elements.Add(new HtmlElementTextContentDiv(item.Render(renderContext), help.Render(renderContext))); } else { row.Elements.Add(new HtmlElementTextContentDiv(item.Render(renderContext))); } } else { row.Elements.Add(new HtmlElementTextContentDiv()); row.Elements.Add(item.Render(context)); row.Elements.Add(new HtmlElementTextContentDiv()); } body.Elements.Add(row); } html.Elements.Add(body); return(html); }
public static HtmlBuilder TextBox( this HtmlBuilder hb, HtmlTypes.TextTypes textType = HtmlTypes.TextTypes.Normal, string controlId = null, string controlCss = null, string text = null, string placeholder = null, string onChange = null, string format = null, bool timepicker = false, string accept = null, string dataId = null, bool validateRequired = false, bool validateNumber = false, decimal validateMinNumber = 0, decimal validateMaxNumber = 0, bool validateDate = false, bool validateEmail = false, string validateEqualTo = null, int validateMaxLength = 0, string action = null, string method = null, Dictionary <string, string> attributes = null, bool _using = true) { if (!_using) { return(hb); } switch (textType) { case HtmlTypes.TextTypes.Normal: return(hb.Input(attributes: new HtmlAttributes() .Id(controlId) .Class(Css.Class("control-textbox", controlCss)) .Type("text") .Value(text) .Placeholder(placeholder) .OnChange(onChange) .DataId(dataId) .DataValidateRequired(validateRequired) .DataValidateNumber(validateNumber) .DataValidateMinNumber( validateMinNumber, _using: validateMinNumber != validateMaxNumber) .DataValidateMaxNumber( validateMaxNumber, _using: validateMinNumber != validateMaxNumber) .DataValidateDate(validateDate) .DataValidateEmail(validateEmail) .DataValidateEqualTo(validateEqualTo) .DataValidateMaxLength(validateMaxLength) .DataAction(action) .DataMethod(method) .Add(attributes))); case HtmlTypes.TextTypes.DateTime: return(hb.Input(attributes: new HtmlAttributes() .Id(controlId) .Class(Css.Class("control-textbox datepicker", controlCss)) .Type("text") .Value(text) .Placeholder(placeholder) .OnChange(onChange) .DataId(dataId) .DataFormat(format) .DataTimepicker(timepicker) .DataValidateRequired(validateRequired) .DataValidateNumber(validateNumber) .DataValidateDate(validateDate) .DataValidateEmail(validateEmail) .DataValidateEqualTo(validateEqualTo) .DataValidateMaxLength(validateMaxLength) .DataAction(action) .DataMethod(method) .Add(attributes))); case HtmlTypes.TextTypes.MultiLine: return(hb.TextArea( attributes: new HtmlAttributes() .Id(controlId) .Class(Css.Class("control-textarea", controlCss)) .Placeholder(placeholder) .OnChange(onChange) .DataId(dataId) .DataValidateRequired(validateRequired) .DataValidateNumber(validateNumber) .DataValidateDate(validateDate) .DataValidateEmail(validateEmail) .DataValidateEqualTo(validateEqualTo) .DataValidateMaxLength(validateMaxLength) .DataAction(action) .DataMethod(method) .Add(attributes), action: () => hb .Text(text: text))); case HtmlTypes.TextTypes.Password: return(hb.Input(attributes: new HtmlAttributes() .Id(controlId) .Class(Css.Class("control-textbox", controlCss)) .Type("password") .Value(text) .Placeholder(placeholder) .OnChange(onChange) .DataId(dataId) .DataValidateRequired(validateRequired) .DataValidateNumber(validateNumber) .DataValidateDate(validateDate) .DataValidateEmail(validateEmail) .DataValidateEqualTo(validateEqualTo) .DataValidateMaxLength(validateMaxLength) .Add(attributes))); case HtmlTypes.TextTypes.File: return(hb.Input(attributes: new HtmlAttributes() .Id(controlId) .Class(Css.Class("control-textbox", controlCss)) .Type("file") .Value(text) .Placeholder(placeholder) .OnChange(onChange) .Accept(accept) .DataId(dataId) .DataValidateRequired(validateRequired) .DataValidateNumber(validateNumber) .DataValidateDate(validateDate) .DataValidateEmail(validateEmail) .DataValidateEqualTo(validateEqualTo) .DataValidateMaxLength(validateMaxLength) .DataAction(action) .DataMethod(method) .Add(attributes))); default: return(hb); } }
public static IAsset Style(Css? asset) { return new StyleAsset(asset); }