internal ColumnFilter(TableColumn column, ICollection <string> values, FilterRigor filterRigor, FilterMethod filterMethod) { this.Column = column; this.Values = values; this.FilterRigor = filterRigor; this.FilterMethod = filterMethod; }
/// <summary> /// Create a new <see cref="ImageHeader"/>. /// </summary> public ImageHeader(int width, int height, byte bitDepth, ColorType colorType, CompressionMethod compressionMethod, FilterMethod filterMethod, InterlaceMethod interlaceMethod) { if (width == 0) { throw new ArgumentOutOfRangeException(nameof(width), "Invalid width (0) for image."); } if (height == 0) { throw new ArgumentOutOfRangeException(nameof(height), "Invalid height (0) for image."); } if (!PermittedBitDepths.TryGetValue(colorType, out var permitted) || !permitted.Contains(bitDepth)) { throw new ArgumentException($"The bit depth {bitDepth} is not permitted for color type {colorType}."); } Width = width; Height = height; BitDepth = bitDepth; ColorType = colorType; CompressionMethod = compressionMethod; FilterMethod = filterMethod; InterlaceMethod = interlaceMethod; }
public ColumnFilterRequest(string columnName, ICollection <string> values, FilterRigor filterRigor, FilterMethod filterMethod) { this.ColumnName = columnName; this.Values = values; this.FilterRigor = filterRigor; this.FilterMethod = filterMethod; }
private static Texture2D Filter(Texture2D inTex, FilterMethod method, params object[] parameters) { float startTime = Time.realtimeSinceStartup; Color[] inPixels = null; try { inPixels = inTex.GetPixels(); } catch (UnityException e) { Debug.LogError("Error while reading the texture : " + e); return(inTex); } Color[] outPixels = new Color[inPixels.Length]; if (method != null) { method(inTex.width, inTex.height, inPixels, ref outPixels, parameters); } float endTime = Time.realtimeSinceStartup; Debug.Log(endTime - startTime); Texture2D outTex = new Texture2D(inTex.width, inTex.height); outTex.SetPixels(outPixels); outTex.Apply(); return(outTex); }
public ExperimentSettings(ExperimentSettings other) { Enabled = other.Enabled; SoundOnDiscovery = other.SoundOnDiscovery; AnimationOnDiscovery = other.AnimationOnDiscovery; StopWarpOnDiscovery = other.StopWarpOnDiscovery; Filter = other.Filter; IsDefault = other.IsDefault; }
/// <summary> /// Constructor /// </summary> /// <param name="filterData">The data to be filtered</param> /// <param name="filterCollection">The filtercollectio to be applied to</param> /// <param name="filterMethod">The filtermethod</param> /// <param name="callback">The callback for successfull filtering</param> public FilterCommand(DatabaseDataSet filterData, FilterCollection filterCollection, FilterMethod filterMethod, CommandFinishedDelegate callback) : base(Priority.Low, callback) { this.filterData = filterData; this.filterCollection = filterCollection; this.filterMethod = filterMethod; this.description = "Filter file " + this.filterData.AbsoluteFileName; }
public Ihdr(UInt32 width, UInt32 height, BitDepth bitDepth, ColorType colorType, CompressionMethod compressionMethod = CompressionMethod.Default, FilterMethod filterMethod = FilterMethod.Default, InterlaceMethod interlaceMethod = InterlaceMethod.None) : base(ChunkType.IHDR) { #region Sanity if(width == 0 || width > Int32.MaxValue) throw new ArgumentOutOfRangeException("width", "width must be greater than 0 and smaller than In32.MaxValue(2^31-1)"); if(height == 0 || height > Int32.MaxValue) throw new ArgumentOutOfRangeException("height", "height must be greater than 0 and smaller than In32.MaxValue(2^31-1)"); BitDepth[] allowedBitDepths; switch (colorType) { case ColorType.Grayscale: if(!(allowedBitDepths = new[] { BitDepth._1, BitDepth._2, BitDepth._4, BitDepth._8, BitDepth._16 }).Contains(bitDepth)) throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType)); break; case ColorType.Rgb: if(!(allowedBitDepths = new[]{BitDepth._8, BitDepth._16}).Contains(bitDepth)) throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType)); break; case ColorType.Palette: if(!(allowedBitDepths = new[] { BitDepth._1, BitDepth._2, BitDepth._4, BitDepth._8}).Contains(bitDepth)) throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType)); break; case ColorType.GrayscaleWithAlpha: if(!(allowedBitDepths = new[] { BitDepth._8, BitDepth._16}).Contains(bitDepth)) throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType)); break; case ColorType.Rgba: if(!(allowedBitDepths = new[] { BitDepth._8, BitDepth._16}).Contains(bitDepth)) throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType)); break; default: throw new ArgumentOutOfRangeException("colorType", String.Format("Unknown colorType: {0}", colorType)); } if(compressionMethod != CompressionMethod.Default) throw new ArgumentOutOfRangeException("compressionMethod", String.Format("Unknown compressionMethod: {0}", compressionMethod)); if(filterMethod != FilterMethod.Default) throw new ArgumentOutOfRangeException("filterMethod", String.Format("Unknown filterMethod: {0}", filterMethod)); var allowedInterlaceMethods = new[] {InterlaceMethod.None, InterlaceMethod.Adam7}; if(!allowedInterlaceMethods.Contains(interlaceMethod)) throw new ArgumentOutOfRangeException("interlaceMethod", String.Format("interlaceMethod must be one of {0}", allowedInterlaceMethods.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)))); #endregion Width = width; Height = height; BitDepth = bitDepth; ColorType = colorType; CompressionMethod = compressionMethod; FilterMethod = filterMethod; InterlaceMethod = interlaceMethod; }
public static IEnumerable<int> Filter(IEnumerable<int> items, FilterMethod method) { foreach (var item in items) { if (method(item)) { yield return item; } } }
public ImageHeader(int width, int height, byte bitDepth, ColorType colorType, CompressionType compression, FilterMethod filterMethod, bool interlaced) { this.Width = width; this.Height = height; this.BitDepth = bitDepth; this.ColorType = colorType; this.CompressionType = compression; this.FilterMethod = filterMethod; this.Interlaced = interlaced; }
internal ColumnFilter(TableColumn column, ColumnFilterRequest filterRequest) { if (column.Name.Trim() != filterRequest.ColumnName.Trim()) { throw new ArgumentException($"{nameof(column.Name)} is different from {nameof(filterRequest.ColumnName)}"); } this.Column = column; this.Values = filterRequest.Values; this.FilterRigor = filterRequest.FilterRigor; this.FilterMethod = filterRequest.FilterMethod; }
private List <int> Filter(List <int> numbers, FilterMethod m) { var results = new List <int>(); foreach (var num in numbers) { if (m(num)) { results.Add(num); } } return(results); }
public List <int> Filter(List <int> numbers, FilterMethod op) { var result = new List <int>(); foreach (var num in numbers) { if (op.Invoke(num)) { result.Add(num); } } return(result); }
private static List <int> Filter(List <int> numbers, FilterMethod m) { var results = new List <int>(); foreach (var num in numbers) { if (m(num)) //Don't need to call invoke since it is a default methods { results.Add(num); } } return(results); }
private static List <Product> FilterProducts(List <Product> list, FilterMethod filter) { List <Product> r = new List <Product>(); foreach (Product p in list) { if (filter(p)) { r.Add(p); } } return(r); }
public static void TestFilterList() { FilterMethod method = null; method += GreaterThan5; foreach (var item in method.GetInvocationList()) { Console.WriteLine("[1] {0}", item.Method); } method += LessThan100; foreach (var item in method.GetInvocationList()) { Console.WriteLine("[2] {0}", item.Method); } method += EqualTo4; foreach (var item in method.GetInvocationList()) { Console.WriteLine("[3] {0}", item.Method); } Console.WriteLine("method(100) {0}", method(100)); IEnumerable <int> list = new[] { 4, 34, 56, 6, 4, 2, 4, 567, 4, 3, 3 }; foreach (var item in FilterList(list, GreaterThan5)) { Console.WriteLine("GreaterThanFive:: {0}", item); } foreach (var item in FilterList(list, LessThan100)) { Console.WriteLine("LessThan100:: {0}", item); } foreach (var item in FilterList(list, n => { n--; return(n > 2); })) { Console.WriteLine("n--; n > 2:: {0}", item); } foreach (var item in FilterList(list, n => n > 2)) { Console.WriteLine("n > 2:: {0}", item); } }
public void OnLoad(ConfigNode node) { Enabled = node.Parse("Enabled", true); SoundOnDiscovery = node.Parse("SoundOnDiscovery", true); AnimationOnDiscovery = node.Parse("AnimationOnDiscovery", true); StopWarpOnDiscovery = node.Parse("StopWarpOnDiscovery", false); string value = node.GetValue("Filter"); if (string.IsNullOrEmpty(value)) { Log.Debug("[ScienceAlert]:Settings: invalid experiment filter"); value = System.Enum.GetValues(typeof(FilterMethod)).GetValue(0).ToString(); } Filter = (FilterMethod)System.Enum.Parse(typeof(FilterMethod), value); IsDefault = node.Parse("IsDefault", false); }
private static Color[] ApplyFilter(int width, int height, FilterMethod method, float startTime, Color[] inPixels, params object[] parameters) { var outPixels = new Color[inPixels.Length]; if (method != null) { method(width, height, inPixels, ref outPixels, parameters); } float endTime = Time.realtimeSinceStartup; LogUtils.DoLog($"Exec time filter apply: {endTime - startTime}s"); return(outPixels); }
private void comboBoxFilterMethod_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxFilterMethod.Text.ToLower() == "check") { this.filterMethod = FilterMethod.checks; //enable controls comboBoxChecks.Enabled = true; //disable cotrols dateTimePickerMaxDate.Enabled = false; dateTimePickerMinDate.Enabled = false; comboBoxProject.Enabled = false; } if (comboBoxFilterMethod.Text.ToLower() == "date") { this.filterMethod = FilterMethod.date; //enable controls dateTimePickerMaxDate.Enabled = true; dateTimePickerMinDate.Enabled = true; //disable cotrols comboBoxChecks.Enabled = false; comboBoxProject.Enabled = false; } if (comboBoxFilterMethod.Text.ToLower() == "project") { this.filterMethod = FilterMethod.project; //enable controls comboBoxProject.Enabled = true; //disable cotrols comboBoxChecks.Enabled = false; dateTimePickerMaxDate.Enabled = false; dateTimePickerMinDate.Enabled = false; } if (comboBoxFilterMethod.Text.ToLower() == "all") { this.filterMethod = FilterMethod.all; //enable controls comboBoxProject.Enabled = true; comboBoxChecks.Enabled = true; dateTimePickerMaxDate.Enabled = true; dateTimePickerMinDate.Enabled = true; } }
public void OnLoad(ConfigNode node) { Enabled = ConfigUtil.Parse <bool>(node, "Enabled", true); SoundOnDiscovery = ConfigUtil.Parse <bool>(node, "SoundOnDiscovery", true); AnimationOnDiscovery = ConfigUtil.Parse <bool>(node, "AnimationOnDiscovery", true); //AssumeOnboard = ConfigUtil.Parse<bool>(node, "AssumeOnboard", false); StopWarpOnDiscovery = ConfigUtil.Parse <bool>(node, "StopWarpOnDiscovery", false); var strFilterName = node.GetValue("Filter"); if (string.IsNullOrEmpty(strFilterName)) { Log.Error("Settings: invalid experiment filter"); strFilterName = Enum.GetValues(typeof(FilterMethod)).GetValue(0).ToString(); } Filter = (FilterMethod)Enum.Parse(typeof(FilterMethod), strFilterName); IsDefault = ConfigUtil.Parse <bool>(node, "IsDefault", false); }
public static string GetOperator(this FilterMethod filter) { Type type = filter.GetType(); string name = Enum.GetName(type, filter); if (name != null) { FieldInfo field = type.GetField(name); if (field != null) { DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; if (attribute != null) { return(attribute.Description); } } } return(null); }
private static Texture2D Filter(Texture2D inTex, FilterMethod method, params object[] parameters) { float startTime = Time.realtimeSinceStartup; Color[] inPixels; try { inPixels = inTex.GetPixels(); } catch (UnityException e) { Debug.LogError("Error while reading the texture : " + e); return(inTex); } Color[] outPixels = ApplyFilter(inTex.width, inTex.height, method, startTime, inPixels, parameters); var outTex = new Texture2D(inTex.width, inTex.height); outTex.SetPixels(outPixels); outTex.Apply(); return(outTex); }
public FilterData(string column, object filter, FilterMethod method) { Column = column; Filter = filter; Method = method; }
/// <summary> /// Create a new Filterset /// </summary> /// <param name="filters">The filters this FilterSet has</param> /// <param name="method">The method this FilterSet filters with</param> public FilterSet(IFilter[] filters, FilterMethod method) { this.FilterMethod = method; this.filters = new List <IFilter>(filters); this.IsValid = true; }
/// <summary> /// Changing filter method, automatically changes time domain to <see cref="TimeDomain.DiscreteTime"/>. /// </summary> public IPIDController SetFilterMethod(FilterMethod method) { base._TimeDomain = TimeDomain.DiscreteTime; base._FilterMethod = method; return(this); }
/// <summary> /// Rescales the Layer, stretching it to the specified size. /// </summary> /// <param name="w"></param> /// <param name="h"></param> /// <param name="filter">The filtering method to use when rescaling</param> public void Rescale(int w, int h, FilterMethod filter = FilterMethod.Linear) { ColorRgba[] result = this.InternalRescale(w, h, filter); if (result == null) return; this.data = result; this.width = w; this.height = h; return; }
public override void Load(byte [] data) { Width = BitConverter.ToUInt32 (data, 0, false); Height = BitConverter.ToUInt32 (data, 4, false); Depth = data [8]; Color = (ColorType) data [9]; //if (Color != ColorType.Rgb) // throw new System.Exception (System.String.Format ("unsupported {0}", Color)); this.Compression = (CompressionMethod) data [10]; if (this.Compression != CompressionMethod.Zlib) throw new System.Exception (System.String.Format ("unsupported {0}", Compression)); Filter = (FilterMethod) data [11]; if (Filter != FilterMethod.Adaptive) throw new System.Exception (System.String.Format ("unsupported {0}", Filter)); Interlace = (InterlaceMethod) data [12]; //if (Interlace != InterlaceMethod.None) // throw new System.Exception (System.String.Format ("unsupported {0}", Interlace)); }
/// <summary>Creates a new collection from provided project, collection will contain all resource files in the project</summary> /// <param name="project">Root project object used to create this collection</param> /// <param name="filteringMethod">Filtering method to be used when recursing through the project. If the method is specified and it returns false, item will not be included in the collection</param> public FilteredProjectCollection(Project project, FilterMethod filteringMethod) { this.project = project; this.FilteringMethod = filteringMethod; this.rootNode = CreateProjectFileTree(this.project); }
/// <summary> /// Rescales the Layer, stretching it to the specified size. /// </summary> /// <param name="w"></param> /// <param name="h"></param> /// <param name="filter">The filtering method to use when rescaling</param> public Layer CloneRescale(int w, int h, FilterMethod filter = FilterMethod.Linear) { ColorRgba[] result = this.InternalRescale(w, h, filter); if (result == null) return this.Clone(); return new Layer(w, h, result); }
/// <summary> /// Creates an instance of this class /// </summary> /// <param name="filterMethod">The filter method to be used</param> public GeometryComponentFilter(FilterMethod filterMethod) { //Assert.IsTrue(filterMethod != null); _do = filterMethod; }
/// <summary>Creates a new collection from provided project, collection will contain all resource files in the project</summary> /// <param name="project">Project to load resource files from</param> /// <param name="filter">Filtering method to decide whether to include a file or not</param> public ResourceFileCollection(Project project, FilterMethod filter) : base(project) { this.FilteringMethod = new FilterMethod(this.IsValidResource); this.supplementFilter = filter; this.RefreshListOfFiles(); }
private ColorRgba[] InternalRescale(int w, int h, FilterMethod filter) { if (this.width == w && this.height == h) return null; ColorRgba[] tempDestData = new ColorRgba[w * h]; if (filter == FilterMethod.Nearest) { // Don't use Parallel.For here, the overhead is too big and the compiler // does a great job optimizing this piece of code without, so don't get in the way. for (int i = 0; i < tempDestData.Length; i++) { int y = i / w; int x = i - (y * w); int xTmp = (x * this.width) / w; int yTmp = (y * this.height) / h; int nTmp = xTmp + (yTmp * this.width); tempDestData[i] = this.data[nTmp]; } } else if (filter == FilterMethod.Linear) { //for (int i = 0; i < tempDestData.Length; i++) System.Threading.Tasks.Parallel.For(0, tempDestData.Length, i => { int y = i / w; int x = i - (y * w); float xRatio = ((float)(x * this.width) / (float)w) + 0.5f; float yRatio = ((float)(y * this.height) / (float)h) + 0.5f; int xTmp = (int)xRatio; int yTmp = (int)yRatio; xRatio -= xTmp; yRatio -= yTmp; int xTmp2 = xTmp + 1; int yTmp2 = yTmp + 1; xTmp = xTmp < this.width ? xTmp : this.width - 1; yTmp = (yTmp < this.height ? yTmp : this.height - 1) * this.width; xTmp2 = xTmp2 < this.width ? xTmp2 : this.width - 1; yTmp2 = (yTmp2 < this.height ? yTmp2 : this.height - 1) * this.width; int nTmp0 = xTmp + yTmp; int nTmp1 = xTmp2 + yTmp; int nTmp2 = xTmp + yTmp2; int nTmp3 = xTmp2 + yTmp2; tempDestData[i].R = (byte) ( ((float)this.data[nTmp0].R * (1.0f - xRatio) * (1.0f - yRatio)) + ((float)this.data[nTmp1].R * xRatio * (1.0f - yRatio)) + ((float)this.data[nTmp2].R * yRatio * (1.0f - xRatio)) + ((float)this.data[nTmp3].R * xRatio * yRatio) ); tempDestData[i].G = (byte) ( ((float)this.data[nTmp0].G * (1.0f - xRatio) * (1.0f - yRatio)) + ((float)this.data[nTmp1].G * xRatio * (1.0f - yRatio)) + ((float)this.data[nTmp2].G * yRatio * (1.0f - xRatio)) + ((float)this.data[nTmp3].G * xRatio * yRatio) ); tempDestData[i].B = (byte) ( ((float)this.data[nTmp0].B * (1.0f - xRatio) * (1.0f - yRatio)) + ((float)this.data[nTmp1].B * xRatio * (1.0f - yRatio)) + ((float)this.data[nTmp2].B * yRatio * (1.0f - xRatio)) + ((float)this.data[nTmp3].B * xRatio * yRatio) ); tempDestData[i].A = (byte) ( ((float)this.data[nTmp0].A * (1.0f - xRatio) * (1.0f - yRatio)) + ((float)this.data[nTmp1].A * xRatio * (1.0f - yRatio)) + ((float)this.data[nTmp2].A * yRatio * (1.0f - xRatio)) + ((float)this.data[nTmp3].A * xRatio * yRatio) ); }); } return tempDestData; }
public void Filter_WhenColumnToFilterAlreadyInFilterList_ShouldDuplicateFilter(string columnName, string value, FilterRigor rigor, FilterMethod method) { // Arrange var values = new List <string> { value, value }; var connectionString = "Data Source=190.190.200.100,1433;Initial Catalog = myDataBase;User ID = myUsername;Password = myPassword;"; var columnsInTable = new string[] { "column1", "column2", "column3" }; var queryExecutorResolverMock = GetQueryExecutorResolverMockWithColumns(columnsInTable); Lifecycle.Container.RegisterInstance(typeof(IQueryExecutorResolver), queryExecutorResolverMock); var dbConnectionMock = new Mock <DbConnection>(); dbConnectionMock.Setup(conn => conn.ConnectionString).Returns(connectionString); var ctx = new SLORMContext(dbConnectionMock.Object, connectionString); var columnFilter = new ColumnFilterRequest(columnName, values, rigor, method); ctx.Filter(columnFilter); // Act ctx.Filter(columnFilter); // Assert var filterRequestCount = ctx.ColumnsToFilter.Where(c => c.Column.Name == columnFilter.ColumnName && c.FilterMethod == columnFilter.FilterMethod && c.FilterRigor == columnFilter.FilterRigor).Count(); Assert.Equal(2, filterRequestCount); }
public SLORMContext Filter(string columnName, ICollection <string> values, FilterRigor rigor, FilterMethod method) { var filterRequest = new ColumnFilterRequest(columnName, values, rigor, method); return(Filter(filterRequest)); }