Example #1
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();

            // custom
            // PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness; // adding a reference to a method

            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast; // adding another reference to the method

            processor.Process("photo.jpg", filterHandler);

            filterHandler += RemoveRedEyeFilter;

            processor.Process("photo.jpg", filterHandler);
        }
Example #2
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();

            PhotoProcessor.PhotoFilterHnadler filterHnadler = filters.ApplyBrightness;
            filterHnadler += filters.ApplyContrast;
            filterHnadler += filters.RemoveRedEyeFilter;
            processor.Process("photo.jpg", filterHnadler);
        }
        //Lesson 2 : Delegates
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();

            PhotoProcessor.PhotoFilterHandler filterhandler = filters.ApplyBrightness;
            filterhandler += filters.ApplyContrast;

            processor.Process("image.jpg", filterhandler);
        }
Example #4
0
        static void Main(string[] args)
        {
            var photoFilters   = new PhotoFilters();
            var photoProcessor = new PhotoProcessor();

            PhotoProcessor.PhotoProcessorHandler filterHandler = photoFilters.ApplyBrightness;
            filterHandler += photoFilters.Resize;
            filterHandler += photoFilters.ApplyContrast;
            filterHandler += RemoveRedEyes;
            photoProcessor.Process("photo.jpg", filterHandler);

            Console.WriteLine();
            Action <Photo> filterHandlerAction = photoFilters.ApplyBrightness;

            filterHandlerAction += photoFilters.Resize;
            filterHandlerAction += photoFilters.ApplyContrast;
            filterHandlerAction += RemoveRedEyes;
            photoProcessor.Process("photo2.jpg", filterHandlerAction);
        }
Example #5
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters = new PhotoFilters();
            Action<Photo> filterHandler = filters.ApplyBrightness;
            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;

            processor.Process("photo.jpg", filterHandler);
        }
Example #6
0
        static void Main(string[] args)
        {
            PhotoProcessor processor     = new PhotoProcessor();
            var            filter        = new PhotoFilters();
            Action <Photo> filterHandler = filter.ApplyBrightness;

            filterHandler += filter.ApplyContrast;
            filterHandler += RemoveRedEye;
            processor.Process("photo.jpg", filterHandler);
        }
        private static void Main(string[] args)
        {
            var            processor     = new PhotoProcessor();
            var            filters       = new PhotoFilters();
            Action <Photo> filterHandler = filters.ApplyBrightess;

            filterHandler += filters.AppyContrast;
            filterHandler += AppyRedEye;

            processor.Process("nekiImidz.jpg", filterHandler);
        }
Example #8
0
        static void Main(string[] args)
        {
            //in .net there are two different built in delegates types: Action and Func
            //difference between two of them are in the fact that funct return result, action asumes void return type!!!
            //till 16 input parameters

            //delegates are pointers to the methods, they know how to call methods
            var processor = new PhotoProcessor();

            processor.Process("photo.jpg");
        }
Example #9
0
        static void Main(string[] args)
        {
            var            photoProcessor = new PhotoProcessor();
            var            filters        = new PhotoFilters();
            Action <Photo> filterHandler  = filters.ApplyBrighttness;

            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;

            photoProcessor.Process("letsgo", filterHandler);
        }
Example #10
0
        static void Main(string[] args)
        {
            var            processor       = new PhotoProcessor();
            var            snapchatfilters = new SnapchatFilters();
            Action <Photo> filterHandler   = snapchatfilters.ApplyDogFacialParts;

            filterHandler += snapchatfilters.ApplyFlowerCrown;
            filterHandler += HighContrastFilter;

            processor.Process("photo.png", filterHandler);
        }
Example #11
0
        static void Main(string[] args)
        {
            var            processor     = new PhotoProcessor();
            var            filter        = new PhotoFilters();
            Action <Photo> filterHandler = filter.ApplyBrightness;

            filterHandler += filter.ApplyContrast;
            filterHandler += RedEyeFilter;
            processor.Process("", filterHandler);
            Console.ReadLine();
        }
Example #12
0
        static void Main(string[] args)
        {
            var            proccessor    = new PhotoProcessor();
            var            filters       = new PhotoFilters();
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            //so we can add and method later and add it to delegate
            filterHandler += RemoveRedEyeFilter;
            proccessor.Process("photo.jpg", filterHandler);
            Console.ReadLine();
        }
