Esempio n. 1
0
 public LibraryCondition(FilteringMode filteringMode, FilteringCondition condition, int maxLimitNum = 0, string filteringText = null)
 {
     FilteringMode = filteringMode;
     Condition = condition?? FilteringCondition.Empty;
     MaxLimitNum = maxLimitNum;
     FilteringText = filteringText;
 }
Esempio n. 2
0
        /// <summary>
        /// Sets the IIR filter mode.
        /// </summary>
        /// <param name="filteringMode"></param>
        public void SetFilterMode(FilteringMode filteringMode)
        {
            byte current = Read8BitsFromRegister((byte)Register.CONFIG);

            current = (byte)((current & 0b1110_0011) | (byte)filteringMode << 2);
            _i2cDevice.Write(new[] { (byte)Register.CONFIG, current });
        }
Esempio n. 3
0
 public virtual void SetFiltering(FilteringMode mode)
 {
     device.BindTexture(textureTarget, Handle);
     device.TexParameteri(textureTarget, TextureParameterName.TextureMinFilter, mode == FilteringMode.Nearest ? (int)TextureMinFilter.NearestMipmapNearest : (int)TextureMinFilter.LinearMipmapLinear);
     device.TexParameteri(textureTarget, TextureParameterName.TextureMagFilter, mode == FilteringMode.Nearest ? (int)TextureMagFilter.Nearest : (int)TextureMagFilter.Linear);
     device.BindTexture(textureTarget, 0);
 }
        /// <summary>Initialises a new instance of the <see cref="BrowserFilter"/> class.</summary>
        public BrowserFilter()
        {
            this.filteringMode = FilteringMode.IncludeAll;

            this.extensionsList.Add(string.Empty);
            this.extensionsList.Add(".ini");
            this.extensionsList.Add(".lnk");
            this.extensionsList.Add(".sys");
        }
        internal static void ReadValuesShouldBeParams(Parameters param, out FilteringMode filterMode, out double threshold,
                                                      out double threshold2)
        {
            ParameterWithSubParams <int> x = param.GetParamWithSubParams <int>("Values should be");
            Parameters subParams           = x.GetSubParameters();
            int        shouldBeIndex       = x.Value;

            threshold  = double.NaN;
            threshold2 = double.NaN;
            switch (shouldBeIndex)
            {
            case 0:
                filterMode = FilteringMode.Valid;
                break;

            case 1:
                filterMode = FilteringMode.GreaterThan;
                threshold  = subParams.GetParam <double>("Minimum").Value;
                break;

            case 2:
                filterMode = FilteringMode.GreaterEqualThan;
                threshold  = subParams.GetParam <double>("Minimum").Value;
                break;

            case 3:
                filterMode = FilteringMode.LessThan;
                threshold  = subParams.GetParam <double>("Maximum").Value;
                break;

            case 4:
                filterMode = FilteringMode.LessEqualThan;
                threshold  = subParams.GetParam <double>("Maximum").Value;
                break;

            case 5:
                filterMode = FilteringMode.Between;
                threshold  = subParams.GetParam <double>("Minimum").Value;
                threshold2 = subParams.GetParam <double>("Maximum").Value;
                break;

            case 6:
                filterMode = FilteringMode.Outside;
                threshold  = subParams.GetParam <double>("Minimum").Value;
                threshold2 = subParams.GetParam <double>("Maximum").Value;
                break;

            default:
                throw new Exception("Should not happen.");
            }
        }
