public void AddOption(string name, System.Action <int> onSelected, System.Action <int> onDeleted = null) { if (doCache) { cachedData.Add(() => { AddOption(name, onSelected, onDeleted); }); return; } DropDownOption option = addOption(name); option.SublistArrow.enabled = false; int index = options.IndexOf(option); option.Option.onClick.AddListener(() => { Contract(); onSelected(index); }); if (onDeleted != null) { option.Delete.onClick.AddListener(() => { onDeleted(index); }); } else { option.Delete.gameObject.SetActive(false); } }
public ButtonView AddOption(string name, Action action, object related = null) { if (this.LastItemSelected == -1) { if (string.IsNullOrEmpty(this.Label)) { ((ButtonView)FindFirstChildByName("button")).Text = name; } this.LastItemSelected.Value = this.DropDownOptions.Count; } var dropDownOption = new DropDownOption() { Text = name, OnClicked = action, Related = related }; DropDownOptions.Add(dropDownOption); var dropButton = new ButtonView(this.ParentGeeUI, DropDownListView, name, Vector2.Zero); dropButton.OnMouseClick += (sender, args) => { OnOptionSelected(dropDownOption); }; return(dropButton); }
public void InitDropDownUI(Dictionary <baseGroceryItemSO.CATEGORY, List <baseGroceryItemSO> > grocerieList) { //panelImage.color = panelDefaultColor; SetPanelActive(true); HomeUI.Instance.startingPage = App_Scenes.Search; HomeUI.Instance.currentPage = App_Scenes.Search; HomeUI.Instance.HomeObject.SetActive(false); //check how many categories i have first //check how many items in each category //start initialising //each category must intialise also foreach (KeyValuePair <baseGroceryItemSO.CATEGORY, List <baseGroceryItemSO> > entry in grocerieList) { GameObject dropDownPrefab = Instantiate(m_DropDownPrefab, m_DropDownParent); DropDownOption dropDownOption = dropDownPrefab.GetComponent <DropDownOption>(); if (dropDownOption == null) { continue; } dropDownOption.Init(entry.Key); foreach (baseGroceryItemSO grocery in entry.Value) { dropDownOption.AddContentToPanel(Instantiate(m_DropDownContentPrefab), grocery.GetEnumID()); } } }
public static List <DropDownOption> GetDocuments() { List <DropDownOption> documents = new List <DropDownOption>(); DataSet dataSet = new DataSet(); using (SqlConnection conn = new SqlConnection(@"Data Source=PGHLT0407\SQLEXPRESS;Initial Catalog=EmployeePortal;Integrated Security=SSPI")) { try { SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("SELECT Code, Value FROM tbl_Document", conn); sqlDataAdapter.Fill(dataSet); } catch (Exception ex) { throw ex; } if (dataSet != null && dataSet.Tables[0] != null) { foreach (DataRow row in dataSet.Tables[0].Rows) { DropDownOption document = new DropDownOption { Code = Convert.ToInt32(row["Code"].ToString()), Value = row["Value"].ToString() }; documents.Add(document); } } } return(documents); }
DropDownOption addOption(string name) { DropDownOption newOption = null; if (refresh) { if (refreshOptionIndex < options.Count) { newOption = options[refreshOptionIndex]; newOption.Option.onClick.RemoveAllListeners(); newOption.Delete.gameObject.SetActive(true); newOption.Delete.onClick.RemoveAllListeners(); } } refreshOptionIndex++; if (newOption == null) { newOption = Instantiate <DropDownOption>(optionTemplate); newOption.gameObject.SetActive(true); RectTransform r = newOption.GetComponent <RectTransform>(); r.SetParent(content, false); options.Add(newOption); subLists.Add(null); } newOption.Text.text = name; return(newOption); }
public List <DropDownOption> CalcSelectDDSizeAndTilesPerBoxAll() { var options = new List <DropDownOption>(); try { using (IDbConnection connection = connectionFactory.Create(connectionString)) { using (IDbCommand command = connection.CreateCommand()) { command.CommandText = "CalcSelectDDSizeAndTilesPerBoxAll"; command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = 30; connection.Open(); using (IDataReader r = command.ExecuteReader(CommandBehavior.CloseConnection)) { while (r.Read()) { DropDownOption option = new DropDownOption { value = r["SizeAndNumInBox"].ToString(), text = r["Descr"].ToString() }; options.Add(option); } } LastErrorMsg = string.Empty; } } } catch (Exception ex) { LastErrorMsg = ex.Message; //consider logging error options = new List <DropDownOption>(); } return(options); }
internal void OnSelectClick(MouseEventArgs e) { if (EnableClearButton) { EnableClearButton = false; return; } if (PopupService.SelectDropDownOptions.Any(x => x.Target.Id == elementSelect.Id)) { return; } dropDownOption = new DropDownOption() { Select = this, Target = elementSelect, OptionContent = ChildContent, Refresh = () => { StateHasChanged(); }, IsShow = true }; PopupService.SelectDropDownOptions.Add(dropDownOption); }
private void cmb_srchPlayerLeague_SelectedIndexChanged(object sender, EventArgs e) { int filterId = -1; if (cmb_srchPlayerLeague.SelectedValue != null) { DropDownOption selectedOption = cmb_srchPlayerLeague.SelectedValue as DropDownOption; filterId = selectedOption.Id; } cmb_srchPlayerClub.DataSource = DropDownHelper.GetClubs(filterId); }
private void cmb_srchPlayerQuality_SelectedIndexChanged(object sender, EventArgs e) { int filterId = -1; if (cmb_srchPlayerQuality.SelectedValue != null) { DropDownOption selectedOption = cmb_srchPlayerQuality.SelectedValue as DropDownOption; filterId = selectedOption.Id; } cmb_srchPlayerRarity.DataSource = DropDownHelper.GetRarities(filterId); }
public void OnOptionSelected(DropDownOption option, bool call = true) { if (string.IsNullOrEmpty(this.Label.Value)) { ((ButtonView)FindFirstChildByName("button")).Text = option.Text; } if (option.OnClicked != null && call) { option.OnClicked(); } this.LastItemSelected.Value = GetOptionIndex(option.Text); this.HideDropDown(); }
internal async Task CloseDropDownAsync(DropDownOption option) { option.IsShow = false; option.HideStatus = AnimationStatus.Begin; StateHasChanged(); await Task.Delay(10); option.HideStatus = AnimationStatus.End; StateHasChanged(); await Task.Delay(200); PopupService.DropDownOptions.Remove(option); option.Refresh(); }
public void Clear() { for (int i = 0; i < options.Count; i++) { DropDownOption b = options[i]; if (subLists[i] != null) { Destroy(subLists[i].gameObject); } Destroy(b.gameObject); } options.Clear(); subLists.Clear(); }
public void EndOptions() { refresh = false; for (int i = options.Count - 1; i >= refreshOptionIndex; i--) { DropDownOption b = options[i]; Destroy(b.gameObject); if (subLists[i] != null) { Destroy(subLists[i].gameObject); } options.RemoveAt(i); subLists.RemoveAt(i); } }
void Start() { //Populate Header Button SetHeader(chosenIndex); float myWidth = GetComponent <RectTransform>().sizeDelta.x;// - widthDelta; //Instantiate Options if (optionDataList.Count == 0) { throw new System.Exception("optionDataList.Count is zero!"); } int i = 0; //Instantite Option elements foreach (LineItemData option in optionDataList) { GameObject newOption = Instantiate(ddOptionPrefab, contentTransform, false); //Set width of child element RectTransform nORect = newOption.GetComponent <RectTransform>(); nORect.sizeDelta = new Vector2(myWidth, nORect.sizeDelta.y); //Pass on Option data DropDownOption newDDO = newOption.GetComponent <DropDownOption>(); newDDO.optionID = i++; newDDO.Unpack(option); newDDO.dropDownMenu = this; //Give each Option a Separator to manage if (ddSeparatorPrefab != null) { GameObject newSeparator = Instantiate(ddSeparatorPrefab, contentTransform, false); //Set width of child element RectTransform nOSep = newSeparator.GetComponent <RectTransform>(); nOSep.sizeDelta = new Vector2(myWidth, nOSep.sizeDelta.y); newDDO.mySeparator = newSeparator; } ddOptionList.Add(newDDO); } //Handle Background height backgroundRect = background.GetComponent <RectTransform>(); sizeRetracted = backgroundRect.rect.size; widthRetracted = backgroundRect.sizeDelta.x; myRect = GetComponent <RectTransform>(); originPosition = myRect.anchoredPosition; SetDeltaHeight(); background.SetActive(false); //layoutGroup layoutGroup.padding.top = (int)elementHeight; }
public static List <DropDownOption> CalcSelectDDSizeAndTilesPerBoxAll(IConfiguration config) { Boolean HasErrors = false; var retval = new List <DropDownOption>(); string dbconn = config.GetConnectionString("DefaultConnection"); using (SqlConnection conn = new SqlConnection(dbconn)) { using (SqlCommand cmd = new SqlCommand("CalcSelectDDSizeAndTilesPerBoxAll", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; try { conn.Open(); using (SqlDataReader r = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { if (r.HasRows) { while (r.Read()) { DropDownOption ddo = new DropDownOption(); ddo.value = r["SizeAndNumInBox"].ToString(); ddo.text = r["Descr"].ToString(); retval.Add(ddo); } } } LastErrorMsg = string.Empty; } catch (Exception ex) { LastErrorMsg = ex.Message; HasErrors = true; } } if (!HasErrors) { return(retval); } else { return(new List <DropDownOption>()); //just an empty list returned } } }
public Task DropDownFieldsHaveNames() { return(TestEnvironment.RunClean(async() => { await TestEnvironment.Current.Board.EnsurePowerUp(new CustomFieldsPowerUp()); var card = await TestEnvironment.Current.BuildCard(); var selection = DropDownOption.Create("test1"); var fieldDef = await TestEnvironment.Current.Board.CustomFields.Add($"{nameof(DropDownFieldsHaveNames)}TooYouKnow", CustomFieldType.DropDown, CancellationToken.None, selection, DropDownOption.Create("test2")); selection = fieldDef.Options.FirstOrDefault(o => o.Text == selection.Text); var field = await fieldDef.SetValueForCard(card, selection); Assert.AreEqual($"{nameof(DropDownFieldsHaveNames)}TooYouKnow", field.Definition.Name); Assert.AreEqual(selection.Text, field.Value.Text); })); }
internal async Task CloseDropDownAsync(DropDownOption option) { option.IsShow = false; if (GlobalBlazuiSettings.DisableAnimation) { PopupService.SelectDropDownOptions.Remove(option); PopupService.DropDownMenuOptions.Remove(option); option.Refresh?.Invoke(); return; } option.HideStatus = AnimationStatus.Begin; StateHasChanged(); await Task.Delay(10); option.HideStatus = AnimationStatus.End; StateHasChanged(); await Task.Delay(200); PopupService.SelectDropDownOptions.Remove(option); PopupService.DropDownMenuOptions.Remove(option); option.Refresh?.Invoke(); }
public ButtonView AddOption(string name, Action action, object related = null) { if (this.LastItemSelected == -1) { if (string.IsNullOrEmpty(this.Label)) ((ButtonView)FindFirstChildByName("button")).Text = name; this.LastItemSelected.Value = this.DropDownOptions.Count; } var dropDownOption = new DropDownOption() { Text = name, OnClicked = action, Related = related }; DropDownOptions.Add(dropDownOption); var dropButton = new ButtonView(this.ParentGeeUI, DropDownListView, name, Vector2.Zero); dropButton.OnMouseClick += (sender, args) => { OnOptionSelected(dropDownOption); }; return dropButton; }
public void AddOption(string name, IList <string> subOptions, System.Action <int> onSelected, System.Action <int> onDeleted = null) { if (doCache) { cachedData.Add(() => { AddOption(name, subOptions, onSelected, onDeleted); }); return; } DropDownOption option = addOption(name); option.SublistArrow.enabled = true; ScrollingDropDown subList = addSublist(); option.Delete.gameObject.SetActive(false); option.OnHover = () => { if (subList.IsExpanded) { //subList.Contract(); } else { subList.Expand(); } }; if (refresh) { subList.BeginOptions(); } for (int i = 0; i < subOptions.Count; i++) { string subOption = subOptions[i]; int index = i; if (onDeleted == null || subOption[0] == '[') { subList.AddOption(subOption, (x) => { Contract(); onSelected(index); }); } else { subList.AddOption(subOption, (x) => { Contract(); onSelected(index); }, (x) => { onDeleted(index); }); } } if (refresh) { subList.EndOptions(); } }
public void OnOptionSelected(DropDownOption option, bool call = true) { if (string.IsNullOrEmpty(this.Label.Value)) ((ButtonView)FindFirstChildByName("button")).Text = option.Text; if (option.OnClicked != null && call) option.OnClicked(); this.LastItemSelected.Value = GetOptionIndex(option.Text); this.HideDropDown(); }