Click here to Skip to main content
15,881,715 members
Articles / Programming Languages / C#

DSGraphEdit: A Reasonable Facsimile of Microsoft's GraphEdit in .NET

Rate me:
Please Sign up or sign in to vote.
4.93/5 (79 votes)
28 Jan 2018MIT7 min read 294.7K   10K   142  
A library for adding DirectShow GraphEdit-like abilities to .NET applications
namespace PropertyGridEx
{
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;

    [Serializable()]public class CustomChoices : ArrayList
	{				
		public CustomChoices(ArrayList array, bool IsSorted)
		{
			this.AddRange(array);
			if (IsSorted)
			{
				this.Sort();
			}
		}
		
		public CustomChoices(ArrayList array)
		{
			this.AddRange(array);
		}
		
		public CustomChoices(string[] array, bool IsSorted)
		{
			this.AddRange(array);
			if (IsSorted)
			{
				this.Sort();
			}
		}
		
		public CustomChoices(string[] array)
		{
			this.AddRange(array);
		}
		
		public CustomChoices(int[] array, bool IsSorted)
		{
			this.AddRange(array);
			if (IsSorted)
			{
				this.Sort();
			}
		}
		
		public CustomChoices(int[] array)
		{
			this.AddRange(array);
		}
		
		public CustomChoices(double[] array, bool IsSorted)
		{
			this.AddRange(array);
			if (IsSorted)
			{
				this.Sort();
			}
		}
		
		public CustomChoices(double[] array)
		{
			this.AddRange(array);
		}
		
		public CustomChoices(object[] array, bool IsSorted)
		{
			this.AddRange(array);
			if (IsSorted)
			{
				this.Sort();
			}
		}
		
		public CustomChoices(object[] array)
		{
			this.AddRange(array);
		}
		
		public ArrayList Items
		{
			get
			{
				return this;
			}
		}
		
		public class CustomChoicesTypeConverter : TypeConverter
		{
			
			private CustomChoicesAttributeList oChoices = null;
			public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context)
			{
				bool returnValue;
				CustomChoicesAttributeList Choices =  (CustomChoicesAttributeList) context.PropertyDescriptor.Attributes[typeof(CustomChoicesAttributeList)];
				if (oChoices != null)
				{
					return true;
				}
				if (Choices != null)
				{
					oChoices = Choices;
					returnValue = true;
				}
				else
				{
					returnValue = false;
				}
				return returnValue;
			}
			public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context)
			{
				bool returnValue;
				CustomChoicesAttributeList Choices =  (CustomChoicesAttributeList) context.PropertyDescriptor.Attributes[typeof(CustomChoicesAttributeList)];
				if (oChoices != null)
				{
					return true;
				}
				if (Choices != null)
				{
					oChoices = Choices;
					returnValue = true;
				}
				else
				{
					returnValue = false;
				}
				return returnValue;
			}
			public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context)
			{
				CustomChoicesAttributeList Choices =  (CustomChoices.CustomChoicesAttributeList) context.PropertyDescriptor.Attributes[typeof(CustomChoicesAttributeList)];
				if (oChoices != null)
				{
					return oChoices.Values;
				}
				return base.GetStandardValues(context);
			}
		}
		
		public class CustomChoicesAttributeList : Attribute
		{
			
			private ArrayList oList = new ArrayList();
			
			public ArrayList Item
			{
				get
				{
					return this.oList;
				}
			}
			
			public TypeConverter.StandardValuesCollection Values
			{
				get
				{
					return new TypeConverter.StandardValuesCollection(this.oList);
				}
			}
			
			public CustomChoicesAttributeList(string[] List)
			{
				oList.AddRange(List);
			}
			
			public CustomChoicesAttributeList(ArrayList List)
			{
				oList.AddRange(List);
			}
			
			public CustomChoicesAttributeList(ListBox.ObjectCollection List)
			{
				oList.AddRange(List);
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior)
United States United States
AKA Rich Insley.

I have over 25 years experience in programming, and I'm completely self taught. (Except for one year at California State University Fresno where I had to learn the God awful language Miranda (http://miranda.org.uk/). I've spent 10 years as a Paratrooper in the US Army during the Clinton Administration.

Comments and Discussions