예제 #1
0
        public List <string> Filter(string input, string filterInput)
        {
            var start   = DateTime.Now;
            var filters = new List <string>();

            try
            {
                var inputArray = input.Split('\n');
                foreach (var filter in filterInput.Split('\n'))
                {
                    filters.Add(filter.ToLower());
                }

                foreach (string filter in filters)
                {
                    if (inputArray.Any(s => s.ToLower().Contains(filter)))
                    {
                        Filtered.AddRange(
                            inputArray.Where(s => s.Contains(filter))
                            );
                    }
                }
            }
            catch (Exception e)
            {
                Error = e.Message;
            }
            Filtered.Sort();
            Filtered = Filtered.Distinct().ToList();
            Duration = (DateTime.Now - start).TotalSeconds;
            return(Filtered);
        }
        private int FilterMdexSources()
        {
            if (Verbose)
            {
                Console.WriteLine();
                Console.WriteLine("Setting mdex source cutoff to snr >= 20");
            }

            Filtered   = Filtered.Filter(IsInSnrRange);
            Unfiltered = Unfiltered.Filter(IsInSnrRange);

            if (Verbose)
            {
                Console.WriteLine(
                    "Filtered mdex reduced to {0} sources",
                    Filtered.Count);

                Console.WriteLine(
                    "Unfiltered mdex reduced to {0} sources",
                    Unfiltered.Count);
            }

            return(Status);

            bool IsInSnrRange(ISource source)
            {
                var snrSource = source as ISnrSource;

                return(snrSource.SignalToNoise >= 20);
            }
        }
예제 #3
0
 public override void Filter(User i_Friend)
 {
     if (i_Friend.Location.Name.Equals(m_CityName))
     {
         Filtered.Add(Current);
     }
 }
예제 #4
0
        public void Refresh()
        {
            var tasks    = _repository.GetAllExecutors(_isFullInfoRequired);
            var filtered = tasks.Select(x => new ExecutorVM(x)).ToList();

            Filtered.Clear();
            filtered.ForEach(x => Filtered.Add(x));
        }
예제 #5
0
        /// <summary>
        /// Returns true if Entry instances are equal
        /// </summary>
        /// <param name="other">Instance of Entry to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Entry other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                     ) &&
                 (
                     DateString == other.DateString ||
                     DateString != null &&
                     DateString.Equals(other.DateString)
                 ) &&
                 (
                     Date == other.Date ||
                     Date != null &&
                     Date.Equals(other.Date)
                 ) &&
                 (
                     Sgv == other.Sgv ||
                     Sgv != null &&
                     Sgv.Equals(other.Sgv)
                 ) &&
                 (
                     Direction == other.Direction ||
                     Direction != null &&
                     Direction.Equals(other.Direction)
                 ) &&
                 (
                     Noise == other.Noise ||
                     Noise != null &&
                     Noise.Equals(other.Noise)
                 ) &&
                 (
                     Filtered == other.Filtered ||
                     Filtered != null &&
                     Filtered.Equals(other.Filtered)
                 ) &&
                 (
                     Unfiltered == other.Unfiltered ||
                     Unfiltered != null &&
                     Unfiltered.Equals(other.Unfiltered)
                 ) &&
                 (
                     Rssi == other.Rssi ||
                     Rssi != null &&
                     Rssi.Equals(other.Rssi)
                 ));
        }
예제 #6
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Type != null)
                {
                    hash = hash * 59 + Type.GetHashCode();
                }

                if (DateString != null)
                {
                    hash = hash * 59 + DateString.GetHashCode();
                }

                if (Date != null)
                {
                    hash = hash * 59 + Date.GetHashCode();
                }

                if (Sgv != null)
                {
                    hash = hash * 59 + Sgv.GetHashCode();
                }

                if (Direction != null)
                {
                    hash = hash * 59 + Direction.GetHashCode();
                }

                if (Noise != null)
                {
                    hash = hash * 59 + Noise.GetHashCode();
                }

                if (Filtered != null)
                {
                    hash = hash * 59 + Filtered.GetHashCode();
                }

                if (Unfiltered != null)
                {
                    hash = hash * 59 + Unfiltered.GetHashCode();
                }

                if (Rssi != null)
                {
                    hash = hash * 59 + Rssi.GetHashCode();
                }

                return(hash);
            }
        }
예제 #7
0
        public ExecutorsVM(IExecutorRepository executorRep, AppSettings appSettings)
        {
            _repository    = executorRep;
            _isAllSelected = Filtered.All(x => x.IsSelected);
            Refresh();

            //_dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            //_dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            //_dispatcherTimer.Interval = appSettings.RefreshUITimeout;
            //_dispatcherTimer.Start();
        }
