1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
12 /// <summary>Efl UI Property_Bind interface. view object can have <see cref="Efl.IModel"/> to manage the data, the interface can help loading and tracking child data from the model property. see <see cref="Efl.IModel"/> see <see cref="Efl.Ui.IFactory"/></summary>
13 [Efl.Ui.IPropertyBindConcrete.NativeMethods]
14 [Efl.Eo.BindingEntity]
15 public interface IPropertyBind :
16 Efl.Eo.IWrapper, IDisposable
18 /// <summary>bind property data with the given key string. when the data is ready or changed, bind the data to the key action and process promised work.</summary>
19 /// <param name="key">key string for bind model property data</param>
20 /// <param name="property">Model property name</param>
21 /// <returns>0 when it succeed, an error code otherwise.</returns>
22 Eina.Error PropertyBind(System.String key, System.String property);
23 /// <summary>Event dispatched when a property on the object has changed due to an user interaction on the object that a model could be interested in.</summary>
24 event EventHandler<Efl.Ui.IPropertyBindPropertiesChangedEvt_Args> PropertiesChangedEvt;
25 /// <summary>Event dispatched when a property on the object is bound to a model. This is useful to not overgenerate event.</summary>
26 event EventHandler<Efl.Ui.IPropertyBindPropertyBoundEvt_Args> PropertyBoundEvt;
28 ///<summary>Event argument wrapper for event <see cref="Efl.Ui.IPropertyBind.PropertiesChangedEvt"/>.</summary>
29 [Efl.Eo.BindingEntity]
30 public class IPropertyBindPropertiesChangedEvt_Args : EventArgs {
31 ///<summary>Actual event payload.</summary>
32 public Efl.Ui.PropertyEvent arg { get; set; }
34 ///<summary>Event argument wrapper for event <see cref="Efl.Ui.IPropertyBind.PropertyBoundEvt"/>.</summary>
35 [Efl.Eo.BindingEntity]
36 public class IPropertyBindPropertyBoundEvt_Args : EventArgs {
37 ///<summary>Actual event payload.</summary>
38 public System.String arg { get; set; }
40 /// <summary>Efl UI Property_Bind interface. view object can have <see cref="Efl.IModel"/> to manage the data, the interface can help loading and tracking child data from the model property. see <see cref="Efl.IModel"/> see <see cref="Efl.Ui.IFactory"/></summary>
41 sealed public class IPropertyBindConcrete :
46 ///<summary>Pointer to the native class description.</summary>
47 public override System.IntPtr NativeClass
51 if (((object)this).GetType() == typeof(IPropertyBindConcrete))
53 return GetEflClassStatic();
57 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
62 /// <summary>Constructor to be used when objects are expected to be constructed from native code.</summary>
63 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
64 private IPropertyBindConcrete(ConstructingHandle ch) : base(ch)
68 [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr
69 efl_ui_property_bind_interface_get();
70 /// <summary>Initializes a new instance of the <see cref="IPropertyBind"/> class.
71 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
72 /// <param name="wh">The native pointer to be wrapped.</param>
73 private IPropertyBindConcrete(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
77 /// <summary>Event dispatched when a property on the object has changed due to an user interaction on the object that a model could be interested in.</summary>
78 public event EventHandler<Efl.Ui.IPropertyBindPropertiesChangedEvt_Args> PropertiesChangedEvt
82 lock (eflBindingEventLock)
84 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
86 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
89 Efl.Ui.IPropertyBindPropertiesChangedEvt_Args args = new Efl.Ui.IPropertyBindPropertiesChangedEvt_Args();
93 value?.Invoke(obj, args);
97 Eina.Log.Error(e.ToString());
98 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
103 string key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTIES_CHANGED";
104 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
110 lock (eflBindingEventLock)
112 string key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTIES_CHANGED";
113 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
117 ///<summary>Method to raise event PropertiesChangedEvt.</summary>
118 public void OnPropertiesChangedEvt(Efl.Ui.IPropertyBindPropertiesChangedEvt_Args e)
120 var key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTIES_CHANGED";
121 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
122 if (desc == IntPtr.Zero)
124 Eina.Log.Error($"Failed to get native event {key}");
128 IntPtr info = Marshal.AllocHGlobal(Marshal.SizeOf(e.arg));
131 Marshal.StructureToPtr(e.arg, info, false);
132 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
136 Marshal.FreeHGlobal(info);
139 /// <summary>Event dispatched when a property on the object is bound to a model. This is useful to not overgenerate event.</summary>
140 public event EventHandler<Efl.Ui.IPropertyBindPropertyBoundEvt_Args> PropertyBoundEvt
144 lock (eflBindingEventLock)
146 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
148 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
151 Efl.Ui.IPropertyBindPropertyBoundEvt_Args args = new Efl.Ui.IPropertyBindPropertyBoundEvt_Args();
152 args.arg = Eina.StringConversion.NativeUtf8ToManagedString(evt.Info);
155 value?.Invoke(obj, args);
159 Eina.Log.Error(e.ToString());
160 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
165 string key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTY_BOUND";
166 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
172 lock (eflBindingEventLock)
174 string key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTY_BOUND";
175 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
179 ///<summary>Method to raise event PropertyBoundEvt.</summary>
180 public void OnPropertyBoundEvt(Efl.Ui.IPropertyBindPropertyBoundEvt_Args e)
182 var key = "_EFL_UI_PROPERTY_BIND_EVENT_PROPERTY_BOUND";
183 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
184 if (desc == IntPtr.Zero)
186 Eina.Log.Error($"Failed to get native event {key}");
190 IntPtr info = Eina.StringConversion.ManagedStringToNativeUtf8Alloc(e.arg);
193 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, info);
197 Eina.MemoryNative.Free(info);
200 /// <summary>bind property data with the given key string. when the data is ready or changed, bind the data to the key action and process promised work.</summary>
201 /// <param name="key">key string for bind model property data</param>
202 /// <param name="property">Model property name</param>
203 /// <returns>0 when it succeed, an error code otherwise.</returns>
204 public Eina.Error PropertyBind(System.String key, System.String property) {
205 var _ret_var = Efl.Ui.IPropertyBindConcrete.NativeMethods.efl_ui_property_bind_ptr.Value.Delegate(this.NativeHandle,key, property);
206 Eina.Error.RaiseIfUnhandledException();
209 private static IntPtr GetEflClassStatic()
211 return Efl.Ui.IPropertyBindConcrete.efl_ui_property_bind_interface_get();
213 /// <summary>Wrapper for native methods and virtual method delegates.
214 /// For internal use by generated code only.</summary>
215 public new class NativeMethods : Efl.Eo.EoWrapper.NativeMethods
217 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
218 /// <summary>Gets the list of Eo operations to override.</summary>
219 /// <returns>The list of Eo operations to be overload.</returns>
220 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
222 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
223 var methods = Efl.Eo.Globals.GetUserMethods(type);
225 if (efl_ui_property_bind_static_delegate == null)
227 efl_ui_property_bind_static_delegate = new efl_ui_property_bind_delegate(property_bind);
230 if (methods.FirstOrDefault(m => m.Name == "PropertyBind") != null)
232 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_ui_property_bind"), func = Marshal.GetFunctionPointerForDelegate(efl_ui_property_bind_static_delegate) });
237 /// <summary>Returns the Eo class for the native methods of this class.</summary>
238 /// <returns>The native class pointer.</returns>
239 public override IntPtr GetEflClass()
241 return Efl.Ui.IPropertyBindConcrete.efl_ui_property_bind_interface_get();
244 #pragma warning disable CA1707, CS1591, SA1300, SA1600
247 private delegate Eina.Error efl_ui_property_bind_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String key, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String property);
250 public delegate Eina.Error efl_ui_property_bind_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String key, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String property);
252 public static Efl.Eo.FunctionWrapper<efl_ui_property_bind_api_delegate> efl_ui_property_bind_ptr = new Efl.Eo.FunctionWrapper<efl_ui_property_bind_api_delegate>(Module, "efl_ui_property_bind");
254 private static Eina.Error property_bind(System.IntPtr obj, System.IntPtr pd, System.String key, System.String property)
256 Eina.Log.Debug("function efl_ui_property_bind was called");
257 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
260 Eina.Error _ret_var = default(Eina.Error);
263 _ret_var = ((IPropertyBind)ws.Target).PropertyBind(key, property);
267 Eina.Log.Warning($"Callback error: {e.ToString()}");
268 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
276 return efl_ui_property_bind_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), key, property);
280 private static efl_ui_property_bind_delegate efl_ui_property_bind_static_delegate;
282 #pragma warning restore CA1707, CS1591, SA1300, SA1600
294 /// <summary>EFL Ui property event data structure triggered when an object property change due to the interaction on the object.</summary>
295 [StructLayout(LayoutKind.Sequential)]
296 [Efl.Eo.BindingEntity]
297 public struct PropertyEvent
299 /// <summary>List of changed properties</summary>
300 public Eina.Array<Eina.Stringshare> Changed_properties;
301 ///<summary>Constructor for PropertyEvent.</summary>
302 public PropertyEvent(
303 Eina.Array<Eina.Stringshare> Changed_properties = default(Eina.Array<Eina.Stringshare>) )
305 this.Changed_properties = Changed_properties;
308 ///<summary>Implicit conversion to the managed representation from a native pointer.</summary>
309 ///<param name="ptr">Native pointer to be converted.</param>
310 public static implicit operator PropertyEvent(IntPtr ptr)
312 var tmp = (PropertyEvent.NativeStruct)Marshal.PtrToStructure(ptr, typeof(PropertyEvent.NativeStruct));
316 #pragma warning disable CS1591
318 ///<summary>Internal wrapper for struct PropertyEvent.</summary>
319 [StructLayout(LayoutKind.Sequential)]
320 public struct NativeStruct
323 public System.IntPtr Changed_properties;
324 ///<summary>Implicit conversion to the internal/marshalling representation.</summary>
325 public static implicit operator PropertyEvent.NativeStruct(PropertyEvent _external_struct)
327 var _internal_struct = new PropertyEvent.NativeStruct();
328 _internal_struct.Changed_properties = _external_struct.Changed_properties.Handle;
329 return _internal_struct;
332 ///<summary>Implicit conversion to the managed representation.</summary>
333 public static implicit operator PropertyEvent(PropertyEvent.NativeStruct _internal_struct)
335 var _external_struct = new PropertyEvent();
336 _external_struct.Changed_properties = new Eina.Array<Eina.Stringshare>(_internal_struct.Changed_properties, false, false);
337 return _external_struct;
342 #pragma warning restore CS1591