/// <summary> /// The callback of the Realized event. /// </summary> /// <since_tizen> preview </since_tizen> protected override void OnRealized() { base.OnRealized(); _focused = new SmartEvent(this, "focused"); _focused.On += (s, e) => Focused?.Invoke(this, EventArgs.Empty); _unfocused = new SmartEvent(this, "unfocused"); _unfocused.On += (s, e) => Unfocused?.Invoke(this, EventArgs.Empty); }
/// <summary> /// The callback of the Realized event. /// </summary> /// <since_tizen> preview </since_tizen> protected override void OnRealized() { base.OnRealized(); _changed = new SmartEvent(this, this.RealHandle, "changed"); _changed.On += (s, e) => ValueChanged?.Invoke(this, EventArgs.Empty); _delayedChanged = new SmartEvent(this, this.RealHandle, "delay,changed"); _delayedChanged.On += (s, e) => DelayedValueChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// The callback of Realized Event /// </summary> /// <since_tizen> preview </since_tizen> protected override void OnRealized() { base.OnRealized(); _scroll = new SmartEvent(this, this.RealHandle, "scroll"); _scrollAnimationStart = new SmartEvent(this, this.RealHandle, "scroll,anim,start"); _scrollAnimationStop = new SmartEvent(this, this.RealHandle, "scroll,anim,stop"); _dragStart = new SmartEvent(this, this.RealHandle, "scroll,drag,start"); _dragStop = new SmartEvent(this, this.RealHandle, "scroll,drag,stop"); _scrollpage = new SmartEvent(this, this.RealHandle, "scroll,page,changed"); }
/// <summary> /// Creates and initializes a new instance of the FlipSelector. /// </summary> /// <param name="parent">Parent EvasObject </param> /// <since_tizen> preview </since_tizen> public FlipSelector(EvasObject parent) : base(parent) { _selected = new SmartEvent(this, Handle, "selected"); _overflowed = new SmartEvent(this, Handle, "overflowed"); _underflowed = new SmartEvent(this, Handle, "underflowed"); _selected.On += SelectedChanged; _overflowed.On += OverflowedChanged; _underflowed.On += UnderflowedChanged; }
/// <summary> /// The callback of the Realized event. /// </summary> /// <since_tizen> preview </since_tizen> protected override void OnRealized() { base.OnRealized(); _changed = new SmartEvent(this, this.RealHandle, "changed"); _changed.On += (s, e) => { DateTime newDateTime = DateTime; DateTimeChanged?.Invoke(this, new DateChangedEventArgs(_cacheDateTime, newDateTime)); DateTime = newDateTime; }; }
/// <summary> /// Sets the file that is used as the image's source with async. /// </summary> /// <param name="file">The path to the file that is used as an image source.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>(true = success, false = error)</returns> /// <since_tizen> preview </since_tizen> public async Task <bool> LoadAsync(string file, CancellationToken cancellationToken = default(CancellationToken)) { if (file == null) { throw new ArgumentNullException(nameof(file)); } Interop.Elementary.elm_image_async_open_set(RealHandle, true); Interop.Elementary.elm_image_preload_disabled_set(RealHandle, false); var tcs = new TaskCompletionSource <bool>(); cancellationToken.Register(() => { if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetCanceled(); } }); SmartEvent loadReady = new SmartEvent(this, RealHandle, "load,ready"); loadReady.On += (s, e) => { LoadingCompleted?.Invoke(this, EventArgs.Empty); if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetResult(true); } }; SmartEvent loadError = new SmartEvent(this, RealHandle, "load,error"); loadError.On += (s, e) => { LoadingFailed?.Invoke(this, EventArgs.Empty); if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetResult(false); } }; using (loadReady) using (loadError) { bool ret = Interop.Elementary.elm_image_file_set(RealHandle, file, null); if (!ret) { throw new InvalidOperationException("Failed to set file to Image"); } // it should be return on main thread, because SmartEvent should be disposed on main thread return(await tcs.Task.ConfigureAwait(true)); } }
/// <summary> /// Sets the file that is used as the image's source with async. /// </summary> /// <param name="file">The path to the file that is used as an image source.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>(true = success, false = error)</returns> /// <since_tizen> preview </since_tizen> public Task <bool> LoadAsync(string file, CancellationToken cancellationToken = default(CancellationToken)) { if (file == null) { throw new ArgumentNullException("file"); } Interop.Elementary.elm_image_async_open_set(RealHandle, true); Interop.Elementary.elm_image_preload_disabled_set(RealHandle, false); var tcs = new TaskCompletionSource <bool>(); cancellationToken.Register(() => { if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetCanceled(); } }); SmartEvent loadReady = new SmartEvent(this, RealHandle, "load,ready"); loadReady.On += (s, e) => { loadReady.Dispose(); LoadingCompleted?.Invoke(this, EventArgs.Empty); if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetResult(true); } }; SmartEvent loadError = new SmartEvent(this, RealHandle, "load,error"); loadError.On += (s, e) => { loadError.Dispose(); LoadingFailed?.Invoke(this, EventArgs.Empty); if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetResult(false); } }; bool ret = Interop.Elementary.elm_image_file_set(RealHandle, file, null); if (!ret) { throw new InvalidOperationException("Failed to set file to Image"); } return(tcs.Task); }
/// <summary> /// Creates and initializes a new instance of the Window class. /// </summary> /// <param name="parent"> /// Parent widget which this window is created on. /// </param> /// <param name="name"> /// Window name. /// </param> /// <param name="type"> /// Window type. /// </param> /// <remarks> /// Window constructor.show window indicator, set callback /// when closing the window in any way outside the program control, /// and set callback when window rotation is changed. /// </remarks> /// <since_tizen> preview </since_tizen> public Window(Window parent, string name, WindowType type) { Name = name; Type = type; Realize(parent); IndicatorMode = IndicatorMode.Show; _deleteRequest = new SmartEvent(this, "delete,request"); _rotationChanged = new SmartEvent(this, "wm,rotation,changed"); _deleteRequest.On += (s, e) => CloseRequested?.Invoke(this, EventArgs.Empty); _rotationChanged.On += (s, e) => RotationChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Creates and initializes a new instance of the List class. /// </summary> /// <param name="parent">The parent is a given container, which will be attached by the list as a child. It's <see cref="EvasObject"/> type.</param> /// <since_tizen> preview </since_tizen> public List(EvasObject parent) : base(parent) { _selected = new SmartEvent <ListItemEventArgs>(this, this.RealHandle, "selected", ListItemEventArgs.CreateFromSmartEvent); _unselected = new SmartEvent <ListItemEventArgs>(this, this.RealHandle, "unselected", ListItemEventArgs.CreateFromSmartEvent); _doubleClicked = new SmartEvent <ListItemEventArgs>(this, this.RealHandle, "clicked,double", ListItemEventArgs.CreateFromSmartEvent); _longpressed = new SmartEvent <ListItemEventArgs>(this, this.RealHandle, "longpressed", ListItemEventArgs.CreateFromSmartEvent); _activated = new SmartEvent <ListItemEventArgs>(this, this.RealHandle, "activated", ListItemEventArgs.CreateFromSmartEvent); _selected.On += (s, e) => { ItemSelected?.Invoke(this, e); }; _unselected.On += (s, e) => { ItemUnselected?.Invoke(this, e); }; _doubleClicked.On += (s, e) => { ItemDoubleClicked?.Invoke(this, e); }; _longpressed.On += (s, e) => { ItemLongPressed?.Invoke(this, e); }; _activated.On += (s, e) => { ItemActivated?.Invoke(this, e); }; }
/// <summary> /// Creates and initializes a new instance of the ContextPopup class. /// </summary> /// <param name="parent">The parent is a given container, which will be attached by ContextPopup /// as a child. It's <see cref="EvasObject"/> type.</param> /// <since_tizen> preview </since_tizen> public ContextPopup(EvasObject parent) : base(parent) { _dismissed = new SmartEvent(this, this.RealHandle, "dismissed"); _dismissed.On += (sender, e) => { Dismissed?.Invoke(this, EventArgs.Empty); }; _onSelected = (data, obj, info) => { ContextPopupItem item = ItemObject.GetItemById((int)data) as ContextPopupItem; item?.SendSelected(); }; }
void InitControl() { _scrollAnimationStart = new ElmSharp.SmartEvent(Control, Control.RealHandle, "scroll,anim,start"); _scrollAnimationStop = new ElmSharp.SmartEvent(Control, Control.RealHandle, "scroll,anim,stop"); _scrollAnimationStart.On += (s, e) => _isAnimation = true; _scrollAnimationStop.On += (s, e) => { if (_animationTaskComplateSource != null) { _animationTaskComplateSource.TrySetResult(true); } _isAnimation = false; }; }
/// <summary> /// Creates and initializes a new instance of the Slider class. /// </summary> /// <param name="parent">The <see cref="EvasObject"/> to which the new Slider will be attached as a child.</param> /// <since_tizen> preview </since_tizen> public Slider(EvasObject parent) : base(parent) { _changed = new SmartEvent(this, this.RealHandle, "changed"); _changed.On += (s, e) => ValueChanged?.Invoke(this, EventArgs.Empty); _delayedChanged = new SmartEvent(this, this.RealHandle, "delay,changed"); _delayedChanged.On += (s, e) => DelayedValueChanged?.Invoke(this, EventArgs.Empty); _dragStarted = new SmartEvent(this, this.RealHandle, "slider,drag,start"); _dragStarted.On += (s, e) => DragStarted?.Invoke(this, EventArgs.Empty); _dragStopped = new SmartEvent(this, this.RealHandle, "slider,drag,stop"); _dragStopped.On += (s, e) => DragStopped?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Creates and initializes a new instance of the Entry class. /// </summary> /// <param name="parent">The EvasObject to which the new Entry will be attached as a child.</param> /// <since_tizen> preview </since_tizen> public Entry(EvasObject parent) : base(parent) { _clicked = new SmartEvent(this, this.RealHandle, "clicked"); _clicked.On += (s, e) => Clicked?.Invoke(this, EventArgs.Empty); _changedByUser = new SmartEvent(this, this.RealHandle, "changed,user"); _changedByUser.On += (s, e) => ChangedByUser?.Invoke(this, EventArgs.Empty); _cursorChanged = new SmartEvent(this, this.RealHandle, "cursor,changed"); _cursorChanged.On += (s, e) => CursorChanged?.Invoke(this, EventArgs.Empty); _activated = new SmartEvent(this, this.RealHandle, "activated"); _activated.On += (s, e) => Activated?.Invoke(this, EventArgs.Empty); }
/// <summary> /// The callback of the Realized Event. /// </summary> /// <since_tizen> preview </since_tizen> protected override void OnRealized() { base.OnRealized(); _languageChanged = new SmartEvent(this, this.RealHandle, "language,changed"); _languageChanged.On += (s, e) => { LanguageChanged?.Invoke(this, EventArgs.Empty); }; _themeChanged = new SmartEvent(this, this.RealHandle, "theme,changed"); _themeChanged.On += (s, e) => { ThemeChanged?.Invoke(this, EventArgs.Empty); }; }
/// <summary> /// Creates and initializes a new instance of the AnimationView class. /// </summary> /// <param name="parent">The parent is a given container, which will be attached by AnimationView as a child. It's <see cref="EvasObject"/> type.</param> /// <since_tizen> preview </since_tizen> public AnimationView(EvasObject parent) : base(parent) { _started = new SmartEvent(this, this.Handle, "play,start"); _repeated = new SmartEvent(this, this.Handle, "play,repeat"); _finished = new SmartEvent(this, this.Handle, "play,done"); _paused = new SmartEvent(this, this.Handle, "play,pause"); _resumed = new SmartEvent(this, this.Handle, "play,resume"); _stopped = new SmartEvent(this, this.Handle, "play,stop"); _updated = new SmartEvent(this, this.Handle, "play,update"); _started.On += (sender, e) => { Started?.Invoke(this, EventArgs.Empty); }; _repeated.On += (sender, e) => { Repeated?.Invoke(this, EventArgs.Empty); }; _finished.On += (sender, e) => { Finished?.Invoke(this, EventArgs.Empty); }; _paused.On += (sender, e) => { Paused?.Invoke(this, EventArgs.Empty); }; _resumed.On += (sender, e) => { Resumed?.Invoke(this, EventArgs.Empty); }; _stopped.On += (sender, e) => { Stopped?.Invoke(this, EventArgs.Empty); }; _updated.On += (sender, e) => { Updated?.Invoke(this, EventArgs.Empty); }; }
public WatchSpinner(EvasObject parent, CircleSurface surface) : base(parent, surface) { Style = "circle"; if (TizenDotnetUtil.TizenAPIVersion == 4) { _wheelAppeared = new ElmSharp.SmartEvent(this, "genlist,show"); _wheelDisappeared = new ElmSharp.SmartEvent(this, "genlist,hide"); } else { _wheelAppeared = new ElmSharp.SmartEvent(this, "list,show"); _wheelDisappeared = new ElmSharp.SmartEvent(this, "list,hide"); } _wheelAppeared.On += (s, e) => WheelAppeared?.Invoke(this, EventArgs.Empty); _wheelDisappeared.On += (s, e) => WheelDisappeared?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Creates and initializes a new instance of the Calendar class. /// </summary> /// <param name="parent"> /// The EvasObject to which the new calendar will be attached as a child. /// </param> /// <since_tizen> preview </since_tizen> public Calendar(EvasObject parent) : base(parent) { _changed = new SmartEvent(this, this.RealHandle, "changed"); _changed.On += (sender, e) => { DateTime selectedDate = SelectedDate; DateChanged?.Invoke(this, new DateChangedEventArgs(_cacheSelectedDate, selectedDate)); _cacheSelectedDate = selectedDate; }; _displayedMonthChanged = new SmartEvent(this, this.RealHandle, "display,changed"); _displayedMonthChanged.On += (sender, e) => { int currentDisplayedMonth = DisplayedTime.Month; DisplayedMonthChanged?.Invoke(this, new DisplayedMonthChangedEventArgs(_cacheDisplayedMonth, currentDisplayedMonth)); _cacheDisplayedMonth = currentDisplayedMonth; }; _calendarFormat = (ref Interop.Libc.SystemTime t) => { return(_dateFormatDelegate(t)); }; }
/// <summary> /// Creates and initializes a new instance of the Toolbar class. /// </summary> /// <param name="parent"> /// A EvasObject to which the new Table instance will be attached. /// </param> /// <since_tizen> preview </since_tizen> public Toolbar(EvasObject parent) : base(parent) { _selected = new SmartEvent <ToolbarItemEventArgs>(this, this.RealHandle, "selected", ToolbarItemEventArgs.CreateFromSmartEvent); _selected.On += (s, e) => { if (e.Item != null) { Selected?.Invoke(this, e); e.Item.SendSelected(); } }; _longpressed = new SmartEvent <ToolbarItemEventArgs>(this, this.RealHandle, "longpressed", ToolbarItemEventArgs.CreateFromSmartEvent); _longpressed.On += (s, e) => { e.Item?.SendLongPressed(); }; _clicked = new SmartEvent <ToolbarItemEventArgs>(this, this.RealHandle, "clicked", ToolbarItemEventArgs.CreateFromSmartEvent); _clicked.On += (s, e) => { e.Item?.SendClicked(); }; }
/// <summary> /// Creates and initializes a new instance of the Index class. /// </summary> /// <param name="parent">The parent is a given container, which will be attached by Index as a child. It's <see cref="EvasObject"/> type.</param> /// <since_tizen> preview </since_tizen> public Index(EvasObject parent) : base(parent) { _delayedChanged = new SmartEvent(this, this.RealHandle, "delay,changed"); _delayedChanged.On += _delayedChanged_On; }
void InitializeSmartEvent() { _selected = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "selected", GenListItemEventArgs.CreateFromSmartEvent); _unselected = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "unselected", GenListItemEventArgs.CreateFromSmartEvent); _activated = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "activated", GenListItemEventArgs.CreateFromSmartEvent); _pressed = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "pressed", GenListItemEventArgs.CreateFromSmartEvent); _released = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "released", GenListItemEventArgs.CreateFromSmartEvent); _doubleClicked = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "clicked,double", GenListItemEventArgs.CreateFromSmartEvent); _expanded = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "expanded", GenListItemEventArgs.CreateFromSmartEvent); _realized = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "realized", GenListItemEventArgs.CreateFromSmartEvent); _unrealized = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "unrealized", GenListItemEventArgs.CreateFromSmartEvent); _longpressed = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "longpressed", GenListItemEventArgs.CreateFromSmartEvent); _moved = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "moved", GenListItemEventArgs.CreateFromSmartEvent); _movedAfter = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "moved,after", GenListItemEventArgs.CreateFromSmartEvent); _movedBefore = new SmartEvent <GenListItemEventArgs>(this, this.RealHandle, "moved,before", GenListItemEventArgs.CreateFromSmartEvent); _scrollAnimationStarted = new SmartEvent(this, this.RealHandle, "scroll,anim,start"); _scrollAnimationStopped = new SmartEvent(this, this.RealHandle, "scroll,anim,stop"); _changed = new SmartEvent(this, this.RealHandle, "changed"); _selected.On += (s, e) => { if (e.Item != null) { ItemSelected?.Invoke(this, e); } }; _unselected.On += (s, e) => { if (e.Item != null) { ItemUnselected?.Invoke(this, e); } }; _activated.On += (s, e) => { if (e.Item != null) { ItemActivated?.Invoke(this, e); } }; _pressed.On += (s, e) => { if (e.Item != null) { ItemPressed?.Invoke(this, e); } }; _released.On += (s, e) => { if (e.Item != null) { ItemReleased?.Invoke(this, e); } }; _doubleClicked.On += (s, e) => { if (e.Item != null) { ItemDoubleClicked?.Invoke(this, e); } }; _expanded.On += (s, e) => { if (e.Item != null) { ItemExpanded?.Invoke(this, e); } }; _realized.On += (s, e) => { if (e.Item != null) { ItemRealized?.Invoke(this, e); } }; _unrealized.On += (s, e) => { if (e.Item != null) { ItemUnrealized?.Invoke(this, e); } }; _longpressed.On += (s, e) => { if (e.Item != null) { ItemLongPressed?.Invoke(this, e); } }; _moved.On += (s, e) => { if (e.Item != null) { ItemMoved?.Invoke(this, e); } }; _movedAfter.On += (s, e) => { if (e.Item != null) { ItemMovedAfter?.Invoke(this, e); } }; _movedBefore.On += (s, e) => { if (e.Item != null) { ItemMovedBefore?.Invoke(this, e); } }; }
/// <summary> /// Creates and initializes a new instance of the Radio class. /// </summary> /// <param name="parent">The EvasObject to which the new Radio will be attached as a child.</param> /// <since_tizen> preview </since_tizen> public Radio(EvasObject parent) : base(parent) { _changed = new SmartEvent(this, this.RealHandle, "changed"); _changed.On += (s, e) => ValueChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Creates and initializes a new instance of the Naviframe class. /// </summary> /// <param name="parent">The parent is a given container which will be attached by Naviframe as a child. It's <see cref="EvasObject"/> type.</param> /// <since_tizen> preview </since_tizen> public Naviframe(EvasObject parent) : base(parent) { _transitionFinished = new SmartEvent(this, this.RealHandle, "transition,finished"); _transitionFinished.On += (s, e) => AnimationFinished?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Creates and initializes a new instance of the Panel class. /// </summary> /// <param name="parent">The EvasObject to which the new panel will be attached as a child.</param> /// <since_tizen> preview </since_tizen> public Panel(EvasObject parent) : base(parent) { _toggled = new SmartEvent(this, this.RealHandle, "toggled"); _toggled.On += (s, e) => Toggled?.Invoke(this, EventArgs.Empty); }
void InitializeSmartEvent() { _selected = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "selected", GenGridItemEventArgs.CreateFromSmartEvent); _unselected = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "unselected", GenGridItemEventArgs.CreateFromSmartEvent); _activated = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "activated", GenGridItemEventArgs.CreateFromSmartEvent); _pressed = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "pressed", GenGridItemEventArgs.CreateFromSmartEvent); _released = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "released", GenGridItemEventArgs.CreateFromSmartEvent); _doubleClicked = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "clicked,double", GenGridItemEventArgs.CreateFromSmartEvent); _realized = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "realized", GenGridItemEventArgs.CreateFromSmartEvent); _unrealized = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "unrealized", GenGridItemEventArgs.CreateFromSmartEvent); _longpressed = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "longpressed", GenGridItemEventArgs.CreateFromSmartEvent); _focused = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "item,focused", GenGridItemEventArgs.CreateFromSmartEvent); _unfocused = new SmartEvent <GenGridItemEventArgs>(this, this.RealHandle, "item,unfocused", GenGridItemEventArgs.CreateFromSmartEvent); _changed = new SmartEvent(this, this.RealHandle, "changed"); _selected.On += (s, e) => { if (e.Item != null) { ItemSelected?.Invoke(this, e); } }; _unselected.On += (s, e) => { if (e.Item != null) { ItemUnselected?.Invoke(this, e); } }; _activated.On += (s, e) => { if (e.Item != null) { ItemActivated?.Invoke(this, e); } }; _pressed.On += (s, e) => { if (e.Item != null) { ItemPressed?.Invoke(this, e); } }; _released.On += (s, e) => { if (e.Item != null) { ItemReleased?.Invoke(this, e); } }; _doubleClicked.On += (s, e) => { if (e.Item != null) { ItemDoubleClicked?.Invoke(this, e); } }; _realized.On += (s, e) => { if (e.Item != null) { ItemRealized?.Invoke(this, e); } }; _unrealized.On += (s, e) => { if (e.Item != null) { ItemUnrealized?.Invoke(this, e); } }; _longpressed.On += (s, e) => { if (e.Item != null) { ItemLongPressed?.Invoke(this, e); } }; _focused.On += (s, e) => { if (e.Item != null) { ItemFocused?.Invoke(this, e); } }; _unfocused.On += (s, e) => { if (e.Item != null) { ItemUnfocused?.Invoke(this, e); } }; _changed.On += (s, e) => { Changed?.Invoke(this, e); }; }
/// <summary> /// Creates and initializes a new instance of the Image class. /// </summary> /// <param name="parent">The parent is a given container, which will be attached by the image as a child. It's <see cref="EvasObject"/> type.</param> /// <since_tizen> preview </since_tizen> public Image(EvasObject parent) : base(parent) { _clicked = new SmartEvent(this, "clicked"); _clicked.On += (s, e) => Clicked?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Sets the stream that is used as the image's source with async. /// </summary> /// <param name="stream">The stream that is used as an image source.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>(true = success, false = error)</returns> /// <since_tizen> preview </since_tizen> public async Task <bool> LoadAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken)) { if (stream == null) { throw new ArgumentNullException("stream"); } Interop.Elementary.elm_image_async_open_set(RealHandle, true); Interop.Elementary.elm_image_preload_disabled_set(RealHandle, false); var tcs = new TaskCompletionSource <bool>(); cancellationToken.Register(() => { if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetCanceled(); } }); SmartEvent loadReady = new SmartEvent(this, RealHandle, "load,ready"); loadReady.On += (s, e) => { loadReady.Dispose(); LoadingCompleted?.Invoke(this, EventArgs.Empty); if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetResult(true); } }; SmartEvent loadError = new SmartEvent(this, RealHandle, "load,error"); loadError.On += (s, e) => { loadError.Dispose(); LoadingFailed?.Invoke(this, EventArgs.Empty); if (tcs != null && !tcs.Task.IsCompleted) { tcs.SetResult(false); } }; using (MemoryStream memstream = new MemoryStream()) { await stream.CopyToAsync(memstream); unsafe { byte[] dataArr = memstream.ToArray(); fixed(byte *data = &dataArr[0]) { bool ret = Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero); if (!ret) { return(false); } } } } return(await tcs.Task); }