示例#1
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);
                }
            }
        }
示例#2
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);
            }
        }
 /// <inheritdoc cref="ControlAttributionAttribute(Type, string)"/>
 /// <param name="maskResName">Image resource name referencing the icon mask</param>
 public ControlAttributionAttribute(Type resType, string iconResName, string maskResName)
 {
     Icon = new ControlIcon(
         ResourceHelper.GetResource <Image>(resType, iconResName),
         ResourceHelper.GetResource <Image>(resType, maskResName));
 }