Esempio n. 6
0
        /// <summary>Shows a modal <see cref="FileSystemBrowserWindow"/> when the button is clicked.</summary>
        /// <param name="sender">The sender object of the event handler.</param>
        /// <param name="e">The state information of the event handler.</param>
        private void ShowDialogButton_Click(object sender, RoutedEventArgs e)
        {
            FilteringMode filteringMode = (FilteringMode)Enum.Parse(typeof(FilteringMode), this.filteringModeComboBox.SelectedValue.ToString());

            BrowserFilter browserFilter = new BrowserFilter(filteringMode);

            foreach (string extension in this.extensionsTextBox.Text.Split(';'))
            {
                browserFilter.AddExtension(extension);
            }

            BrowserSettings browserSettings = new BrowserSettings();

            CultureInfo currentCultureInfo = Thread.CurrentThread.CurrentCulture;

            browserSettings.BrowsingMode          = (BrowsingMode)Enum.Parse(typeof(BrowsingMode), this.browsingModeComboBox.SelectedValue.ToString());
            browserSettings.ByteMultiple          = (ByteMultiple)Enum.Parse(typeof(ByteMultiple), this.byteMultipleComboBox.SelectedValue.ToString());
            browserSettings.HasAvailableFreeSpace = (bool)this.hasAvailableFreeSpace.IsChecked;
            browserSettings.HasDriveFormat        = (bool)this.hasDriveFormat.IsChecked;
            browserSettings.HasDriveType          = (bool)this.hasDriveType.IsChecked;
            browserSettings.HasRootDirectory      = (bool)this.hasRootDirectory.IsChecked;
            browserSettings.HasTotalFreeSpace     = (bool)this.hasTotalFreeSpace.IsChecked;
            browserSettings.HasTotalSize          = (bool)this.hasTotalSize.IsChecked;
            browserSettings.HasVolumeLabel        = (bool)this.hasVolumeLabel.IsChecked;
            browserSettings.MaximumFiles          = int.Parse(this.maximumFilesTextBox.Text, currentCultureInfo);
            browserSettings.MaximumDirectories    = int.Parse(this.maximumDirectoriesTextBox.Text, currentCultureInfo);
            browserSettings.MinimumFiles          = int.Parse(this.minimumFilesTextBox.Text, currentCultureInfo);
            browserSettings.MinimumDirectories    = int.Parse(this.minimumDirectoriesTextBox.Text, currentCultureInfo);
            browserSettings.Path = this.pathTextBox.Text;

            FileSystemBrowserWindow fileSystemBrowserWindow = new FileSystemBrowserWindow(browserFilter, browserSettings);

            fileSystemBrowserWindow.Owner = this;

            if (fileSystemBrowserWindow.ShowDialog() ?? true)
            {
                foreach (string directory in fileSystemBrowserWindow.SelectedDirectories)
                {
                    this.resultListView.Items.Add(new { Type = "Directory", Path = directory });
                }

                foreach (string file in fileSystemBrowserWindow.SelectedFiles)
                {
                    this.resultListView.Items.Add(new { Type = "File", Path = file });
                }
            }
        }
 internal static void NonzeroFilter1(bool rows, int minValids, bool percentage, IMatrixData mdata, Parameters param,
                                     double threshold, double threshold2, FilteringMode filterMode)
 {
     if (rows)
     {
         List <int> valids = new List <int>();
         for (int i = 0; i < mdata.RowCount; i++)
         {
             int count = 0;
             for (int j = 0; j < mdata.ColumnCount; j++)
             {
                 if (IsValid(mdata.Values.Get(i, j), threshold, threshold2, filterMode))
                 {
                     count++;
                 }
             }
             if (Valid(count, minValids, percentage, mdata.ColumnCount))
             {
                 valids.Add(i);
             }
         }
         FilterRows(mdata, param, valids.ToArray());
     }
     else
     {
         List <int> valids = new List <int>();
         for (int j = 0; j < mdata.ColumnCount; j++)
         {
             int count = 0;
             for (int i = 0; i < mdata.RowCount; i++)
             {
                 if (IsValid(mdata.Values.Get(i, j), threshold, threshold2, filterMode))
                 {
                     count++;
                 }
             }
             if (Valid(count, minValids, percentage, mdata.RowCount))
             {
                 valids.Add(j);
             }
         }
         FilterColumns(mdata, param, valids.ToArray());
     }
 }
Esempio n. 8
0
        public bool ApplyFilters(ChatMessage targetMessage, FilteringMode mode)
        {
            bool filtered = true;

            if (targetMessage == null)
            {
                return(false);
            }
            lock (this.availableFilters)
            {
                if (this.availableFilters.Count == 0)
                {
                    return(false);
                }
                switch (mode)
                {
                case FilteringMode.And:
                    for (int i = 0; i < this.availableFilters.Count; i++)
                    {
                        if (!this.availableFilters[i].Query(targetMessage))
                        {
                            filtered = false;
                            break;
                        }
                    }
                    break;

                case FilteringMode.Or:
                    for (int i = 0; i < this.availableFilters.Count; i++)
                    {
                        if (this.availableFilters[i].Query(targetMessage))
                        {
                            filtered = true;
                            break;
                        }
                    }
                    break;
                }
            }
            return(filtered);
        }
