Exemplo n.º 1
0
        public SelectableLabel(SpriteFont font, string[] options, Vector2 location, Justification justification, LabelType type, float parameter = 0.0f, Stroke stroke = null)
        {
            _font               = font;
            _lastLocation       = location;
            _inputJustification = justification;
            _inputType          = type;
            _inputParameter     = parameter;
            _inputStroke        = stroke;
            GenerateStrokeOffsets();
            Options.AddRange(options);
            for (int i = 0; i < Options.Count; i++)
            {
                Text += Options[i];
                if (i < (Options.Count - 1))
                {
                    Text += " " + separator + " ";
                }
            }
            Update(location, InactiveColor, justification, type, parameter);

            string temp = "";

            optionOffset.Add(new Vector2(0f, 0f));
            for (int i = 0; i < Options.Count - 1; i++)
            {
                temp += Options[i] + " " + separator + " ";
                var size = Util.MeasureString(_font, temp);
                optionOffset.Add(new Vector2(size.X * _scale, 0f));
            }
        }
Exemplo n.º 2
0
        public override void CreateElements()
        {
            base.CreateElements();

            Options.AddRange(_options.Select(ElementFactory.CreateOption));

            foreach (var option in Options)
            {
                option.CreateElements();
            }
        }
 public override bool CanAssist(RichCommandLineContext context)
 {
     if (TargetArgument != null && TargetArgument.ArgumentType.IsEnum)
     {
         Options.Clear();
         Options.AddRange(Enum.GetNames(TargetArgument.ArgumentType).Select(name => ContextAssistSearchResult.FromString(name)));
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public override bool CanAssist(RichCommandLineContext context)
 {
     if (context.CurrentTokenIndex == 0 && Definition.Actions.Count > 0)
     {
         Options.Clear();
         Options.AddRange(Definition.Actions.Select(a => ContextAssistSearchResult.FromString(a.DefaultAlias)));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 5
0
 internal PopUpInputIndex(string caption, string message, IEnumerable <TItems> options, int?defaultIndex) : base(caption, message)
 {
     Draft = defaultIndex ?? -1;
     Options.AddRange(options.Select(_ => _?.ToString() ?? "--"));
 }
Exemplo n.º 6
0
 public StatePickerAssistant()
 {
     Options.AddRange(States.Select(s => ContextAssistSearchResult.FromString(s)));
 }
Exemplo n.º 7
0
 public SettingOption(string title, string[] options)
 {
     Title = title;
     Options.AddRange(options);
     InitializeOptionObj();
 }
Exemplo n.º 8
0
 public void AddOptions(params object[] options)
 {
     Options.AddRange(options);
 }
Exemplo n.º 9
0
        public override void ProcessOptions(string[] values)
        {
            var id = 0;

            switch (_selectedOption)
            {
            case AirlineOptions.ShowAllFlights:
                CurrentAirlineObjects = AirlineObjects.Where(arg => (arg as Flight) != null).ToList();
                if (CurrentAirlineObjects.Count > 0)
                {
                    Options.Clear();
                    Options.AddRange(s_edit);
                    Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                }
                break;

            case AirlineOptions.ShowArrivals:
                CurrentAirlineObjects = AirlineObjects.Where(arg => (arg as Flight) != null && ((Flight)arg).Type == FlightType.Arrival).ToList();
                if (CurrentAirlineObjects.Count > 0)
                {
                    Options.Clear();
                    Options.AddRange(s_edit);
                    Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                }
                break;

            case AirlineOptions.ShowDepartues:
                CurrentAirlineObjects = AirlineObjects.Where(arg => (arg as Flight) != null && ((Flight)arg).Type == FlightType.Departure).ToList();
                if (CurrentAirlineObjects.Count > 0)
                {
                    Options.Clear();
                    Options.AddRange(s_edit);
                    Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                }
                break;

            case AirlineOptions.SearchFlights:
                if (values.Length > 0)
                {
                    Find(values);
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.AddAFlight:
                if (values.Length > 0)
                {
                    if (Add(values))
                    {
                        OnDisplayInfoChanged(new AirlineObjectEventArgs {
                            DisplayInfo = "The Flight has been added successfully", ConsoleColor = ConsoleColor.Green
                        });
                    }
                    else
                    {
                        OnDisplayInfoChanged(new AirlineObjectEventArgs {
                            DisplayInfo = "The Flight wasn't added", ConsoleColor = ConsoleColor.Red, HasError = true
                        });
                    }
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                CurrentAirlineObjects = AirlineObjects;
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.EditTheFlight:
                if (values.Length > 0)
                {
                    if (Edit(values))
                    {
                        OnDisplayInfoChanged(new AirlineObjectEventArgs {
                            DisplayInfo = "The Flight has been edited successfully", ConsoleColor = ConsoleColor.Green
                        });
                    }
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                CurrentAirlineObjects = AirlineObjects;
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.EditPassangersOfTheFlight:
                if (values.Length > 0)
                {
                    var optionsArray = values[0].Split(' ');
                    if ((optionsArray.Length == 3) && (int.TryParse(optionsArray[2], out id)) && (id > 0) && (id < CurrentAirlineObjects.Count + 1))
                    {
                        var flight = CurrentAirlineObjects[id - 1] as Flight;
                        if (flight != null)
                        {
                            IndexOfCurrentAirlineManager = id - 1;
                            CurrentAirlineManager        = flight;
                        }
                    }
                }
                CurrentAirlineObjects = null;
                Options = new List <AirlineOptions>();
                Options.AddRange(s_general);
                break;

            case AirlineOptions.DeleteTheFlight:
                if (values.Length > 0)
                {
                    var optionsArray = values[0].Split(' ');
                    if ((optionsArray.Length == 3) && (int.TryParse(optionsArray[2], out id)) && (id > 0) && (id < CurrentAirlineObjects.Count + 1))
                    {
                        if (Delete(CurrentAirlineObjects[id - 1]))
                        {
                            CurrentAirlineObjects = AirlineObjects;
                            OnDisplayInfoChanged(new AirlineObjectEventArgs {
                                DisplayInfo = "Removed Successfully"
                            });
                        }
                    }
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.ClearTheConsole:
                OnDisplayInfoChanged(new AirlineObjectEventArgs {
                    ClearConsole = true
                });
                CurrentAirlineObjects = null;
                Options = new List <AirlineOptions>();
                Options.AddRange(s_general);
                break;

            case AirlineOptions.Info:
                OnDisplayInfoChanged(new AirlineObjectEventArgs
                {
                    ConsoleColor = ConsoleColor.Yellow,
                    DisplayInfo  = "You are inside Airport manager where you can work with flights and it's info, " +
                                   "if you would like to receive an information about passanger and edit it, please go to 'Edit passangers of the flight'.\n" +
                                   "In case if you need to exit from Application, just chose 'Exit or level up' menu item"
                });
                CurrentAirlineObjects = null;
                Options = new List <AirlineOptions>();
                Options.AddRange(s_general);
                break;

            case AirlineOptions.LoadFromFile:
                if (values.Length > 0)
                {
                    try
                    {
                        if (OpenFromFile(values[0]))
                        {
                            OnDisplayInfoChanged(new AirlineObjectEventArgs {
                                DisplayInfo = "Loaded successfully", ConsoleColor = ConsoleColor.Green
                            });
                            CurrentAirlineObjects = AirlineObjects;
                        }
                        else
                        {
                            OnDisplayInfoChanged(new AirlineObjectEventArgs {
                                DisplayInfo = "Can't load from file", ConsoleColor = ConsoleColor.Red, HasError = true
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        OnDisplayInfoChanged(new AirlineObjectEventArgs {
                            DisplayInfo = $"Couldn't load data from file because of: {ex.Message}", ConsoleColor = ConsoleColor.Red, HasError = true
                        });
                    }
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                break;

            case AirlineOptions.SaveToFile:
                if (values.Length > 0)
                {
                    try
                    {
                        if (SaveToFile(values[0]))
                        {
                            OnDisplayInfoChanged(new AirlineObjectEventArgs {
                                DisplayInfo = "Saved successfully", ConsoleColor = ConsoleColor.Green
                            });
                        }
                        else
                        {
                            OnDisplayInfoChanged(new AirlineObjectEventArgs {
                                DisplayInfo = "Can't save to file", ConsoleColor = ConsoleColor.Red, HasError = true
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        OnDisplayInfoChanged(new AirlineObjectEventArgs {
                            DisplayInfo = $"Couldn't save data to file because of: {ex.Message}", ConsoleColor = ConsoleColor.Red, HasError = true
                        });
                    }
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                break;

            case AirlineOptions.ExitOrLevelUp:
                CurrentAirlineManager = null;
                CurrentAirlineObjects = null;
                Options = new List <AirlineOptions>();
                Options.AddRange(s_general);
                Reset();
                break;
            }
        }
Exemplo n.º 10
0
 public TestOptProv(params Option[] optionTestValues)
 {
     Options = new Options();
     Options.AddRange(optionTestValues);
 }
        public EmployerFeatureAuthorisationHandlerTestsFixture SetOption()
        {
            Options.AddRange(new[] { "ProviderRelationships" });

            return(this);
        }
Exemplo n.º 12
0
        public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (context.TryAddContext <SelectBoxContext, SelectBoxTagHelper>(out SelectBoxContext selectBoxContext) &&
                context.TryAddContext <TextBoxContext, TextBoxTagHelper>(out TextBoxContext textBoxContext))
            {
                await output.GetChildContentAsync();

                if (Options.IsNotNull())
                {
                    Options.AddRange(selectBoxContext.Options);
                }
                else
                {
                    Options = selectBoxContext.Options;
                }

                if (Options.Any())
                {
                    Options = Options.OrderBy(t => t.Order).ToList();

                    var select = new TagBuilder("select");

                    select.Attributes.Add("id", Id);
                    select.Attributes.Add("name", Field);
                    select.Attributes.Add("class", InputClasses);

                    if (IsDisabled)
                    {
                        select.Attributes.Add("disabled", "disabled");
                    }

                    if (Rows > 0)
                    {
                        select.Attributes.Add("multiple", "multiple");
                        select.Attributes.Add("size", Rows.ToString());
                    }

                    if (!IsPlaceHolderDestroyed && Rows <= 0)
                    {
                        select.InnerHtml.AppendHtml($"<option value=''>{PlaceholderValue}</option>");
                    }

                    var sections = Options.Where(t => !String.IsNullOrWhiteSpace(t.Section)).Select(t => t.Section).Distinct();

                    if (sections.Any())
                    {
                        foreach (var section in sections)
                        {
                            var optgroup = new TagBuilder("optgroup");

                            optgroup.Attributes.Add("label", section);

                            foreach (var option in Options.Where(t => t.Section == section))
                            {
                                optgroup.InnerHtml.AppendHtml($"<option value='{option.Value}'>{option.Name}</option>");
                            }

                            select.InnerHtml.AppendHtml(optgroup);
                        }
                    }
                    else
                    {
                        foreach (var option in Options)
                        {
                            select.InnerHtml.AppendHtml($"<option value='{option.Value}'>{option.Name}</option>");
                        }
                    }

                    var inputGroup = BuildInputContainer(select, textBoxContext);

                    if (String.IsNullOrWhiteSpace(Name))
                    {
                        output.TransformOutput(inputGroup);
                    }
                    else
                    {
                        base.OutputFormGroup(output, inputGroup);
                    }

                    return;
                }
            }

            output.SuppressOutput();
        }
Exemplo n.º 13
0
        public override void ProcessOptions(string[] values)
        {
            var id = 0;

            switch (_selectedOption)
            {
            case AirlineOptions.ShowPassangers:
                CurrentAirlineObjects = AirlineObjects.Where(arg => (arg as Passenger) != null).ToList();
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.SearchPassangers:
                if (values.Length > 0)
                {
                    Find(values);
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.AddAPassanger:
                if (values.Length > 0)
                {
                    if (Add(values))
                    {
                        OnDisplayInfoChanged(new AirlineObjectEventArgs {
                            DisplayInfo = "The Passanger has been added successfully", ConsoleColor = ConsoleColor.Green
                        });
                    }
                    else
                    {
                        OnDisplayInfoChanged(new AirlineObjectEventArgs {
                            DisplayInfo = "The Passanger wasn't added", ConsoleColor = ConsoleColor.Red, HasError = true
                        });
                    }
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                CurrentAirlineObjects = AirlineObjects;
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.EditThePassanger:
                if (values.Length > 0)
                {
                    if (Edit(values))
                    {
                        OnDisplayInfoChanged(new AirlineObjectEventArgs {
                            DisplayInfo = "The Passanger has been edited successfully", ConsoleColor = ConsoleColor.Green
                        });
                    }
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                CurrentAirlineObjects = AirlineObjects;
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.DeleteThePassanger:
                if (values.Length > 0)
                {
                    var optionsArray = values[0].Split(' ');
                    if ((optionsArray.Length == 3) && (int.TryParse(optionsArray[2], out id)) && (id > 0) && (id < CurrentAirlineObjects.Count + 1))
                    {
                        if (Delete(CurrentAirlineObjects[id - 1]))
                        {
                            CurrentAirlineObjects = AirlineObjects;
                            OnDisplayInfoChanged(new AirlineObjectEventArgs {
                                DisplayInfo = "Removed Successfully"
                            });
                        }
                    }
                }
                else
                {
                    OnDisplayInfoChanged(new AirlineObjectEventArgs {
                        DisplayInfo = "Empty values provided", ConsoleColor = ConsoleColor.Red, HasError = true
                    });
                }
                Options.Clear();
                Options.AddRange(s_edit);
                Options.AddRange(s_general.Where(arg => Options.IndexOf(arg) < 0));
                break;

            case AirlineOptions.ClearTheConsole:
                OnDisplayInfoChanged(new AirlineObjectEventArgs {
                    ClearConsole = true
                });
                CurrentAirlineObjects = null;
                Options = new List <AirlineOptions>();
                Options.AddRange(s_general);
                break;

            case AirlineOptions.Info:
                OnDisplayInfoChanged(new AirlineObjectEventArgs
                {
                    ConsoleColor = ConsoleColor.Yellow,
                    DisplayInfo  = "You are inside flight where you can work with passangers and it's info, \n" +
                                   "In case if you need to go back to Airline manager, just chose 'Exit or level up' menu item"
                });
                CurrentAirlineObjects = null;
                Options = new List <AirlineOptions>();
                Options.AddRange(s_general);
                break;

            case AirlineOptions.ExitOrLevelUp:
                CurrentAirlineManager = null;
                CurrentAirlineObjects = null;
                Options = new List <AirlineOptions>();
                Options.AddRange(s_general);
                Reset();
                break;
            }
        }
Exemplo n.º 14
0
 public SettingsManager(IEnumerable <Option> options, String propertiesFilePath)
 {
     _optionsAll.AddRange(options);
 }