public IPluginOptionViewModel Construct(IOption option) { if (option is IListOption) { var optionType = option.GetType().FindBaseType(typeof(ListOption <>)); if (optionType != null) { var tValue = optionType.GetGenericArguments().First(); var generic = _constructListOptionMethodInfo.MakeGenericMethod(tValue); var opt = generic.Invoke(this, new object?[] { option }); if (opt != null) { return((IPluginOptionViewModel)opt); } } } return(option switch { BooleanOption bOption => new PluginBooleanOptionViewModel(bOption, _localizationProvider), NumberOption nOption => new PluginNumberOptionViewModel(nOption, _localizationProvider), TextOption tOption => new PluginTextOptionViewModel(tOption, _localizationProvider), CommandOption cOption => new PluginCommandOptionViewModel(cOption, _localizationProvider), EncryptedTextOption eOption => new PluginEncryptedTextOptionViewModel(eOption, _localizationProvider), StringCollectionOption sOption => new PluginStringCollectionOptionViewModel(sOption, _localizationProvider), DisplayOption dOption => new PluginDisplayOptionViewModel(dOption, _localizationProvider), _ => ConstructDisplayOption(option) });
public IEnumerator Typing(TextOption opt) { GameObject node1 = Instantiate(incomimng, parent.transform); PhoneTextMaker maker1 = node1.GetComponent <PhoneTextMaker>(); RectTransform rect1 = node1.GetComponent <RectTransform>(); maker1.CalculateSpaceNeeded(". . ."); rect1.localPosition = new Vector3(rect1.localPosition.x, -totalHeight - (maker1.heightDetermined * 0.5f), rect1.localPosition.z); totalHeight += maker1.heightDetermined + heightBuffer; yield return(new WaitForSeconds(1.5f)); totalHeight -= maker1.heightDetermined + heightBuffer; Destroy(node1); GameObject node2 = Instantiate(incomimng, parent.transform); PhoneTextMaker maker2 = node2.GetComponent <PhoneTextMaker>(); RectTransform rect2 = node2.GetComponent <RectTransform>(); TextDialogueManager t = GameObject.Find("SceneManager").GetComponent <TextDialogueManager>(); maker2.CalculateSpaceNeeded(t.nodes[opt.nodeID].text); rect2.localPosition = new Vector3(rect2.localPosition.x, -totalHeight - (maker2.heightDetermined * 0.5f), rect2.localPosition.z); totalHeight += maker2.heightDetermined + heightBuffer; MakeThoughts(t.nodes[opt.nodeID].options); }
private void SaveScreen() { if (_currentScreen == null || _loadingScreen) { return; } lblSaveSuccess.Visibility = Visibility.Collapsed; saveTimer.Stop(); saveCounter = 0; var screen = Screens.Single(x => x.Id == _currentScreen.Id); screen.InternalName = txtScreenName.Text; screen.ScreenIntroMessage = txtScreenIntro.Text; if (_currentOption != null) { var option = screen.Options.Single(x => x.Id == _currentOption.Id); option.Text = txtOptionText.Text; if (ddlOptionConditionType.SelectedItem != null) { var selectedConditionType = ddlOptionConditionType.SelectedItem as ComboBoxItem; var typeId = Convert.ToInt32(selectedConditionType.Tag); if (typeId > 0) { option.ShowCondition.Type = (ConditionType)typeId; option.ShowCondition.Parameter = txtOptionConditionValue.Text; } } if (_currentAction != null) { var action = _currentOption.Actions.SingleOrDefault(x => x.Id == _currentAction.Id); if (ddlActionTypes.SelectedItem != null && action != null) { var selectedActionType = ddlActionTypes.SelectedItem as ComboBoxItem; var typeId = Convert.ToInt32(selectedActionType.Tag); if (typeId > 0) { action.Type = (ActionType)typeId; action.Parameter = txtActionParameter.Text; } } _currentAction = action; } _currentOption = option; } _currentScreen = screen; lblSaveSuccess.Visibility = Visibility.Visible; saveTimer.Start(); UpdateNames(); }
public void Bot_TextboxCreated(TextOption option) { Dispatcher.InvokeAsync(delegate { OptionsButton.Visibility = Visibility.Visible; _textOptions.Add(option); TextOptions.Items.Refresh(); }); }
public void addTextOption(string language, string name, string text) { Language langToUpdate = langs.Find(lang => lang.language == language); if (langToUpdate != null) { TextOption textValue = new TextOption(); textValue.key = name; textValue.val = text; langToUpdate.textValues.Add(textValue); } }
private static void AddLabel(TextOption options, string key, string culture, IList <string> result) { var label = options.Items.Where(r => r.Value == key) .Select(r => r.Name) .Where(r => r.ContainsKey(culture.ToString())) .Select(r => r[culture.ToString()]) .FirstOrDefault(); if (label != null) { result.Add(label); } }
public void CreateText(int index, string content, bool isName) { if (isName) { TextOptions[index] = new TextOption(content, "Custom text option " + index + " for use in scripts.", ""); } else { TextOptions[index] = new TextOption("Text " + index + ": ", content, ""); } TextboxCreated?.Invoke(TextOptions[index]); }
public Boolean MatchesComposition(CartItem ci) { if (ci.ProductID != ProductID || VariantID != ci.VariantID) { return(false); } if (CustomerEntersPrice || ci.CustomerEntersPrice) { return(false); } if (!ChosenColor.Equals(ci.ChosenColor)) { return(false); } if (!ChosenSize.Equals(ci.ChosenSize)) { return(false); } if (!TextOption.Equals(ci.TextOption)) { return(false); } if (ShippingAddressID != ci.ShippingAddressID) { return(false); } if ((IsAKit || ci.IsAKit) && !KitComposition.Matches(ci.KitComposition)) { return(false); } if (Price != ci.Price) { return(false); } if (CartType != ci.CartType) { return(false); } return(true); }
public void Bot_TextboxRemoved(TextOption option) { Dispatcher.InvokeAsync(delegate { if (_textOptions.Count == 1 && _sliderOptions.Count == 0) { OptionsButton.Content = "Show Options"; OptionsButton.Visibility = Visibility.Collapsed; OptionSliders.Visibility = Visibility.Collapsed; TextOptions.Visibility = Visibility.Collapsed; } _textOptions.Remove(option); TextOptions.Items.Refresh(); }); }
private void BtnDeleteOption_Click(object sender, RoutedEventArgs e) { if (_currentScreen == null || _currentOption == null || listOptions.SelectedItem == null || !_currentScreen.Options.Any()) { return; } _currentScreen.Options.RemoveAll(x => x.Id == _currentOption.Id); listOptions.Items.Remove(listOptions.SelectedItem); _currentOption = null; _currentAction = null; ClearOption(); RenumberScreens(); }
public GameObject AddOption(string text, GameObject parent, int destinationIndex = -1) { ////add destination node to list if it doesn't already exist -- was messing up due to the parent node being added after the options were added //if (!nodes.Contains(parent)) // nodes.Add(parent); GameObject option = Instantiate(optionPrefab, GameObject.Find("Canvas").transform); TextOption opt = option.GetComponent <TextOption>(); //create an option object if (destinationIndex != -1) { opt.text = text; opt.nodeID = destinationIndex; //opt.resultNode = nodes[opt.nodeID]; } return(option); }
public void ShowOptions(List <Choice> choices) { int index = 0; existingOptions = new List <TextOption>(); foreach (Choice choice in choices) { TextOption option = Instantiate <TextOption>(optionPrefab); float offset = (choices.Count - index) * option.text.rectTransform.rect.size.y; option.text.rectTransform.parent = text.rectTransform.parent; option.text.rectTransform.position = new Vector2(text.rectTransform.position.x, text.rectTransform.rect.yMax + offset); option.UseChoice(choice); option.SetSelected(index == 0); existingOptions.Add(option); ++index; } }
private static string GetValue(string key, CultureInfo culture, TextOption options) { if (key == null) { return(null); } var option = options?.Items.FirstOrDefault(x => x.Value == key); if (option == null) { return(key); } string translation; if (option.Name.TryGetValue(culture?.Name ?? CultureInfo.CurrentCulture.Name, out translation)) { return(translation); } return(key); }
public void SettingValueShouldOnlySucceedWhenValueIsInRange(string value, int minLength, int maxLength, bool inRange) { // Arrange var sut = new TextOption(string.Empty, string.Empty, string.Empty) { MaximumLength = maxLength, MinimumLength = minLength }; // Act sut.Value = value; // Assert if (inRange) { Assert.Equal(value, sut.Value); } else { Assert.NotEqual(value, sut.Value); } }
private void NewOption() { if (_currentScreen == null) { return; } var newOption = new TextOption(); newOption.Id = 1; if (_currentScreen.Options.Any()) { newOption.Id = _currentScreen.Options.Max(x => x.Id) + 1; } newOption.ShowCondition.Type = ConditionType.None; ddlOptionConditionType.SelectedItem = ddlOptionConditionType.Items[0]; _currentScreen.Options.Add(newOption); _currentOption = newOption; var newOptionListItem = new ListBoxItem { Tag = newOption.Id, Content = "Option - " + newOption.Id }; listOptions.Items.Add(newOptionListItem); foreach (ListBoxItem item in listOptions.Items) { var tag = (int)item.Tag; if (tag == newOption.Id) { listOptions.SelectedItem = item; } } LoadSelectedOption(); NewAction(); }
public MainMenu(GraphicsDevice Graphics, ContentManager Content) { graphics = Graphics; this.Content = Content; TextOption startOption = new TextOption { Texture = Content.Load<Texture2D>("start") }; TextOption howToOption = new TextOption { Texture = Content.Load<Texture2D>("howto") }; TextOption quitOption = new TextOption { Texture = Content.Load<Texture2D>("quit") }; startOption.Focused += option_Focused; howToOption.Focused += option_Focused; quitOption.Focused += option_Focused; startOption.Toggled += startOption_Toggled; howToOption.Toggled += howToOption_Toggled; quitOption.Toggled += quitOption_Toggled; textMenu = new Menu<TextOption>(MenuItemPlacement.Vertical, 50, new Dimensions(startOption.Texture.Width, startOption.Texture.Height)); textMenu.Position = new Vector2(graphics.PresentationParameters.BackBufferWidth - textMenu.ItemBounds.Width, graphics.PresentationParameters.BackBufferHeight); textMenu.Opacity = 0f; textMenu.AddItem(startOption); textMenu.AddItem(howToOption); textMenu.AddItem(quitOption); TransitionIn(); }
public TfsConfiguration(IDispatcher uiDispatcher, ConfigurationFlags flags = ConfigurationFlags.None) : base(uiDispatcher) { Localizer = new TfsLocalizer(); _url = new TextOption(string.Empty, TextIds.UrlName, TextIds.UrlDescription); _collectionName = new TextOption(string.Empty, TextIds.CollectionNameName, TextIds.CollectionNameDescription); _project = new ProjectOption(); _repository = new RepositoryOption(); _authenticationType = new EnumOption <AuthenticationType>(AuthenticationType.Windows, TextIds.AuthenticationTypeName, TextIds.AuthenticationTypeDescription); _userName = new TextOption(string.Empty, TextIds.UserNameName, TextIds.UserNameDescription); _password = new EncryptedTextOption(string.Empty, TextIds.PasswordName, TextIds.PasswordDescription); _token = new EncryptedTextOption(string.Empty, TextIds.TokenName, TextIds.TokenDescription); UpdateAuthenticationFieldsVisibility(_authenticationType.Value); _authenticationType.ValueChanged += AuthenticationType_ValueChanged; if (flags.HasFlag(ConfigurationFlags.HideRepository)) { _repository.IsVisible = false; } var projectValueCalculator = CreateCalculator(FetchProjectsAsync, OnProjectsFetched); projectValueCalculator.Attach(_url, _collectionName); projectValueCalculator.Attach(_authenticationType, _token, _password, _userName); projectValueCalculator.Affect(_project); if (!flags.HasFlag(ConfigurationFlags.HideRepository)) { var repositoryValueCalculator = CreateCalculator(FetchRepositoriesAsync, OnRepositoriesFetched); repositoryValueCalculator.Attach(_url, _collectionName); repositoryValueCalculator.Attach(_project); repositoryValueCalculator.Attach(_authenticationType, _token, _password, _userName); repositoryValueCalculator.Affect(_repository); } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(null); } var result = new List <TextOption>(); var i = 0; while (reader.Read()) { if (reader.TokenType == JsonToken.EndArray) { break; } TextOption option; if (reader.TokenType == JsonToken.StartObject) { option = serializer.Deserialize <TextOption>(reader); } else { option = new TextOption { Name = reader.Value.ToString(), Value = i }; i++; } option.Name = option.Name?.RemoveLanguageLookup().Split('.').LastOrDefault(); result.Add(option); } return(result.Any() ? result.ToArray() : null); }
private void LoadSelectedOption() { if (listOptions.SelectedItem == null || _currentScreen == null) { _currentOption = null; return; } _loadingScreen = true; ClearOption(); var selectedOption = listOptions.SelectedItem as ListBoxItem; var optionId = Convert.ToInt32(selectedOption.Tag); if (optionId == -1) { return; } var option = _currentScreen.Options.Single(x => x.Id == optionId); _currentOption = option; txtOptionText.Text = option.Text; if (option.ShowCondition != null) { var conditionType = (int)option.ShowCondition.Type; if (conditionType != 0) { ddlOptionConditionType.SelectedItem = (from ComboBoxItem item in ddlOptionConditionType.Items where item.Tag.ToString() == conditionType.ToString() select item) .First(); txtOptionConditionValue.Text = Convert.ToString(option.ShowCondition.Parameter); } } else { ddlOptionConditionType.SelectedItem = null; txtOptionConditionValue.Text = ""; } //Load Actions ddlActions.Items.Clear(); foreach (var a in option.Actions) { ddlActions.Items.Add(new ComboBoxItem { Tag = a.Id, Content = "Action - " + a.Id }); } if (option.Actions.Any()) { ddlActions.SelectedItem = ddlActions.Items[0]; LoadSelectedAction(); } _loadingScreen = false; }
public void CreateText(int index, string content) { TextOptions[index] = new TextOption("Text " + index + ": ", "Custom text option " + index + " for use in scripts.", content); TextboxCreated?.Invoke(TextOptions[index]); }
public static IEnumerable <string> GetTextOptionValues(TextOption options, IList <string> values, CultureInfo cultureInfo) { return(values.Select(value => GetTextOptionValue(options, value, cultureInfo))); }
public static string GetTextOptionValue(TextOption options, string value, CultureInfo cultureInfo) { var option = options?.Items?.FirstOrDefault(x => x.Value == value); return(option != null && option.Name.TryGetValue(cultureInfo.Name, out var translation) ? translation : value.ToString(cultureInfo)); }
public SearchComponentPage(Assembly assembly, ComponentTypeEnumeration type, IEnumerable <Firm> firms, IEnumerable <Lookup> lookups, GetUnitVM unitModel) { InitializeComponent(); Assembly = assembly; ComponentTypeEnumeration = type; Search.Text = $"Search {type.GetDescription()}"; Search.Clicked += Search_Clicked; foreach (var unit in unitModel.Units) { switch (unit.UnitType) { case UnitType.CheckboxGroup: var checkboxGroupOption = new CheckboxGroupOption(unit); UnitList.Children.Add(checkboxGroupOption); break; case UnitType.RadiobuttonGroup: var radioButtonOption = new RadiobuttonGroupOption(unit); UnitList.Children.Add(radioButtonOption); break; case UnitType.Range: var rangeOption = new RangeOption(unit); UnitList.Children.Add(rangeOption); break; case UnitType.Text: foreach (var option in unit.Options) { var textInput = new TextOption(unit, option); UnitList.Children.Add(textInput); } break; default: break; } } var firmUnit = new Unit { Name = "Firms", Key = "firms", UnitType = UnitType.CheckboxGroup, Options = firms.Select(x => new Option { Key = "firms", Text = $"{x.Name} ({x.Country})", Value = x.Id }) }; var firmsOption = new CheckboxGroupOption(firmUnit); UnitList.Children.Add(firmsOption); foreach (var lookup in lookups) { var lookupUnit = new Unit { Name = lookup.Name, Key = lookup.Key, UnitType = UnitType.CheckboxGroup, Options = lookup.LookupValues.Select(x => new Option { Key = lookup.Key, Text = x.DisplayText, Value = x.Id }) }; var lookupOption = new CheckboxGroupOption(lookupUnit); UnitList.Children.Add(lookupOption); } }
private void AddOptionsToTextOptionField(TextOptionImportPageViewModel textOptionImportPageViewModel, FieldDefinition textOptionField, TextOption option, KeyValuePair <string, List <KeyValuePair <string, string> > > textOption) { if (option != null && option.Items.FirstOrDefault(x => x.Value == textOption.Key) == null) { this.Log().Info($"Adding Text Option: {textOption.Key}/{textOption.Value.FirstOrDefault().Value} to Field: {textOptionField.Id} in Area: {textOptionImportPageViewModel.Area}"); if (textOption.Value.FirstOrDefault().Key == Value) { option.Items.Add(new TextOption.Item { Value = textOption.Key, Name = new Dictionary <string, string> { { "en-US", textOption.Value.FirstOrDefault().Value }, { "sv-SE", textOption.Value.FirstOrDefault().Value } } }); } else { option.Items.Add(new TextOption.Item { Value = textOption.Key, Name = textOption.Value.ToDictionary(x => x.Key, x => x.Value) }); } } }
public Configuration() { Url = new TextOption("https://localhost:44311/", "Url", string.Empty); }
public PluginTextOptionViewModel(TextOption valueOption, ILocalizationProvider localizationProvider) : base(valueOption.Value, valueOption.NameTextId) { _pluginOptionViewModelImplementation = new PluginOptionViewModelImplementation <string?>(valueOption, localizationProvider, this); }