                Color = Color.Green,
                Duration = 61,
                Resources = { { "Incubator", 1 } }
            };

            Activity t6 = new Activity()
            {
                Name = "Transport2",
                Color = Color.Red,
                Duration = 3,
                Resources = { { "iSWAP", 1 }, { "Incubator", 1 }  }
            };
            Activity t7 = new Activity()
            {
                Name = "Pipeeting2",
                Color = Color.Blue,
                Duration = 9,
                Resources = { { "STAR", 1 } }
            };

            Activity t4 = new Activity()
            {
                Name = "Transport3",
                Color = Color.Red,
                Duration = 5,
                Resources = { { "iSWAP", 1 }, { "Reader", 1 } }
            };

            Activity t5 = new Activity() { Name = "Read", Color = Color.Orange, Duration = 10 };
            t5.Resources["Reader"] = 1;

            Activities = new Activity[] { t1, tw, t2, t3,t6,t7, t4, t5 };
            Name = "Assay2";
        }
    }
    public class Task5 : Task
    {
        public Task5()
        {
            Name = "Assay5";
            Activity t1 = new Activity()
            {
                Name = "Pipetting1",
                Color = Color.Blue,
                Duration = 10,
                Resources = { { "STAR", 1 } }
            };

            Activity tw = new Activity() { Name = "Waiting", Color = Color.BlueViolet, Duration = 3 };

            Activity t2 = new Activity()
            {
                Name = "Transport1",
                Color = Color.Red,
                Duration = 5,
                Resources = { { "iSWAP", 1 }, { "Incubator", 1 } }
            };

            Activity t3 = new Activity()
            {
                Name = "Incubation",
                Color = Color.Green,
                Duration = 60,
                Resources = { { "Incubator",1  } }
            };

            Activity t4 = new Activity()
            {
                Name = "Transport2",
                Color = Color.Red,
                Duration = 5,
                Resources = { { "iSWAP", 1 }, { "Incubator", 1 }, { "Reader", 1 } }
            };

            Activity t5 = new Activity() { Name = "Read", Color = Color.Orange, Duration = 10 };
            t5.Resources["Reader"] = 1;

            Activities = new Activity[] { t1, tw, t2, t3, t4, t5 };
        }
    }
    public class Task4 : Task
    {
        public Task4()
        {
            Activity t1 = new Activity()
            {
                Name = "Pipetting1",
                Color = Color.Blue,
                Duration = 10,
                Resources = { { "STAR", 1 } }
            };

            Activity tw = new Activity() { Name = "Waiting", Color = Color.BlueViolet, Duration = 3 };

            Activity t2 = new Activity()
            {
                Name = "Transport1",
                Color = Color.Red,
                Duration = 5,
                Resources = { { "iSWAP", 1 }, { "Incubator", 1 } }
            };

            Activity t3 = new Activity()
            {
                Name = "Incubation",
                Color = Color.Green,
                Duration = 60,
                Resources = { { "Incubator", 1 } }
            };

            Activity t4 = new Activity()
            {
                Name = "Transport2",
                Color = Color.Red,
                Duration = 5,
                Resources = { { "iSWAP", 1 }, { "Incubator", 1 }, { "Reader", 1 } }
            };

            Activity t5 = new Activity() { Name = "Read", Color = Color.Orange, Duration = 10 };
            t5.Resources["Reader"] = 1;

            Activities = new Activity[] { t1, tw, t2, t3, t4, t5 };
            Name = "Assay2";
        }
    }
    public class TestSh
    {

        static void Main()
        {
            try
            {
                Test();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
        public static void Test()
        {
            EmbedScheduler scheduler = new EmbedScheduler();
            scheduler.Register(new Resource() { Name = "STAR", Count = 1, Color = Color.Blue });
            scheduler.Register(new Resource() { Name = "iSWAP", Count = 1, Color = Color.Red });
            scheduler.Register(new Resource() { Name = "Incubator", Count = 10, Color = Color.Green });
            scheduler.Register(new Resource() { Name = "Shaker", Count = 1, Color = Color.Yellow });
            scheduler.Register(new Resource() { Name = "Reader", Count = 1, Color = Color.Orange });
            IRuntimeResource reader = scheduler.GetResource("Reader");
            IRuntimeResource incubator = scheduler.GetResource("Incubator");
            //reader.DisableUnit(1);
            incubator.DisableUnit(3);

            scheduler.Activate(new Task1() { Name = "Assay1_1" });
            scheduler.Activate(new Task2() { Name = "Assay2_2" }, new Dictionary<int, TaskRelation>() { { 1, TaskRelation.AfterTaskEnd } });
            scheduler.Activate(new Task3() { Name = "Assay3_3" });
            scheduler.Activate(new Task2() { Name = "Assay2_4" }, new Dictionary<int, TaskRelation>() { { 3, TaskRelation.AfterTaskEnd } });
            scheduler.Activate(new Task4() { Name = "Assay4_5" }, new Dictionary<int, TaskRelation>() { { 1, TaskRelation.BeforeRunEnd } });
            scheduler.Activate(new Task1() { Name = "Assay1_6" });
            scheduler.Activate(new Task5() { Name = "Assay5_7" });
            scheduler.Activate(new Task1() { Name = "Assay1_8" }, new Dictionary<int, TaskRelation>() { { 1, TaskRelation.AfterTaskEnd } });
            scheduler.Activate(new Task3() { Name = "Assay3_9" });
            scheduler.Activate(new Task3() { Name = "Assay3_10" }, new Dictionary<int,TaskRelation>(){{9, TaskRelation.AfterTaskStart}});
            scheduler.Activate(new Task4() { Name = "Assay4_11" }, new Dictionary<int, TaskRelation>() { { 9, TaskRelation.AfterTaskStart } });
            scheduler.Activate(new Task1() { Name = "Assay1_12" });
            scheduler.Activate(new Task2() { Name = "Assay2_13" });
            scheduler.Activate(new Task3() { Name = "Assay3_14" });
            scheduler.Activate(new Task3() { Name = "Assay3_15" });
            scheduler.Activate(new Task4() { Name = "Assay4_16" });
            scheduler.Activate(new Task5() { Name = "Assay5_17" });
            scheduler.Activate(new Task2() { Name = "Assay2_18" });
            scheduler.Activate(new Task1() { Name = "Assay1_19" });
            scheduler.Activate(new Task2() { Name = "Assay2_20" });
            scheduler.Activate(new Task1() { Name = "Assay1_21" });
            scheduler.Activate(new Task5() { Name = "Assay5_22" });
            scheduler.Activate(new Task1() { Name = "Assay1_23" });
            scheduler.Activate(new Task2() { Name = "Assay2_24" });
            scheduler.Activate(new Task3() { Name = "Assay3_25" });
            scheduler.Activate(new Task1() { Name = "Assay1_26" });
            scheduler.Activate(new Task2() { Name = "Assay2_27" });
            scheduler.Activate(new Task1() { Name = "Assay1_28" });
            sched