protected override PropertyManagerPageSelectionBoxControl CreateControl(
            IPropertyManagerPageSelectionbox swCtrl, IAttributeSet atts, IMetadata metadata,
            SwPropertyManagerPageHandler handler, short height)
        {
            swCtrl.SingleEntityOnly = !(typeof(IList).IsAssignableFrom(atts.ContextType));

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

            swCtrl.Height = height;

            ISelectionCustomFilter customFilter = null;

            var filters = SelectionBoxConstructorHelper.GetDefaultFilters(atts);

            bool focusOnOpen = false;

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

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

                if (selAtt.SelectionColor != 0)
                {
                    swCtrl.SetSelectionColor(true, (int)selAtt.SelectionColor);
                }

                if (selAtt.Filters?.Any() == true)
                {
                    filters = selAtt.Filters;
                }

                swCtrl.Mark = selAtt.SelectionMark;

                focusOnOpen = selAtt.Focused;

                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}");
                    }
                }
            }

            swCtrl.SetSelectionFilters(filters.Select(f => (swSelectType_e)f).ToArray());

            return(new PropertyManagerPageSelectionBoxControl(m_SwApp, atts.Id, atts.Tag,
                                                              swCtrl, handler, atts.ContextType, customFilter, focusOnOpen));
        }
Exemple #2
0
        public PropertyManagerPageSelectionBoxControl(ISwApplication app, int id, object tag,
                                                      IPropertyManagerPageSelectionbox selBox,
                                                      SwPropertyManagerPageHandler handler, Type objType, ISelectionCustomFilter customFilter, bool defaultFocus)
            : base(selBox, id, tag, handler)
        {
            m_App          = app;
            m_ObjType      = objType;
            m_ElementType  = SelectionBoxConstructorHelper.GetElementType(m_ObjType);
            m_CustomFilter = customFilter;

            m_DefaultFocus = defaultFocus;

            m_Handler.SelectionChanged += OnSelectionChanged;

            if (m_DefaultFocus)
            {
                m_Handler.Opened += OnPageOpened;
            }

            m_Handler.SubmitSelection += OnSubmitSelection;
        }
 protected override BitmapLabelType_e?GetDefaultBitmapLabel(IAttributeSet atts)
 {
     return(SelectionBoxConstructorHelper.GetDefaultBitmapLabel(atts));
 }
 protected virtual SelectType_e[] GetDefaultFilters(IAttributeSet atts, out ISelectionCustomFilter customFilter)
 {
     return(SelectionBoxConstructorHelper.GetDefaultFilters(atts, out customFilter));
 }