예제 #8
0
        public override void Filter(User i_Friend)
        {
            Current = i_Friend;

            foreach (Page page in i_Friend.LikedPages)
            {
                if (page.Id.Equals(m_PageID))
                {
                    Filtered.Add(Current);
                }
            }
        }
예제 #9
0
        protected override void LoadComplete()
        {
            base.LoadComplete();
            Active.BindValueChanged(_ =>
            {
                playStateChangeSamples();
                UpdateState();
            });
            Filtered.BindValueChanged(_ => updateFilterState());

            UpdateState();
            FinishTransforms(true);
        }
예제 #10
0
        public IList <string> Knowledge(string filter)
        {
            IEnumerable <string> result =
                new Yaapii.Atoms.Enumerable.Mapped <string, string>(
                    name => new Normalized(name).AsString(),
                    this.mem.Keys
                    );

            if (filter != "")
            {
                result = new Filtered <string>(name => name.StartsWith(filter), result);
            }
            return(new ListOf <string>(result));
        }
예제 #11
0
        private int FilterBounds()
        {
            if (Verbose)
            {
                Console.WriteLine();
                Console.WriteLine("Calculating intersection of regions");
            }

            var bounds1 = SourceMatchLists.GetBounds(Filtered);
            var bounds2 = SourceMatchLists.GetBounds(Spitzer);

            var minRa = Angle.FromRadians(
                Max(bounds1.minRa.Radians, bounds2.minRa.Radians));

            var maxRa = Angle.FromRadians(
                Min(bounds1.maxRa.Radians, bounds2.maxRa.Radians));

            var minDec = Angle.FromRadians(
                Max(bounds1.minDec.Radians, bounds2.minDec.Radians));

            var maxDec = Angle.FromRadians(
                Min(bounds1.maxDec.Radians, bounds2.maxDec.Radians));

            if (Verbose)
            {
                Console.WriteLine("Min RA={0}", minRa);
                Console.WriteLine("Max RA={0}", maxRa);
                Console.WriteLine("Min Dec={0}", minDec);
                Console.WriteLine("Max Dec={0}", maxDec);

                Console.WriteLine();
                Console.WriteLine(
                    "Filtering source lists to bounded region.");
            }

            Filtered   = Filtered.Filter(InBounds);
            Unfiltered = Unfiltered.Filter(InBounds);
            Spitzer    = Spitzer.Filter(InBounds);

            return(Status);

            bool InBounds(ISource source)
            {
                return
                    (source.RA >= minRa &&
                     source.RA <= maxRa &&
                     source.Dec >= minDec &&
                     source.Dec <= maxDec);
            }
        }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            ICoffee coffee = new Espresso();
            Debug.Log("Coffee discription and cost: " + coffee.GetDescription() + " $" + coffee.GetCost());
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            ICoffee coffee = new Filtered();
            Debug.Log("Coffee discription and cost: " + coffee.GetDescription() + " $" + coffee.GetCost());
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            ICoffee coffee = new ChocolateDecorator(new Espresso());
            Debug.Log("Coffee discription and cost: " + coffee.GetDescription() + " $" + coffee.GetCost());
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            ICoffee coffee = new ChocolateDecorator(new Filtered());
            Debug.Log("Coffee discription and cost: " + coffee.GetDescription() + " $" + coffee.GetCost());
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            ICoffee coffee = new MilkDecorator(new Espresso());
            Debug.Log("Coffee discription and cost: " + coffee.GetDescription() + " $" + coffee.GetCost());
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            ICoffee coffee = new MilkDecorator(new Filtered());
            Debug.Log("Coffee discription and cost: " + coffee.GetDescription() + " $" + coffee.GetCost());
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            ICoffee coffee = new ChocolateDecorator(new MilkDecorator(new Filtered()));
            Debug.Log("Coffee discription and cost: " + coffee.GetDescription() + " $" + coffee.GetCost());
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            ICoffee coffee = new ChocolateDecorator(new MilkDecorator(new Espresso()));
            Debug.Log("Coffee discription and cost: " + coffee.GetDescription() + " $" + coffee.GetCost());
        }
    }
예제 #13
0
        private void RefilterVars(DomNodeType nodeType)
        {
            var fea = new FilteringEventArgs(nodeType);

            // Fire filtering event
            Filtering.Raise(this, fea);

            // Do any filtering
            foreach (var luaVar in fea.LuaVarsToFilter)
            {
                luaVar.Visible = !IsVariableFiltered(luaVar);
            }

            // Fire filtered event
            Filtered.Raise(this, new FilteredEventArgs(nodeType));
        }
