Esempio n. 1
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell(OptionsViewControllerCell.Key) as OptionsViewControllerCell;

            if (cell == null)
            {
                cell = new OptionsViewControllerCell();
            }

            uint flags = WritePadAPI.recoGetFlags();
            var  sw    = new UISwitch();

            sw.ValueChanged += (object sender, EventArgs e) => {
                UISwitch swit = (UISwitch)sender;
                flags = WritePadAPI.recoGetFlags();
                switch (swit.Tag)
                {
                case (int)WritePadOptions.kWritePadOptionsSepLetters:
                    flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_SEPLET);
                    break;

                case (int)WritePadOptions.kWritePadOptionsSingleWord:
                    flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_SINGLEWORDONLY);
                    break;

                case (int)WritePadOptions.kWritePadOptionsLearner:
                    flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_ANALYZER);
                    break;

                case (int)WritePadOptions.kWritePadOptionsAutcorrector:
                    flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_CORRECTOR);
                    break;

                case (int)WritePadOptions.kWritePadOptionsUserDict:
                    flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_USERDICT);
                    break;

                case (int)WritePadOptions.kWritePadOptionsDictionaryOnly:
                    flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_ONLYDICT);
                    break;
                }
                WritePadAPI.recoSetFlags(flags);
            };
            sw.Tag             = indexPath.Row;
            cell.AccessoryView = sw;
            switch (indexPath.Row)
            {
            case (int)WritePadOptions.kWritePadOptionsSepLetters:
                sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_SEPLET);
                cell.TextLabel.Text = "Separate letters mode (PRINT)";
                break;

            case (int)WritePadOptions.kWritePadOptionsSingleWord:
                sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_SINGLEWORDONLY);
                cell.TextLabel.Text = "Disable word segmentation (single word)";
                break;

            case (int)WritePadOptions.kWritePadOptionsLearner:
                sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_ANALYZER);
                cell.TextLabel.Text = "Enable Automatic learner";
                break;

            case (int)WritePadOptions.kWritePadOptionsAutcorrector:
                sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_CORRECTOR);
                cell.TextLabel.Text = "Enable Autocorrector";
                break;

            case (int)WritePadOptions.kWritePadOptionsUserDict:
                sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_USERDICT);
                cell.TextLabel.Text = "Enable User Dictionary";
                break;

            case (int)WritePadOptions.kWritePadOptionsDictionaryOnly:
                sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_ONLYDICT);
                cell.TextLabel.Text = "Recognize Dictionary Words Only";
                break;
            }

            return(cell);
        }
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell (OptionsViewControllerCell.Key) as OptionsViewControllerCell;
            if (cell == null)
                cell = new OptionsViewControllerCell ();

            uint flags = WritePadAPI.recoGetFlags();
            var sw = new UISwitch();
            sw.ValueChanged += (object sender, EventArgs e) => {
                UISwitch swit = (UISwitch)sender;
                flags = WritePadAPI.recoGetFlags();
                switch( swit.Tag )
                {
                    case (int)WritePadOptions.kWritePadOptionsSepLetters :
                        flags = WritePadAPI.setRecoFlag( flags, swit.On, WritePadAPI.FLAG_SEPLET );
                        break;
                    case (int)WritePadOptions.kWritePadOptionsSingleWord :
                        flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_SINGLEWORDONLY);
                        break;
                    case (int)WritePadOptions.kWritePadOptionsLearner :
                        flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_ANALYZER);
                        break;
                    case (int)WritePadOptions.kWritePadOptionsAutcorrector :
                        flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_CORRECTOR);
                        break;
                    case (int)WritePadOptions.kWritePadOptionsUserDict :
                        flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_USERDICT);
                        break;
                    case (int)WritePadOptions.kWritePadOptionsDictionaryOnly :
                        flags = WritePadAPI.setRecoFlag(flags, swit.On, WritePadAPI.FLAG_ONLYDICT);
                        break;
                }
                WritePadAPI.recoSetFlags( flags );
            };
            sw.Tag = indexPath.Row;
            cell.AccessoryView = sw;
            switch( indexPath.Row )
            {
                case (int)WritePadOptions.kWritePadOptionsSepLetters :
                    sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_SEPLET);
                    cell.TextLabel.Text = "Separate letters mode (PRINT)";
                    break;
                case (int)WritePadOptions.kWritePadOptionsSingleWord :
                    sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_SINGLEWORDONLY);
                    cell.TextLabel.Text = "Disable word segmentation (single word)";
                    break;
                case (int)WritePadOptions.kWritePadOptionsLearner :
                    sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_ANALYZER);
                    cell.TextLabel.Text = "Enable Automatic learner";
                    break;
                case (int)WritePadOptions.kWritePadOptionsAutcorrector :
                    sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_CORRECTOR);
                    cell.TextLabel.Text = "Enable Autocorrector";
                    break;
                case (int)WritePadOptions.kWritePadOptionsUserDict :
                    sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_USERDICT);
                    cell.TextLabel.Text = "Enable User Dictionary";
                    break;
                case (int)WritePadOptions.kWritePadOptionsDictionaryOnly:
                    sw.On = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_ONLYDICT);
                    cell.TextLabel.Text = "Recognize Dictionary Words Only";
                    break;
            }

            return cell;
        }