Beispiel #1
0
        /// <summary>
        /// When something changes the property areaChoice (via something like a menubar),
        /// this ensures that the matching button is highlighted.
        /// This also handles getting the tool right when the area (or the tool) changes.
        /// </summary>
        public void OnPropertyChanged(string propertyName)
        {
            switch (propertyName)
            {
            case "areaChoice":
                string areaName = m_mediator.PropertyTable.GetStringProperty("areaChoice", null);
                foreach (ChoiceGroup group in m_choiceGroupCollectionCache)
                {
                    foreach (ListPropertyChoice choice in group)                             // group must already be populated
                    {
                        if (choice.Value == areaName)
                        {
                            string listId = GetListIdFromListPropertyChoice(choice);
                            var    tab    = m_sidepane.GetTabByName(listId);
                            if (tab != null)
                            {
                                // We need to explicitly set the tool if we can, since the sidepane will
                                // choose the first tool if one has never been chosen, and end up
                                // overwriting the property table value.  See FWR-2004.
                                string propToolForArea = "ToolForAreaNamed_" + areaName;
                                string toolForArea     = m_mediator.PropertyTable.GetStringProperty(propToolForArea, null);
                                m_sidepane.SelectTab(tab);
                                // FWR-2895 Deleting a Custom list could result in needing to
                                // update the PropertyTable.
                                if (!String.IsNullOrEmpty(toolForArea) && !toolForArea.StartsWith("?"))
                                {
                                    var fsuccess = m_sidepane.SelectItem(tab, toolForArea);
                                    if (!fsuccess)
                                    {
                                        m_mediator.PropertyTable.SetProperty(propToolForArea, null);
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                break;

            default:
                // This helps fix FWR-2004.
                if (propertyName.StartsWith("ToolForAreaNamed_"))
                {
                    string areaChoice      = m_mediator.PropertyTable.GetStringProperty("areaChoice", null);
                    string propToolForArea = "ToolForAreaNamed_" + areaChoice;
                    if (propertyName == propToolForArea)
                    {
                        string toolForArea = m_mediator.PropertyTable.GetStringProperty(propertyName, null);
                        SetToolForCurrentArea(toolForArea);
                    }
                }
                break;
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the current sidebar tab item.
        /// </summary>
        /// <param name="tabName">Name of tab containing the tab item to make current.</param>
        /// <param name="itemName">Name of tab item to make current.</param>
        /// <param name="generateEvents"><c>true</c> to cause events to be fired when setting
        /// the current sidebar tab item (like when the user clicks on an item). Otherwise,
        /// <c>false</c>.</param>
        /// ------------------------------------------------------------------------------------
        public void SetCurrentTabItem(string tabName, string itemName, bool generateEvents)
        {
            Tab tab = m_sidePane.GetTabByName(tabName);

            m_sidePane.SelectItem(tab, itemName);
        }