Esempio n. 9
0
 public void SetFiltering(FilteringMode mode)
 {
     underlyingTexture.SetFiltering(mode);
 }
Esempio n. 10
0
 public DiffRefreshAction(FilteringMode filteringMode) : base(filteringMode)
 {
     
 }
        private static void NonzeroFilterGroup(int minValids, bool percentage, IMatrixData mdata, Parameters param,
			bool oneGroup, double threshold, double threshold2, FilteringMode filterMode, IList<string[]> groupCol)
        {
            List<int> valids = new List<int>();
            string[] groupVals = ArrayUtils.UniqueValuesPreserveOrder(groupCol);
            Array.Sort(groupVals);
            int[][] groupInds = CalcGroupInds(groupVals, groupCol);
            for (int i = 0; i < mdata.RowCount; i++){
                int[] counts = new int[groupVals.Length];
                int[] totals = new int[groupVals.Length];
                for (int j = 0; j < groupInds.Length; j++){
                    for (int k = 0; k < groupInds[j].Length; k++){
                        if (groupInds[j][k] >= 0){
                            totals[groupInds[j][k]]++;
                        }
                    }
                    if (PerseusPluginUtils.IsValid(mdata.Values.Get(i, j), threshold, threshold2, filterMode)){
                        for (int k = 0; k < groupInds[j].Length; k++){
                            if (groupInds[j][k] >= 0){
                                counts[groupInds[j][k]]++;
                            }
                        }
                    }
                }
                bool[] groupValid = new bool[counts.Length];
                for (int j = 0; j < groupValid.Length; j++){
                    groupValid[j] = PerseusPluginUtils.Valid(counts[j], minValids, percentage, totals[j]);
                }
                if (oneGroup ? ArrayUtils.Or(groupValid) : ArrayUtils.And(groupValid)){
                    valids.Add(i);
                }
            }
            PerseusPluginUtils.FilterRows(mdata, param, valids.ToArray());
        }
Esempio n. 12
0
 /// <summary>
 /// 构造一个 <see cref="FilteringRegex"/>。
 /// </summary>
 /// <param name="pattern">给定的模式字符串。</param>
 /// <param name="filtering">给定的 <see cref="FilteringMode"/>。</param>
 public FilteringRegex(string pattern, FilteringMode filtering)
     : base(pattern)
 {
     Filtering = filtering;
 }
