示例#1
0
        protected override PropertyManagerPageSelectionBoxEx CreateControl(
            IPropertyManagerPageSelectionbox swCtrl, IAttributeSet atts, THandler handler, short height)
        {
            var selAtt = atts.Get <SelectionBoxAttribute>();

            swCtrl.SetSelectionFilters(selAtt.Filters);
            swCtrl.Mark = selAtt.SelectionMark;

            swCtrl.SingleEntityOnly = !(typeof(IList).IsAssignableFrom(atts.BoundType));

            ISelectionCustomFilter customFilter = null;

            if (selAtt.CustomFilter != null)
            {
                customFilter = Activator.CreateInstance(selAtt.CustomFilter) as ISelectionCustomFilter;

                if (customFilter == null)
                {
                    throw new InvalidCastException(
                              $"Specified custom filter of type {selAtt.CustomFilter.FullName} cannot be cast to {typeof(ISelectionCustomFilter).FullName}");
                }
            }

            if (height == -1)
            {
                height = 20;
            }

            swCtrl.Height = height;

            if (atts.Has <SelectionBoxOptionsAttribute>())
            {
                var style = atts.Get <SelectionBoxOptionsAttribute>();

                if (style.Style != 0)
                {
                    swCtrl.Style = (int)style.Style;
                }

                if (style.SelectionColor != 0)
                {
                    swCtrl.SetSelectionColor(true, ConvertColor(style.SelectionColor));
                }
            }

            return(new PropertyManagerPageSelectionBoxEx(m_App, atts.Id, atts.Tag,
                                                         swCtrl, handler, atts.BoundType, customFilter));
        }
示例#2
0
 public static void SetSelectionColor(this IPropertyManagerPageSelectionbox box, swUserPreferenceIntegerValue_e color)
 {
     box.SetSelectionColor(true, (int)color);
 }