1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
10 /// <summary>Efl file saving interface
11 /// (Since EFL 1.22)</summary>
12 [Efl.IFileSaveConcrete.NativeMethods]
13 public interface IFileSave :
14 Efl.Eo.IWrapper, IDisposable
16 /// <summary>Save the given image object's contents to an (image) file.
17 /// 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.
19 /// 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".
20 /// (Since EFL 1.22)</summary>
21 /// <param name="file">The filename to be used to save the image (extension obligatory).</param>
22 /// <param name="key">The image key in the file (if an Eet one), or <c>null</c>, otherwise.</param>
23 /// <param name="info">The flags to be used (<c>null</c> for defaults).</param>
24 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
25 bool Save(System.String file, System.String key, ref Efl.FileSaveInfo info);
27 /// <summary>Efl file saving interface
28 /// (Since EFL 1.22)</summary>
29 sealed public class IFileSaveConcrete :
34 ///<summary>Pointer to the native class description.</summary>
35 public override System.IntPtr NativeClass
39 if (((object)this).GetType() == typeof(IFileSaveConcrete))
41 return GetEflClassStatic();
45 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
50 [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr
51 efl_file_save_interface_get();
52 /// <summary>Initializes a new instance of the <see cref="IFileSave"/> class.
53 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
54 private IFileSaveConcrete(System.IntPtr raw) : base(raw)
58 /// <summary>Save the given image object's contents to an (image) file.
59 /// 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.
61 /// 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".
62 /// (Since EFL 1.22)</summary>
63 /// <param name="file">The filename to be used to save the image (extension obligatory).</param>
64 /// <param name="key">The image key in the file (if an Eet one), or <c>null</c>, otherwise.</param>
65 /// <param name="info">The flags to be used (<c>null</c> for defaults).</param>
66 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
67 public bool Save(System.String file, System.String key, ref Efl.FileSaveInfo info) {
68 Efl.FileSaveInfo.NativeStruct _in_info = info;
69 var _ret_var = Efl.IFileSaveConcrete.NativeMethods.efl_file_save_ptr.Value.Delegate(this.NativeHandle,file, key, ref _in_info);
70 Eina.Error.RaiseIfUnhandledException();
74 private static IntPtr GetEflClassStatic()
76 return Efl.IFileSaveConcrete.efl_file_save_interface_get();
78 /// <summary>Wrapper for native methods and virtual method delegates.
79 /// For internal use by generated code only.</summary>
80 public class NativeMethods : Efl.Eo.NativeClass
82 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
83 /// <summary>Gets the list of Eo operations to override.</summary>
84 /// <returns>The list of Eo operations to be overload.</returns>
85 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
87 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
88 var methods = Efl.Eo.Globals.GetUserMethods(type);
90 if (efl_file_save_static_delegate == null)
92 efl_file_save_static_delegate = new efl_file_save_delegate(save);
95 if (methods.FirstOrDefault(m => m.Name == "Save") != null)
97 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) });
102 /// <summary>Returns the Eo class for the native methods of this class.</summary>
103 /// <returns>The native class pointer.</returns>
104 public override IntPtr GetEflClass()
106 return Efl.IFileSaveConcrete.efl_file_save_interface_get();
109 #pragma warning disable CA1707, CS1591, SA1300, SA1600
111 [return: MarshalAs(UnmanagedType.U1)]
112 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.NativeStruct info);
114 [return: MarshalAs(UnmanagedType.U1)]
115 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.NativeStruct info);
117 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");
119 private static bool save(System.IntPtr obj, System.IntPtr pd, System.String file, System.String key, ref Efl.FileSaveInfo.NativeStruct info)
121 Eina.Log.Debug("function efl_file_save was called");
122 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
125 Efl.FileSaveInfo _in_info = info;
126 bool _ret_var = default(bool);
129 _ret_var = ((IFileSave)ws.Target).Save(file, key, ref _in_info);
133 Eina.Log.Warning($"Callback error: {e.ToString()}");
134 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
143 return efl_file_save_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), file, key, ref info);
147 private static efl_file_save_delegate efl_file_save_static_delegate;
149 #pragma warning restore CA1707, CS1591, SA1300, SA1600
157 /// <summary>Info used to determine various attributes when saving a file.
158 /// (Since EFL 1.22)</summary>
159 [StructLayout(LayoutKind.Sequential)]
160 public struct FileSaveInfo
162 /// <summary>The quality level (0-100) to save the file with; commonly used when saving image files.</summary>
164 /// <summary>The compression level (0-100) to save the file with.</summary>
165 public uint Compression;
166 /// <summary>The encoding to use when saving the file.</summary>
167 public System.String Encoding;
168 ///<summary>Constructor for FileSaveInfo.</summary>
170 uint Quality = default(uint),
171 uint Compression = default(uint),
172 System.String Encoding = default(System.String) )
174 this.Quality = Quality;
175 this.Compression = Compression;
176 this.Encoding = Encoding;
179 ///<summary>Implicit conversion to the managed representation from a native pointer.</summary>
180 ///<param name="ptr">Native pointer to be converted.</param>
181 public static implicit operator FileSaveInfo(IntPtr ptr)
183 var tmp = (FileSaveInfo.NativeStruct)Marshal.PtrToStructure(ptr, typeof(FileSaveInfo.NativeStruct));
187 #pragma warning disable CS1591
189 ///<summary>Internal wrapper for struct FileSaveInfo.</summary>
190 [StructLayout(LayoutKind.Sequential)]
191 public struct NativeStruct
196 public uint Compression;
197 ///<summary>Internal wrapper for field Encoding</summary>
198 public System.IntPtr Encoding;
199 ///<summary>Implicit conversion to the internal/marshalling representation.</summary>
200 public static implicit operator FileSaveInfo.NativeStruct(FileSaveInfo _external_struct)
202 var _internal_struct = new FileSaveInfo.NativeStruct();
203 _internal_struct.Quality = _external_struct.Quality;
204 _internal_struct.Compression = _external_struct.Compression;
205 _internal_struct.Encoding = Eina.MemoryNative.StrDup(_external_struct.Encoding);
206 return _internal_struct;
209 ///<summary>Implicit conversion to the managed representation.</summary>
210 public static implicit operator FileSaveInfo(FileSaveInfo.NativeStruct _internal_struct)
212 var _external_struct = new FileSaveInfo();
213 _external_struct.Quality = _internal_struct.Quality;
214 _external_struct.Compression = _internal_struct.Compression;
215 _external_struct.Encoding = Eina.StringConversion.NativeUtf8ToManagedString(_internal_struct.Encoding);
216 return _external_struct;
221 #pragma warning restore CS1591