1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
8 /// <summary>Efl file saving interface</summary>
9 [FileSaveNativeInherit]
10 public interface FileSave :
11 Efl.Eo.IWrapper, IDisposable
13 /// <summary>Save the given image object's contents to an (image) file.
14 /// The extension suffix on <c>file</c> will determine which saver module Evas is to use when saving, thus the final file's format. If the file supports multiple data stored in it (Eet ones), you can specify the key to be used as the index of the image in it.
16 /// You can specify some flags when saving the image. Currently acceptable flags are <c>quality</c> and <c>compress</c>. Eg.: "quality=100 compress=9".</summary>
17 /// <param name="file">The filename to be used to save the image (extension obligatory).</param>
18 /// <param name="key">The image key in the file (if an Eet one), or <c>null</c>, otherwise.</param>
19 /// <param name="info">The flags to be used (<c>null</c> for defaults).</param>
20 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
21 bool Save( System.String file, System.String key, ref Efl.FileSaveInfo info);
23 /// <summary>Efl file saving interface</summary>
24 sealed public class FileSaveConcrete :
29 ///<summary>Pointer to the native class description.</summary>
30 public System.IntPtr NativeClass {
32 if (((object)this).GetType() == typeof (FileSaveConcrete))
33 return Efl.FileSaveNativeInherit.GetEflClassStatic();
35 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
38 private System.IntPtr handle;
39 ///<summary>Pointer to the native instance.</summary>
40 public System.IntPtr NativeHandle {
41 get { return handle; }
43 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
44 efl_file_save_interface_get();
45 ///<summary>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
46 public FileSaveConcrete(System.IntPtr raw)
49 register_event_proxies();
51 ///<summary>Destructor.</summary>
56 ///<summary>Releases the underlying native instance.</summary>
57 void Dispose(bool disposing)
59 if (handle != System.IntPtr.Zero) {
60 Efl.Eo.Globals.efl_unref(handle);
61 handle = System.IntPtr.Zero;
64 ///<summary>Releases the underlying native instance.</summary>
68 GC.SuppressFinalize(this);
70 ///<summary>Casts obj into an instance of this type.</summary>
71 public static FileSaveConcrete static_cast(Efl.Object obj)
74 throw new System.ArgumentNullException("obj");
75 return new FileSaveConcrete(obj.NativeHandle);
77 ///<summary>Verifies if the given object is equal to this one.</summary>
78 public override bool Equals(object obj)
80 var other = obj as Efl.Object;
83 return this.NativeHandle == other.NativeHandle;
85 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
86 public override int GetHashCode()
88 return this.NativeHandle.ToInt32();
90 ///<summary>Turns the native pointer into a string representation.</summary>
91 public override String ToString()
93 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
95 void register_event_proxies()
98 /// <summary>Save the given image object's contents to an (image) file.
99 /// The extension suffix on <c>file</c> will determine which saver module Evas is to use when saving, thus the final file's format. If the file supports multiple data stored in it (Eet ones), you can specify the key to be used as the index of the image in it.
101 /// You can specify some flags when saving the image. Currently acceptable flags are <c>quality</c> and <c>compress</c>. Eg.: "quality=100 compress=9".</summary>
102 /// <param name="file">The filename to be used to save the image (extension obligatory).</param>
103 /// <param name="key">The image key in the file (if an Eet one), or <c>null</c>, otherwise.</param>
104 /// <param name="info">The flags to be used (<c>null</c> for defaults).</param>
105 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
106 public bool Save( System.String file, System.String key, ref Efl.FileSaveInfo info) {
107 var _in_info = Efl.FileSaveInfo_StructConversion.ToInternal(info);
108 var _ret_var = Efl.FileSaveNativeInherit.efl_file_save_ptr.Value.Delegate(this.NativeHandle, file, key, ref _in_info);
109 Eina.Error.RaiseIfUnhandledException();
110 info = Efl.FileSaveInfo_StructConversion.ToManaged(_in_info);
114 public class FileSaveNativeInherit : Efl.Eo.NativeClass{
115 public static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Efl);
116 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
118 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
119 if (efl_file_save_static_delegate == null)
120 efl_file_save_static_delegate = new efl_file_save_delegate(save);
121 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, "efl_file_save"), func = Marshal.GetFunctionPointerForDelegate(efl_file_save_static_delegate)});
124 public override IntPtr GetEflClass()
126 return Efl.FileSaveConcrete.efl_file_save_interface_get();
128 public static IntPtr GetEflClassStatic()
130 return Efl.FileSaveConcrete.efl_file_save_interface_get();
134 [return: MarshalAs(UnmanagedType.U1)] private delegate bool efl_file_save_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String file, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String key, ref Efl.FileSaveInfo_StructInternal info);
137 [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_file_save_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String file, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))] System.String key, ref Efl.FileSaveInfo_StructInternal info);
138 public static Efl.Eo.FunctionWrapper<efl_file_save_api_delegate> efl_file_save_ptr = new Efl.Eo.FunctionWrapper<efl_file_save_api_delegate>(_Module, "efl_file_save");
139 private static bool save(System.IntPtr obj, System.IntPtr pd, System.String file, System.String key, ref Efl.FileSaveInfo_StructInternal info)
141 Eina.Log.Debug("function efl_file_save was called");
142 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.data_get(pd);
143 if(wrapper != null) {
144 var _in_info = Efl.FileSaveInfo_StructConversion.ToManaged(info);
145 bool _ret_var = default(bool);
147 _ret_var = ((FileSave)wrapper).Save( file, key, ref _in_info);
148 } catch (Exception e) {
149 Eina.Log.Warning($"Callback error: {e.ToString()}");
150 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
152 info = Efl.FileSaveInfo_StructConversion.ToInternal(_in_info);
155 return efl_file_save_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), file, key, ref info);
158 private static efl_file_save_delegate efl_file_save_static_delegate;
162 /// <summary>Info used to determine various attributes when saving a file.</summary>
163 [StructLayout(LayoutKind.Sequential)]
164 public struct FileSaveInfo
166 /// <summary>The quality level (0-100) to save the file with; commonly used when saving image files.</summary>
168 /// <summary>The compression level (0-100) to save the file with.</summary>
169 public uint Compression;
170 /// <summary>The encoding to use when saving the file.</summary>
171 public System.String Encoding;
172 ///<summary>Constructor for FileSaveInfo.</summary>
174 uint Quality=default( uint),
175 uint Compression=default( uint),
176 System.String Encoding=default( System.String) )
178 this.Quality = Quality;
179 this.Compression = Compression;
180 this.Encoding = Encoding;
182 public static implicit operator FileSaveInfo(IntPtr ptr)
184 var tmp = (FileSaveInfo_StructInternal)Marshal.PtrToStructure(ptr, typeof(FileSaveInfo_StructInternal));
185 return FileSaveInfo_StructConversion.ToManaged(tmp);
188 ///<summary>Internal wrapper for struct FileSaveInfo.</summary>
189 [StructLayout(LayoutKind.Sequential)]
190 public struct FileSaveInfo_StructInternal
195 public uint Compression;
196 ///<summary>Internal wrapper for field Encoding</summary>
197 public System.IntPtr Encoding;
198 ///<summary>Implicit conversion to the internal/marshalling representation.</summary>
199 public static implicit operator FileSaveInfo(FileSaveInfo_StructInternal struct_)
201 return FileSaveInfo_StructConversion.ToManaged(struct_);
203 ///<summary>Implicit conversion to the managed representation.</summary>
204 public static implicit operator FileSaveInfo_StructInternal(FileSaveInfo struct_)
206 return FileSaveInfo_StructConversion.ToInternal(struct_);
209 /// <summary>Conversion class for struct FileSaveInfo</summary>
210 public static class FileSaveInfo_StructConversion
212 internal static FileSaveInfo_StructInternal ToInternal(FileSaveInfo _external_struct)
214 var _internal_struct = new FileSaveInfo_StructInternal();
216 _internal_struct.Quality = _external_struct.Quality;
217 _internal_struct.Compression = _external_struct.Compression;
218 _internal_struct.Encoding = Eina.MemoryNative.StrDup(_external_struct.Encoding);
220 return _internal_struct;
223 internal static FileSaveInfo ToManaged(FileSaveInfo_StructInternal _internal_struct)
225 var _external_struct = new FileSaveInfo();
227 _external_struct.Quality = _internal_struct.Quality;
228 _external_struct.Compression = _internal_struct.Compression;
229 _external_struct.Encoding = Eina.StringConversion.NativeUtf8ToManagedString(_internal_struct.Encoding);
231 return _external_struct;