Example #1
0
        /// <summary>
        /// Add item during refresh.
        /// </summary>
        /// <param name="items"></param>
        protected override void UpdateStyleList(StyleListItem[] items)
        {
            if (m_ignoreListRefresh)
            {
                return;
            }

            string selectedStyle = ListBoxControl.SelectedItem != null?
                                   ListBoxControl.SelectedItem.ToString() : string.Empty;

            ListBoxControl.Items.Clear();
            ListBoxControl.BeginUpdate();
            ListBoxControl.Items.AddRange(items);
            ListBoxControl.EndUpdate();

            SelectedStyleName = selectedStyle;

            // Ensure an item is selected, even if the previous selection is no longer
            // shown.
            if (!String.IsNullOrEmpty(selectedStyle) && ListBoxControl.SelectedItem == null)
            {
                if (ListBoxControl.Items.Count > 0)
                {
                    ListBoxControl.SelectedIndex = 0;
                }
            }
        }
Example #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the styles in the m_ctrl list based on the ExcludeStylesWithContext and
        /// ShowOnlyStylesOfType properties. This should be called when the caller wants to
        /// update the m_ctrl list after changing one of those two properties, but doesn't want
        /// to rebuild the entire m_styleItemList.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void Refresh()
        {
            if (m_ignoreListRefresh)
            {
                return;
            }

            string selectedStyle = ListBoxControl.SelectedItem != null?
                                   ListBoxControl.SelectedItem.ToString() : string.Empty;

            ListBoxControl.Items.Clear();
            ListBoxControl.BeginUpdate();
            RefreshStyleItemList(selectedStyle);
            ListBoxControl.EndUpdate();
        }