public MainWindow() { InitializeComponent(); _memory = new DynamicMemoryList(Memsize, DynamicMemoryList.Modes.FF); lstMemory.ItemsSource = _memory; RefreshFullMem(); RefreshRestMem(); }
private void rdoBF_Checked(object sender, RoutedEventArgs e) { if (_memory is DynamicMemoryList) { ((DynamicMemoryList)_memory).Reset(Memsize, DynamicMemoryList.Modes.BF); } else { _memory = new DynamicMemoryList(Memsize, DynamicMemoryList.Modes.BF); lstMemory.ItemsSource = _memory; } RefreshRestMem(); }
private void btnSetBlocks_Click(object sender, RoutedEventArgs e) { int[] blocks = GetBlocks(txtBlocks.Text); if (blocks.Sum() > Memsize) { MessageBox.Show(this, "分区总大小超出总内存大小,请重新分配", "参数错误"); return; } _memory = new StaticMemoryList(blocks); lstMemory.ItemsSource = _memory; RefreshFullMem(); RefreshRestMem(); }
private void btnResetSeq_Click(object sender, RoutedEventArgs e) { instructionIndex = 1; try { var memstr = App.Sequence[0].Split(' '); string kind = memstr[0]; int size = Int32.Parse(memstr[1]); switch (kind.Trim('@').ToUpper()) { case "FF": _memory = new DynamicMemoryList(size, DynamicMemoryList.Modes.FF); lstMemory.ItemsSource = _memory; break; case "BF": _memory = new DynamicMemoryList(size, DynamicMemoryList.Modes.BF); lstMemory.ItemsSource = _memory; break; case "FIX": int[] blocks = GetBlocks(memstr[2]); _memory = new StaticMemoryList(blocks); lstMemory.ItemsSource = _memory; break; default: MessageBox.Show(this, "未检测到内存分区模式,请重新编写序列", "指令错误"); return; } } catch (IndexOutOfRangeException) { MessageBox.Show(this, "序列中没有内容", "指令错误"); } if (instructionIndex < App.Sequence.Length) { txtNextInst.Text = App.Sequence[instructionIndex].ToUpper(); } else { txtNextInst.Text = "END"; } }