private void RenderLinks(List <MobilePagesWraper> collection, StackLayout layout)
        {
            rownum   = colnum = 0;
            lastItem = collection.Last();

            try
            {
                Grid grid = this.CreateGrid();
                layout.Children.Add(grid);

                foreach (MobilePagesWraper wrpr in collection)
                {
                    EbMenuItem item = new EbMenuItem(wrpr)
                    {
                        Style = (Style)HelperFunctions.GetResourceValue("MenuItemFrame"),
                        GestureRecognizers = { gesture }
                    };

                    SetGrid(grid, item, wrpr);
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
            }
        }
        private void MenuItemTapped(object sender, EventArgs e)
        {
            if (ItemTaped == null)
            {
                return;
            }
            else
            {
                MobilePagesWraper wraper = (sender as EbMenuItem).PageWraper;

                if (ItemTaped.CanExecute(wraper))
                {
                    ItemTaped.Execute(wraper);
                }
            }
        }
 public static EbMobilePage GetExternalPage(string Refid)
 {
     if (string.IsNullOrEmpty(Refid))
     {
         return(null);
     }
     try
     {
         MobilePagesWraper wrpr = App.Settings.ExternalMobilePages?.Find(item => item.RefId == Refid);
         return(wrpr?.GetPage());
     }
     catch (Exception ex)
     {
         EbLog.Error("external page not found, " + ex.Message);
     }
     return(null);
 }
        //HomeViewModel.cs
        //public async Task<List<MobilePagesWraper>> UpdateDataAsync()
        //{
        //    List<MobilePagesWraper> collection = null;
        //    try
        //    {
        //        EbMobileSolutionData data = await App.Settings.GetSolutionDataAsync(false, 6000, async status =>
        //        {
        //            collection = await this.GetDataAsync();

        //            if (status == ResponseStatus.TimedOut)
        //            {
        //                Utils.Alert_SlowNetwork();
        //                EbLog.Info("[solutiondata api] raised timeout in UpdateDataAsync");
        //            }
        //            else
        //            {
        //                Utils.Alert_NetworkError();
        //                EbLog.Info("[solutiondata api] raised network error in UpdateDataAsync");
        //            }
        //        });

        //        if (data != null)
        //        {
        //            App.Settings.MobilePages = App.Settings.CurrentApplication.MobilePages;
        //            App.Settings.WebObjects = App.Settings.CurrentApplication.WebObjects;
        //            collection = await this.GetDataAsync();
        //            Utils.Toast("Refreshed");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        EbLog.Error("menu update failed :: " + ex.Message);
        //    }
        //    return collection ?? new List<MobilePagesWraper>();
        //}

        public async Task <List <MobilePagesWraper> > GetFromMenuPreload(EbApiMeta apimeta)
        {
            RestClient  client  = new RestClient(App.Settings.RootUrl);
            RestRequest request = new RestRequest($"api/{apimeta.Name}/{apimeta.Version}", Method.GET);

            request.AddHeader(AppConst.BTOKEN, App.Settings.BToken);
            request.AddHeader(AppConst.RTOKEN, App.Settings.RToken);

            MenuPreloadResponse resp = null;

            try
            {
                IRestResponse response = await client.ExecuteAsync(request);

                if (response.IsSuccessful)
                {
                    resp = JsonConvert.DeserializeObject <MenuPreloadResponse>(response.Content);
                }
            }
            catch (Exception ex)
            {
                EbLog.Error("Error on menu preload api request :: " + ex.Message);
            }

            List <MobilePagesWraper> pages = new List <MobilePagesWraper>();

            if (resp != null && resp.Result != null)
            {
                List <MobilePagesWraper> all = App.Settings.MobilePages ?? new List <MobilePagesWraper>();

                foreach (string objName in resp.Result)
                {
                    MobilePagesWraper wraper = all.Find(item => item.Name == objName);

                    if (wraper != null)
                    {
                        pages.Add(wraper);
                    }
                }
            }
            return(pages);
        }
        private void SetGrid(Grid grid, View item, MobilePagesWraper current)
        {
            grid.Children.Add(item, colnum, rownum);

            if (colnum == 2)
            {
                if (current != lastItem)
                {
                    grid.RowDefinitions.Add(new RowDefinition {
                        Height = GridLength.Auto
                    });
                    rownum++;
                }
                colnum = 0;
            }
            else
            {
                colnum += 1;
            }
        }
Example #6
0
        public EbMenuItem(MobilePagesWraper wrpr)
        {
            this.PageWraper = wrpr;

            content = new Grid
            {
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(80)
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                }
            };
            this.Content = content;

            this.AppendIcon();
            this.AppendLabel();
        }
Example #7
0
 private void MergeObjectsInSolutionData(EbMobileSolutionData New, List <AppData> OldApps)
 {
     if (OldApps == null)
     {
         return;
     }
     foreach (AppData app in New.Applications)
     {
         foreach (MobilePagesWraper wraper in app.MobilePages)
         {
             if (string.IsNullOrEmpty(wraper.Json))
             {
                 foreach (AppData _app in OldApps)
                 {
                     MobilePagesWraper _w = _app.MobilePages.Find(e => e.RefId == wraper.RefId);
                     if (_w != null)
                     {
                         wraper.Json = _w.Json;
                         break;
                     }
                 }
             }
         }
         foreach (WebObjectsWraper wraper in app.WebObjects)
         {
             if (string.IsNullOrEmpty(wraper.Json))
             {
                 foreach (AppData _app in OldApps)
                 {
                     WebObjectsWraper _w = _app.WebObjects.Find(e => e.RefId == wraper.RefId);
                     if (_w != null)
                     {
                         wraper.Json = _w.Json;
                         break;
                     }
                 }
             }
         }
     }
 }