Example #1
0
 public SelectElement(IWebElement element, IWebDriver driver) : base(element, driver)
 {
     if (element.TagName == "select")
     {
         OldStyleSelect       = new OpenQA.Selenium.Support.UI.SelectElement(element);
         LazyAvailableOptions = new Lazy <IList <IWebElement> >(() => OldStyleSelect.Options);
         LazySelectedOptions  = new Lazy <IList <IWebElement> >(() => OldStyleSelect.AllSelectedOptions);
     }
     else
     {
         var listId = element.GetAttribute("list");
         if (string.IsNullOrWhiteSpace(listId))
         {
             throw new Exception("The {element.TagName} is neither a select element nor an element with a list attribute");
         }
         LazyAvailableOptions = new Lazy <IList <IWebElement> >(() => driver.FindElements(By.XPath($"//datalist[@id='{listId}']/option")));
         LazySelectedOptions  = new Lazy <IList <IWebElement> >(() => new List <IWebElement>());
         var value = element.GetAttribute("value");
         if (!string.IsNullOrWhiteSpace(value))
         {
             var selected = AvailableOptions.Where(o => o.GetAttribute("value") == value);
             if (selected.None())
             {
                 throw new Exception($"element with list:{listId} and value:{value} did not find any mathching options in the {AvailableOptions.Count()} options");
             }
             if (selected.Many())
             {
                 throw new Exception($"element with list:{listId} and value:{value} found {selected.Count()} mathching options in the {AvailableOptions.Count()} options");
             }
             SelectedOptions.Add(selected.First());
         }
     }
 }
Example #2
0
        public MainViewModel()
        {
            DownloadDepotTools = new CommandHandler {
                Action = OnDownloadDepotTools
            };
            UpdateDepotTools = new CommandHandler {
                Action = OnUpdateDepotTools
            };
            BrowseSource = new CommandHandler {
                Action = OnBrowseSource
            };
            DownloadSource = new CommandHandler {
                Action = OnDownloadSource
            };
            UpdateSource = new CommandHandler {
                Action = OnUpdateSource
            };
            GetOptionsAvailable = new CommandHandler {
                Action = OnUpdateOptions
            };
            OpenReadMe = new CommandHandler {
                Action = OnOpenReadMe
            };
            ExploreConfiguration = new CommandHandler {
                Action = OnExploreConfiguration
            };
            ConfigureBuild = new CommandHandler {
                Action = OnConfigureBuild
            };
            BrowseBuildFolder = new CommandHandler {
                Action = OnBrowseBuild
            };
            MoveAvailable = new CommandHandler {
                Action = OnMoveAvailable
            };
            MoveSelected = new CommandHandler {
                Action = OnMoveSelected
            };
            BrowseWindowsKit = new CommandHandler {
                Action = OnBrowseWindowsKit
            };
            BuildV8 = new CommandHandler {
                Action = OnBuildV8
            };

            // The available options are those that are not selected
            foreach (var option in Config.BuildOptions)
            {
                if (option.Selected)
                {
                    SelectedOptions.Add(option);
                }
                else
                {
                    AvailableOptions.Add(option);
                }
            }
            InvokePropertyChanged(nameof(Config));
        }
Example #3
0
 protected override AvailableOptions[] GetAvailableOptions(Direction direction)
 {
     return(new[]
     {
         AvailableOptions.AnyMove(),
         AvailableOptions.Are(Option.AttackWithFire, Option.ConsumeFire, Option.NoOperation)
     });
 }
Example #4
0
        public override async Task Initialize()
        {
            await base.Initialize();

            var selectedOption = await userPreferences.CalendarNotificationsSettings().FirstAsync();

            AvailableOptions.ForEach(opt => opt.Selected = opt.Option == selectedOption);
        }
        public override async Task Initialize()
        {
            await base.Initialize();

            var selectedOption = await userPreferences.CalendarNotificationsSettings().FirstAsync();

            SelectedOptionIndex = AvailableOptions.IndexOf(selectedOption);
        }
