public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); this.NavigationController.SetNavigationBarHidden(true, true); KeysCollectionView.ReloadData(); }
void HandleLongGesture(UIGestureRecognizer gesture) { if (_editModeEnabled) { return; } switch (gesture.State) { case UIGestureRecognizerState.Began: _selIndPath = KeysCollectionView.IndexPathForItemAtPoint(gesture.LocationInView(View)); if (_selIndPath != null) { KeysCollectionView.BeginInteractiveMovementForItem(_selIndPath); } break; case UIGestureRecognizerState.Changed: KeysCollectionView.UpdateInteractiveMovement(gesture.LocationInView(View)); break; case UIGestureRecognizerState.Ended: KeysCollectionView.EndInteractiveMovement(); break; default: KeysCollectionView.CancelInteractiveMovement(); break; } }
/// <summary> /// Switch the keys from edit mode to normal mode and vice-versa. /// </summary> /// <param name="sender">Sender.</param> partial void EditModeChange(NSObject sender) { _editModeEnabled = !_editModeEnabled; EditBtn.Selected = _editModeEnabled; _keySourceData.SetEditMode(_editModeEnabled); KeysCollectionView.ReloadData(); DisableActionButtons(_editModeEnabled); }
private void HandleKeyMoved(NSIndexPath destination) { var sourceCell = _loadedConfiguration.Keys[_selIndPath.Row]; _loadedConfiguration.Keys.RemoveAt(_selIndPath.Row); _loadedConfiguration.Keys.Insert(destination.Row, sourceCell); KeysCollectionView.ReloadData(); ConfigsEngine.SaveConfiguration(_loadedConfiguration); }
/// <summary> /// Enable, disable night mode /// </summary> /// <param name="nightModeEnabled">self explanatory</param> void OnNightModeChanged(bool nightModeEnabled) { this.KeysCollectionView.BackgroundColor = Util.BackgroundColor; this.View.SetNeedsDisplay(); KeysCollectionView.SetNeedsDisplay(); ConfigNameLbl.SetNeedsDisplay(); KeysCollectionView.ReloadData(); }
/// <summary> /// Load the selected configuration on the screen /// </summary> /// <param name="configuration">the configuration object</param> private void LoadConfiguration(KeyConfiguration configuration) { InvokeOnMainThread(() => { _loadedConfiguration = configuration; Util.SetLastConfigurationUsed(_loadedConfiguration.Name); _keySourceData.UpdateSource(_loadedConfiguration.Keys); KeysCollectionView.ReloadData(); ConfigNameLbl.Text = _loadedConfiguration.Name.ToUpper(); }); }
/// <summary> /// The edit key view controller has been dismissed /// </summary> /// <param name="save">If set to <c>true</c> reload the configuration .</param> /// <param name="applyStyleToAll">If set to <c>true</c> apply the style to all keys</param> void HandleDismissEditKeyVC(bool save, bool applyStyleToAll) { if (save) { if (applyStyleToAll) { ApplyStyleToAllKeys(_editKeyViewController._loadedKey); } ConfigsEngine.SaveConfiguration(_loadedConfiguration); KeysCollectionView.ReloadData(); } _editKeyViewController.DismissViewController(true, null); }
/// <summary> /// A key on the keycollectionview has been pressed /// </summary> /// <param name="key">The pressed Key.</param> void HandleKeyPressed(FPKey key) { if (_editModeEnabled) { if (_editKeyViewController == null) { _editKeyViewController = new EditKeyVC(); _editKeyViewController.OnDismissViewController += HandleDismissEditKeyVC; } _editKeyViewController.ModalPresentationStyle = UIModalPresentationStyle.FormSheet; _editKeyViewController.SetKey(key); _editKeyViewController._isOsx = _loadedConfiguration.OSx; this.PresentViewController(_editKeyViewController, true, null); } else { CommsEngine.Instance.Send(key.Action); if (key.PersistSelected) //needs to change the color { KeysCollectionView.ReloadData(); } } }
void ReleaseDesignerOutlets() { if (bannerView != null) { bannerView.Dispose(); bannerView = null; } if (ConfigListTableView != null) { ConfigListTableView.Dispose(); ConfigListTableView = null; } if (ConfigNameLbl != null) { ConfigNameLbl.Dispose(); ConfigNameLbl = null; } if (EditBtn != null) { EditBtn.Dispose(); EditBtn = null; } if (ExportConfigBtn != null) { ExportConfigBtn.Dispose(); ExportConfigBtn = null; } if (ImportConfigBtn != null) { ImportConfigBtn.Dispose(); ImportConfigBtn = null; } if (KeysCollectionView != null) { KeysCollectionView.Dispose(); KeysCollectionView = null; } if (NewConfigBtn != null) { NewConfigBtn.Dispose(); NewConfigBtn = null; } if (SearchConfigBtn != null) { SearchConfigBtn.Dispose(); SearchConfigBtn = null; } if (SelectConfigBtn != null) { SelectConfigBtn.Dispose(); SelectConfigBtn = null; } if (SettingsBtn != null) { SettingsBtn.Dispose(); SettingsBtn = null; } }
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 }