Esempio n. 13
0
 /// <summary>
 /// 构造一个 <see cref="FilteringRegex"/>。
 /// </summary>
 /// <param name="pattern">给定的模式字符串。</param>
 /// <param name="filtering">给定的 <see cref="FilteringMode"/>。</param>
 /// <param name="options">给定的 <see cref="RegexOptions"/>。</param>
 public FilteringRegex(string pattern, FilteringMode filtering, RegexOptions options)
     : base(pattern, options)
 {
     Filtering = filtering;
 }
 /// <summary>Initialises a new instance of the <see cref="BrowserFilter"/> class.</summary>
 /// <param name="filteringMode">The filtering mode for the <see cref="filteringMode"/> field.</param>
 public BrowserFilter(FilteringMode filteringMode)
 {
     this.filteringMode = filteringMode;
 }
        internal static void ReadValuesShouldBeParams(Parameters param, out FilteringMode filterMode, out double threshold,
			out double threshold2)
        {
            ParameterWithSubParams<int> x = param.GetParamWithSubParams<int>("Values should be");
            Parameters subParams = x.GetSubParameters();
            int shouldBeIndex = x.Value;
            threshold = double.NaN;
            threshold2 = double.NaN;
            switch (shouldBeIndex){
                case 0:
                    filterMode = FilteringMode.Valid;
                    break;
                case 1:
                    filterMode = FilteringMode.GreaterThan;
                    threshold = subParams.GetParam<double>("Minimum").Value;
                    break;
                case 2:
                    filterMode = FilteringMode.GreaterEqualThan;
                    threshold = subParams.GetParam<double>("Minimum").Value;
                    break;
                case 3:
                    filterMode = FilteringMode.LessThan;
                    threshold = subParams.GetParam<double>("Maximum").Value;
                    break;
                case 4:
                    filterMode = FilteringMode.LessEqualThan;
                    threshold = subParams.GetParam<double>("Maximum").Value;
                    break;
                case 5:
                    filterMode = FilteringMode.Between;
                    threshold = subParams.GetParam<double>("Minimum").Value;
                    threshold2 = subParams.GetParam<double>("Maximum").Value;
                    break;
                case 6:
                    filterMode = FilteringMode.Outside;
                    threshold = subParams.GetParam<double>("Minimum").Value;
                    threshold2 = subParams.GetParam<double>("Maximum").Value;
                    break;
                default:
                    throw new Exception("Should not happen.");
            }
        }
        internal static void NonzeroFilter1(bool rows, int minValids, bool percentage, IMatrixData mdata, Parameters param,
			double threshold, double threshold2, FilteringMode filterMode)
        {
            if (rows){
                List<int> valids = new List<int>();
                for (int i = 0; i < mdata.RowCount; i++){
                    int count = 0;
                    for (int j = 0; j < mdata.ColumnCount; j++){
                        if (IsValid(mdata.Values.Get(i, j), threshold, threshold2, filterMode)){
                            count++;
                        }
                    }
                    if (Valid(count, minValids, percentage, mdata.ColumnCount)){
                        valids.Add(i);
                    }
                }
                FilterRows(mdata, param, valids.ToArray());
            } else{
                List<int> valids = new List<int>();
                for (int j = 0; j < mdata.ColumnCount; j++){
                    int count = 0;
                    for (int i = 0; i < mdata.RowCount; i++){
                        if (IsValid(mdata.Values.Get(i, j), threshold, threshold2, filterMode)){
                            count++;
                        }
                    }
                    if (Valid(count, minValids, percentage, mdata.RowCount)){
                        valids.Add(j);
                    }
                }
                FilterColumns(mdata, param, valids.ToArray());
            }
        }
Esempio n. 17
0
 /// <summary>
 /// 构造一个 <see cref="FilteringRegex"/>。
 /// </summary>
 /// <param name="pattern">给定的模式字符串。</param>
 /// <param name="filtering">给定的 <see cref="FilteringMode"/>。</param>
 /// <param name="options">给定的 <see cref="RegexOptions"/>。</param>
 /// <param name="matchTimeout">给定的 <see cref="TimeSpan"/>。</param>
 public FilteringRegex(string pattern, FilteringMode filtering, RegexOptions options, TimeSpan matchTimeout)
     : base(pattern, options, matchTimeout)
 {
     Filtering = filtering;
 }
Esempio n. 18
0
        public override void Save()
        {
            string path = System.IO.Path.ChangeExtension(fileName_, "xml");

            if (DefaultValue.IsDefault(this))
            {
                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }
                return;
            }

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("texture");

            doc.AppendChild(root);

            XmlElement addr = writeAddress(doc, "u", UAddress);

            if (addr != null && !DefaultValue.IsDefault(this, "UAddress"))
            {
                root.AppendChild(addr);
            }
            addr = writeAddress(doc, "v", VAddress);
            if (addr != null && !DefaultValue.IsDefault(this, "VAddress"))
            {
                root.AppendChild(addr);
            }
            addr = writeAddress(doc, "w", WAddress);
            if (addr != null && !DefaultValue.IsDefault(this, "WAddress"))
            {
                root.AppendChild(addr);
            }

            if (BorderColor != null && !DefaultValue.IsDefault(this, "BorderColor"))
            {
                XmlElement bc = doc.CreateElement("border");
                bc.SetAttribute("color", UColor.ColorToString(BorderColor));
                root.AppendChild(bc);
            }

            XmlElement filt = doc.CreateElement("filter");

            filt.SetAttribute("mode", FilteringMode.ToString().ToLower());
            if (!DefaultValue.IsDefault(this, "FilteringMode"))
            {
                root.AppendChild(filt);
            }

            if (Mipmapping && !DefaultValue.IsDefault(this, "Mipmapping"))
            {
                XmlElement elem = doc.CreateElement("mipmap");
                elem.SetAttribute("enabled", "true");
                root.AppendChild(elem);
            }

            if (SRGBEnabled && !DefaultValue.IsDefault(this, "SRGBEnabled"))
            {
                XmlElement elem = doc.CreateElement("srgb");
                elem.SetAttribute("enabled", "true");
                root.AppendChild(elem);
            }

            XmlWriterSettings xws = new XmlWriterSettings {
                OmitXmlDeclaration = true, Indent = true
            };

            using (XmlWriter xw = XmlWriter.Create(System.IO.Path.ChangeExtension(Name, "xml"), xws))
                doc.Save(xw);
        }
