Пример #1
0
        //this is called after the user Select the image from dropbox
        private void DownloadImageTask(NSUrl imageLink, string imageName)
        {
            try{
                UIImage img = Util.FromNSUrl(imageLink);
                if (img != null)
                {
                    ConfigsEngine.SaveImageForCurrentConfiguration(imageName, img);
                    InvokeOnMainThread(() => {
                        if (_iconSelection == IconSelection.DEFAULT)
                        {
                            DefaultIconBtn.SetImage(img, UIControlState.Normal);
                            DefaultIconBtn.BackgroundColor = UIColor.Clear;
                            _loadedDefaultIconName         = imageName;
                        }
                        else if (_iconSelection == IconSelection.SELECTED)
                        {
                            SelectedIconBtn.SetImage(img, UIControlState.Normal);
                            SelectedIconBtn.BackgroundColor = UIColor.Clear;
                            _loadedSelectedIconName         = imageName;
                        }

                        _activityIndicator.StopAnimating();
                        _activityIndicator.RemoveFromSuperview();
                    });
                }
            }
            catch (Exception) {
                InvokeOnMainThread(() => {
                    var alert = new UIAlertView("Error", "Error downloading image from dropbox", null, "Ok");
                    alert.Show();
                });
            }
        }
Пример #2
0
        public void UpdateKeyLayout(FPKey key)
        {
            if (key.DefaultIcon != null && key.DefaultIcon != string.Empty)               //if there is an icon, we display an icon
            {
                Icon.Image       = UIImage.FromFile(ConfigsEngine.GetImageForCurrentConfiguration(key.DefaultIcon));
                Icon.Hidden      = false;
                MainTitle.Hidden = true;
            }
            else
            {
                MainTitle.Text   = key.MainTitle;
                Icon.Hidden      = true;
                MainTitle.Hidden = false;
            }

            SubTitle.Text       = key.SubTitle;
            SubTitle.TextColor  = Util.GetUicolorFromRGBString(key.SubTitleColor);
            MainTitle.TextColor = Util.GetUicolorFromRGBString(key.MainTitleColor);

            this.Layer.BorderColor = Util.BorderColor;

            if (key.BackgroundColor == null && key.Action == null)
            {
                this.BackgroundColor = Util.CellBackgroundColor;
            }
            else if (key.BackgroundColor == null && key.Action != null)
            {
                this.BackgroundColor = UIColor.White;
            }
            else
            {
                this.BackgroundColor = Util.GetUicolorFromRGBString(key.BackgroundColor);
            }
        }
Пример #3
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            MainTitleTbox.Text  = _loadedKey.MainTitle;
            SubTitleTbox.Text   = _loadedKey.SubTitle;
            PersistentSwitch.On = _loadedKey.PersistSelected;
            if (_loadedKey.DefaultIcon != null && _loadedKey.DefaultIcon != string.Empty)
            {
                if (System.IO.File.Exists(ConfigsEngine.GetImageForCurrentConfiguration(_loadedKey.DefaultIcon)))
                {
                    DefaultIconBtn.SetImage(UIImage.FromFile(ConfigsEngine.GetImageForCurrentConfiguration(_loadedKey.DefaultIcon)), UIControlState.Normal);
                    _loadedDefaultIconName = _loadedKey.DefaultIcon;
                }
            }
            else
            {
                DefaultIconBtn.SetImage(null, UIControlState.Normal);
                _loadedDefaultIconName = string.Empty;
            }
            if (!string.IsNullOrEmpty(_loadedKey.SelectedIcon))
            {
                SelectedIconBtn.SetImage(UIImage.FromFile(ConfigsEngine.GetImageForCurrentConfiguration(_loadedKey.SelectedIcon)), UIControlState.Normal);
                _loadedSelectedIconName = _loadedKey.SelectedIcon;
            }
            else
            {
                SelectedIconBtn.SetImage(null, UIControlState.Normal);
                _loadedKey.SelectedIcon = string.Empty;
            }

            TitleColorBtn.BackgroundColor        = Util.GetUicolorFromRGBString(_loadedKey.MainTitleColor);
            SubtitleColorBtn.BackgroundColor     = Util.GetUicolorFromRGBString(_loadedKey.SubTitleColor);
            TitleSelColorBtn.BackgroundColor     = Util.GetUicolorFromRGBString(_loadedKey.SelectedMainTitleColor);
            SubtitleSelColorBtn.BackgroundColor  = Util.GetUicolorFromRGBString(_loadedKey.SelectedSubTitleColor);
            BackgroundColorBtn.BackgroundColor   = Util.GetUicolorFromRGBString(_loadedKey.BackgroundColor);
            BackroundSelColorBtn.BackgroundColor = Util.GetUicolorFromRGBString(_loadedKey.SelectedBackgroundColor);
            ActionTbox.Text = "";
            _actionKeys.Clear();

            if (_loadedKey.Action != null)
            {
                try
                {
                    _actionKeys = JsonConvert.DeserializeObject <List <int> >(_loadedKey.Action);
                }
                catch (Exception e)
                {
                    FPLog.Instance.WriteLine("Error deserializing key");
                }
            }

            if (_actionKeys != null && _actionKeys.Count > 0)
            {
                PopulateActionTextBox();
            }


            SetupKeyboard();
        }
