Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapDisplayFilterTool"/> class.
        /// </summary>
        /// <param name="toolManager">The <see cref="ToolManager"/>.</param>
        public MapDisplayFilterTool(ToolManager toolManager) : base(toolManager, CreateSettings())
        {
            _filterCollection = new MapDrawFilterHelperCollection();

            var s = ToolBarControl.ControlSettings.AsSplitButtonSettings();

            s.ToolTipText   = "Filters what is displayed on the map";
            s.ClickToEnable = true;

            // Set up the DropDownItems
            _tsManageFilters = new ToolStripButton("Manage Filters...", null, _tsManageFilters_Click);

            s.DropDownItems.Add(new ToolStripSeparator());
            s.DropDownItems.Add(_tsManageFilters);

            // Forward any existing filters to the _filterCollection_Added method (easy way to deal with the fact that we
            // haven't added the event hooks yet)
            foreach (var f in _filterCollection.Filters)
            {
                _filterCollection_Added(_filterCollection, new MapDrawFilterHelperCollectionEventArgs(f));
            }

            // Listen to the filter collection events
            _filterCollection.Added   += _filterCollection_Added;
            _filterCollection.Removed += _filterCollection_Removed;
            _filterCollection.Renamed += _filterCollection_Renamed;
        }
Пример #2
0
        /// <summary>
        /// Handles when a filter is removed from the collection.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapDrawFilterHelperCollectionEventArgs"/> instance containing the event data.</param>
        void _filterCollection_Removed(MapDrawFilterHelperCollection sender, MapDrawFilterHelperCollectionEventArgs e)
        {
            // Remove the filter from the ToolBarControl's DropDownItems

            FilterToolStripItem ftsi;

            if (!_tsFilters.TryGetValue(e.Filter, out ftsi))
            {
                const string errmsg = "Failed to find FilterToolStripItem for filter `{0}`.";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, e.Filter);
                }
                Debug.Fail(string.Format(errmsg, e.Filter));
                return;
            }

            Debug.Assert(ftsi.Filter == e.Filter);

            _tsFilters.Remove(e.Filter);
            ftsi.Dispose();

            // If the filter we just got rid of was the active one, set the active filter to null
            if (e.Filter == _currentFilter)
            {
                _currentFilter = null;
            }
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapDisplayFilterTool"/> class.
        /// </summary>
        /// <param name="toolManager">The <see cref="ToolManager"/>.</param>
        public MapDisplayFilterTool(ToolManager toolManager) : base(toolManager, CreateSettings())
        {
            _filterCollection = new MapDrawFilterHelperCollection();

            var s = ToolBarControl.ControlSettings.AsSplitButtonSettings();
            s.ToolTipText = "Filters what is displayed on the map";
            s.ClickToEnable = true;

            // Set up the DropDownItems
            _tsManageFilters = new ToolStripButton("Manage Filters...", null, _tsManageFilters_Click);

            s.DropDownItems.Add(new ToolStripSeparator());
            s.DropDownItems.Add(_tsManageFilters);

            // Forward any existing filters to the _filterCollection_Added method (easy way to deal with the fact that we
            // haven't added the event hooks yet)
            foreach (var f in _filterCollection.Filters)
            {
                _filterCollection_Added(_filterCollection, new MapDrawFilterHelperCollectionEventArgs(f));
            }

            // Listen to the filter collection events
            _filterCollection.Added += _filterCollection_Added;
            _filterCollection.Removed += _filterCollection_Removed;
            _filterCollection.Renamed += _filterCollection_Renamed;
        }
Пример #4
0
        /// <summary>
        /// Handles hwen a filter is added to the collection.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapDrawFilterHelperCollectionEventArgs"/> instance containing the event data.</param>
        void _filterCollection_Added(MapDrawFilterHelperCollection sender, MapDrawFilterHelperCollectionEventArgs e)
        {
            // Add the new filter to the ToolBarControl's DropDownItems

            var ftsi = new FilterToolStripItem(e.Filter, e.FilterName);

            ftsi.CheckedChanged += ftsi_CheckedChanged;

            _tsFilters.Add(e.Filter, ftsi);

            var s = ToolBarControl.ControlSettings.AsSplitButtonSettings();

            s.DropDownItems.Insert(0, ftsi);
        }
Пример #5
0
        /// <summary>
        /// Handles the corresponding event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapDrawFilterHelperCollectionRenameEventArgs"/> instance containing the event data.</param>
        void _filterCollection_Renamed(MapDrawFilterHelperCollection sender, MapDrawFilterHelperCollectionRenameEventArgs e)
        {
            // Update the displayed name

            FilterToolStripItem ftsi;

            if (!_tsFilters.TryGetValue(e.Filter, out ftsi))
            {
                const string errmsg = "Failed to find FilterToolStripItem for filter `{0}`.";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, e.Filter);
                }
                Debug.Fail(string.Format(errmsg, e.Filter));
                return;
            }

            Debug.Assert(ftsi.Filter == e.Filter);

            ftsi.FilterNameChanged(e.FilterName);
        }
Пример #6
0
        /// <summary>
        /// Handles the corresponding event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapDrawFilterHelperCollectionRenameEventArgs"/> instance containing the event data.</param>
        void _filterCollection_Renamed(MapDrawFilterHelperCollection sender, MapDrawFilterHelperCollectionRenameEventArgs e)
        {
            // Update the displayed name

            FilterToolStripItem ftsi;
            if (!_tsFilters.TryGetValue(e.Filter, out ftsi))
            {
                const string errmsg = "Failed to find FilterToolStripItem for filter `{0}`.";
                if (log.IsErrorEnabled)
                    log.ErrorFormat(errmsg, e.Filter);
                Debug.Fail(string.Format(errmsg, e.Filter));
                return;
            }

            Debug.Assert(ftsi.Filter == e.Filter);

            ftsi.FilterNameChanged(e.FilterName);
        }
Пример #7
0
        /// <summary>
        /// Handles when a filter is removed from the collection.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapDrawFilterHelperCollectionEventArgs"/> instance containing the event data.</param>
        void _filterCollection_Removed(MapDrawFilterHelperCollection sender, MapDrawFilterHelperCollectionEventArgs e)
        {
            // Remove the filter from the ToolBarControl's DropDownItems

            FilterToolStripItem ftsi;
            if (!_tsFilters.TryGetValue(e.Filter, out ftsi))
            {
                const string errmsg = "Failed to find FilterToolStripItem for filter `{0}`.";
                if (log.IsErrorEnabled)
                    log.ErrorFormat(errmsg, e.Filter);
                Debug.Fail(string.Format(errmsg, e.Filter));
                return;
            }

            Debug.Assert(ftsi.Filter == e.Filter);

            _tsFilters.Remove(e.Filter);
            ftsi.Dispose();

            // If the filter we just got rid of was the active one, set the active filter to null
            if (e.Filter == _currentFilter)
                _currentFilter = null;
        }
Пример #8
0
        /// <summary>
        /// Handles hwen a filter is added to the collection.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MapDrawFilterHelperCollectionEventArgs"/> instance containing the event data.</param>
        void _filterCollection_Added(MapDrawFilterHelperCollection sender, MapDrawFilterHelperCollectionEventArgs e)
        {
            // Add the new filter to the ToolBarControl's DropDownItems

            var ftsi = new FilterToolStripItem(e.Filter, e.FilterName);
            ftsi.CheckedChanged += ftsi_CheckedChanged;

            _tsFilters.Add(e.Filter, ftsi);

            var s = ToolBarControl.ControlSettings.AsSplitButtonSettings();
            s.DropDownItems.Insert(0, ftsi);
        }