Example #1
0
        /// <summary>Kills the specified groups. </summary>
        /// <param name="groups">The groups.</param>
        /// <exception cref="ArgumentNullException">groups cannot be null.</exception>
        public void Kill(TargetProcessGroupCollection groups)
        {
            if (groups == null)
            {
                throw new ArgumentNullException(nameof(groups));
            }

            var names     = groups.DistinctArmedNames.ToArray();
            var processes = GetSessionProcessesWithName(names);

            foreach (var p in processes)
            {
                p.Kill();
            }
        }
        /// <summary>Sets the armed status of contained processes based on the given target collection.</summary>
        /// <param name="collection">The target collection.</param>
        public void SetArmed(TargetProcessGroupCollection collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            foreach (var rp in this)
            {
                rp.Armed = null;                                                      //Reset all 'armed's to null.
            }
            foreach (var target in collection.ArmedTargets)                           //Loop through collection groups
            {
                foreach (var p in this.Where(rp => rp.Name.ToUpper() == target.Name)) //Loop through group targets
                {
                    p.Armed = target.Armed;
                }
            }
            base.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
        }