예제 #14
0
        public void InitAccounts(ListBox list, string sorting)
        {
            try
            {
                Accounts.Clear();
                Filtered.Clear();
                SqlConnection con = new SqlConnection(conStrSQL);
                if (!sorting.Equals(""))
                {
                    sorting = String.Format(" ORDER BY {0}", sorting);
                }
                string comStr = "SELECT * " +
                                "FROM AccountTable " +
                                "WHERE username = '******' AND deleted = '0'" + sorting + ";";
                using (SqlCommand cmd = new SqlCommand(comStr, con))
                {
                    con.Open();
                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Account acc = new Account
                        {
                            id         = Convert.ToInt32(reader["id"]),
                            Email      = reader["email"].ToString(),
                            Onlineuser = reader["onlineuser"].ToString(),
                            Password   = EncryptionHelper.Encrypt(reader["password"].ToString(), cryptokey),
                            Title      = reader["title"].ToString(),
                            Url        = reader["url"].ToString(),
                            marked     = reader["marked"].ToString().Equals("1")
                        };

                        Accounts.Add(acc);
                        Filtered.Add(acc);
                    }
                }
                con.Close();
                update(list);
            }
            catch (SqlException)
            {
                if (German)
                {
                    throw new Exception("Fehler beim Verbinden zur Datenbank!\n Versuchen Sie es in einer halben Stunde erneut, wenn Sie sich bis dahin noch immer nicht anmelden können, schreiben Sie ein Email an: [email protected]");
                }
                throw new Exception("An error accured while trying to connect to the database!\n Try to connect again in 30 minutes, if it won't work then contact us at: [email protected]");
            }
        }
        private void Handler(object sender, EventArgs args)
        {
            var  item          = (Type)sender;
            bool filterApplies = Filter(item);

            if (filterApplies)
            {
                if (!Filtered.Contains(item))
                {
                    var previous = Filtered.LastOrDefault();
                    if (previous != null)
                    {
                        _ignoreSourceChangeEvents = true;
                        try
                        {
                            int idxInsertAfter = Source.IndexOf(previous);
                            Source.Remove(item);
                            if (idxInsertAfter < Source.Count)
                            {
                                Source.Insert(idxInsertAfter, item);
                            }
                            else
                            {
                                Source.Add(item);
                            }
                        }
                        finally
                        {
                            _ignoreSourceChangeEvents = false;
                        }
                    }
                    Filtered.Add(item);
                }
                return;
            }
            else
            {
                if (Filtered.Contains(item))
                {
                    Filtered.Remove(item);
                }
                return;
            }
        }
예제 #16
0
 public void Dispose()
 {
     try
     {
         if (!Disposed)
         {
             UnFiltered.Dispose();
             Filtered.Dispose();
             Timestamps.Dispose();
             PacketIds?.Dispose();
             EcgSamplesData.Dispose();
             EcgTaskWriter.Dispose();
             Hdf5.CloseGroup(GroupId);
             Disposed = true;
         }
     }
     catch (Exception e)
     {
         Logger.LogError($"Error during dispose of ECG: {e.Message}");
     }
 }
        ///// <summary>
        ///// Fetches only root node.
        ///// The root node is found if <paramref name="root"/> contains "*" or the root node name.
        ///// </summary>
        ///// <param name="root">Root node name</param>
        ///// <param name="dom">Document</param>
        ///// <returns>Found nodes</returns>
        //private IEnumerable<XmlNode> RootOnly(string root, XmlNode dom)
        //{
        //    var rootElem = new XmlDocumentOf(dom).Value().DocumentElement;
        //    var targets = new ManyOf<XmlNode>();  // empty list

        //    if (
        //        root != null &&
        //        rootElem != null &&
        //        ("*".Equals(root) || rootElem.Name.Equals(root))
        //    )
        //    {
        //        targets = new ManyOf<XmlNode>(rootElem);
        //    }
        //    return targets;
        //}

        /// <summary>
        /// Get roots to start searching from.
        /// The root nodes are the <paramref name="nodes"/> if there are any or the document root node.
        /// </summary>
        /// <param name="dom">Document</param>
        /// <param name="nodes">Current nodes</param>
        /// <returns>Root nodes to start searching from</returns>
        private IEnumerable <XNode> Roots(XNode dom, IEnumerable <XNode> nodes)
        {
            IEnumerable <XNode> roots = nodes;

            // Return document root if there are no nodes.
            if (new LengthOf(nodes).Value() == 0)
            {
                roots = new ManyOf <XNode>(
                    new XmlDocumentOf(
                        dom
                        ).Value().Document);
            }

            // DocumentElement may be null. Then remove it from the list.
            roots =
                new Filtered <XNode>(
                    (node) => node != null,
                    roots
                    );

            return(roots);
        }