Пример #4
0
        /// <summary>
        /// Exports the configuration. Create a zip file which can be shared
        /// </summary>
        /// <param name="sender">Sender.</param>
        async partial void ExportConfiguration(NSObject sender)
        {
            UIActivityIndicatorView activityIndicator = new UIActivityIndicatorView(ExportConfigBtn.Frame);

            activityIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray;
            activityIndicator.StartAnimating();
            this.View.AddSubview(activityIndicator);
            ExportConfigBtn.Hidden = true;
            string zip = await ConfigsEngine.CreateFileForExport(_loadedConfiguration);

            activityIndicator.StopAnimating();
            activityIndicator.RemoveFromSuperview();
            ExportConfigBtn.Hidden = false;

            if (zip == string.Empty)
            {
                UIAlertView alertError = new UIAlertView("Error".Localize(), "Error Creating Zip File".Localize(), null, "Ok".Localize());
                alertError.Show();
                return;
            }

            var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(zip));

            viewer.PresentOpenInMenu(ExportConfigBtn.Frame, this.View, true);
        }
Пример #5
0
        public void UpdateKeyLayoutSelected(FPKey key)
        {
            if (key.SelectedIcon != null && key.SelectedIcon != string.Empty)                //if there is an icon, we display an icon
            {
                Icon.Image = UIImage.FromFile(ConfigsEngine.GetImageForCurrentConfiguration(key.SelectedIcon));
            }
            else
            {
                MainTitle.Text = key.MainTitle;
            }

            SubTitle.Text       = key.SubTitle;
            SubTitle.TextColor  = Util.GetUicolorFromRGBString(key.SelectedSubTitleColor);
            MainTitle.TextColor = Util.GetUicolorFromRGBString(key.SelectedMainTitleColor);

            if (key.BackgroundColor == null)
            {
                this.BackgroundColor = UIColor.Cyan;
            }
            else
            {
                this.BackgroundColor = Util.GetUicolorFromRGBString(key.SelectedBackgroundColor);
            }

            this.Layer.BorderColor = UIColor.Green.CGColor;
        }
Пример #6
0
        private async Task <bool> LoadDefaultConfiguration()
        {
            _loadedConfiguration = await ConfigsEngine.LoadDefaultConfiguration(Util.IsOSxServer);

            Util.SetLastConfigurationUsed(_loadedConfiguration.Name);
            LoadConfiguration(_loadedConfiguration);
            return(true);
        }
Пример #7
0
        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);
        }
Пример #8
0
 /// <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);
 }
Пример #9
0
 /// <summary>
 /// A configuration has been deleted from the list of configurations tableview
 /// </summary>
 /// <param name="name">the configuration name</param>
 async void OnConfigurationDeleted(string name)
 {
     FPLog.Instance.WriteLine("Configuration Deleted: {0}", FPLog.LoggerLevel.LOG_INFORMATION, name);
     if (_loadedConfiguration.Name == name)
     {
         new UIAlertView("Error".Localize(), "Configuration In Use".Localize(), null, "Ok".Localize()).Show();
     }
     else
     {
         ConfigsEngine.DeleteConfiguration(name);
         _configsSource.UpdateData(await ConfigsEngine.GetListOfConfigurations());
         ConfigListTableView.ReloadData();
     }
 }
