public Page1(List <int> l, int cap, int un_p, int alg) { InitializeComponent(); m = new RAM_fix(l, cap); proc = new process_list(); un_plus = un_p; proc.Set_alg(alg); }
// la liste de toute les partitions de la ram public void afficher(Canvas ram, process_list pro) { Application.Current.Dispatcher.Invoke((Action) delegate { int i = 0; int pos = 0; byte color = 0; while (true) { list_rep[i].View(ram, pos, color, pro, capacite); color += 100 % 255; pos += list_rep[i].Get_taille() * 435 / capacite; i++; if (i == list_rep.Count) { break; } } }); }
public void View(Canvas ram, int pos, byte color, process_list pro, int cap) { Application.Current.Dispatcher.Invoke((Action) delegate { front = new Rectangle(); front.Width = 220; int pos2 = Get_taille() * 435 / cap; front.Height = Get_taille() * 435 / cap; TextBlock deb = new TextBlock(); deb.Text = "@" + (Get_adr() + 100).ToString(); deb.Foreground = new SolidColorBrush(Color.FromRgb(62, 62, 66)); deb.FontWeight = FontWeights.UltraBold; ram.Children.Add(deb); Canvas.SetTop(deb, pos - 5); Canvas.SetLeft(deb, 30); if (G_vide()) { front.Fill = new SolidColorBrush(Color.FromRgb(255, 255, 255)); front.Stroke = new SolidColorBrush(Color.FromRgb(0, 255, 184)); DoubleAnimation db2 = new DoubleAnimation(5, 1, TimeSpan.FromMilliseconds(1000)); front.BeginAnimation(Rectangle.StrokeThicknessProperty, db2); } else { Color clr = new Color(); clr = pro.Get_color_by_id(Get_id()); if (pro.Get_time_by_id(Get_id()) == 1) { front.Fill = new SolidColorBrush(Color.FromRgb(color, color, color)); //Color clr = new Color(); clr = Color.FromRgb(color, 255, 180); // Create a ColorAnimation to animate the button's background. ColorAnimation myColorAnimation = new ColorAnimation(); myColorAnimation.From = clr; myColorAnimation.To = Colors.White; myColorAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(2000)); // Apply the animation to the brush's Color property. front.Fill.BeginAnimation(SolidColorBrush.ColorProperty, myColorAnimation); front.StrokeThickness = 5; clr = pro.Get_color_by_id(Get_id()); //front.Stroke = new SolidColorBrush(Color.FromRgb(clr.R,clr.G,clr.B)); front.Stroke = new SolidColorBrush(Color.FromRgb(0, 255, 180)); // le rectangle de out Rectangle rec_out = new Rectangle(); rec_out.Width = 30; rec_out.Height = 5; ram.Children.Add(rec_out); Canvas.SetTop(rec_out, pos2 / 2 + pos); Canvas.SetLeft(rec_out, 5); rec_out.Fill = new SolidColorBrush(Color.FromRgb(clr.R, clr.G, clr.B)); // creation d'un triangle Polygon myPolygon = new Polygon(); myPolygon.Fill = new SolidColorBrush(Color.FromRgb(clr.R, clr.G, clr.B)); System.Windows.Point Point1 = new System.Windows.Point(9, pos + pos2 / 2 - 2); System.Windows.Point Point2 = new System.Windows.Point(1, pos + pos2 / 2 + 3); System.Windows.Point Point3 = new System.Windows.Point(9, pos + pos2 / 2 + 8); PointCollection myPointCollection = new PointCollection(); myPointCollection.Add(Point1); myPointCollection.Add(Point2); myPointCollection.Add(Point3); myPolygon.Points = myPointCollection; ram.Children.Add(myPolygon); // //name of the processus TextBlock nom = new TextBlock(); nom.Text = pro.Get_name_by_id(Get_id()); nom.Foreground = new SolidColorBrush(Colors.White); nom.FontWeight = FontWeights.UltraBold; nom.Width = 20; nom.Height = 20; ram.Children.Add(nom); Canvas.SetTop(nom, pos + pos2 / 2 - 12); Canvas.SetLeft(nom, 54); Canvas.SetZIndex(nom, 1); DoubleAnimation db2 = new DoubleAnimation(0, 10, TimeSpan.FromMilliseconds(2000)); front.BeginAnimation(Rectangle.StrokeThicknessProperty, db2); // Ellipse fron = new Ellipse(); fron.Width = 30; fron.Height = 30; fron.Fill = new SolidColorBrush(Color.FromRgb(clr.R, clr.G, clr.B)); ram.Children.Add(fron); Canvas.SetTop(fron, pos + pos2 / 2 - 18); Canvas.SetLeft(fron, 45); System.Timers.Timer tim; tim = new System.Timers.Timer(5); tim.Start(); tim.Elapsed += delegate(object sender1, ElapsedEventArgs ev) { movEvent(sender1, ev, fron, nom, tim); }; tim.AutoReset = true; tim.Enabled = true; } else if (pro.Get_fulltime_by_id(Get_id()) - pro.Get_time_by_id(Get_id()) == 1) { front.Fill = new SolidColorBrush(Color.FromRgb(255, 255, 255)); //Color clr = new Color(); clr = Color.FromRgb(color, 255, 180); // Create a ColorAnimation to animate the button's background. ColorAnimation myColorAnimation = new ColorAnimation(); myColorAnimation.From = Colors.White; myColorAnimation.To = clr; myColorAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(2000)); // Apply the animation to the brush's Color property. front.Fill.BeginAnimation(SolidColorBrush.ColorProperty, myColorAnimation); front.StrokeThickness = 10; clr = pro.Get_color_by_id(Get_id()); // front.Stroke = new SolidColorBrush(Color.FromRgb(clr.R, clr.G, clr.B)); front.Stroke = new SolidColorBrush(Color.FromRgb(0, 255, 180)); // le rectangle de out Rectangle rec_out = new Rectangle(); rec_out.Width = 30; rec_out.Height = 5; ram.Children.Add(rec_out); Canvas.SetTop(rec_out, pos2 / 2 + pos); Canvas.SetLeft(rec_out, 300); rec_out.Fill = new SolidColorBrush(Color.FromRgb(clr.R, clr.G, clr.B)); // creation d'un triangle Polygon myPolygon = new Polygon(); myPolygon.Fill = new SolidColorBrush(Color.FromRgb(clr.R, clr.G, clr.B)); System.Windows.Point Point1 = new System.Windows.Point(303, pos + pos2 / 2 - 2); System.Windows.Point Point2 = new System.Windows.Point(295, pos + pos2 / 2 + 3); System.Windows.Point Point3 = new System.Windows.Point(303, pos + pos2 / 2 + 8); PointCollection myPointCollection = new PointCollection(); myPointCollection.Add(Point1); myPointCollection.Add(Point2); myPointCollection.Add(Point3); myPolygon.Points = myPointCollection; ram.Children.Add(myPolygon); //name of the processus TextBlock nom = new TextBlock(); nom.Text = pro.Get_name_by_id(Get_id()); nom.Foreground = new SolidColorBrush(Colors.White); nom.FontWeight = FontWeights.UltraBold; nom.Width = 20; nom.Height = 20; ram.Children.Add(nom); Canvas.SetTop(nom, pos + pos2 / 2 - 12); Canvas.SetLeft(nom, 340); Canvas.SetZIndex(nom, 1); // DoubleAnimation db2 = new DoubleAnimation(front.StrokeThickness, 0, TimeSpan.FromMilliseconds(2000)); front.BeginAnimation(Rectangle.StrokeThicknessProperty, db2); // Ellipse fron = new Ellipse(); fron.Width = 30; fron.Height = 30; fron.Fill = new SolidColorBrush(Color.FromRgb(clr.R, clr.G, clr.B)); ram.Children.Add(fron); Canvas.SetTop(fron, pos + pos2 / 2 - 18); Canvas.SetLeft(fron, 333); System.Timers.Timer time; time = new System.Timers.Timer(5); time.Start(); time.Elapsed += delegate(object sender1, ElapsedEventArgs ev) { movEvent(sender1, ev, fron, nom, time); }; time.AutoReset = true; time.Enabled = true; // } else { front.Fill = new SolidColorBrush(Color.FromRgb(color, 255, 180)); TextBlock nom = new TextBlock(); nom.Text = pro.Get_name_by_id(Get_id()); nom.Foreground = new SolidColorBrush(Colors.White); nom.FontWeight = FontWeights.UltraBold; nom.Width = 20; nom.Height = 20; ram.Children.Add(nom); Canvas.SetTop(nom, pos + pos2 / 2 - 12); Canvas.SetLeft(nom, 255); Canvas.SetZIndex(nom, 1); } Rectangle ou = new Rectangle(); ou.Width = (pro.Get_fulltime_by_id(Get_id()) - pro.Get_time_by_id(Get_id())) * 100 / pro.Get_fulltime_by_id(Get_id()); ou.Height = 5; ou.Fill = new SolidColorBrush(Color.FromRgb(clr.R, clr.G, clr.B)); br.Width = 100; br.Height = 5; ou.RadiusY = 3; // br.RadiusX = 3; ou.RadiusX = 3; // br.RadiusY = 3; //br.Foreground = new SolidColorBrush(Color.FromRgb(0,240,190)); // br.Fill = new SolidColorBrush(Color.FromRgb(255, 255, 255)); ram.Children.Add(br); ram.Children.Add(ou); Canvas.SetTop(br, pos + pos2 / 2 - 4); Canvas.SetLeft(br, 130); Canvas.SetZIndex(br, 1); Canvas.SetTop(ou, pos + pos2 / 2 - 4); Canvas.SetLeft(ou, 130); Canvas.SetZIndex(ou, 2); //br.Value = (pro.Get_fulltime_by_id(G_vide()) - pro.Get_time_by_id(G_vide()) + 1) * 100 / pro.Get_fulltime_by_id(G_vide()); DoubleAnimation db = new DoubleAnimation((pro.Get_fulltime_by_id(Get_id()) - pro.Get_time_by_id(Get_id()) + 1) * 100 / pro.Get_fulltime_by_id(Get_id()), TimeSpan.FromMilliseconds(500)); ou.BeginAnimation(Rectangle.WidthProperty, db); //br.Value = pro.Get_time_by_id(G_vide()) * 100 / pro.Get_fulltime_by_id(G_vide()); } ram.Children.Add(front); Canvas.SetTop(front, pos); Canvas.SetLeft(front, 70); }); }