예제 #18
0
 public IEnumerator <T> GetEnumerator()
 {
     return(Filtered.GetEnumerator());
 }
예제 #19
0
 public void Init()
 {
     instance = new Filtered();
 }
예제 #20
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(Filtered.GetEnumerator());
 }
예제 #21
0
 public void RemoveAt(int index)
 {
     Filtered.RemoveAt(index);
 }
예제 #22
0
 public bool Remove(T item)
 {
     return(Filtered.Remove(item));
 }
예제 #23
0
 public void Init()
 {
     instance = new Filtered();
 }
 /// <summary>
 /// GetEnumerator
 /// </summary>
 /// <returns></returns>
 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 {
     return(Filtered.GetEnumerator());
 }
예제 #25
0
 public void CopyTo(T[] array, int arrayIndex)
 {
     Filtered.CopyTo(array, arrayIndex);
 }
예제 #26
0
 public void Clear()
 {
     Filtered.Clear();
 }
예제 #27
0
 public void Add(T item)
 {
     Filtered.Add(item);
 }
예제 #28
0
        private void AppendSample(ECGFrame[] samples, int length)
        {
            var sampleForSize = samples.First();

            double[,] unFilteredData = new double[length * sampleForSize.FrameData.First().Count, sampleForSize.FrameData.Count];
            double[,] filteredData   = new double[length * sampleForSize.FilteredFrameData.First().Count, sampleForSize.FilteredFrameData.Count];
            long[,] timestampData    = new long[length * sampleForSize.FilteredFrameData.First().Count, 1];
            ulong[,] packetIdData    = samples[0].PacketId == UInt64.MaxValue ? null : new ulong[length, 1];
            ulong[,] kalpaClockData  = samples[0].KalpaClock == UInt64.MaxValue ? null : new ulong[length, 1];

            for (var i = 0; i < length; i++)
            {
                var dataSample = samples[i];
                var rows       = dataSample.FrameData.First().Count;
                var columns    = dataSample.FrameData.Count;
                for (int rowIndex = 0; rowIndex < rows; rowIndex++)
                {
                    for (var columnIndex = 0; columnIndex < columns; columnIndex++)
                    {
                        unFilteredData[i * rows + rowIndex, columnIndex] = dataSample.FrameData[columnIndex][rowIndex];
                    }
                }

                rows    = dataSample.FilteredFrameData.First().Count;
                columns = dataSample.FilteredFrameData.Count;
                for (int rowIndex = 0; rowIndex < rows; rowIndex++)
                {
                    for (var columnIndex = 0; columnIndex < columns; columnIndex++)
                    {
                        filteredData[i * rows + rowIndex, columnIndex] = dataSample.FilteredFrameData[columnIndex][rowIndex];
                    }
                }

                int rowsTimestamps = dataSample.FilteredFrameData.First().Count;

                for (int k = 0; k < rowsTimestamps; k++)
                {
                    var date = dataSample.Timestamp;
                    if (SamplingRate > 0)
                    {
                        date = (long)(dataSample.Timestamp + k * 1000.0 / SamplingRate);
                    }
                    timestampData[i * rowsTimestamps + k, 0] = date;
                    EndDateTime = date;
                }
                if (packetIdData != null)
                {
                    packetIdData[i, 0] = dataSample.PacketId;
                }

                if (kalpaClockData != null)
                {
                    kalpaClockData[i, 0] = dataSample.KalpaClock;
                }
            }
            UnFiltered.AppendOrCreateDataset(unFilteredData);
            Filtered.AppendOrCreateDataset(filteredData);
            Timestamps.AppendOrCreateDataset(timestampData);
            if (packetIdData != null)
            {
                PacketIds.AppendOrCreateDataset(packetIdData);
            }
        }
예제 #29
0
 public int IndexOf(T item)
 {
     return(Filtered.IndexOf(item));
 }
예제 #30
0
 public bool Contains(T item)
 {
     return(Filtered.Contains(item));
 }
예제 #31
0
 public void Insert(int index, T item)
 {
     Filtered.Insert(index, item);
 }