Пример #10
0
        private async void RefreshConfigurationsList()
        {
            RemoteConfigsTable.Hidden = true;
            _activityIndicator.StartAnimating();
            this.Add(_activityIndicator);
            var configs = await ConfigsEngine.GetServerConfigurations();

            if (configs != null)
            {
                _source.UpdateData(configs);
                RemoteConfigsTable.ReloadData();
            }
            RemoteConfigsTable.Hidden = false;
            _activityIndicator.RemoveFromSuperview();
        }
Пример #11
0
        /// <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);
        }
Пример #12
0
 /// <summary>
 /// Import a configuration from dropbox
 /// </summary>
 /// <param name="sender">Sender.</param>
 partial void ImportConfiguration(NSObject sender)
 {
     DBChooser.DefaultChooser.OpenChooser(DBChooserLinkType.Direct, this, async(results) => {
         if (results == null)
         {
             // results is null if the user cancels
             //new UIAlertView ("Cancelled", "User cancelled!", null, "Continue").Show ();
         }
         else
         {
             var confs = await ConfigsEngine.ImportFile(results[0].Link.ToString(), results[0].Name);
             InvokeOnMainThread(() => {
                 new UIAlertView("Import", confs, null, "Ok".Localize()).Show();
             });
         }
     });
 }
Пример #13
0
        partial void NewConfiguration(NSObject sender)
        {
            UIAlertView alert = new UIAlertView("New Configuration".Localize(), "Please Enter Name".Localize(), null, "Cancel".Localize(), "Create Empty".Localize(), "Copy Current".Localize());

            alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;

            alert.Clicked += (object s, UIButtonEventArgs e) =>
            {
                if (e.ButtonIndex != 0)
                {
                    string name = alert.GetTextField(0).Text;
                    if (name == "")
                    {
                        return;
                    }

                    KeyConfiguration conf = null;


                    if (e.ButtonIndex == 2)                     //copy
                    {
                        conf = ConfigsEngine.CreateNewConfiguration(name, _loadedConfiguration);
                    }
                    else if (e.ButtonIndex == 1)                     //empty
                    {
                        conf = ConfigsEngine.CreateNewConfiguration(name, null);
                    }


                    if (conf != null)
                    {
                        LoadConfiguration(conf);
                    }
                    else
                    {
                        UIAlertView alertError = new UIAlertView("Error".Localize(), "Configuration already exists".Localize(), null, "Ok".Localize());
                        alertError.Show();
                    }
                }
            };

            alert.Show();
        }
Пример #14
0
        /// <summary>
        /// load the list of configurations
        /// </summary>
        /// <param name="sender">Sender.</param>

        /*async partial void SelectConfiguration (NSObject sender)
         * {
         *
         * }*/

        async partial void OnSelectConfigurationBtnTouchUpInside(NSObject sender)
        {
            if (_configListPopOver.PopoverVisible)
            {
                return;
            }

            _configListPopOver.PresentFromRect(SelectConfigBtn.Frame, View, UIPopoverArrowDirection.Up, true);
            ConfigListTableView.Hidden = true;
            UIActivityIndicatorView activityIndicator = new UIActivityIndicatorView(new CoreGraphics.CGRect(ConfigListTableView.Frame.Width / 2 - 25, ConfigListTableView.Frame.Height / 2 - 25, 50, 50));

            activityIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray;
            activityIndicator.StartAnimating();
            ConfigListTableView.AddSubview(activityIndicator);

            var confs = await ConfigsEngine.GetListOfConfigurations();

            _configsSource.UpdateData(confs);
            ConfigListTableView.ReloadData();
            ConfigListTableView.Hidden = false;
            activityIndicator.RemoveFromSuperview();
        }
Пример #15
0
 private async void OnConfigSelected(RepoConfig config)
 {
     string configZipFile = await ConfigsEngine.ImportFile(config.Path, config.Name);
 }
Пример #16
0
        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
        }