Example #6
0
 /// <summary>
 /// Updates the collection of available handlers
 /// </summary>
 private void _updateAvailableHandlers()
 {
     AvailableOptions.ForEach(x => x.AvailableHandlers.Clear());
     foreach (LoadedHandler handler in _factory.LoadedHandlers)
     {
         ResultsHandlerViewModel vm = new ResultsHandlerViewModel(handler);
         _registerHandlerVM(vm);
     }
 }
Example #7
0
        public void SetSelectedOption(int index)
        {
            if (index != -1 && AvailableOptions.ElementAt(index) == null)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            SelectedOptionIndex = index;
            OnSelectedOptionChanged();
        }
Example #8
0
 public void SetValue(AvailableOptions optionId, bool value)
 {
     foreach (Option o in list)
     {
         if (o.GetId() == (int)optionId)
         {
             o.SetValue(value);
             break;
         }
     }
 }
Example #9
0
 public void AddOption(string option)
 //Añade una opción a las disponibles de la Stage
 {
     if (option != null)
     {
         AvailableOptions.Add(new Option(option));
     }
     else
     {
         string err_msg = "Error al cargar las opciones";
         throw new GameFlowError(err_msg);
     }
 }
Example #10
0
        public bool GetValue(AvailableOptions id)
        {
            bool value = false;

            foreach (Option o in list)
            {
                if (o.GetId() == (int)id)
                {
                    value = o.GetValue();
                    break;
                }
            }
            return(value);
        }
Example #11
0
        protected override AvailableOptions[] GetAvailableOptions(Direction direction)
        {
            if (direction.IsVertical)
            {
                return new AvailableOptions[0] {
                }
            }
            ;

            return(new[]
            {
                AvailableOptions.Are(Option.Left, Option.Right),
                AvailableOptions.Are(Option.AdditionalSpiritPhase)
            });
        }
    }
Example #12
0
        protected override AvailableOptions[] GetAvailableOptions(Direction direction)
        {
            if (direction.IsHorizontal)
            {
                return new AvailableOptions[0] {
                }
            }
            ;

            return(new[]
            {
                AvailableOptions.Are(Option.Forward),
                AvailableOptions.Are(Option.Forward, Option.NoOperation)
            });
        }
    }
Example #13
0
        public void CheckAvailability()
        {
            AvailableOptions.Clear();

            foreach (IAccomodation accomodation in _accomodationList)
            {
                if (accomodation.HasSameLocationAs(_selectedLocation))
                {
                    if (accomodation.HasRoomsAvailableIn(_reservation.ReservationPeriod))
                    {
                        Option option = new Option(accomodation, accomodation.GetBestOptionFor(_reservation));
                        option.ComputeTotalPriceFor(_reservation.ReservationPeriod);
                        AvailableOptions.Add(option);
                    }
                }
            }
        }
Example #14
0
 protected override AvailableOptions[] GetAvailableOptions(Direction direction)
 {
     if (direction.IsHorizontal)
     {
         return(new[]
         {
             AvailableOptions.AnyMove()
         });
     }
     else
     {
         return(new[]
         {
             AvailableOptions.Are(Option.NoOperation)
         });
     }
 }
Example #15
0
 protected override AvailableOptions[] GetAvailableOptions(Direction direction)
 {
     if (direction.IsVertical)
     {
         return new[]
         {
             AvailableOptions.AnyMove()
         };
     }
     else
     {
         return new[]
         {
             AvailableOptions.Are(Option.NoOperation)
         };
     }
 }
Example #16
0
 public SelectElement(IWebElement element, IWebDriver driver) : base(element, driver)
 {
     if (element.TagName == "select")
     {
         OldStyleSelect       = new OpenQA.Selenium.Support.UI.SelectElement(element);
         LazyAvailableOptions = new Lazy <IList <IWebElement> >(() => OldStyleSelect.Options);
         LazySelectedOptions  = new Lazy <IList <IWebElement> >(() => OldStyleSelect.AllSelectedOptions);
     }
     else
     {
         var listId = element.GetAttribute("list");
         LazyAvailableOptions = new Lazy <IList <IWebElement> >(() => driver.FindElements(By.XPath($"//datalist[@id='{listId}']/option")));
         LazySelectedOptions  = new Lazy <IList <IWebElement> >(() => new List <IWebElement>());
         var value = element.GetAttribute("value");
         if (!string.IsNullOrWhiteSpace(value))
         {
             SelectedOptions.Add(AvailableOptions.First(o => o.GetAttribute("value") == value));
         }
     }
 }