Example #13
0
        static void Main(string[] args)
        {
            var process = new PhotoProcessor();
            var filters = new PhotoFilters();
            // Setting our delegator || using .NET Action
            Action <Photo> filterHandler = filters.AddContrast;

            filterHandler += filters.GenericFilter;
            filterHandler += removeRedEye;

            //we pass filter here so itr will apply functions through delegators
            process.Process("photo.jpg", filterHandler);
        }
Example #14
0
        static void Main_two(string[] args)
        {
            var photoProcessor = new PhotoProcessor();

            var filters = new PhotoFilters();
            // create delegate
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEye;

            photoProcessor.Process("photo.png", filterHandler);
        }
Example #15
0
        static void Main(string[] args)
        {
            var pic       = new Photo();
            var processor = new PhotoProcessor(
                new PhotoFilters(
                    new List <IEffect>()
            {
                new BrightnessEffect(), new ContrastEffect(), new ResizeEffect()
            }),
                pic);

            processor.Process();
        }
Example #16
0
        public static void ExampleWithOriginalDelegate()
        {
            var processor = new PhotoProcessor();

            var filters = new PhotoFilters();

            PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            filterHandler += filters.ApplyContrast;
            filterHandler += filters.Resize;
            filterHandler += RemoveRedEyeFilter; // exemplo de extensão

            processor.Process("photo.jpg", filterHandler);
        }
Example #17
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();

            PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            filterHandler += filters.ApplyContrast;
            filterHandler += filters.Resize;
            filterHandler += ApplySaturation;

            processor.Process("urlphoto", filterHandler);


            //the same but using default delegates
            Action <Photo> filterHandler2 = filters.ApplyContrast;

            processor.Process("urlphoto", filterHandler2);



            Console.ReadLine();
        }
Example #18
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();
            // Erzeugen des Handlers
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;

            // Übergeben des Handlers
            processor.Process("photo.jpg", filterHandler);
        }
Example #19
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();
            ///Action is delegate here and filterhandler is pointer to method
            ///and Func is used when your delegate should return a value
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;

            processor.Process("photo.jpg", filterHandler);
        }
Example #20
0
        //Delegate in an object that know how to call a method or multiple method
        //a pointer to a function - that provies flexibility and Extensability
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filter    = new PhotoFilters();

            PhotoProcessor.PhotoFilterHandler filterHandler = filter.ApplyBrightness;
            filterHandler += filter.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;
            processor.Process("photo.jpg", filterHandler);

            //Buildin delegates:
            //System.Action // for a method that not returns a value;
            //System.Func // for a method that returns value
        }
Example #21
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();

            // Adds methods to the delegate, note that they all must have the same signature as defined in the delegate.
            // PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness; // With custom delegate
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;

            processor.Process("photo.jpg", filterHandler);
        }
Example #22
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();

            PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            filterHandler += RemoveRedEyeFilter;
            filterHandler += filters.ApplyContrast;
            // Using filterHandler (delegate)
            processor.Processing("photo.jpg", filterHandler);

            // Using Action<Photo>
            processor.Process("image.jpg", filters.ApplyBrightness);
        }
        static void Main(string[] args)
        {
            var photoProcessor = new PhotoProcessor();
            var filters        = new PhotoFilters();
            var photo          = new Photo();

            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += Test;
            filterHandler += Test2;


            photoProcessor.Process("photo.jpg", filterHandler);
        }
Example #24
0
        static void Main(string[] args)
        {
            var process = new PhotoProcessor();
            var filter  = new PhotoFilters();

            // First Implementation "Es antigua"
            //PhotoProcessor.PhotoFilterHandler filterHandler = filter.ApplyBrightness;
            Action <Photo> filterHandler = filter.ApplyBrightness;

            filterHandler += filter.ApplyContrast;
            filterHandler += filter.Resize;
            filterHandler += RemoveRedEyeFilter;

            process.Process("photo.img", filterHandler);
        }
        static void Main(string[] args)
        {
            //var procesor = new PhotoProcesor();
            //procesor.Process("Test.jpg");

            var procesor = new PhotoProcessor();
            var filters  = new PhotoFilters();

            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;

            procesor.Process("Test.jpg", filterHandler);
        }
