Esempio n. 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);
                            }
                        }
                    }
                }
            }
        }
        private void LoadOptions(XmlConfigurationOptionCollection options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            foreach (XmlConfigurationOption option in options)
            {
                try
                {
                    if (!option.Hidden)
                    {
                        XmlConfigurationOptionPropertyDescriptor pd = new XmlConfigurationOptionPropertyDescriptor(option);
                        _descriptors.Add(pd);
                        _table.Add(pd, option);
                    }
                }
                catch (System.Exception systemException)
                {
                    System.Diagnostics.Trace.WriteLine(systemException);
                }
            }
        }
		private void LoadOptions(XmlConfigurationOptionCollection options)
		{
			if (options == null)
				throw new ArgumentNullException("options");
			
			foreach(XmlConfigurationOption option in options)
			{
				try
				{
					if (!option.Hidden)
					{
						XmlConfigurationOptionPropertyDescriptor pd = new XmlConfigurationOptionPropertyDescriptor(option);                        
						_descriptors.Add(pd);
						_table.Add(pd, option);
					}
				}
				catch(System.Exception systemException)
				{
					System.Diagnostics.Trace.WriteLine(systemException);
				}
			}
		}