예제 #1
0
        /// <summary>
        /// Called to build menus and toolbars.  Override this method to customize menu and toolbar building.
        /// </summary>
        /// <remarks>
        /// The default implementation simply clears and re-creates the toolstrip using methods on the
        /// utility class <see cref="ToolStripBuilder"/>.
        /// </remarks>
        /// <param name="kind"></param>
        /// <param name="toolStrip"></param>
        /// <param name="actionModel"></param>
        protected virtual void BuildToolStrip(ToolStripBuilder.ToolStripKind kind, ToolStrip toolStrip, ActionModelNode actionModel)
        {
            // avoid flicker
            toolStrip.SuspendLayout();
            // very important to clean up the existing ones first
            ToolStripBuilder.Clear(toolStrip.Items);

            if (actionModel != null)
            {
                if (actionModel.ChildNodes.Count > 0)
                {
                    // Toolstrip should only be visible if there are items on it
                    if (kind == ToolStripBuilder.ToolStripKind.Toolbar)
                    {
                        ToolStripBuilder.BuildToolStrip(kind, toolStrip.Items, actionModel.ChildNodes, ToolStripBuilder.ToolStripBuilderStyle.GetDefault(), ToolStripSettings.Default.IconSize);
                    }
                    else
                    {
                        ToolStripBuilder.BuildToolStrip(kind, toolStrip.Items, actionModel.ChildNodes);
                    }
                }
            }

            toolStrip.ResumeLayout();
        }
예제 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public AlertViewerComponentControl(AlertViewerComponent component)
            : base(component)
        {
            InitializeComponent();

            _component = component;

            ToolStripBuilder.BuildToolStrip(ToolStripBuilder.ToolStripKind.Toolbar, _toolbar.Items, _component.AlertActions.ChildNodes);

            _alertTableView.Table     = _component.Alerts;
            _alertTableView.MenuModel = _component.AlertActions;

            // need to work with these manually, because data-binding doesn't work well with toolstrip comboboxes
            _filter.Items.AddRange(_component.FilterChoices.Cast <object>().Select(i => new FilterItem(i, _component.FormatFilter)).ToArray());
            _filter.SelectedIndex         = 0;
            _filter.SelectedIndexChanged += _activityFilter_SelectedIndexChanged;
        }