SmartClient Software factory中的Composite UI Application Block(Cab)技术了解(六):SmartPartInfo

本文介绍如何在SCSF框架中使用SmartPartInfo来控制视图的表现效果,包括创建继承ISmartPartInfoProvider的视图类并实现GetSmartPartInfo方法,以及在基础设施类中应用SmartPartInfo。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SmartPartInfo描述和实例

 

       界面显示时有各种属性,而对这些属性的控制在SCSF中都是通过SmartPartInfo来进行控制,这样可以通过视图与不同的SmartPartInfo来控制视图的不同表现效果。

1.         在上面的项目中增加一个视图infoView,同时需要该视图继承一个IsmartPartInfoProvider的类,该类实现一个GetSmartPartInfo的方法,用于给容器调用。

  [SmartPart]

    public partial class infoView : UserControl, IinfoView, ISmartPartInfoProvider

    {

      。。。

        #region ISmartPartInfoProvider 成员

        public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)

        {

            ISmartPartInfo spi = null;

            if (smartPartInfoType.IsAssignableFrom(typeof(WindowSmartPartInfo)))

            {

                WindowSmartPartInfo wspi = new WindowSmartPartInfo();

                wspi.Modal = true;

                wspi.MaximizeBox = false;//去掉最大化

                wspi.MinimizeBox = false;//去掉最小化

                wspi.ControlBox = true;

 

                wspi.Keys[WindowWorkspaceSetting.TitleLabel] = this.label1;

 

                spi = wspi;

            }

            else

            {

                spi = Activator.CreateInstance(smartPartInfoType) as ISmartPartInfo;

            }

            spi.Description = "this is info description";

            spi.Title = "this.is info title";

            return spi;

        }

        #endregion

    }

 

2.        在项目Infrastructure.Library的类WindowWorkspace中的OnApplySmartPartInfo方法增加部分对应的代码:

        protected override void OnApplySmartPartInfo(Control smartPart, Microsoft.Practices.CompositeUI.WinForms.WindowSmartPartInfo smartPartInfo)

        {

           。。。

                #region add the label to show the smartpartinfo title

                if (spi.Keys.ContainsKey(WindowWorkspaceSetting.TitleLabel))

                {

                    Label lb = (Label)spi.Keys[WindowWorkspaceSetting.TitleLabel];

                    lb.Text = spi.Title;

                }

                #endregion

 

            }

        }

3.       运行后结果如下:

2.7.1

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值