Example #17
0
        public ModuleOption(AvailableOptions code, ModulePanel panel, ModuleOption parent = null)
        {
            this.Code = code;
            this.Name = code.ToString();
            this.Set = false;
            this.Parent = parent;
            this.Panel = panel;
            this.AnalysisName = panel.AnalysisName;

            switch (this.Code)
            {
                case AvailableOptions.ECG_BASELINE:
                    this.ModuleParam = new ECG_Baseline_Params();
                    panel.OptionParams[this] = this.ModuleParam;
                    panel.Params[this.Code] = this.ModuleParam;
                    break;
                case AvailableOptions.R_PEAKS:
                    this.ModuleParam = new R_Peaks_Params(R_Peaks_Method.EMD, this.getAnalysisName());
                    panel.OptionParams[this] = this.ModuleParam;
                    panel.Params[this.Code] = this.ModuleParam;
                    break;
                case AvailableOptions.WAVES:
                    this.ModuleParam = new Waves_Params();
                    panel.OptionParams[this] = this.ModuleParam;
                    panel.Params[this.Code] = this.ModuleParam;
                    break;
                case AvailableOptions.ATRIAL_FIBER:
                    this.ModuleParam = new Atrial_Fibr_Params(Detect_Method.POINCARE);
                    panel.OptionParams[this] = this.ModuleParam;
                    panel.Params[this.Code] = this.ModuleParam;
                    break;
                default:
                    this.ModuleParam = null;
                    break;
            }
        }
        public AvailableOptions GetAvailableOptions()
        {
            AvailableOptions options = new AvailableOptions();

            foreach (EnumLanguage cat in Enum.GetValues(typeof(EnumLanguage)))
            {
                options.Language.Add(cat.GetDescription());
            }

            foreach (EnumResponseGroup cat in Enum.GetValues(typeof(EnumResponseGroup)))
            {
                options.ResponseGroup.Add(cat.GetDescription());
            }

            foreach (EnumImageType cat in Enum.GetValues(typeof(EnumImageType)))
            {
                options.ImageType.Add(cat.GetDescription());
            }

            foreach (EnumOrientation cat in Enum.GetValues(typeof(EnumOrientation)))
            {
                options.Orientation.Add(cat.GetDescription());
            }

            foreach (EnumCategory cat in Enum.GetValues(typeof(EnumCategory)))
            {
                options.Category.Add(cat.GetDescription());
            }

            foreach (EnumVideoType cat in Enum.GetValues(typeof(EnumVideoType)))
            {
                options.VideoType.Add(cat.GetDescription());
            }

            return(options);
        }
Example #19
0
        public void ShowBookingVoucherView()
        {
            BookingVoucherView      bookingVoucherView      = new BookingVoucherView();
            BookingVoucherViewModel bookingVoucherViewModel = new BookingVoucherViewModel();

            if (_roomsToReserve.Count != 0)
            {
                ObservableCollection <IRoom> newList = new ObservableCollection <IRoom>();
                foreach (IRoom room in _roomsToReserve)
                {
                    newList.Add(room);
                }
                _selectedOption.RoomList = newList;
            }

            bookingVoucherViewModel.Reservation = new Reservation(_reservation.Owner, _selectedOption.Hotel, _reservation.ReservationPeriod, _reservation.NumberOfPersons, _selectedOption);
            bookingVoucherView.DataContext      = bookingVoucherViewModel;

            bookingVoucherView.Show();
            Reservation = new Reservation();

            AvailableOptions.Clear();
            RoomsToReserve.Clear();
        }
Example #20
0
        public Tuple<ModuleOption, ModuleParams> ModuleOptionAndParams(AvailableOptions code)
        {
            foreach (KeyValuePair<ModuleOption, ModuleParams> entry in OptionParams)
            {
                if (entry.Key.Code == code && entry.Key.Set == true)
                {
                    Tuple<ModuleOption, ModuleParams> correctOptionParams = new Tuple<ModuleOption, ModuleParams>(entry.Key, entry.Value);

                        return correctOptionParams;
                }

            }

            return null;
        }
