/// <summary> /// Adds the given <paramref name="filter"/> /// to the chain. /// </summary> /// <param name="filter">Filter to add.</param> /// <exception cref="ArgumentNullException">When <paramref name="filter"/> is null.</exception> /// <exception cref="ArgumentException">When the type of <paramref name="filter"/> is unknown.</exception> public void AddPixelFilter(IPixelFilter filter) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } if (filter is IPixelValueFilter vf) { _valueFilters.Add(new KeyValuePair <IPixelValueFilter, bool>(vf, true)); } else if (filter is IPixelIndexFilter inf) { _indexFilters.Add(new KeyValuePair <IPixelIndexFilter, bool>(inf, true)); } else if (filter is IPixelAutoFilter af) { _autoFilters.Add(new KeyValuePair <IPixelAutoFilter, bool>(af, true)); } else { throw new ArgumentException("Unknown pixel filter type", nameof(filter)); } RebuildActiveFilters(); }
/// <summary> /// Sets the active state of the given <paramref name="filter"/>. /// </summary> /// <param name="filter">Filter to add.</param> /// <param name="isActive">Active state of the filter in the chain.</param> /// <exception cref="ArgumentNullException">When <paramref name="filter"/> is null.</exception> /// <exception cref="ArgumentException">When the type of <paramref name="filter"/> is unknown.</exception> public void SetIsActiveState(IPixelFilter filter, bool isActive) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } if (filter is IPixelValueFilter vf) { _valueFilters[_valueFilters.IndexOf(_valueFilters.First(kvp => kvp.Key == vf))] = new KeyValuePair <IPixelValueFilter, bool>(vf, isActive); } else if (filter is IPixelIndexFilter inf) { _indexFilters[_indexFilters.IndexOf(_indexFilters.First(kvp => kvp.Key == inf))] = new KeyValuePair <IPixelIndexFilter, bool>(inf, isActive); } else if (filter is IPixelAutoFilter af) { _autoFilters[_autoFilters.IndexOf(_autoFilters.First(kvp => kvp.Key == af))] = new KeyValuePair <IPixelAutoFilter, bool>(af, isActive); } else { throw new ArgumentException("Unknown pixel filter type", nameof(filter)); } RebuildActiveFilters(); }
/// <summary> /// Removes the given <paramref name="filter"/> /// from the chain. /// </summary> /// <param name="filter">Filter to add.</param> /// <exception cref="ArgumentNullException">When <paramref name="filter"/> is null.</exception> /// <exception cref="ArgumentException">When the type of <paramref name="filter"/> is unknown.</exception> public void RemovePixelFilter(IPixelFilter filter) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } if (filter is IPixelValueFilter vf) { _valueFilters.Remove(_valueFilters.First(kvp => kvp.Key == vf)); } else if (filter is IPixelIndexFilter inf) { _indexFilters.Remove(_indexFilters.First(kvp => kvp.Key == inf)); } else if (filter is IPixelAutoFilter af) { _autoFilters.Remove(_autoFilters.First(kvp => kvp.Key == af)); } else { throw new ArgumentException("Unknown pixel filter type", nameof(filter)); } RebuildActiveFilters(); }
public void Bind(object pArgument) { if (pArgument is nullToValueFunctionArguments) { nullToValueFunctionArguments args = (nullToValueFunctionArguments)pArgument; inrs = args.Raster; newvalue = args.NewValue; ndFilt.NoDataToPixelValue = newvalue; pFilt = (IPixelFilter)ndFilt; noDataArr = args.NoDataArray; myFunctionHelper.Bind(inrs); myRasterInfo = args.RasterInfo; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: nullToValueFunctonArguments"); } }
public void Bind(object pArgument) { if (pArgument is nullToValueFunctionArguments) { nullToValueFunctionArguments args = (nullToValueFunctionArguments)pArgument; inrs = args.Raster; newvalue = args.NewValue; ndFilt.NoDataToPixelValue = newvalue; pFilt = (IPixelFilter)ndFilt; noDataArr = args.NoDataArray; myFunctionHelper.Bind(inrs); myRasterInfo = args.RasterInfo; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: nullToValueFunctonArguments"); } }
public void AddFilter(IPixelFilter filter) { filters.Add(filter); }