Beispiel #1
0
        /// <summary>
        /// Occurs when the context menu is popped up for the property grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnGridContextMenuPoppedUp(object sender, EventArgs e)
        {
            // grab the grid
            PropertyGrid grid = this._propertyGrid;

            if (grid != null)
            {
                // grab the selected item
                if (grid.SelectedGridItem != null)
                {
                    GridItem item = grid.SelectedGridItem;
                    if (item != null)
                    {
                        // grab the descriptor as one of our option descriptors
                        XmlConfigurationOptionPropertyDescriptor descriptor = item.PropertyDescriptor as XmlConfigurationOptionPropertyDescriptor;
                        if (descriptor != null)
                        {
                            XmlConfigurationOption option = descriptor.Option;
                            if (option != null)
                            {
                                // construct a new menu item for it
                                XmlConfigurationOptionPropertyDescriptorMenuItem menuItem = new XmlConfigurationOptionPropertyDescriptorMenuItem("Has changes", new EventHandler(OnToggleOptionHasChangesClicked), option);
                                // determine its checked state
                                menuItem.Checked = option.HasChanges;
                                // rinse and repeat
                                _contextMenu.MenuItems.Clear();
                                _contextMenu.MenuItems.Add(menuItem);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Occurs when the "Has changes" menu item is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnToggleOptionHasChangesClicked(object sender, EventArgs e)
        {
            // grab one of our custom menu items
            XmlConfigurationOptionPropertyDescriptorMenuItem menuItem = sender as XmlConfigurationOptionPropertyDescriptorMenuItem;

            if (menuItem != null)
            {
                // and the option it points to
                XmlConfigurationOption option = menuItem.Option;
                if (option != null)
                {
                    // toggle the check
                    option.HasChanges = !menuItem.Checked;

                    // if changed, then trigger the changed event for the option
                    if (option.HasChanges)
                    {
                        option.TriggerChange();
                    }
                }
            }
        }
		/// <summary>
		/// Occurs when the context menu is popped up for the property grid
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnGridContextMenuPoppedUp(object sender, EventArgs e)
		{
			// grab the grid
			PropertyGrid grid = this._propertyGrid;
			if (grid != null)
			{
				// grab the selected item
				if (grid.SelectedGridItem != null)
				{
					GridItem item = grid.SelectedGridItem;
					if (item != null)
					{
						// grab the descriptor as one of our option descriptors
						XmlConfigurationOptionPropertyDescriptor descriptor = item.PropertyDescriptor as XmlConfigurationOptionPropertyDescriptor;
						if (descriptor != null)
						{
							XmlConfigurationOption option = descriptor.Option;
							if (option != null)
							{
								// construct a new menu item for it
								XmlConfigurationOptionPropertyDescriptorMenuItem menuItem = new XmlConfigurationOptionPropertyDescriptorMenuItem("Has changes", new EventHandler(OnToggleOptionHasChangesClicked), option);
								// determine its checked state
								menuItem.Checked = option.HasChanges;
								// rinse and repeat								
								_contextMenu.MenuItems.Clear();
								_contextMenu.MenuItems.Add(menuItem);
							}
						}						
					}
				}
			}
		}