Example #1
0
		/// <summary>
		/// Removes the first occurence of a specific <see cref="ReferencePath"/> from the collection.
		/// </summary>
		/// <param name="refPath">The <see cref="ReferencePath"/> to remove from the collection.</param>
		/// <exception cref="ArgumentNullException"><paramref name="refPath"/> is a <see langword="null"/>.</exception>
		/// <remarks>
		/// Elements that follow the removed element move up to occupy the vacated spot and the indexes of the elements that are moved are also updated.
		/// </remarks>
		public void Remove(ReferencePath refPath)
		{
			if (refPath == null)
				throw new ArgumentNullException("refPath");

			this.List.Remove(refPath);
		}
Example #2
0
		/// <summary>
		/// Adds the specified <see cref="ReferencePath"/> object to the collection.
		/// </summary>
		/// <param name="refPath">The <see cref="ReferencePath"/> to add to the collection.</param>
		/// <exception cref="ArgumentNullException"><paramref name="refPath"/> is a <see langword="null"/>.</exception>
		/// <remarks>
		/// If the path in <paramref name="refPath"/> matches one already existing in the collection, the
		/// operation is silently ignored.
		/// </remarks>
		public void Add(ReferencePath refPath)
		{
			if (refPath == null)
				throw new ArgumentNullException("refPath");

			if (!base.InnerList.Contains(refPath))
				this.List.Add(refPath);
		}
Example #3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ReferencePath"/> class from an existing <see cref="ReferencePath"/> instance.
		/// </summary>
		/// <param name="refPath">An existing <see cref="ReferencePath"/> instance.</param>
		/// <exception cref="ArgumentNullException"><paramref name="refPath"/> is a <see langword="null"/>.</exception>
		public ReferencePath(ReferencePath refPath)
		{
			if (refPath == null)
				throw new ArgumentNullException("refPath");

			base.Path = refPath.Path;
			base.FixedPath = refPath.FixedPath;
			this._IncludeSubDirectories = refPath._IncludeSubDirectories;
		}
Example #4
0
			/// <inheritDoc/>
			public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
			{
				if (value is ReferencePath)
				{
					object result = base.EditValue(context, provider, ((ReferencePath)value).Path);
					if ((string)result == ((ReferencePath)value).Path)
					{
						return value;
					}
					else
					{
						if (((string)result).Length > 0)
						{
							ReferencePath newValue = new ReferencePath((ReferencePath)value);
							newValue.Path = (string)result;
							return newValue;
						}
						else
						{
							return new ReferencePath();
						}
					}
				}
				else
				{
					return base.EditValue(context, provider, value);
				}
			}
Example #5
0
			/// <inheritDoc/>
			public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
			{
				Debug.WriteLine("RefPath:TypeConv.ConvertFrom  value=>" + value.ToString());
				if (value is string) 
				{
					ReferencePath rp = new ReferencePath((string)value);
					Debug.WriteLine("  rp=>" + rp.ToString());
					return rp;
				}
				return base.ConvertFrom(context, culture, value);
			}
		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			string path = null;

			ShellBrowseForFolderDialog folderDialog = new ShellBrowseForFolderDialog();
			folderDialog.hwndOwner = this.Handle;
			
			if (folderDialog.ShowDialog() == DialogResult.OK) 
			{
				path = folderDialog.FullName;

				foreach (ListViewItem sel_li in listView1.SelectedItems)
				{
					sel_li.Selected = false;
				}
				ReferencePath rp = new ReferencePath();
				rp.Path = path;
				ListViewItem li = new ListViewItem();
				listView1.Items.Add(li);
				li.Tag = rp;
				UpdateListItem(li);
				_refPaths.Add(rp);
				li.Selected = true;
			}
		}