/// <summary> /// A configuration has been selected from the list of configurations tableview /// </summary> /// <param name="name">the configuration name</param> void OnConfigurationSelected(string name) { FPLog.Instance.WriteLine("Configuration Selected: {0}", FPLog.LoggerLevel.LOG_INFORMATION, name); var config = ConfigsEngine.LoadConfiguration(name); if (config != null) { LoadConfiguration(config); } else { UIAlertView alertError = new UIAlertView("Error".Localize(), "Error Loading Configuration".Localize(), null, "Ok".Localize()); alertError.Show(); } _configListPopOver.Dismiss(true); }
public override void ViewDidLoad() { base.ViewDidLoad(); bannerView.Hidden = true; UIApplication.SharedApplication.SetStatusBarHidden(true, false); Util.SetColorsOnStartup(); this.KeysCollectionView.BackgroundColor = Util.BackgroundColor; ClearButton(ExportConfigBtn); ExportConfigBtn.SetImage(Images.ExportConfigImg, UIControlState.Normal); ClearButton(ImportConfigBtn); ImportConfigBtn.SetImage(Images.ImportConfigImg, UIControlState.Normal); ClearButton(NewConfigBtn); NewConfigBtn.SetImage(Images.NewConfigImg, UIControlState.Normal); ClearButton(SearchConfigBtn); SearchConfigBtn.SetImage(Images.SearchConfigImg, UIControlState.Normal); ClearButton(SelectConfigBtn); SelectConfigBtn.SetImage(Images.ListConfigsImg, UIControlState.Normal); ClearButton(SettingsBtn); SettingsBtn.SetImage(Images.SettingsImg, UIControlState.Normal); ClearButton(EditBtn); EditBtn.SetImage(Images.EditConfigImg, UIControlState.Normal); //EditBtn.SetImage(Images.EditConfigImgSelected,UIControlState.Selected); //load last used configuration or default if (Util.GetLastConfigurationUsed() == null) //this is the first run ever { DBManager.Instance.CreateTables(); _keySourceData = new KeySource(new List <FPKey> ()); } else { _loadedConfiguration = ConfigsEngine.LoadConfiguration(Util.GetLastConfigurationUsed()); _keySourceData = new KeySource(_loadedConfiguration.Keys); ConfigNameLbl.Text = _loadedConfiguration.Name.ToUpper(); } //TODO add iphone KeysCollectionView.RegisterNibForCell(UINib.FromName("KeyCell_iPad", NSBundle.MainBundle), KeyCell.Key); _keySourceData.KeyPressed += HandleKeyPressed; _keySourceData.OnKeyMoved += HandleKeyMoved; KeysCollectionView.Source = _keySourceData; KeysCollectionView.DelaysContentTouches = false; var longPressGesture = new UILongPressGestureRecognizer(HandleLongGesture); KeysCollectionView.AddGestureRecognizer(longPressGesture); #region Config popOver UIViewController configListViewController = new UIViewController(); configListViewController.View = ConfigListTableView; configListViewController.View.BackgroundColor = UIColor.White; _configListPopOver = new UIPopoverController(configListViewController); _configListPopOver.BackgroundColor = UIColor.White; _configsSource = new ConfigurationsListSource(); _configsSource.OnConfigurationSelected += OnConfigurationSelected; _configsSource.OnConfigurationDeleted += OnConfigurationDeleted; ConfigListTableView.Source = _configsSource; ConfigListTableView.ReloadData(); ConfigListTableView.TableFooterView = new UIView(); #endregion Util.OnEnableNightMode += OnNightModeChanged; #if !DISCONNECTED CommsEngine.Instance.OnServerDisconnected += HandleOnServerDisconnected; if (Util.GetServerIP() == null) //first Time { PresentServerSelection(); } else { CommsEngine.Instance.OnClientConnected += HandleOnClientConnected; ConnectToLastKnownServer(); } #else if (Util.GetLastConfigurationUsed() == null) { LoadDefaultConfiguration(); } #endif }