//执行按钮 private void Start_Click(object sender, RoutedEventArgs e) { //准备处理容器 ITEM.Clear(); for (int i = 0; i < RealRam.Count(); i++) { ITEM.Add(RealRam[i]); } //内存未开辟判定 if (RealRam.Count() == 0) { MessageBox.Show("还未初始化内存空间"); return; } RAM r = new RAM(); //得到处理实例 for (int i = 0; i < Op.Count(); i++) { if (Op[i].Status == Status.Wait) { r = Op[i]; break; } } //特殊判定 if (r.Opera == "释放" && !IsExist(r.ID, ITEM)) { MessageBox.Show("ID不存在"); r.Status = Status.Failed; return; } //申请操作 if (r.Opera == "申请") { if (this.ff.IsChecked == true) { r.Status = RAM.First_fit(ITEM, r.ID, r.Size); } else if (this.nf.IsChecked == true) { r.Status = RAM.Next_fit(ITEM, r.ID, r.Size); } else if (this.bf.IsChecked == true) { r.Status = RAM.Best_fit(ITEM, r.ID, r.Size); } else if (this.wf.IsChecked == true) { r.Status = RAM.Worst_fit(ITEM, r.ID, r.Size); } } //回收操作 if (r.Opera == "释放") { r.Status = RAM.Recycle(ITEM, r.ID, r.Size); } //重新放回元素 RealRam.Clear(); for (int i = 0; i < ITEM.Count(); i++) { RealRam.Add(ITEM[i]); } DataGrid table = this.OperaTable as DataGrid; table.ItemsSource = null; table.ItemsSource = Op; }