예제 #1
0
        /// <summary>
        /// Handles behavior attach
        /// </summary>
        unsafe static partial void Host_HandleAttachBehavior(ISciterNotifications host, IntPtr pns)
        {
            var datantf = (SCN_ATTACH_BEHAVIOR *)pns;
            var e       = new AttachBehaviorEventArgs(Element.Create(datantf->element), datantf->GetBehaviorName());

            host.ProcessAttachBehavior(e);

            e.Behavior = e.Behavior ?? SciterFactory.ResolveBehavior(e.BehaviorName);
            if (e.Behavior != null)
            {
                datantf->elementProc   = ElementEventProcEntryPoint;
                datantf->elementTag    = InstanceProtector.Protect(e.Behavior);
                datantf->elementEvents = (EVENT_GROUPS)e.EventGroups;
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a scripting ctor definition from the reflection info
        /// </summary>
        private static SciterNativeMethodDef DefineCtorMethod(Type type)
        {
            return(new SciterNativeMethodDef()
            {
                name = "this",

                // Construction callback implementation
                method = (IntPtr hvm, ref JsonValue p_data_slot, IntPtr argv, int argc, ref JsonValue retval) =>
                {
                    try
                    {
                        var result = Activator.CreateInstance(type, JsonPtrToArray(argv, argc));
                        var data_slot_value = InstanceProtector.Protect(result);

                        p_data_slot.SetNativeObject(data_slot_value);
                        _registrations[hvm].Instances.Add(data_slot_value, result);
                    }
                    catch (Exception ex)
                    {
                        SciterHostApi.SciterNativeThrow(hvm, ex.Message);
                    }
                }
            });
        }
예제 #3
0
        /// <summary>
        /// Assings host callback to the sciter window
        /// </summary>
        /// <param name="hWndSciter"></param>
        /// <param name="ntf"></param>
        public static void SciterSetCallback(IntPtr hWndSciter, ISciterNotifications ntf)
        {
            Debug.Assert(ntf != null, "Notification callback cannot be null");

            HTMLayoutSetCallback(hWndSciter, _nativeCallback, InstanceProtector.Protect(ntf));
        }
예제 #4
0
 /// <summary>
 /// Attach/Detach ElementEventProc to the Sciter window.
 /// All events will start first here (in SINKING phase) and if not consumed will end up here.
 /// You can install Window EventHandler only once - it will survive all document reloads.
 /// </summary>
 public void WindowDetachEventHandler(IntPtr hWnd, ISciterBehavior bhv)
 {
     CheckResult(SciterWindowDetachEventHandler(hWnd, SciterHostApi.ElementEventProcEntryPoint, InstanceProtector.Protect(bhv)));
 }
예제 #5
0
 /// <summary>
 /// Attach ElementEventProc to the element and subscribe it to events providede by subscription parameter
 /// See Sciter::attach_event_handler.
 /// </summary>
 public void AttachEventHandler(Element he, ISciterBehavior behavior)
 {
     CheckResult(SciterAttachEventHandler(he.Handle, SciterHostApi.ElementEventProcEntryPoint, InstanceProtector.Protect(behavior)));
 }
예제 #6
0
        /// <summary>
        /// Attach/Detach ElementEventProc to the element
        /// See Sciter::event_handler.
        /// </summary>
        public void DetachEventHandler(Element he, ISciterBehavior behavior)
        {
            var r = SciterDetachEventHandler(he.Handle, SciterHostApi.ElementEventProcEntryPoint, InstanceProtector.Protect(behavior));

            // DetachEventHandler can return SCDOM_PASSIVE_HANDLE if element was detached from the tree
            CheckResult(r == ScDomResult.SCDOM_PASSIVE_HANDLE ? ScDomResult.SCDOM_OK : r);
        }
예제 #7
0
 /// <summary>
 /// Assings host callback to the sciter window
 /// </summary>
 /// <param name="hWndSciter"></param>
 /// <param name="ntf"></param>
 public static void SciterSetCallback(IntPtr hWndSciter, ISciterNotifications ntf)
 {
     SciterSetCallback(hWndSciter, _nativeCallback, InstanceProtector.Protect(ntf));
 }