示例#1
0
        // --------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        // --------------------------------------------------------------------------------------------
        protected ToolWindowPane()
        {
            _BitmapIndex      = -1;
            _BitmapResourceID = -1;
            _ToolBarLocation  = ToolbarLocation.Top;

            // --- Obtain attributes of the class
            foreach (object attr in GetType().GetCustomAttributes(false))
            {
                var captionAttr = attr as InitialCaptionAttribute;
                if (captionAttr != null)
                {
                    Caption = ResourceResolver <TPackage> .GetString(captionAttr.Value);

                    continue;
                }
                var resIdAttr = attr as BitmapResourceIdAttribute;
                if (resIdAttr != null)
                {
                    BitmapResourceID = resIdAttr.ResourceId;
                    BitmapIndex      = resIdAttr.BitmapIndex;
                    continue;
                }
                var toolbarAttr = attr as ToolbarAttribute;
                if (toolbarAttr != null)
                {
                    var toolbarProvider =
                        Activator.CreateInstance(toolbarAttr.Value) as IToolbarProvider;
                    if (toolbarProvider != null)
                    {
                        ToolBar = toolbarProvider.CommandId;
                    }
                    continue;
                }
                var toolLocAttr = attr as ToolbarLocationAttribute;
                if (toolLocAttr != null)
                {
                    _ToolBarLocation = toolLocAttr.Location;
                    continue;
                }
            }
        }