Esempio n. 19
0
 public RefreshAction(FilteringMode filteringMode)
 {
     _filteringMode = filteringMode;
 }
        private static void NonzeroFilter1(bool rows, int minValids, IMatrixData mdata, Parameters param, double threshold,
			double threshold2, FilteringMode filterMode)
        {
            if (rows){
                List<int> valids = new List<int>();
                for (int i = 0; i < mdata.RowCount; i++){
                    int count = 0;
                    for (int j = 0; j < mdata.ExpressionColumnCount; j++){
                        if (Valid(mdata[i, j], threshold, threshold2, filterMode)){
                            count++;
                        }
                    }
                    if (count >= minValids){
                        valids.Add(i);
                    }
                }
                PerseusPluginUtils.FilterRows(mdata, param, valids.ToArray());
            } else{
                List<int> valids = new List<int>();
                for (int j = 0; j < mdata.ExpressionColumnCount; j++){
                    int count = 0;
                    for (int i = 0; i < mdata.RowCount; i++){
                        if (Valid(mdata[i, j], threshold, threshold2, filterMode)){
                            count++;
                        }
                    }
                    if (count >= minValids){
                        valids.Add(j);
                    }
                }
                PerseusPluginUtils.FilterColumns(mdata, param, valids.ToArray());
            }
        }
Esempio n. 21
0
 public void SetFiltering(FilteringMode mode)
 {
     throw new Exception();
 }
        private static void NonzeroFilterGroup(int minValids, IMatrixData mdata, Parameters param, bool oneGroup,
			double threshold, double threshold2, FilteringMode filterMode, IList<string[]> groupCol)
        {
            List<int> valids = new List<int>();
            string[] groupVals = ArrayUtils.UniqueValuesPreserveOrder(groupCol);
            Array.Sort(groupVals);
            int[][] groupInds = CalcGroupInds(groupVals, groupCol);
            for (int i = 0; i < mdata.RowCount; i++){
                int[] counts = new int[groupVals.Length];
                for (int j = 0; j < mdata.ExpressionColumnCount; j++){
                    if (Valid(mdata[i, j], threshold, threshold2, filterMode)){
                        for (int k = 0; k < groupInds[j].Length; k++){
                            if (groupInds[j][k] >= 0){
                                counts[groupInds[j][k]]++;
                            }
                        }
                    }
                }
                if ((oneGroup ? ArrayUtils.Max(counts) : ArrayUtils.Min(counts)) >= minValids){
                    valids.Add(i);
                }
            }
            PerseusPluginUtils.FilterRows(mdata, param, valids.ToArray());
        }
        internal static bool IsValid(double data, double threshold, double threshold2, FilteringMode filterMode)
        {
            switch (filterMode)
            {
            case FilteringMode.Valid:
                return(!double.IsNaN(data) && !double.IsNaN(data));

            case FilteringMode.GreaterThan:
                return(data > threshold);

            case FilteringMode.GreaterEqualThan:
                return(data >= threshold);

            case FilteringMode.LessThan:
                return(data < threshold);

            case FilteringMode.LessEqualThan:
                return(data <= threshold);

            case FilteringMode.Between:
                return(data >= threshold && data <= threshold2);

            case FilteringMode.Outside:
                return(data < threshold || data > threshold2);
            }
            throw new Exception("Never get here.");
        }
 private static bool Valid(double data, double threshold, double threshold2, FilteringMode filterMode)
 {
     switch (filterMode){
         case FilteringMode.Valid:
             return !double.IsNaN(data) && !double.IsNaN(data);
         case FilteringMode.GreaterThan:
             return data > threshold;
         case FilteringMode.GreaterEqualThan:
             return data >= threshold;
         case FilteringMode.LessThan:
             return data < threshold;
         case FilteringMode.LessEqualThan:
             return data <= threshold;
         case FilteringMode.Between:
             return data >= threshold && data <= threshold2;
         case FilteringMode.Outside:
             return data < threshold || data > threshold2;
     }
     throw new Exception("Never get here.");
 }
