/// <summary> /// maoling: private method, please call GetOptions() in FieldDropdown instead!!! /// Return a sorted list of variable names for variable dropdown menus. /// Include a special option at the end for creating a new variable name. /// </summary> private FieldDropdownMenu[] DropdownCreate() { List <VariableModel> varModels = null; string name = GetText(); // Don't create a new variable if there is nothing selected. var createSelectedVariable = !string.IsNullOrEmpty(name); Workspace workspace = SourceBlock != null ? SourceBlock.Workspace : null; if (workspace != null) { // Get a copy of the list, so that adding rename and new variable options // doesn't modify the workspace's list. varModels = workspace.GetVariablesOfType(""); varModels.Sort(VariableModel.CompareByName); } if (varModels == null) { varModels = new List <VariableModel>(); } List <FieldDropdownMenu> options = new List <FieldDropdownMenu>(); for (int i = 0; i < varModels.Count; i++) { options.Add(new FieldDropdownMenu() { Text = varModels[i].Name, Value = varModels[i].ID }); } if (Define.FIELD_VARIABLE_ADD_MANIPULATION_OPTIONS) { options.Add(new FieldDropdownMenu() { Text = I18n.Get(MsgDefine.RENAME_VARIABLE), Value = MsgDefine.RENAME_VARIABLE }); options.Add(new FieldDropdownMenu() { Text = I18n.Get(MsgDefine.DELETE_VARIABLE), Value = MsgDefine.DELETE_VARIABLE }); } return(options.ToArray()); }