Example #26
0
        static void Main(string[] args)
        {
            var photoProcessor = new PhotoProcessor();
            var filters        = new PhotoFilters();
            var transform      = new Transformations();

            PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            filterHandler += filters.ApplyContrast;
            filterHandler += filters.Resize;
            filterHandler += transform.Crop;

            photoProcessor.Process(filterHandler);

            Console.ReadLine();
        }
        // Delegate = Object that knows how to call a method or a group of methods
        // Help designing extensible and flexible applications
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            var filters   = new PhotoFilters();
            // PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;


            processor.Process("photo.jpg", filterHandler);

            Console.ReadKey();
        }
Example #28
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();
            //processor.Process("P");
            var filters = new PhotoFilters();
            //PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += filters.Resize;
            filterHandler += AddWrinkles;
            processor.Process("p", filterHandler);

            Console.ReadLine();
        }
Example #29
0
        static void Main(string[] args)
        {
            var processor = new PhotoProcessor();

            var photoFilters = new PhotoFilters();

            // Custom delegate
            //PhotoProcessor.PhotoFilterHandler filterHandler = photoFilters.ApplyBrightness;

            Action <Photo> filterHandler = photoFilters.ApplyBrightness;

            filterHandler += photoFilters.Resize;
            filterHandler += RemoveRedEyeFilter;

            processor.Process("Test path", filterHandler);
        }
Example #30
0
        static void Main(string[] args)
        {
            /*
             *  Delegate is an object that knows how to call a method or a group of methods and is also a reference to a function.
             */

            var            processor     = new PhotoProcessor();
            var            filters       = new PhotoFilters();
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyContrast;
            filterHandler += filters.Resize;
            filterHandler += RemoveRedEyesFilter;

            processor.Process("photo.jpeg", filterHandler);
        }
Example #31
0
        static void Main(string[] args)
        {
            var process = new PhotoProcessor();

            //process.Process("photo.jpg");

            var filters = new PhotoFilters();
            //PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            System.Action<Photo> filterHandler = filters.ApplyBrightness;
            filterHandler += filters.ApplyContrast;
            filterHandler += RemoveRedEyeFilter;

            process.Process("photo.jpg",filterHandler);

            Console.ReadLine();
        }
Example #32
0
        static void Main(string[] args)
        {
            var photoProcessor = new PhotoProcessor();
            var filters        = new PhotoFilters();

            // Use generic delegate instead of custom
            //PhotoProcessor.PhotoFilterHandler filterHandler = filters.ApplyBrightness;
            Action <Photo> filterHandler = filters.ApplyBrightness;

            filterHandler += filters.ApplyConstrast;
            filterHandler += RemoveRedEyeFilter;


            //photoProcessor.Process("photo.jpg");
            photoProcessor.Process("photo.jpg", filterHandler);
        }
Example #33
0
        static void Main(string[] args)
        {
            //a delegate is an object that knows how to call a method (or a group of methods)
            //simply -- a delegate is a reference to a method/function(s)

            //why?
            //For designing extensible and flexible applications (eg frameworks often used here)

            //multicast delegate lets us have multiple function pointers.
            //delegate is just one.

            PhotoProcessor proc = new PhotoProcessor();

            //interface vs delegate
            //some is personal taste
            //delegates event design pattern, caller doesn't need to access properties

            //if photoprocessor needed to access other properties or methods a delegate wouldn't work.


            //so what we've done here is we created an instance of the photofilters object so we could reference it's methods.
            //we created an instance of the delegate and then assigned the method from photofilters to it.
            PhotoFilters photofilters = new PhotoFilters();
            PhotoProcessor.PhotoFilterHandler filterHandler = photofilters.ApplyBrightness;

            //adding more points/methods
            filterHandler += photofilters.ApplyContrast;
            filterHandler += photofilters.Resize;
            filterHandler += Program.RemoveRedeye;
            proc.Process("path here", filterHandler);

            //when passing the reference to the delegate you don't need the () because you're not passing anything or calling the method.
            Action<Photo> filterHandler2 = photofilters.ApplyBrightness;
            filterHandler2 += RemoveRedeye;

            proc.SuperProces("photopath", filterHandler2);


        }