Esempio n. 25
0
        private static void NonzeroFilterGroup(int minValids, bool percentage, IMatrixData mdata, Parameters param,
                                               bool oneGroup, double threshold, double threshold2, FilteringMode filterMode, IList <string[]> groupCol)
        {
            List <int> valids = new List <int>();

            string[] groupVals = ArrayUtils.UniqueValuesPreserveOrder(groupCol);
            Array.Sort(groupVals);
            int[][] groupInds = CalcGroupInds(groupVals, groupCol);
            for (int i = 0; i < mdata.RowCount; i++)
            {
                int[] counts = new int[groupVals.Length];
                int[] totals = new int[groupVals.Length];
                for (int j = 0; j < groupInds.Length; j++)
                {
                    for (int k = 0; k < groupInds[j].Length; k++)
                    {
                        if (groupInds[j][k] >= 0)
                        {
                            totals[groupInds[j][k]]++;
                        }
                    }
                    if (PerseusPluginUtils.IsValid(mdata.Values.Get(i, j), threshold, threshold2, filterMode))
                    {
                        for (int k = 0; k < groupInds[j].Length; k++)
                        {
                            if (groupInds[j][k] >= 0)
                            {
                                counts[groupInds[j][k]]++;
                            }
                        }
                    }
                }
                bool[] groupValid = new bool[counts.Length];
                for (int j = 0; j < groupValid.Length; j++)
                {
                    groupValid[j] = PerseusPluginUtils.Valid(counts[j], minValids, percentage, totals[j]);
                }
                if (oneGroup ? ArrayUtils.Or(groupValid) : ArrayUtils.And(groupValid))
                {
                    valids.Add(i);
                }
            }
            PerseusPluginUtils.FilterRows(mdata, param, valids.ToArray());
        }
Esempio n. 26
0
 internal static IMatrixData NonzeroFilter1Split(bool rows, int minValids, bool percentage, IMatrixData mdata,
                                                 Parameters param, double threshold, double threshold2, FilteringMode filterMode)
 {
     if (rows)
     {
         IMatrixData supplTab  = (IMatrixData)mdata.Clone();
         List <int>  valids    = new List <int>();
         List <int>  notvalids = new List <int>();
         for (int i = 0; i < mdata.RowCount; i++)
         {
             int count = 0;
             for (int j = 0; j < mdata.ColumnCount; j++)
             {
                 if ((IsValid(mdata.Values.Get(i, j), threshold, threshold2, filterMode)))
                 {
                     count++;
                 }
             }
             if ((Valid(count, minValids, percentage, mdata.ColumnCount)))
             {
                 valids.Add(i);
             }
             else
             {
                 notvalids.Add(i);
             }
         }
         //  FilterRowsNew(mdata, param, valids.ToArray());
         supplTab.ExtractRows(notvalids.ToArray());
         return(supplTab);
     }
     else
     {
         IMatrixData supplTab  = (IMatrixData)mdata.Clone();
         List <int>  valids    = new List <int>();
         List <int>  notvalids = new List <int>();
         for (int j = 0; j < mdata.ColumnCount; j++)
         {
             int count = 0;
             for (int i = 0; i < mdata.RowCount; i++)
             {
                 if (IsValid(mdata.Values.Get(i, j), threshold, threshold2, filterMode))
                 {
                     count++;
                 }
             }
             if (Valid(count, minValids, percentage, mdata.RowCount))
             {
                 valids.Add(j);
             }
             else
             {
                 notvalids.Add(j);
             }
         }
         supplTab.ExtractColumns(notvalids.ToArray());
         // FilterColumnsNew(mdata, param, valids.ToArray());
         return(supplTab);
     }
 }