Пример #1
0
        protected override bool initListBoxControl(ListBoxControl <string> listControl, ModelElement mel)
        {
            if (!(mel is VDCodeSnippet))
            {
                return(false);
            }

            LinkedElementCollection <VDWidget> linkedWidgets = ((VDCodeSnippet)mel).LinkedWidgets;

            if (linkedWidgets == null)
            {
                return(false);
            }

            foreach (VDWidget linkedWidget in linkedWidgets)
            {
                listControl.AddItem(getWidgetString(linkedWidget), linkedWidget.WidgetName);
            }

            return(true);
        }
Пример #2
0
        protected virtual TValue internalEditValue(IWindowsFormsEditorService editorService, ModelElement mel,
                                                   ITypeDescriptorContext context, IServiceProvider provider, TValue value)
        {
            ListBoxControl <TValue> control = new ListBoxControl <TValue>(editorService, this.hasNoneListItem);

            if (!initListBoxControl(control, mel))
            {
                return(value);
            }

            // make the old value selected in the list
            string oldval = value.ToString();

            if (string.IsNullOrEmpty(oldval))
            {
                control.SelectedIndex = 0;
            }
            else
            {
                control.SelectedIndex = control.FindString(oldval);
            }

            // show list
            editorService.DropDownControl(control);

            // get new value
            TValue newval        = default(TValue);
            int    selectedIndex = control.SelectedIndex;

            if (selectedIndex >= 0)
            {
                newval = (TValue)((NameValue)(control.Items[selectedIndex])).Value;
            }

            return(newval);
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="listControl"></param>
 /// <returns>Succeeded or not</returns>
 protected virtual bool initListBoxControl(ListBoxControl <TValue> listControl, ModelElement mel)
 {
     return(false);
 }