Example #21
0
        private async void OnUpdateOptions()
        {
            try
            {
                EnableButtons(false);

                var workingFolder = Path.Combine(Config.SourceFolder, "v8");
                var configFolder  = (Application.Current as App).ConfigFolder;
                var genFolder     = Path.Combine(configFolder, "Downloads", "out.gn", "defaults");
                var argsFileName  = Path.Combine(configFolder, "Downloads", "gn_defaults.txt");

                if (!Directory.Exists(workingFolder))
                {
                    MessageBox.Show($"You must select an existing V8 source folder for the depot_tools to be able to produce a list "
                                    + "of available compiler options", $"V8 folder not found - '{workingFolder}'");
                    StatusText = "Updating build options failed";
                    return;
                }
                if (Directory.Exists(genFolder))
                {
                    try
                    {
                        FileSystem.DeleteDirectory(genFolder, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show($"Cannot delete '{genFolder}'; is that folder open in another program?"
                                        , $"Building V8 failed");
                        StatusText = $"failed to delete '{genFolder}'";
                        return;
                    }
                }

                var batch = new BatchFile
                {
                    WorkingDirectory = workingFolder,
                    Model            = this,
                    Title            = $"retrieving the list of available build options",
                };
                if (!CheckPython(batch.PythonFileName))
                {
                    return;
                }

                // batch.Commands.Add($"call python tools\\dev\\v8gen.py gen -b {Config.BuildConfiguration} \"{genFolder}\" --no-goma");
                var gnFileName = Path.Combine(Config.DepotToolsFolder, "gn.py");
                batch.Commands.Add($"\"{batch.PythonFileName}\" \"{gnFileName}\" gen \"{genFolder}\"");
                batch.Commands.Add($"\"{batch.PythonFileName}\" \"{gnFileName}\" args \"{genFolder}\" --list >{argsFileName}");
                StatusText = batch.Title;
                StatusText = await batch.Run();

                //var installer = CreateInstaller();
                //StatusText = "Extracting build options";
                //installer.WorkingDirectory = Path.Combine(Config.SourceFolder, "v8");

                //installer.Arguments = $"/k title Generating a list of build options & gn gen \"{genFolder}\" & gn args \"{genFolder}\" --list >{argsFileName}";
                //await Task.Run(() => Process.Start(installer).WaitForExit());

                var existingOptions = new Dictionary <string, BuildOption>(StringComparer.OrdinalIgnoreCase);
                foreach (var option in Config.BuildOptions)
                {
                    existingOptions[option.Name] = option;
                }
                AvailableOptions.Clear();
                SelectedOptions.Clear();

                StatusText = "Parsing build options";
                Config.BuildOptions.Clear();
                var               lines              = File.ReadAllLines(argsFileName);
                BuildOption       currentOption      = null;
                OptionParserState state              = OptionParserState.None;
                StringBuilder     descriptionBuilder = null;
                for (var ii = 0; ii < lines.Length; ++ii)
                {
                    var line = lines[ii];
                    switch (state)
                    {
                    case OptionParserState.None:
                    case OptionParserState.Name:
                        descriptionBuilder = new StringBuilder();
                        var name = line.Trim();
                        if (existingOptions.TryGetValue(name, out currentOption))
                        {
                            existingOptions.Remove(name);
                        }
                        else
                        {
                            currentOption = new Configuration.BuildOption
                            {
                                Name = line
                            };
                        }
                        if (currentOption.Selected)
                        {
                            SelectedOptions.Add(currentOption);
                        }
                        else
                        {
                            AvailableOptions.Add(currentOption);
                        }
                        Config.BuildOptions.Add(currentOption);
                        state = OptionParserState.Current;
                        break;

                    case OptionParserState.Current:
                        currentOption.Default = line.Split('=')[1].Trim();
                        state = OptionParserState.From;
                        break;

                    case OptionParserState.From:
                        state = OptionParserState.Blank;
                        break;

                    case OptionParserState.Blank:
                        state = OptionParserState.Description;
                        break;

                    case OptionParserState.Description:
                        if (!string.IsNullOrEmpty(line) && line[0] != ' ')
                        {
                            --ii;       // Reparse this line, it's the next name
                            currentOption.Description = descriptionBuilder.ToString().Trim();
                            state = OptionParserState.Name;
                        }
                        else
                        {
                            descriptionBuilder.Append(' ');
                            descriptionBuilder.Append(line.Trim());
                        }
                        break;
                    }
                }
                if (currentOption != null && descriptionBuilder != null && (descriptionBuilder.Length > 0))
                {
                    currentOption.Description = descriptionBuilder.ToString();
                }
                StatusText = "Ready";
            }
            finally
            {
                EnableButtons(true);
            }
        }
Example #22
0
    public static AvailableOptions workOutOptionsForActivityAndLangArea(ApplicationID para_appID, int para_langArea)
    {
        //int appID = (int) para_appID;

        string levelDBFilePath = "Localisation_Files/"+langCode+"/Instructions_"+langCode+"_"+para_appID;

        Dictionary<string,List<int>> validKeysAndCodes = new Dictionary<string, List<int>>();
        List<string> listKeys = new List<string>();

        TextAsset ta = (TextAsset) Resources.Load(levelDBFilePath,typeof(TextAsset));

        if(ta==null){
            Debug.LogError("Localisation_Files/"+langCode+"/Instructions_"+langCode+"_"+para_appID);

        }
        string text = ta.text;
        string[] lineArr = text.Split('\n');
        foreach(string line in lineArr)
        {
            string[] values = line.Split(',');

            // values[0] == application ID
            // values[1] == language area
            // values[3] == index
            // values[4] == default level string.

            if(System.Convert.ToInt32(values[0]) == para_langArea)
            {
                // Check for valid attributes.

                string lvlStr = values[3];
                string[] lvlStrParts = lvlStr.Split('-');

                for(int i=0; i<lvlStrParts.Length; i++)
                {
                    string tmpPart = lvlStrParts[i];
                    string charKey = ""+tmpPart[0];
                    int numCode = int.Parse(tmpPart.Substring(1));

                    if( ! validKeysAndCodes.ContainsKey(charKey))
                    {
                        validKeysAndCodes.Add(charKey,new List<int>());
                        listKeys.Add (charKey);
                    }

                    if( ! (validKeysAndCodes[charKey].Contains(numCode)))
                    {
                        validKeysAndCodes[charKey].Add(numCode);
                    }
                }
            }
        }

        // Sort items.
        List<string> tmpKeys = new List<string>(validKeysAndCodes.Keys);
        for(int i=0; i<tmpKeys.Count; i++)
        {
            validKeysAndCodes[tmpKeys[i]].Sort();
        }

        Dictionary<string,string[]> validKeysAndReadableOptions = new Dictionary<string, string[]>();
        Dictionary<string,string> validKeysAndTitles = new Dictionary<string, string>();

        foreach(string key in listKeys)
        {

            List<string> nxtReadableOptions = new List<string>();

            //if(wvServCom.language==LanguageCode.EN){
            // Special override for text to speech. (Displays Off and On instead of 0 and 1).
            if(key == "T")
            {
                if (validKeysAndCodes[key].Count==1)
                    continue;

                validKeysAndTitles.Add(key,LocalisationMang.translate("Text-to-speech"));

                nxtReadableOptions.AddRange(new string[] {LocalisationMang.translate("Off"),LocalisationMang.translate("On")});
                for(int k=2; k<validKeysAndCodes[key].Count; k++)
                {
                    nxtReadableOptions.Add("?");
                }
                validKeysAndReadableOptions.Add(key,nxtReadableOptions.ToArray());

            }
            else if((key == "A"))
            {
                if (validKeysAndCodes[key].Count==1)
                    continue;

                string title = LocalisationMang.translate("Accuracy");

                if(para_appID==ApplicationID.MAIL_SORTER){
                    title = LocalisationMang.translate("Packages");
                }else if(para_appID==ApplicationID.SERENADE_HERO){
                    title = LocalisationMang.translate("Alternatives");
                }else if(para_appID==ApplicationID.WHAK_A_MOLE){
                    title = LocalisationMang.translate("Distractors");
                }else if(para_appID==ApplicationID.MOVING_PATHWAYS){
                    title = LocalisationMang.translate("Number of paths");
                }else if(para_appID==ApplicationID.ENDLESS_RUNNER){
                    title = LocalisationMang.translate("Words per door");
                }

                validKeysAndTitles.Add(key,title);

                if(para_appID==ApplicationID.MAIL_SORTER){
                    for(int k=0; k<validKeysAndCodes[key].Count; k++)
                    {
                        nxtReadableOptions.Add(""+(validKeysAndCodes[key][k]+1));
                    }

                }else{

                    for(int k=0; k<validKeysAndCodes[key].Count; k++)
                    {
                        nxtReadableOptions.Add(""+validKeysAndCodes[key][k]);
                    }

                }
                validKeysAndReadableOptions.Add(key,nxtReadableOptions.ToArray());

            }else if(key == "S")
            {
                if (validKeysAndCodes[key].Count==1)
                    continue;

                string title = LocalisationMang.translate("Speed");

                if(para_appID==ApplicationID.MAIL_SORTER){
                    title = LocalisationMang.translate("Rotating speed");
                }else if(para_appID==ApplicationID.WHAK_A_MOLE){
                    title = LocalisationMang.translate("Monkey speed");
                }else if(para_appID==ApplicationID.MOVING_PATHWAYS){
                    title = LocalisationMang.translate("Square size");
                }else if(para_appID==ApplicationID.ENDLESS_RUNNER){
                    title = LocalisationMang.translate("Monkey speed");
                }else if(para_appID==ApplicationID.DROP_CHOPS){
                    title = LocalisationMang.translate("Split time");
                }else if(para_appID==ApplicationID.SERENADE_HERO){
                    title = LocalisationMang.translate("Speed");
                }else if(para_appID==ApplicationID.TRAIN_DISPATCHER){
                    title = LocalisationMang.translate("Attempts");
                }

                validKeysAndTitles.Add(key,title);

                if(para_appID==ApplicationID.DROP_CHOPS){//Invert the labels for solomon
                    for(int k=0; k<validKeysAndCodes[key].Count; k++)
                    {
                        nxtReadableOptions.Add(new string[]{LocalisationMang.translate("High"),LocalisationMang.translate("Medium"),LocalisationMang.translate("Low")}[validKeysAndCodes[key][k]]);
                    }

                }else{
                for(int k=0; k<validKeysAndCodes[key].Count; k++)
                {
                    nxtReadableOptions.Add(new string[]{LocalisationMang.translate("Low"),LocalisationMang.translate("Medium"),LocalisationMang.translate("High")}[validKeysAndCodes[key][k]]);
                }
                }
                validKeysAndReadableOptions.Add(key,nxtReadableOptions.ToArray());

            }else if(key == "M")
            {
                if (validKeysAndCodes[key].Count==1)
                    continue;

                string title = LocalisationMang.translate("Mode");

                validKeysAndTitles.Add(key,title);

                if(langCode==LanguageCode.EN){

                    if(para_langArea==6){
                        nxtReadableOptions.Add("Letter to letter");
                        nxtReadableOptions.Add("Letter to word");

                    }else if(para_langArea==3){
                        nxtReadableOptions.Add("Category");
                        nxtReadableOptions.Add("Count");

                    }else{

                        for(int k=0; k<validKeysAndCodes[key].Count; k++)
                        {
                            nxtReadableOptions.Add(""+validKeysAndCodes[key][k]);
                        }
                    }

                }else{

                    //if(para_appID==ApplicationID.MOVING_PATHWAYS){

                    nxtReadableOptions.Add(LocalisationMang.translate("Letter to letter"));
                    nxtReadableOptions.Add(LocalisationMang.translate("Letter to word"));

                    //}else{

                    //}
                }
                validKeysAndReadableOptions.Add(key,nxtReadableOptions.ToArray());

            }else if(key == "W")
            {

                validKeysAndTitles.Add(key,LocalisationMang.translate("Word difficulty"));

                if (validKeysAndCodes[key].Count==1){

                    List<int> options = new List<int>();
                    for(int k=0; k<3; k++)
                    {
                        nxtReadableOptions.Add(new string[]{LocalisationMang.translate("Easy"),LocalisationMang.translate("Medium"),LocalisationMang.translate("Hard")}[k]);
                        options.Add((k+1)*3);
                    }

                    validKeysAndCodes[key] = options;
                }else{
                    for(int k=0; k<validKeysAndCodes[key].Count; k++)
                    {
                        //Debug.Log(validKeysAndCodes[key][k]);
                        nxtReadableOptions.Add(new string[]{LocalisationMang.translate("Easy"),"","","",LocalisationMang.translate("Medium"),"","","","",LocalisationMang.translate("Hard")}[validKeysAndCodes[key][k]]);
                    }

                }
                validKeysAndReadableOptions.Add(key,nxtReadableOptions.ToArray());

            }else if(key == "B")
            {
                if (validKeysAndCodes[key].Count==1)
                    continue;

                string title = LocalisationMang.translate("Number of words");

                if(para_appID==ApplicationID.MAIL_SORTER){
                    title = LocalisationMang.translate("Number of rounds");
                }else if(para_appID==ApplicationID.MOVING_PATHWAYS){
                    title = LocalisationMang.translate("Words per difficulty");
                }

                validKeysAndTitles.Add(key,title);

                if (validKeysAndCodes[key].Count==1){

                    List<int> options = new List<int>();
                    for(int k=1; k<10; k++)
                    {
                        nxtReadableOptions.Add(""+k);
                        options.Add((k));
                    }

                    validKeysAndCodes[key] = options;

                }else{

                    if(para_appID==ApplicationID.MAIL_SORTER){
                        for(int k=0; k<validKeysAndCodes[key].Count; k++)
                        {
                            nxtReadableOptions.Add(""+validKeysAndCodes[key][k]/4);
                        }
                    }else{
                        for(int k=0; k<validKeysAndCodes[key].Count; k++)
                        {
                            nxtReadableOptions.Add(""+validKeysAndCodes[key][k]);
                        }
                    }

                }
                validKeysAndReadableOptions.Add(key,nxtReadableOptions.ToArray());

            }else if(key=="X"){

                if (validKeysAndCodes[key].Count==1)
                    continue;

                validKeysAndTitles.Add(key,LocalisationMang.translate("Tricky words"));
                for(int k=0; k<validKeysAndCodes[key].Count; k++)
                {
                    nxtReadableOptions.Add(new string[]{"0/4","1/4","2/4","3/4"}[validKeysAndCodes[key][k]]);
                }
                validKeysAndReadableOptions.Add(key,nxtReadableOptions.ToArray());

            }else if(key=="D"){
                if (validKeysAndCodes[key].Count==1)
                    continue;

                validKeysAndTitles.Add(key,LocalisationMang.translate("Distractors"));
                for(int k=0; k<validKeysAndCodes[key].Count; k++)
                {
                    nxtReadableOptions.Add(new string[]{"0/4","1/4","2/4","3/4"}[validKeysAndCodes[key][k]]);
                }
                validKeysAndReadableOptions.Add(key,nxtReadableOptions.ToArray());

            }

        }

        // Construct the AvailableOptions data structure.
        AvailableOptions avOps = null;
        Dictionary<string,OptionInfo> opInfoLookup = new Dictionary<string, OptionInfo>();

        foreach(KeyValuePair<string,string[]> pair in  validKeysAndReadableOptions)
        {
            if( ! opInfoLookup.ContainsKey(pair.Key))
            {
                OptionInfo nxtOpInf = new OptionInfo(pair.Key,validKeysAndCodes[pair.Key],validKeysAndReadableOptions[pair.Key],validKeysAndTitles[pair.Key]);
                opInfoLookup.Add(pair.Key,nxtOpInf);
            }
        }

        avOps = new AvailableOptions(new List<string>(validKeysAndReadableOptions.Keys),opInfoLookup);
        return avOps;
    }
    private void updateAvailableOptions()
    {
        ApplicationID reqAppIDToSearch = currAcID;

        // Warning. Cache usage should be invalidated if the language area and difficulty combo changes.
        if(optionsCache == null) { optionsCache = new Dictionary<ApplicationID, AvailableOptions>(); }
        if(optionsCache.ContainsKey(reqAppIDToSearch))
        {
            loadedOptions = optionsCache[reqAppIDToSearch];
        }
        else
        {
            loadedOptions = LocalisationMang.workOutOptionsForActivityAndLangArea(reqAppIDToSearch,langArea);
            optionsCache.Add(reqAppIDToSearch,loadedOptions);
        }

        selectorArr = new int[loadedOptions.validKeys.Count];
        for(int i=0; i<loadedOptions.validKeys.Count; i++)
        {
            selectorArr[i] = 0;
        }
    }
Example #24
0
 public ModuleOption AddSuboptionAndMoveDown(AvailableOptions code)
 {
     var suboption = new ModuleOption(code, this.Panel, this);
     this.Suboptions.Add(suboption);
     return suboption;
 }
Example #25
0
 public ModuleOption AddSuboptionAndMoveUp(AvailableOptions code)
 {
     this.Suboptions.Add(new ModuleOption(code, this.Panel, this));
     return this.Parent;
 }
Example #26
0
        public override void Enter(string text)
        {
            if (OldStyleSelect != null)
            {
                if (text == null)
                {
                    return;
                }

                if (OldStyleSelect != null)
                {
                    var id = OldStyleSelect.WrappedElement.GetAttribute("id");
                    if (string.IsNullOrWhiteSpace(id))
                    {
                        try
                        {
                            OldStyleSelect.SelectByText(text);
                            return;
                        }
                        catch { }

                        try
                        {
                            OldStyleSelect.SelectByText(text.ToUpper());
                            return;
                        }
                        catch { }

                        try
                        {
                            OldStyleSelect.SelectByText(ToCammelCase(text));
                            return;
                        }
                        catch { }

                        try
                        {
                            OldStyleSelect.SelectByText(text.ToLower());
                            return;
                        }
                        catch { }

                        try
                        {
                            OldStyleSelect.SelectByValue(text);
                            return;
                        }
                        catch { }

                        //Partial match ?
                        var l        = AvailableOptions.ToList();
                        var realText = l.Where(x => x.Text.ToLower().Contains(text.ToLower()));
                        if (realText.Count() == 1)
                        {
                            try
                            {
                                OldStyleSelect.SelectByIndex(l.IndexOf(realText.First()));
                                return;
                            }
                            catch { }
                        }
                    }
                    var key     = text.ToUpper();
                    var options = FindByExactMatch(id, key);

                    if (options.One())
                    {
                        OldStyleSelect.SelectByValue(options.First().GetAttribute("value"));
                        return;
                    }
                    if (options.Many())
                    {
                        if (options.One(x => x.Text.ToUpper() == text.ToUpper()))
                        {
                            OldStyleSelect.SelectByValue(options.First(x => x.Text.ToUpper() == text.ToUpper()).GetAttribute("value"));
                        }
                        else
                        {
                            OldStyleSelect.SelectByValue(options.First().GetAttribute("value"));
                        }
                        return;
                    }
                    options = FindByContains(id, key);

                    if (options.One())
                    {
                        OldStyleSelect.SelectByValue(options.First().GetAttribute("value"));
                        return;
                    }
                    if (options.Many())
                    {
                        if (options.One(x => x.Text.ToUpper().Contains(text.ToUpper())))
                        {
                            OldStyleSelect.SelectByValue(options.First(x => x.Text.ToUpper().Contains(text.ToUpper())).GetAttribute("value"));
                        }
                        else
                        {
                            OldStyleSelect.SelectByValue(options.First().GetAttribute("value"));
                        }
                        return;
                    }
                }
                throw new GherkinException($"Unable to find {text} in the selection, only found {OldStyleSelect.Options.LogFormat(x => x.Text)}");
            }
            else
            {
                var options = AvailableOptions.Where(o => string.Equals(o.GetAttribute("value"), text, ComparisonDefaults.StringComparison));
                if (options.One())
                {
                    WebElement.SendKeys(options.First().GetAttribute("value"));
                }
                else if (options.Many())
                {
                    throw new GherkinException("too many matches"); //TODO: cleanup
                }
                else
                {
                    throw new GherkinException("no matches");
                }
            }
        }