/// <summary>
 /// Creates connections with the jobs <paramref name="job"/> is depending on.
 /// </summary>
 /// <param name="job">Job where all arcs will ending.</param>.
 protected void CreateConnections(JobCo job)
 {
     foreach (int id in job.Depend)
     {
         CreateConnection(Jobs.FromId(id), job);
     }
 }
 /// <summary>
 /// Decreases the ExecTime of the jobs that JobCoCo depends of, if needed.
 /// </summary>
 /// <param name="JobCoCo"></param>
 public override void ActualiseConnectedJobs(JobCo JobCoCo)
 {
     foreach (JobCo JobCo in Jobs.Where(j => j.Depend.Contains(JobCoCo.Id)))
     {
         JobCo.ActualiseExecTime(L);
     }
 }
 /// <summary>
 /// Deletes connections with the jobs <paramref name="job"/> is depending on.
 /// </summary>
 /// <param name="job">Job where all arcs are ending.</param>
 protected void DeleteConnections(JobCo job)
 {
     L[job.Id].Clear();
     foreach (int id in job.Depend)
     {
         DeleteConnection(Jobs.FromId(id), job);
     }
 }
        /// <summary>
        /// Creates the arc from <paramref name="jobCo1"/> to <paramref name="jobCo2"/>.
        /// </summary>
        /// <param name="jobCo1">Where the arc is coming from.</param>
        /// <param name="jobCo2">Where the arc is ending.</param>
        protected void CreateConnection(JobCo jobCo1, JobCo jobCo2)
        {
            //M[JobCo1.Id, JobCo2.Id] = 1;
            //if (M[JobCo2.Id, JobCo1.Id] != 1)
            //    M[JobCo2.Id, JobCo1.Id] = -1;

            L[jobCo1.Id].Add(jobCo2.Id);
        }
 /// <summary>
 /// Deletes the arc from <paramref name="jobCo1"/> to <paramref name="jobCo2"/>
 /// </summary>
 /// <param name="jobCo1">Where the arc is coming from.</param>
 /// <param name="jobCo2">Where the arc is ending.</param>
 protected void DeleteConnection(JobCo jobCo1, JobCo jobCo2)
 {
     //M[JobCo1.Id, JobCo2.Id] = 0;
     //if (M[JobCo2.Id, JobCo1.Id] == 1)
     //    M[JobCo1.Id, JobCo2.Id] = -1;
     //else
     //    M[JobCo2.Id, JobCo1.Id] = 0;
     bool b = L[jobCo1.Id].Remove(jobCo2.Id);
 }
        /// <summary>
        /// This method adds the rectangle representing the JobCoCo <paramref name="j"/> for <paramref name="machine"/> in the graphic.
        /// </summary>
        /// <param name="j">Parameter of the JobCoCo that will be added. </param>
        /// <param name="late">Boolean indicating if the JobCo is late or not.</param>
        /// <param name="couleur"> Brush of the color of the JobCo, which has to be defined by the userId (UserColor). </param>
        /// <param name="machine"> Integer representing which machine has the JobCo.</param>
        private void AddJobCo(JobCo j, bool late, Brush couleur, int machine)
        {
            int exeT = j.ExecTime;
            int t    = j.Time;
            // Dessin forme
            Rectangle Alpha = new Rectangle
            {
                Fill   = couleur,
                Stroke = Brushes.Black,
                Height = height / 2,
                Width  = exeT * pixelMultiplier
            };

            Rectangle Beta = new Rectangle
            {
                Fill   = couleur,
                Stroke = Brushes.Black,
                Height = height / 2,
                Width  = t * pixelMultiplier
            };


            if (late)
            {
                Alpha.Fill = LatePattern(couleur);
                Beta.Fill  = LatePattern(couleur);
            }


            // Insertion in canvas
            Canvas.SetTop(Alpha, HeightCal(machine));
            Canvas.SetLeft(Alpha, WidthCalCo(machine));
            Canvas.SetZIndex(Alpha, 1);

            Canvas.SetTop(Beta, HeightCalCo(machine));
            Canvas.SetLeft(Beta, WidthCal(machine));
            Canvas.SetZIndex(Beta, 0);

            //Add ID first
            TextBlock testo = new TextBlock();

            testo.Text = j.Id.ToString();
            Canvas.SetTop(testo, HeightCal(machine) + 5);
            Canvas.SetLeft(testo, WidthCalCo(machine) + 10);
            Panel.Children.Add(testo);
            Canvas.SetZIndex(testo, 2);

            //Add ID
            TextBlock textBlock = new TextBlock();

            textBlock.Text = j.Id.ToString();
            Canvas.SetTop(textBlock, HeightCal(machine) + 30);
            Canvas.SetLeft(textBlock, WidthCal(machine) + 10);
            Panel.Children.Add(textBlock);
            Canvas.SetZIndex(textBlock, 2);

            // Set new last pixels
            maxTime[machine]     += t * pixelMultiplier;
            maxExecTime[machine] += exeT * pixelMultiplier;

            Panel.Width = maxTime.Max() + 10;
            Panel.Children.Add(Alpha);
            Panel.Children.Add(Beta);
        }
 /// <summary>
 /// This method adds the rectangle representing the JobCoCo <paramref name="j"/> for <paramref name="machine"/> in the graphic. Case with one or many users and many machines.
 /// </summary>
 /// <param name="machine"> Integer representing which machine has the JobCo.</param>
 /// <param name="j">Parameter of the JobCoCo that will be added. </param>
 /// <param name="late">Boolean indicating if the JobCo is late or not.</param>
 public void AddJobCo(JobCo j, bool late, int user, int machine) => AddJobCo(j, late, userColors.Length == 1 ? PickBrush() : userColors[user], machine);
 /// <summary>
 /// This method adds the rectangle representing the JobCoCo <paramref name="j"/> in the graphic for the case where there is one machine ad one user.
 /// </summary>
 /// <param name="j">Parameter of the JobCoCo that will be added. </param>
 /// <param name="late">Boolean indicating if the JobCo is late or not.</param>
 public void AddJobCo(JobCo j, bool late) => AddJobCo(j, late, PickBrush(), 0);
 public abstract void ActualiseConnectedJobs(JobCo JobCo);
 /// <summary>
 /// Executes <paramref name="jobCo"/>. Deletes all arcs containing <paramref name="jobCo"/> in the oriented graph.
 /// <param name="jobCo">The job to execute.</param>
 public void ExecuteJob(JobCo jobCo)
 {
     leftJobs.Remove(jobCo);
     DeleteConnections(jobCo);
     ActualiseConnectedJobs(jobCo);
 }
 /// <summary>
 /// Unexecutes <paramref name="jobCo"/>. Puts back all arcs containing <paramref name="jobCo"/> in the oriented graph.
 /// </summary>
 /// <param name="jobCo">The job to unexecute.</param>
 public void UnExecuteJob(JobCo jobCo)
 {
     leftJobs.Add(jobCo);
     CreateConnections(jobCo);
     ActualiseConnectedJobs(jobCo);
 }