Example #1
0
        /// <summary>
        /// To add an item on the application content layout
        /// </summary>
        /// <param name="item">ApplicationListItem</param>
        /// <returns>ApplicationLayoutItem</returns>
        public ApplicationLayoutItem AddItem(ApplicationListItem item)
        {
            var layoutItem = new ApplicationLayoutItem(item)
            {
            };

            layoutItem.WidthRequest = this.Width / 2;
            this.Children.Add(layoutItem);
            return(layoutItem);
        }
Example #2
0
 /// <summary>
 /// To initialize some fields when the class is instantiated
 /// </summary>
 void Initialize()
 {
     _applications           = new ObservableCollection <ApplicationListItem>();
     _message                = new Message {
     };
     _selectedAppControlType = AppControlType.Unknown;
     _selectedItem           = new ApplicationListItem {
         Id = null
     };
 }
 /// <summary>
 /// A constructor for the ApplicationItem
 /// </summary>
 /// <param name="item">An ApplicationListItem item</param>
 public ApplicationLayoutItem(ApplicationListItem item) : base()
 {
     _data = item;
     AppId = _data.Id;
     InitializeComponent();
 }
Example #4
0
        /// <summary>
        /// To update application layout
        /// </summary>
        /// <returns>A Task to update application layout asynchrously</returns>
        Task UpdateContentLayout()
        {
            return(Task.Run(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    _applications.Children.Clear();
                });

                var selected = ((MainViewModel)BindingContext).SelectedAppControlType;
                var apps = ApplicationControlHelper.GetApplicationIdsForSpecificAppControlType(selected);
                foreach (var app in apps)
                {
                    var iconPath = ApplicationControlHelper.GetApplicationIconPath(app);
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        /// Add an item to the list
                        var item = new ApplicationListItem
                        {
                            Id = app,
                            IconPath = iconPath,
                            BlendColor = Color.Gray,
                        };
                        ((MainViewModel)BindingContext).Applications.Add(item);

                        _applications.AddItem(item).Selected += OnItemSelected;
                    });
                }

                Device.BeginInvokeOnMainThread(() =>
                {
                    /// Add an empty item to the list
                    var item = new ApplicationListItem
                    {
                        Id = null,
                        IconPath = null,
                        BlendColor = Color.Gray,
                    };
                    ((MainViewModel)BindingContext).Applications.Add(item);

                    _applications.AddItem(item);
                });

                /// For application list
                Children.Add(
                    _applications,
                    Constraint.RelativeToParent((parent) =>
                {
                    return 0;
                }),
                    Constraint.RelativeToParent((parent) =>
                {
                    return parent.Height * 0.2411;
                }),
                    Constraint.RelativeToParent((parent) =>
                {
                    return parent.Width;
                }),
                    Constraint.RelativeToParent((parent) =>
                {
                    return parent.Height * 0.5265;
                }));
            }));
        }