Beispiel #1
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                List <string> values = value as List <string>;

                _seasons = new List <string>();
                var weatherService = EditorConfigHelper.Config.Services.OfType <WeatherService>().FirstOrDefault();

                if (weatherService != null)
                {
                    foreach (var s in weatherService.TimeConfiguration.Seasons)
                    {
                        _seasons.Add(s.Name);
                    }
                }

                if (provider != null)
                {
                    // use windows forms editor service to show drop down
                    IWindowsFormsEditorService edSvc = provider.GetService(typeof(IWindowsFormsEditorService))
                                                       as IWindowsFormsEditorService;
                    if (edSvc == null)
                    {
                        return(value);
                    }

                    if (editor == null)
                    {
                        editor = new CheckValuesEditorControl <string>();
                    }

                    // prepare list
                    editor.Begin(edSvc, _seasons, values);

                    // show drop down now
                    edSvc.DropDownControl(editor);

                    // now we take the result
                    value = new List <string>(editor.GetSelectedValues());

                    // reset
                    editor.End();
                }

                return(value);
            }
Beispiel #2
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                List <BlockProfile> values = null;

                if (value != null)
                {
                    values = new List <BlockProfile>(EditorConfigHelper.Config.BlockProfiles.Where(x => ((List <byte>)value).Contains(x.Id) && x.Name != "System Reserved")); //value as List<BlockProfile>;
                }

                if (provider != null)
                {
                    // use windows forms editor service to show drop down
                    IWindowsFormsEditorService edSvc = provider.GetService(typeof(IWindowsFormsEditorService))
                                                       as IWindowsFormsEditorService;
                    if (edSvc == null)
                    {
                        return(value);
                    }

                    if (editor == null)
                    {
                        editor = new CheckValuesEditorControl <BlockProfile>();
                    }

                    // prepare list

                    editor.Begin(edSvc, EditorConfigHelper.Config.BlockProfiles.Where(x => x.Name != "System Reserved").OrderBy(x => x.Name).ToList(), values);

                    // show drop down now
                    edSvc.DropDownControl(editor);

                    // now we take the result
                    value = new List <byte>(editor.GetSelectedValues().Select(x => x.Id));

                    // reset
                    editor.End();
                }

                return(value);
            }