Пример #1
0
        /// <summary>
        /// Create new element, the element is disconnected initially from the DOM.
        /// Element created with ref_count = 1 thus you must call Sciter_UnuseElement on returned handler.
        /// </summary>
        public ElementRef CreateElement(string tag, string text)
        {
            var he = default(IntPtr);

            CheckResult(SciterCreateElement(MarshalUtility.StringToAnsi(tag), text, out he));
            return(new ElementRef(he));
        }
Пример #2
0
        /// <summary>
        /// Get element's style attribute.
        /// </summary>
        public string GetStyleAttribute(Element he, String name)
        {
            var value = default(IntPtr);

            CheckResult(SciterGetStyleAttribute(he.Handle, MarshalUtility.StringToAnsi(name), out value));
            return(Marshal.PtrToStringUni(value));
        }
Пример #3
0
        /// <summary>
        /// Get value of any element's attribute by name.
        /// </summary>
        public string GetAttribute(IntPtr he, string name)
        {
            var value = default(IntPtr);

            CheckResult(SciterGetAttributeByName(he, MarshalUtility.StringToAnsi(name), out value));
            return(Marshal.PtrToStringUni(value));
        }
Пример #4
0
        /// <summary>
        /// Load HTML from in memory buffer with base.
        /// </summary>
        public static bool SciterLoadHtml(IntPtr hWndSciter, string html, string baseUrl)
        {
            Debug.Assert(html != null, "Html parameter cannot be null");

            var bytes = MarshalUtility.StringToByteUtf8(html, true);

            return(HtmlayoutLoadHtml(hWndSciter, bytes, bytes.Length, baseUrl));
        }
Пример #5
0
        /// <summary>
        /// Get text of the element and information where child elements are placed.
        /// </summary>
        public string GetElementHtml(Element element, bool outer)
        {
            IntPtr text;

            CheckResult(SciterGetElementHtml(element.Handle, out text, outer));

            return(MarshalUtility.PtrToStringUtf8(text));
        }
Пример #6
0
        /// <summary>
        /// Get element's text.
        /// </summary>
        public string GetElementType(Element element)
        {
            IntPtr type;

            CheckResult(SciterGetElementType(element.Handle, out type));

            return(MarshalUtility.PtrToStringAnsi(type));
        }
Пример #7
0
        /// <summary>
        /// Returns parent element satisfying given css selector
        /// </summary>
        public Element SelectParent(Element element, string cssSelector, int depth)
        {
            var parent = default(IntPtr);

            CheckResult(SciterSelectParent(element.Handle, MarshalUtility.StringToAnsi(cssSelector), depth, out parent));

            return(Element.Create(parent));
        }
Пример #8
0
        /// <summary>
        /// Get value of any element's attribute by attribute's number.
        /// </summary>
        public KeyValuePair <string, string> GetAttribute(Element he, int index)
        {
            IntPtr name;
            IntPtr value;

            CheckResult(SciterGetNthAttribute(he.Handle, index, out name, out value));

            return(new KeyValuePair <string, string>(MarshalUtility.PtrToStringAnsi(name), Marshal.PtrToStringUni(value)));
        }
Пример #9
0
        /// <summary>
        /// Selects child elements
        /// </summary>
        public void SelectElements(Element he, String cssSelector, Predicate <Element> selector)
        {
            var result = SciterSelectElements(he.Handle, MarshalUtility.StringToAnsi(cssSelector),
                                              (IntPtr handle, IntPtr arg) =>
            {
                var element  = Element.CreateInternal(handle);
                var selected = selector(element);

                element.Drop();
                return(selected ? 1 : 0);
            }, IntPtr.Zero);

            CheckResult(result);
        }
Пример #10
0
 /// <summary>
 /// Sets a new value to json object
 /// </summary>
 public void SetValue(object data)
 {
     if (data != null)
     {
         if (data is string)
         {
             var str = (string)data;
             NativeMethods.ValueStringDataSet(ref this, str, str.Length, 0);
         }
         else if (data is int)
         {
             var ival = (int)data;
             NativeMethods.ValueIntDataSet(ref this, ival, VALUE_TYPE.T_INT, 0);
         }
         else if (data is double)
         {
             var dval = (double)data;
             NativeMethods.ValueFloatDataSet(ref this, dval, VALUE_TYPE.T_FLOAT, 0);
         }
         else if (data is bool)
         {
             var bval = (bool)data;
             NativeMethods.ValueIntDataSet(ref this, bval ? 1 : 0, VALUE_TYPE.T_BOOL, 0);
         }
         else if (data is byte[])
         {
             var bytes = (byte[])data;
             NativeMethods.ValueBinaryDataSet(ref this, bytes, bytes.Length, VALUE_TYPE.T_BYTES, 0);
         }
         else if (data is decimal)
         {
             var ddata = (decimal)data;
             NativeMethods.ValueInt64DataSet(ref this, Decimal.ToInt64(ddata), VALUE_TYPE.T_CURRENCY, 0);
         }
         else if (data is DateTime)
         {
             var ddata = (DateTime)data;
             if (ddata.Kind == DateTimeKind.Utc)
             {
                 NativeMethods.ValueInt64DataSet(ref this, ddata.ToFileTimeUtc(), VALUE_TYPE.T_DATE, 7 + (int)VALUE_UNIT_TYPE_DATE.DT_UTC);
             }
             else
             {
                 NativeMethods.ValueInt64DataSet(ref this, ddata.ToFileTime(), VALUE_TYPE.T_DATE, 7);
             }
         }
         else if (data is IDictionary)
         {
             SetDictValue((IDictionary)data);
         }
         else if (data is IList)
         {
             SetArrayValue((IList)data);
         }
         else
         {
             SetDictValue(MarshalUtility.ObjectToDict(data));
         }
     }
     else
     {
         Clear();
     }
 }
Пример #11
0
 /// <summary>
 /// Returns method name
 /// </summary>
 public string GetName()
 {
     return(MarshalUtility.PtrToStringAnsi(name));
 }
Пример #12
0
            public EVENT_GROUPS elementEvents; /**< [out] EVENT_GROUPS bit flags, event groups elementProc subscribed to. */

            public String GetBehaviorName()
            {
                return(MarshalUtility.PtrToStringAnsi(behaviorName));
            }
Пример #13
0
 public byte[] GetData()
 {
     return(MarshalUtility.MarshalData(data, dataSize));
 }
Пример #14
0
 /// <summary>
 /// Set element's style attribute.
 /// </summary>
 public void SetStyleAttribute(Element he, String name, String value)
 {
     CheckResult(SciterSetStyleAttribute(he.Handle, MarshalUtility.StringToAnsi(name), value));
 }
Пример #15
0
        /// <summary>
        /// Updates element html
        /// </summary>
        public void SetElementHtml(Element he, String text, SET_ELEMENT_HTML loc)
        {
            var bytes = MarshalUtility.StringToByteUtf8(text);

            CheckResult(SciterSetElementHtml(he.Handle, bytes, bytes.Length, loc));
        }