public App() { if (config == null) { config = new Configuration(); IPlatformInfo platformInfo = DependencyService.Get <IPlatformInfo>(); CrossLogger.Current.Info("Kala", "Model: " + platformInfo.GetModel()); CrossLogger.Current.Info("Kala", "Version: " + platformInfo.GetVersion()); CrossLogger.Current.Debug("Kala", @"URL Settings: '" + Settings.Protocol + "://" + Settings.Server + ":" + Settings.Port.ToString() + "'"); CrossLogger.Current.Debug("Kala", @"Auth Settings: '" + Settings.Username + " / " + Settings.Password + "'"); CrossLogger.Current.Debug("Kala", @"Sitemap Settings: '" + Settings.Sitemap + "'"); } ; //Initialize FFImageLoading with Authentication FFImageLoading.AuthenticatedHttpImageClientHandler.Initialize(); //TabbedPage setup if (tp.Children.Count == 0) { tp.BackgroundColor = App.config.BackGroundColor; tp.BarBackgroundColor = App.config.BackGroundColor; tp.BarTextColor = App.config.TextColor; tp.CurrentPageChanged += (sender, e) => { //Reset screensaver timer App.config.LastActivity = DateTime.Now; CrossLogger.Current.Debug("Kala", "Reset Screensaver timer"); }; /**/ //Show a busy signal here as we can't display anything until we have downloaded the sitemap with its items. No async. Pointless.. sitemaps = Sitemap.GetActiveSitemap(Settings.Sitemap); //Selected sitemap was not found, display settings page to make change if (sitemaps == null) { //Add settings tab MainPage = new Views.Page1(); } else { Sitemap sitemap = new Sitemap(); sitemap.GetUpdates(); sitemap.CreateSitemap(sitemaps); CrossLogger.Current.Debug("Kala", "Got Sitemaps"); //Add settings tab last App.tp.Children.Add(new Views.Page1()); MainPage = App.tp; } } else { MainPage = App.tp; } App.config.Initialized = true; }
/// <summary> /// Parse Sitemap file /// </summary> /// <returns>nothing</returns> private void ParseSitemap(Models.Sitemap.Sitemap items) { try { foreach (Models.Sitemap.Widget page in items.Homepage.Widgets) { CrossLogger.Current.Debug("Kala", "Label: " + page.Label); //Populate Page, if it contains elements to parse if (page.Label != string.Empty) { Dictionary <string, string> pageKeyValuePairs = Helpers.SplitCommand(page.Label); CrossLogger.Current.Debug("Kala", "Label: " + pageKeyValuePairs["label"]); #region page if (page.LinkedPage != null) { if (pageKeyValuePairs.ContainsKey("sx") && pageKeyValuePairs.ContainsKey("sy") && pageKeyValuePairs.ContainsKey("label")) { if (!pageKeyValuePairs.ContainsKey("icon")) { pageKeyValuePairs.Add("icon", null); } CrossLogger.Current.Debug("Kala", "Sitemap - Create Grid using: " + pageKeyValuePairs["label"] + ", " + pageKeyValuePairs["sx"] + ", " + pageKeyValuePairs["sy"] + ", " + pageKeyValuePairs["icon"]); Grid grid = CreatePage(pageKeyValuePairs["label"], pageKeyValuePairs["sx"], pageKeyValuePairs["sy"], pageKeyValuePairs["icon"]); foreach (Models.Sitemap.Widget3 item in page.LinkedPage.Widgets) { ParseWidgets(grid, item); } } } #endregion page else { CrossLogger.Current.Warn("Kala", "Unknown: " + ToString()); switch (pageKeyValuePairs["widget"].ToUpper()) { case "SITEMAP": CrossLogger.Current.Debug("Kala", "Sitemap:" + pageKeyValuePairs["name"]); Models.Sitemaps.Sitemap sitemaps = GetActiveSitemap(pageKeyValuePairs["name"]); if (sitemaps != null) { Sitemap sitemap = new Sitemap(); sitemap.CreateSitemap(sitemaps); CrossLogger.Current.Debug("Kala", "Got ActiveSitemap"); } break; } } } } } catch (Exception ex) { CrossLogger.Current.Error("Sitemap", "ParseSitemap() crashed: " + ex.ToString()); } }
/// <summary> /// Parse Sitemap file /// </summary> /// <returns>nothing</returns> private void ParseSitemap(Models.Sitemap.Sitemap items) { foreach (Models.Sitemap.Widget page in items.homepage.widget) { CrossLogger.Current.Debug("Kala", "Label: " + page.label); //Populate Page, if it contains elements to parse if (page.label != string.Empty) { Dictionary <string, string> pageKeyValuePairs = Helpers.SplitCommand(page.label); CrossLogger.Current.Debug("Kala", "Label: " + pageKeyValuePairs["label"]); #region page if (page.linkedPage != null) { Grid grid = null; if (pageKeyValuePairs.ContainsKey("sx") && pageKeyValuePairs.ContainsKey("sy")) { if (pageKeyValuePairs.ContainsKey("icon")) { grid = CreatePage(pageKeyValuePairs["label"], pageKeyValuePairs["sx"], pageKeyValuePairs["sy"], pageKeyValuePairs["icon"]); } else { grid = CreatePage(pageKeyValuePairs["label"], pageKeyValuePairs["sx"], pageKeyValuePairs["sy"], null); } } //Shortcut var w = page.linkedPage.widget; //If more than one item page frame if (w.GetType() == typeof(JArray)) { List <Models.Sitemap.Widget3> w_items = ((JArray)w).ToObject <List <Models.Sitemap.Widget3> >(); foreach (Models.Sitemap.Widget3 item in w_items) { ParseWidgets(grid, item); } } //If one item in page frame else if (w.GetType() == typeof(JObject)) { Models.Sitemap.Widget3 item = ((JObject)w).ToObject <Models.Sitemap.Widget3>(); ParseWidgets(grid, item); } else { CrossLogger.Current.Warn("Kala", "Unknown: " + w.ToString()); } } #endregion page else { CrossLogger.Current.Warn("Kala", "Unknown: " + ToString()); switch (pageKeyValuePairs["widget"].ToUpper()) { case "SITEMAP": CrossLogger.Current.Debug("Kala", "Sitemap:" + pageKeyValuePairs["name"]); Models.Sitemaps.Sitemap sitemaps = GetActiveSitemap(pageKeyValuePairs["name"]); if (sitemaps != null) { Sitemap sitemap = new Sitemap(); sitemap.CreateSitemap(sitemaps); CrossLogger.Current.Debug("Kala", "Got ActiveSitemap"); } break; } } } } }
public App() { if (Config == null) { Config = new Configuration(); IPlatformInfo platformInfo = DependencyService.Get <IPlatformInfo>(); CrossLogger.Current.Info("Kala", "Model: " + platformInfo.GetModel()); CrossLogger.Current.Info("Kala", "Version: " + platformInfo.GetVersion()); CrossLogger.Current.Info("Kala", "Wifi MAC address: " + platformInfo.GetWifiMacAddress()); CrossLogger.Current.Debug("Kala", @"URL Settings: '" + Settings.Protocol + "://" + Settings.Server + ":" + Settings.Port.ToString() + "'"); CrossLogger.Current.Debug("Kala", @"Auth Settings: '" + Settings.Username + " / " + Settings.Password + "'"); CrossLogger.Current.Debug("Kala", @"Sitemap Settings: '" + Settings.Sitemap + "'"); } //Initialize FFImageLoading with Authentication FFImageLoading.AuthenticatedHttpImageClientHandler.Initialize(); //TabbedPage setup if (Tp.Children.Count == 0) { Tp.BackgroundColor = Config.BackGroundColor; Tp.BarBackgroundColor = Config.BackGroundColor; Tp.BarTextColor = Config.TextColor; Tp.CurrentPageChanged += (sender, e) => { //Reset screensaver timer Config.LastActivity = DateTime.Now; CrossLogger.Current.Debug("Kala", "Reset Screensaver timer"); }; //Auto configured sitemap? var WifiMac = DependencyService.Get <IPlatformInfo>().GetWifiMacAddress(); Sitemaps = Sitemap.GetActiveSitemap(WifiMac); if (Sitemaps == null) { Sitemaps = Sitemap.GetActiveSitemap(Settings.Sitemap); //Selected sitemap was not found, display settings page to make change if (Sitemaps == null) { //Add settings tab with Wifi Mac as default Settings.Sitemap = WifiMac; MainPage = new Pages.Settings(); } } if (Sitemaps != null) { Sitemap sitemap = new Sitemap(); sitemap.GetUpdates(); sitemap.CreateSitemap(Sitemaps); CrossLogger.Current.Debug("Kala", "Got Sitemaps"); if (Config.Settings) { //Add settings tab last Tp.Children.Add(new Pages.Settings()); } MainPage = Tp; } } else { MainPage = Tp; } Config.Initialized = true; }