public void TestSciterElement() { SciterElement el = SciterElement.Create("div"); SciterElement el2 = new SciterElement(el._he); Assert.IsTrue(el == el2); }
public void RecreateTagPath(uint uid, List <uint> uidstack, List <string> tagpath) { if (actual_uidstack != null && actual_uidstack.Count >= uidstack.Count && Enumerable.SequenceEqual(uidstack, actual_uidstack.Take(uidstack.Count))) { var r = _se.ChildrenCount; var rrrr = _se.SelectAll("*"); var el_li = _se.SelectAll("li").Single(li => li.ExpandoValue["uuid"].Get(-1) == uid); el_li.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_CURRENT); } else { ResetTagPath(); actual_uidstack = uidstack; for (int i = 0; i < tagpath.Count; i++) { var el_li = SciterElement.Create("li"); _se.Append(el_li); el_li.SetHTML("<text>" + tagpath[i] + "</text>"); el_li.ExpandoValue["uuid"] = new SciterValue(uidstack[i]); if (uidstack[i] == uid) { el_li.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_CURRENT); } } App.AppHost.InvokePost(() => _se.Refresh()); } }
protected override bool OnFocus(SciterElement element, FocusArgs args) { Debug.WriteLine($"focus-behavior: {args.Event}"); SciterColor color; switch (args.Event) { case FocusEvents.Got: color = SciterColor.CornflowerBlue; break; case FocusEvents.Lost: color = SciterColor.Crimson; break; default: return(base.OnFocus(element, args)); } element .SetStyleValue("background-color", $"{color.ToShortHtmlColor()}") .SetHtml(SciterElement.Create("div", $"{args.Event}").Html); return(base.OnFocus(element, args)); }
public void TestSciterElement() { SciterElement el = SciterElement.Create("div"); SciterElement el2 = SciterElement.Attach(el.Handle); Assert.IsTrue(el == el2); }
public void Create_element_from_tag(string tag) { var element = SciterElement.Create(tag); Assert.IsNotNull(element); Assert.AreEqual(tag, element.Tag); }
public void Create_element_from_tag_and_text(string tag) { var element = SciterElement.Create(tag, "text"); Assert.IsNotNull(element); Assert.AreEqual(tag, element.Tag); Assert.AreEqual("text", element.Text); Assert.AreEqual($"<{tag}>text</{tag}>", element.Html); Assert.AreEqual("text", element.InnerHtml); }
public void AppendElement_using_SciterElement_with_Func_returns_the_correct_element(string expectedTag, string expectedChildTag) { var element = _sciterWindow .RootElement.AppendElement(SciterElement.Create(expectedTag), elm => elm.AppendElement(SciterElement.Create(expectedChildTag))); Assert.IsNotNull(element); Assert.AreEqual(expectedTag, element.Tag); Assert.AreEqual(1, _sciterWindow.RootElement.ChildCount); Assert.AreEqual(1, element.ChildCount); Assert.AreEqual(expectedChildTag, element.FirstChild().Tag); }
public void Element_set_and_get_state(string tag) { var element = SciterElement.Create(tag); element.SetState(ElementState.Checked); Assert.IsNotNull(element); Assert.IsTrue(element.State.HasFlag(ElementState.Checked)); Assert.AreEqual(element.State, element.GetState()); }
public void Element_set_and_get_attribute_value_from_func_with_object(string tag) { var element = SciterElement.Create(tag); element.SetAttributeValue("unittest", sciterElement => sciterElement.Tag, element); Assert.IsNotNull(element); Assert.AreEqual(tag, element.Tag); Assert.AreEqual(1, element.AttributeCount); Assert.AreEqual(tag, element.GetAttributeValue("unittest")); Assert.AreEqual(tag, element.Attributes["unittest"]); }
public void Clone_element(string tag) { var element = _sciterWindow .RootElement.AppendElement(SciterElement.Create(tag), elm => elm); var clonedElement = _sciterWindow .RootElement.AppendElement(element.Clone(), elm => elm); Assert.IsNotNull(element); Assert.IsNotNull(clonedElement); Assert.AreEqual(2, _sciterWindow.RootElement.ChildCount); Assert.AreNotEqual(element.UniqueId, clonedElement.UniqueId); }
public void Clear_element_text(string tag) { var element = _sciterWindow .RootElement.AppendElement(SciterElement.Create(tag), elm => elm); element.AppendElement("elm", "this is my text"); Assert.IsNotNull(element); Assert.IsFalse(string.IsNullOrWhiteSpace(element.Text)); element.ClearText(); Assert.AreEqual(string.Empty, element.Text); }
public void Element_set_and_get_attribute_value_from_string_v2(string tag) { var element = SciterElement.Create(tag); element["unittest"] = "value"; Assert.IsNotNull(element); Assert.AreEqual(tag, element.Tag); Assert.AreEqual(1, element.AttributeCount); Assert.AreEqual("value", element.GetAttributeValue("unittest")); Assert.AreEqual("value", element["unittest"]); Assert.AreEqual("value", element.Attributes["unittest"]); }
// tree DOM handling private static void AddElement(SciterElement tree_el_parent, SciterElement origin_el_add) { SciterNode origin_nd = origin_el_add.ToNode(); Debug.Assert(origin_nd.IsElement); string tag = origin_el_add.Tag; SciterElement tree_el_new = SciterElement.Create("option"); tree_el_parent.Append(tree_el_new); uint uid = origin_el_add.UID; Debug.Assert(uid != 0); tree_el_new.SetAttribute("value", uid.ToString()); tree_el_new.SetHTML(UI_ElementCaption(origin_el_add)); bool has_real_childs = false; uint nchilds = origin_nd.ChildrenCount; for (uint i = 0; i < nchilds; i++) { SciterNode nd = origin_nd[i]; if (nd.IsElement) { AddElement(tree_el_new, nd.ToElement()); has_real_childs = true; } else { bool new_option = AddNode(tree_el_new, uid, nd); if (new_option) { has_real_childs = true; } } } if (has_real_childs) { if (tag == "html" || tag == "body") { tree_el_new.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_EXPANDED); //tree_el_new.set_attribute("expanded", ""); } else { tree_el_new.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_COLLAPSED); } } }
public void Verify_element_prev_sibling() { var div = SciterElement.Create("div"); var text = SciterElement.Create("text"); var ul = SciterElement.Create("ul"); _sciterWindow .RootElement .AppendElement(div) .AppendElement(text) .AppendElement(ul); Assert.AreEqual(ul.PreviousSibling.UniqueId, text.UniqueId); Assert.AreEqual(text.PreviousSibling.UniqueId, div.UniqueId);; }
protected override bool OnExchange(SciterElement element, ExchangeArgs args) { switch (args.Event) { case ExchangeEvent.DragEnter: element.SetAttributeValue("active", "true"); return(true); case ExchangeEvent.DragLeave: element.RemoveAttribute("active"); return(true); case ExchangeEvent.Drag: return(true); case ExchangeEvent.Drop: element.RemoveAttribute("active"); var fileList = new List <string>(); if (args.Value.IsArray) { fileList.AddRange(args.Value.AsEnumerable().Where(w => w.IsString).Select(s => s.AsString())); } if (args.Value.IsString) { fileList.Add(args.Value.AsString()); } element.SetHtml(string.Concat(fileList.Select(s => SciterElement.Create("text", s).Html))); return(true); case ExchangeEvent.WillAcceptDrop: // Use this for a drop filter! //var fileList = new List<string>(); //if (args.Value.IsArray) // fileList.AddRange(args.Value.AsEnumerable().Where(w => w.IsString).Select(s => s.AsString())); //if (args.Value.IsString) // fileList.Add(args.Value.AsString()); //return fileList.All(a => Path.GetExtension(a).Equals(".exe")); return(true); default: return(base.OnExchange(element, args)); } }
public void Verify_element_next_sibling() { var div = SciterElement.Create("div"); var text = SciterElement.Create("text"); var ul = SciterElement.Create("ul"); _sciterWindow .RootElement .AppendElement(div) .AppendElement(text) .AppendElement(ul); Assert.AreEqual(_sciterWindow.RootElement.GetChildAtIndex(0).UniqueId, div.UniqueId); Assert.AreEqual(div.NextSibling.UniqueId, text.UniqueId); Assert.AreEqual(text.NextSibling.UniqueId, ul.UniqueId); }
public void Verify_element_parent() { var div = SciterElement.Create("div"); var text = SciterElement.Create("text"); var ul = SciterElement.Create("ul"); _sciterWindow .RootElement .AppendElement(div, elm => elm) .AppendElement(text, elm => elm) .AppendElement(ul, elm => elm); Assert.AreEqual(ul.Parent.UniqueId, text.UniqueId); Assert.AreEqual(text.Parent.UniqueId, div.UniqueId); Assert.AreEqual(div.Parent.UniqueId, _sciterWindow.RootElement.UniqueId); }
public void Verify_element_last_sibling() { var div = SciterElement.Create("div"); var text = SciterElement.Create("text"); var ul = SciterElement.Create("ul"); _sciterWindow .RootElement .AppendElement(div) .AppendElement(text) .AppendElement(ul); Assert.AreEqual(div.LastSibling.UniqueId, ul.UniqueId); Assert.AreEqual(text.LastSibling.UniqueId, ul.UniqueId); Assert.AreEqual(ul.LastSibling.UniqueId, ul.UniqueId); }
public void Element_first_last_child_at_index(string tag) { var element = _sciterWindow .RootElement.AppendElement(SciterElement.Create(tag), elm => elm); element .AppendElement("first", "first child") .AppendElement("middle", "middle child") .AppendElement("last", "last child"); Assert.IsNotNull(element); Assert.AreEqual(3, element.ChildCount); Assert.AreEqual(element[0].UniqueId, element.GetChildAtIndex(0).UniqueId); Assert.AreEqual(element[1].UniqueId, element.GetChildAtIndex(1).UniqueId); Assert.AreEqual(element[2].UniqueId, element.GetChildAtIndex(2).UniqueId); }
public void Element_first_last_child(string tag) { var element = _sciterWindow .RootElement.AppendElement(SciterElement.Create(tag), elm => elm); element .AppendElement("first", "first child") .AppendElement("middle", "middle child") .AppendElement("last", "last child"); Assert.IsNotNull(element); Assert.AreEqual(3, element.ChildCount); Assert.AreEqual(0, element.FirstChild().Index); Assert.AreEqual(element[element.FirstChild().Index].UniqueId, element.FirstChild().UniqueId); Assert.AreEqual(2, element.LastChild().Index); Assert.AreEqual(element[element.LastChild().Index].UniqueId, element.LastChild().UniqueId); }
private static bool AddNode(SciterElement tree_el_parent, uint origin_parent_uid, SciterNode origin_nd) { Debug.Assert(origin_nd.ChildrenCount == 0); if (origin_nd.IsComment) { return(false); } if (string.IsNullOrWhiteSpace(origin_nd.Text)) { return(false); } SciterElement tree_el_new = SciterElement.Create("option"); tree_el_parent.Append(tree_el_new); tree_el_new.SetAttribute("value", origin_parent_uid.ToString()); // UID tree_el_new.Text = origin_nd.Text; return(true); }