示例#1
0
 protected virtual TControlSw CreateSwControlInPage(IPropertyManagerPage2 page,
                                                    ControlOptionsAttribute opts, IAttributeSet atts)
 {
     if (m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1))
     {
         return(page.AddControl2(atts.Id, (short)m_Type, atts.Name,
                                 (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
     }
     else
     {
         return(page.AddControl(atts.Id, (short)m_Type, atts.Name,
                                (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
     }
 }
示例#2
0
        private ControlOptionsAttribute GetControlOptions(IAttributeSet atts)
        {
            ControlOptionsAttribute opts;

            if (atts.Has <ControlOptionsAttribute>())
            {
                opts = atts.Get <ControlOptionsAttribute>();
            }
            else
            {
                opts = new ControlOptionsAttribute();
            }

            return(opts);
        }
 protected override PropertyManagerPageOptionBox CreateSwControlInGroup(IPropertyManagerPageGroup group,
                                                                        ControlOptionsAttribute opts, IAttributeSet atts)
 {
     return(CreateOptionBoxControl(opts, atts,
                                   (int id, short controlType, string caption, short leftAlign, int options, string tip) =>
     {
         if (m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1))
         {
             return group.AddControl2(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
         }
         else
         {
             return group.AddControl(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
         }
     }));
 }
        private PropertyManagerPageOptionBox CreateOptionBoxControl(ControlOptionsAttribute opts, IAttributeSet atts,
                                                                    ControlCreatorDelegate creator)
        {
            var options = EnumExtension.GetEnumFields(atts.BoundType);

            var ctrls = new IPropertyManagerPageOption[options.Count];

            for (int i = 0; i < options.Count; i++)
            {
                var name = options.ElementAt(i).Value;
                ctrls[i] = creator.Invoke(atts.Id + i, (short)swPropertyManagerPageControlType_e.swControlType_Option, name,
                                          (short)opts.Align, (short)opts.Options, atts.Description);
            }

            return(new PropertyManagerPageOptionBox(ctrls));
        }
        protected virtual TControlSw CreateSwControl(object host, ControlOptionsAttribute opts, IAttributeSet atts)
        {
            var legacy = !m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1);

            switch (host)
            {
            case IPropertyManagerPage2 page:
                if (!legacy)
                {
                    return(page.AddControl2(atts.Id, (short)m_Type, atts.Name,
                                            (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
                }
                else
                {
                    return(page.AddControl(atts.Id, (short)m_Type, atts.Name,
                                           (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
                }

            case IPropertyManagerPageTab tab:
                if (!legacy)
                {
                    return(tab.AddControl2(atts.Id, (short)m_Type, atts.Name,
                                           (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
                }
                else
                {
                    return(tab.AddControl(atts.Id, (short)m_Type, atts.Name,
                                          (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
                }

            case IPropertyManagerPageGroup group:
                if (!legacy)
                {
                    return(group.AddControl2(atts.Id, (short)m_Type, atts.Name,
                                             (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
                }
                else
                {
                    return(group.AddControl(atts.Id, (short)m_Type, atts.Name,
                                            (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
                }

            default:
                throw new NotSupportedException("Host is not supported");
            }
        }
示例#6
0
        protected override PropertyManagerPageOptionBox CreateSwControl(object host, ControlOptionsAttribute opts, IAttributeSet atts)
        => CreateOptionBoxControl(opts, atts,
                                  (int id, short controlType, string caption, short leftAlign, int options, string tip) =>
        {
            var legacy = !m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1);

            switch (host)
            {
            case IPropertyManagerPage2 page:
                if (!legacy)
                {
                    return(page.AddControl2(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption);
                }
                else
                {
                    return(page.AddControl(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption);
                }

            case IPropertyManagerPageTab tab:
                if (!legacy)
                {
                    return(tab.AddControl2(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption);
                }
                else
                {
                    return(tab.AddControl(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption);
                }

            case IPropertyManagerPageGroup group:
                if (!legacy)
                {
                    return(group.AddControl2(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption);
                }
                else
                {
                    return(group.AddControl(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption);
                }

            default:
                throw new NotSupportedException("Host is not supported");
            }
        });
示例#7
0
 protected override IPropertyManagerPageBitmapButton CreateSwControlInTab(IPropertyManagerPageTab tab, ControlOptionsAttribute opts, IAttributeSet atts)
 {
     SetButtonSpecificType(atts);
     return(base.CreateSwControlInTab(tab, opts, atts));
 }
示例#8
0
        private void AssignControlAttributes(TControlSw ctrl, ControlOptionsAttribute opts, IAttributeSet atts)
        {
            var swCtrl = ctrl as IPropertyManagerPageControl;

            if (opts.BackgroundColor != 0)
            {
                swCtrl.BackgroundColor = ConvertColor(opts.BackgroundColor);
            }

            if (opts.TextColor != 0)
            {
                swCtrl.TextColor = ConvertColor(opts.TextColor);
            }

            if (opts.Left != -1)
            {
                swCtrl.Left = opts.Left;
            }

            if (opts.Top != -1)
            {
                swCtrl.Top = opts.Top;
            }

            if (opts.Width != -1)
            {
                swCtrl.Width = opts.Width;
            }

            if (opts.ResizeOptions != 0)
            {
                swCtrl.OptionsForResize = (int)opts.ResizeOptions;
            }

            ControlIcon icon = null;

            var commonIcon = atts.BoundMemberInfo?.TryGetAttribute <IconAttribute>()?.Icon;

            if (commonIcon != null)
            {
                icon = new ControlIcon(commonIcon);
            }

            if (atts.Has <ControlAttributionAttribute>())
            {
                var attribution = atts.Get <ControlAttributionAttribute>();

                if (attribution.StandardIcon != 0)
                {
                    swCtrl.SetStandardPictureLabel((int)attribution.StandardIcon);
                }
                //else if (attribution.Icon != null)
                //{
                //    icon = attribution.Icon;
                //}
            }

            if (icon != null)
            {
                var icons = m_IconConv.ConvertIcon(icon);
                var res   = swCtrl.SetPictureLabelByName(icons[0], icons[1]);
                Debug.Assert(res);
            }
        }
示例#9
0
        private void AssignControlAttributes(TControlSw ctrl, ControlOptionsAttribute opts, IAttributeSet atts)
        {
            var swCtrl = ctrl as IPropertyManagerPageControl;

            if (opts.BackgroundColor != 0)
            {
                swCtrl.BackgroundColor = ConvertColor(opts.BackgroundColor);
            }

            if (opts.TextColor != 0)
            {
                swCtrl.TextColor = ConvertColor(opts.TextColor);
            }

            if (opts.Left != -1)
            {
                swCtrl.Left = opts.Left;
            }

            if (opts.Top != -1)
            {
                swCtrl.Top = opts.Top;
            }

            if (opts.Width != -1)
            {
                swCtrl.Width = opts.Width;
            }

            if (opts.ResizeOptions != 0)
            {
                swCtrl.OptionsForResize = (int)opts.ResizeOptions;
            }

            ControlIcon icon = null;

            var commonIcon = atts.BoundMemberInfo?.TryGetAttribute <IconAttribute>()?.Icon;

            if (commonIcon != null)
            {
                icon = new ControlIcon(IconsConverter.FromXImage(commonIcon));
            }

            var hasIcon = false;

            if (atts.Has <StandardControlIconAttribute>())
            {
                var attribution = atts.Get <StandardControlIconAttribute>();

                if (attribution.Label != 0)
                {
                    hasIcon = true;
                    swCtrl.SetStandardPictureLabel((int)attribution.Label);
                }
            }

            if (icon != null)
            {
                hasIcon = true;
                var icons = m_IconConv.ConvertIcon(icon);
                var res   = swCtrl.SetPictureLabelByName(icons[0], icons[1]);
                Debug.Assert(res);
            }

            if (!hasIcon)
            {
                var defIcon = GetDefaultBitmapLabel(atts);

                if (defIcon.HasValue)
                {
                    swCtrl.SetStandardPictureLabel((int)defIcon.Value);
                }
            }
        }