2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
19 using Tizen.Applications;
20 using System.Runtime.InteropServices;
22 namespace Tizen.Applications
25 /// The class for receiving widget events and sending data to the widget.
27 /// <since_tizen> 3 </since_tizen>
28 public class WidgetControl : IDisposable
30 private const string LogTag = "Tizen.Applications.WidgetControl";
31 private static Interop.WidgetService.LifecycleCallback _onLifecycleCallback;
33 /// Class for the widget instance.
35 /// <since_tizen> 3 </since_tizen>
38 private string _widgetId;
40 internal Instance(string widgetId)
48 /// <since_tizen> 3 </since_tizen>
49 public string Id { get; internal set; }
52 /// Gets the widget content.
54 /// <since_tizen> 3 </since_tizen>
55 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
56 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
57 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
58 public Bundle GetContent()
62 Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetContent(_widgetId, Id, out h);
66 case Interop.WidgetService.ErrorCode.InvalidParameter:
67 throw new InvalidOperationException("Invalid parameter at unmanaged code");
68 case Interop.WidgetService.ErrorCode.IoError:
69 throw new InvalidOperationException("Failed to access DB");
70 case Interop.WidgetService.ErrorCode.NotSupported:
71 throw new NotSupportedException("Not supported");
74 return new Bundle(new SafeBundleHandle(h, true));
78 /// Changes the content for the widget instance.
80 /// <since_tizen> 3 </since_tizen>
81 /// <param name="content">Content to be changed.</param>
82 /// <param name="force"> True if you want to update your widget even if the provider is paused, otherwise false.</param>
83 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
84 /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
85 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
86 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
87 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
88 public void ChangeContent(Bundle content, bool force)
90 Interop.WidgetService.ErrorCode err = Interop.WidgetService.UpdateContent(_widgetId, Id, content.SafeBundleHandle, force ? 1 : 0);
94 case Interop.WidgetService.ErrorCode.InvalidParameter:
95 throw new ArgumentException("Invalid parameter");
97 case Interop.WidgetService.ErrorCode.Canceled:
98 throw new InvalidOperationException("Provider is paused, so this update request is canceld");
100 case Interop.WidgetService.ErrorCode.OutOfMemory:
101 throw new InvalidOperationException("Out-of-memory at unmanaged code");
103 case Interop.WidgetService.ErrorCode.Fault:
104 throw new InvalidOperationException("Failed to create a request packet");
106 case Interop.WidgetService.ErrorCode.PermissionDenied:
107 throw new UnauthorizedAccessException();
109 case Interop.WidgetService.ErrorCode.NotSupported:
110 throw new NotSupportedException("Not supported");
115 /// Changes the update period for the widget instance.
117 /// <since_tizen> 3 </since_tizen>
118 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
119 /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
120 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
121 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
122 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
123 public void ChangePeriod(double period)
125 Interop.WidgetService.ErrorCode err = Interop.WidgetService.ChangePeriod(_widgetId, Id, period);
129 case Interop.WidgetService.ErrorCode.InvalidParameter:
130 throw new ArgumentException("Invalid parameter");
132 case Interop.WidgetService.ErrorCode.OutOfMemory:
133 throw new InvalidOperationException("Out-of-memory at unmanaged code");
135 case Interop.WidgetService.ErrorCode.Fault:
136 throw new InvalidOperationException("Failed to create a request packet");
138 case Interop.WidgetService.ErrorCode.PermissionDenied:
139 throw new UnauthorizedAccessException();
141 case Interop.WidgetService.ErrorCode.NotSupported:
142 throw new NotSupportedException("Not supported");
148 /// The class for the widget size information.
150 /// <since_tizen> 3 </since_tizen>
159 /// Enumeration for the types of widget size.
161 /// <since_tizen> 3 </since_tizen>
162 public enum SizeType : int
165 /// 175x175 based on 720x1280 resolution.
170 /// 354x175 based on 720x1280 resolution.
175 /// 354x354 based on 720x1280 resolution.
180 /// 712x175 based on 720x1280 resolution.
185 /// 712x354 based on 720x1280 resolution.
190 /// 712x533 based on 720x1280 resolution.
195 /// 712x712 based on 720x1280 resolution.
200 /// 712x891 based on 720x1280 resolution.
205 /// 712x1070 based on 720x1280 resolution.
211 /// 224x215 based on 720x1280 resolution.
216 /// 680x215 based on 720x1280 resolution.
221 /// 680x653 based on 720x1280 resolution.
226 /// 720x1280 based on 720x1280 resolution.
234 /// <since_tizen> 3 </since_tizen>
235 public int Width { get; internal set; }
240 /// <since_tizen> 3 </since_tizen>
241 public int Height { get; internal set; }
244 /// The path for the widget preview image file.
246 /// <since_tizen> 3 </since_tizen>
247 public string PreviewImagePath { get; internal set; }
250 /// The size type of the widget.
252 /// <since_tizen> 3 </since_tizen>
253 public SizeType Type { get; internal set; }
256 private event EventHandler<WidgetLifecycleEventArgs> _created;
257 private event EventHandler<WidgetLifecycleEventArgs> _resumed;
258 private event EventHandler<WidgetLifecycleEventArgs> _paused;
259 private event EventHandler<WidgetLifecycleEventArgs> _destroyed;
260 private bool _disposedValue = false;
261 private static IDictionary<string, int> s_lifecycleEventRefCnt = new Dictionary<string, int>();
262 private static IList<WidgetControl> s_eventObjects = new List<WidgetControl>();
265 /// Factory method for the WidgetControl.
266 /// It will create all the objects of WidgetControl based on the package ID.
268 /// <since_tizen> 3 </since_tizen>
269 /// <param name="pkgId">Package ID.</param>
270 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
271 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
272 /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
273 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
274 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
275 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
276 public static WidgetControl[] CreateAll(string pkgId)
278 List<WidgetControl> list = new List<WidgetControl>();
280 Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetWidgetListByPkgId(pkgId, (widgetId, isPrime, userData) =>
282 list.Add(new WidgetControl(widgetId));
287 case Interop.WidgetService.ErrorCode.InvalidParameter:
288 throw new ArgumentException("Invalid parameter");
290 case Interop.WidgetService.ErrorCode.IoError:
291 throw new InvalidOperationException("Failed to access DB");
293 case Interop.WidgetService.ErrorCode.PermissionDenied:
294 throw new UnauthorizedAccessException();
296 case Interop.WidgetService.ErrorCode.NotSupported:
297 throw new NotSupportedException("Not supported");
300 return list.ToArray();
304 /// Gets all the widget IDs by the package ID.
306 /// <since_tizen> 3 </since_tizen>
307 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
308 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
309 /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
310 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
311 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
312 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
313 public static string[] GetWidgetIds(string pkgId)
315 List<string> list = new List<string>();
317 Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetWidgetListByPkgId(pkgId, (widgetId, isPrime, userData) =>
324 case Interop.WidgetService.ErrorCode.InvalidParameter:
325 throw new ArgumentException("Invalid parameter");
327 case Interop.WidgetService.ErrorCode.IoError:
328 throw new InvalidOperationException("Failed to access DB");
330 case Interop.WidgetService.ErrorCode.PermissionDenied:
331 throw new UnauthorizedAccessException();
333 case Interop.WidgetService.ErrorCode.NotSupported:
334 throw new NotSupportedException("Not supported");
337 return list.ToArray();
341 /// Gets main appid of the widget.
343 /// <since_tizen> 6 </since_tizen>
344 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
345 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
346 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
347 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
348 public string MainAppId
352 string str = Interop.WidgetService.GetWidgetMainAppId(Id);
353 Interop.WidgetService.ErrorCode err =
354 (Interop.WidgetService.ErrorCode)Internals.Errors.ErrorFacts.GetLastResult();
357 case Interop.WidgetService.ErrorCode.PermissionDenied:
358 throw new UnauthorizedAccessException();
360 case Interop.WidgetService.ErrorCode.NotSupported:
361 throw new NotSupportedException("Not supported");
369 /// Gets package ID of the widget.
371 /// <since_tizen> 6 </since_tizen>
372 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
373 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
374 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
375 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
376 public string PackageId
380 string str = Interop.WidgetService.GetWidgetPackageId(Id);
381 Interop.WidgetService.ErrorCode err =
382 (Interop.WidgetService.ErrorCode)Internals.Errors.ErrorFacts.GetLastResult();
385 case Interop.WidgetService.ErrorCode.PermissionDenied:
386 throw new UnauthorizedAccessException();
388 case Interop.WidgetService.ErrorCode.NotSupported:
389 throw new NotSupportedException("Not supported");
399 /// <since_tizen> 3 </since_tizen>
400 public string Id { get; internal set; }
403 /// The flag value for "nodisplay".
405 /// <since_tizen> 3 </since_tizen>
406 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
407 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
408 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
409 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
410 public bool IsNoDisplay
414 int ret = Interop.WidgetService.GetNoDisplay(Id);
415 Interop.WidgetService.ErrorCode err =
416 (Interop.WidgetService.ErrorCode)Internals.Errors.ErrorFacts.GetLastResult();
419 case Interop.WidgetService.ErrorCode.PermissionDenied:
420 throw new UnauthorizedAccessException();
422 case Interop.WidgetService.ErrorCode.NotSupported:
423 throw new NotSupportedException("Not supported");
434 /// The event handler for a created widget instance.
436 /// <since_tizen> 3 </since_tizen>
437 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
438 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
439 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
440 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
441 public event EventHandler<WidgetLifecycleEventArgs> Created
445 RegisterLifecycleEvent();
451 UnregisterLifecycleEvent();
456 /// The event handler for a resumed widget instance.
458 /// <since_tizen> 3 </since_tizen>
459 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
460 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
461 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
462 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
463 public event EventHandler<WidgetLifecycleEventArgs> Resumed
467 RegisterLifecycleEvent();
473 UnregisterLifecycleEvent();
478 /// The event handler for a paused widget instance.
480 /// <since_tizen> 3 </since_tizen>
481 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
482 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
483 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
484 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
485 public event EventHandler<WidgetLifecycleEventArgs> Paused
489 RegisterLifecycleEvent();
495 UnregisterLifecycleEvent();
500 /// The event handler for a destroyed widget instance.
502 /// <since_tizen> 3 </since_tizen>
503 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
504 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
505 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
506 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
507 public event EventHandler<WidgetLifecycleEventArgs> Destroyed
511 RegisterLifecycleEvent();
517 UnregisterLifecycleEvent();
522 /// The constructor of the WidgetControl object.
524 /// <since_tizen> 3 </since_tizen>
525 /// <param name="widgetId">Widget ID.</param>
526 public WidgetControl(string widgetId)
532 /// Finalizer of the WidgetControl class.
540 /// Gets the objects for widget instance information.
542 /// <since_tizen> 3 </since_tizen>
543 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
544 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
545 /// <exception cref="NotSupportedException">Thrown when the API is not supported in this device.</exception>
546 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
547 public IEnumerable<Instance> GetInstances()
549 IList<Instance> instances = new List<Instance>();
550 Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetInstances(Id, (widgetId, instanceId, userData) =>
552 instances.Add(new Instance(widgetId) { Id = instanceId });
557 case Interop.WidgetService.ErrorCode.InvalidParameter:
558 throw new InvalidOperationException("Invalid parameter at unmanaged code");
560 case Interop.WidgetService.ErrorCode.NotSupported:
561 throw new NotSupportedException();
563 case Interop.WidgetService.ErrorCode.PermissionDenied:
564 throw new UnauthorizedAccessException();
571 /// Gets the objects for widget scale information.
573 /// <since_tizen> 3 </since_tizen>
574 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
575 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
576 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
577 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
578 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
579 public IEnumerable<Scale> GetScales()
589 IList<Scale> scales = new List<Scale>();
590 Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetSupportedSizes(Id, ref cnt1, out wPtr, out hPtr);
594 Log.Error(LogTag, "No supported size :" + Id);
600 case Interop.WidgetService.ErrorCode.InvalidParameter:
601 throw new InvalidOperationException("Invalid parameter at unmanaged code");
603 case Interop.WidgetService.ErrorCode.IoError:
604 throw new InvalidOperationException("Failed to access DB");
606 case Interop.WidgetService.ErrorCode.PermissionDenied:
607 throw new UnauthorizedAccessException();
609 case Interop.WidgetService.ErrorCode.NotSupported:
610 throw new NotSupportedException();
613 Marshal.Copy(wPtr, w, 0, cnt1);
614 Interop.Libc.Free(wPtr);
617 Marshal.Copy(hPtr, h, 0, cnt1);
618 Interop.Libc.Free(hPtr);
620 err = Interop.WidgetService.GetSupportedSizeTypes(Id, ref cnt2, out typesPtr);
623 case Interop.WidgetService.ErrorCode.InvalidParameter:
624 throw new InvalidOperationException("Invalid parameter at unmanaged code");
626 case Interop.WidgetService.ErrorCode.IoError:
627 throw new InvalidOperationException("Failed to access DB");
629 case Interop.WidgetService.ErrorCode.PermissionDenied:
630 throw new UnauthorizedAccessException();
635 Log.Error(LogTag, "Count not match cnt1 :" + cnt1 + ", cnt2 :" + cnt2);
639 types = new int[cnt2];
640 Marshal.Copy(typesPtr, types, 0, cnt2);
641 Interop.Libc.Free(typesPtr);
643 for (int i = 0; i < cnt1; i++)
645 string prev = Interop.WidgetService.GetPreviewImagePath(Id, types[i]);
647 scales.Add(new Scale()
651 PreviewImagePath = prev,
652 Type = (Scale.SizeType)types[i]
659 /// Gets the widget name.
661 /// <since_tizen> 3 </since_tizen>
662 /// <param name="lang">Language.</param>
663 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
664 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
665 /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
666 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
667 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
668 public string GetName(string lang)
671 throw new ArgumentNullException();
673 string str = Interop.WidgetService.GetName(Id, lang);
674 Interop.WidgetService.ErrorCode err =
675 (Interop.WidgetService.ErrorCode)Internals.Errors.ErrorFacts.GetLastResult();
679 case Interop.WidgetService.ErrorCode.PermissionDenied:
680 throw new UnauthorizedAccessException();
682 case Interop.WidgetService.ErrorCode.NotSupported:
683 throw new NotSupportedException();
690 /// Gets the widget icon path.
692 /// <since_tizen> 3 </since_tizen>
693 /// <param name="lang">Language.</param>
694 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
695 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
696 /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
697 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
698 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
699 public string GetIconPath(string lang)
702 throw new ArgumentNullException();
704 string pkgId = Interop.WidgetService.GetPkgId(Id);
705 string str = Interop.WidgetService.GetIcon(pkgId, lang);
706 Interop.WidgetService.ErrorCode err =
707 (Interop.WidgetService.ErrorCode)Internals.Errors.ErrorFacts.GetLastResult();
711 case Interop.WidgetService.ErrorCode.PermissionDenied:
712 throw new UnauthorizedAccessException();
714 case Interop.WidgetService.ErrorCode.NotSupported:
715 throw new NotSupportedException();
722 /// Releases all the resources used by the WidgetControl class.
724 /// <since_tizen> 3 </since_tizen>
725 /// <feature>http://tizen.org/feature/shell.appwidget</feature>
726 /// <exception cref="InvalidOperationException">Thrown in case of failed conditions.</exception>
727 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
728 /// <exception cref="NotSupportedException">Thrown in case of feature not supported.</exception>
729 public void Dispose()
732 GC.SuppressFinalize(this);
735 private void Dispose(bool disposing)
747 UnregisterLifecycleEvent();
749 _disposedValue = true;
753 private void RegisterLifecycleEvent()
755 if (!s_lifecycleEventRefCnt.ContainsKey(Id))
756 s_lifecycleEventRefCnt[Id] = 0;
758 if (_created != null || _paused != null || _resumed != null || _destroyed != null)
761 if (s_lifecycleEventRefCnt[Id] == 0)
763 if (_onLifecycleCallback == null)
764 _onLifecycleCallback = new Interop.WidgetService.LifecycleCallback(OnLifecycleEvent);
766 Interop.WidgetService.ErrorCode err = Interop.WidgetService.SetLifecycleEvent(Id, _onLifecycleCallback, IntPtr.Zero);
769 case Interop.WidgetService.ErrorCode.InvalidParameter:
770 throw new InvalidOperationException("Invalid parameter at unmanaged code");
772 case Interop.WidgetService.ErrorCode.PermissionDenied:
773 throw new UnauthorizedAccessException();
775 case Interop.WidgetService.ErrorCode.NotSupported:
776 throw new NotSupportedException();
780 s_lifecycleEventRefCnt[Id]++;
781 s_eventObjects.Add(this);
782 Log.Debug(LogTag, "register lifecycle cb " + Id + " [" + s_lifecycleEventRefCnt[Id] + "]");
785 private void UnregisterLifecycleEvent()
787 if (!s_lifecycleEventRefCnt.ContainsKey(Id))
790 if (s_lifecycleEventRefCnt[Id] <= 0)
793 if (_created != null || _paused != null || _resumed != null || _destroyed != null)
796 if (s_lifecycleEventRefCnt[Id] == 1)
798 Interop.WidgetService.ErrorCode err = Interop.WidgetService.UnsetLifecycleEvent(Id, IntPtr.Zero);
802 case Interop.WidgetService.ErrorCode.InvalidParameter:
803 throw new InvalidOperationException("Invalid parameter at unmanaged code");
805 case Interop.WidgetService.ErrorCode.PermissionDenied:
806 throw new UnauthorizedAccessException();
808 case Interop.WidgetService.ErrorCode.NotExist:
809 throw new InvalidOperationException("Event handler is not exist");
811 case Interop.WidgetService.ErrorCode.NotSupported:
812 throw new NotSupportedException();
814 _onLifecycleCallback = null;
817 s_eventObjects.Remove(this);
818 s_lifecycleEventRefCnt[Id]--;
819 Log.Debug(LogTag, "unregister lifecycle cb " + Id + " [" + s_lifecycleEventRefCnt[Id] + "]");
822 private static int OnLifecycleEvent(string widgetId, Interop.WidgetService.LifecycleEvent e, string instanceId, IntPtr userData)
824 Log.Debug(LogTag, "Lifecycle event : " + instanceId + " [" + e + "]");
827 case Interop.WidgetService.LifecycleEvent.Created:
828 foreach (WidgetControl c in s_eventObjects)
830 if (c.Id.CompareTo(widgetId) == 0)
832 c._created?.Invoke(null, new WidgetLifecycleEventArgs()
835 InstanceId = instanceId,
836 Type = WidgetLifecycleEventArgs.EventType.Created
842 case Interop.WidgetService.LifecycleEvent.Resumed:
843 foreach (WidgetControl c in s_eventObjects)
845 if (c.Id.CompareTo(widgetId) == 0)
847 c._resumed?.Invoke(null, new WidgetLifecycleEventArgs()
850 InstanceId = instanceId,
851 Type = WidgetLifecycleEventArgs.EventType.Resumed
857 case Interop.WidgetService.LifecycleEvent.Paused:
858 foreach (WidgetControl c in s_eventObjects)
860 if (c.Id.CompareTo(widgetId) == 0)
862 c._paused?.Invoke(null, new WidgetLifecycleEventArgs()
865 InstanceId = instanceId,
866 Type = WidgetLifecycleEventArgs.EventType.Paused
872 case Interop.WidgetService.LifecycleEvent.Destroyed:
873 foreach (WidgetControl c in s_eventObjects)
875 if (c.Id.CompareTo(widgetId) == 0)
877 c._destroyed?.Invoke(null, new WidgetLifecycleEventArgs()
880 InstanceId = instanceId,
881 Type = WidgetLifecycleEventArgs.EventType.Destroyed