private void RamWatchNewWatch_Load(object sender, EventArgs e) { if (InitialLocation.X > 0 || InitialLocation.Y > 0) { Location = InitialLocation; } _loading = false; SetAddressBoxProperties(); switch (_mode) { default: case Mode.New: switch (MemoryDomains.First().WordSize) { default: case 1: SizeDropDown.SelectedItem = SizeDropDown.Items[0]; break; case 2: SizeDropDown.SelectedItem = SizeDropDown.Items[1]; break; case 4: SizeDropDown.SelectedItem = SizeDropDown.Items[2]; break; } break; case Mode.Duplicate: case Mode.Edit: switch (_watchList[0].Size) { case WatchSize.Byte: SizeDropDown.SelectedItem = SizeDropDown.Items[0]; break; case WatchSize.Word: SizeDropDown.SelectedItem = SizeDropDown.Items[1]; break; case WatchSize.DWord: SizeDropDown.SelectedItem = SizeDropDown.Items[2]; break; } var index = DisplayTypeDropDown.Items.IndexOf(Watch.DisplayTypeToString(_watchList[0].Type)); DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[index]; if (_watchList.Count > 1) { NotesBox.Enabled = false; NotesBox.Text = string.Empty; AddressBox.Enabled = false; AddressBox.Text = _watchList.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr)); BigEndianCheckBox.ThreeState = true; if (_watchList.Select(s => s.Size).Distinct().Count() > 1) { DisplayTypeDropDown.Enabled = false; } } else { NotesBox.Text = _watchList[0].Notes; AddressBox.SetFromLong(_watchList[0].Address); } SetBigEndianCheckBox(); DomainDropDown.Enabled = false; break; } }
private void CheatListView_QueryItemText(int index, RollColumn column, out string text, ref int offsetX, ref int offsetY) { text = ""; if (index >= MainForm.CheatList.Count || MainForm.CheatList[index].IsSeparator) { return; } var columnName = column.Name; switch (columnName) { case NameColumn: text = MainForm.CheatList[index].Name; break; case AddressColumn: text = MainForm.CheatList[index].AddressStr; break; case ValueColumn: text = MainForm.CheatList[index].ValueStr; break; case CompareColumn: text = MainForm.CheatList[index].CompareStr; break; case OnColumn: text = MainForm.CheatList[index].Enabled ? "*" : ""; break; case DomainColumn: text = MainForm.CheatList[index].Domain.Name; break; case SizeColumn: text = MainForm.CheatList[index].Size.ToString(); break; case EndianColumn: text = (MainForm.CheatList[index].BigEndian ?? false) ? "Big" : "Little"; break; case TypeColumn: text = Watch.DisplayTypeToString(MainForm.CheatList[index].Type); break; case ComparisonTypeColumn: text = MainForm.CheatList[index].ComparisonType switch { Cheat.CompareType.None => "", Cheat.CompareType.Equal => "=", Cheat.CompareType.GreaterThan => ">", Cheat.CompareType.GreaterThanOrEqual => ">=", Cheat.CompareType.LessThan => "<", Cheat.CompareType.LessThanOrEqual => "<=", Cheat.CompareType.NotEqual => "!=", _ => "" }; break; } }
private void CheatListView_QueryItemText(int index, int column, out string text) { text = string.Empty; if (index >= Global.CheatList.Count || Global.CheatList[index].IsSeparator) { return; } var columnName = CheatListView.Columns[column].Name; switch (columnName) { case NAME: text = Global.CheatList[index].Name; break; case ADDRESS: text = Global.CheatList[index].AddressStr; break; case VALUE: text = Global.CheatList[index].ValueStr; break; case COMPARE: text = Global.CheatList[index].CompareStr; break; case ON: text = Global.CheatList[index].Enabled ? "*" : string.Empty; break; case DOMAIN: text = Global.CheatList[index].Domain.Name; break; case SIZE: text = Global.CheatList[index].Size.ToString(); break; case ENDIAN: text = (Global.CheatList[index].BigEndian ?? false) ? "Big" : "Little"; break; case TYPE: text = Watch.DisplayTypeToString(Global.CheatList[index].Type); break; case COMPARISONTYPE: switch (Global.CheatList[index].ComparisonType) { case Cheat.COMPARISONTYPE.NONE: text = ""; break; case Cheat.COMPARISONTYPE.EQUAL: text = "="; break; case Cheat.COMPARISONTYPE.GREATER_THAN: text = ">"; break; case Cheat.COMPARISONTYPE.GREATER_THAN_OR_EQUAL: text = ">="; break; case Cheat.COMPARISONTYPE.LESS_THAN: text = "<"; break; case Cheat.COMPARISONTYPE.LESS_THAN_OR_EQUAL: text = "<="; break; case Cheat.COMPARISONTYPE.NOT_EQUAL: text = "!="; break; default: text = ""; break; } break; } }
private void CheatListView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) { text = ""; if (index >= Global.CheatList.Count || Global.CheatList[index].IsSeparator) { return; } var columnName = column.Name; switch (columnName) { case NameColumn: text = Global.CheatList[index].Name; break; case AddressColumn: text = Global.CheatList[index].AddressStr; break; case ValueColumn: text = Global.CheatList[index].ValueStr; break; case CompareColumn: text = Global.CheatList[index].CompareStr; break; case OnColumn: text = Global.CheatList[index].Enabled ? "*" : ""; break; case DomainColumn: text = Global.CheatList[index].Domain.Name; break; case SizeColumn: text = Global.CheatList[index].Size.ToString(); break; case EndianColumn: text = (Global.CheatList[index].BigEndian ?? false) ? "Big" : "Little"; break; case TypeColumn: text = Watch.DisplayTypeToString(Global.CheatList[index].Type); break; case ComparisonTypeColumn: switch (Global.CheatList[index].ComparisonType) { case Cheat.CompareType.None: text = ""; break; case Cheat.CompareType.Equal: text = "="; break; case Cheat.CompareType.GreaterThan: text = ">"; break; case Cheat.CompareType.GreaterThanOrEqual: text = ">="; break; case Cheat.CompareType.LessThan: text = "<"; break; case Cheat.CompareType.LessThanOrEqual: text = "<="; break; case Cheat.CompareType.NotEqual: text = "!="; break; default: text = ""; break; } break; } }
public Cheat GetCheat() { var domain = MemoryDomains[DomainDropDown.SelectedItem.ToString()]; var address = AddressBox.ToRawInt().Value; if (address < domain.Size) { var watch = Watch.GenerateWatch( MemoryDomains[DomainDropDown.SelectedItem.ToString()], AddressBox.ToRawInt().Value, GetCurrentSize(), Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()), BigEndianCheckBox.Checked, NameBox.Text); Cheat.CompareType comparisonType; switch (CompareTypeDropDown.SelectedItem.ToString()) { case "": comparisonType = Cheat.CompareType.None; break; case "=": comparisonType = Cheat.CompareType.Equal; break; case ">": comparisonType = Cheat.CompareType.GreaterThan; break; case ">=": comparisonType = Cheat.CompareType.GreaterThanOrEqual; break; case "<": comparisonType = Cheat.CompareType.LessThan; break; case "<=": comparisonType = Cheat.CompareType.LessThanOrEqual; break; case "!=": comparisonType = Cheat.CompareType.NotEqual; break; default: comparisonType = Cheat.CompareType.None; break; } return(new Cheat( watch, ValueBox.ToRawInt().Value, CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value, true, comparisonType)); } else { MessageBox.Show($"{address} is not a valid address for the domain {domain.Name}", "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(Cheat.Separator); } }
private void DisplayTypeDropDown_SelectedIndexChanged(object sender, EventArgs e) { ValueBox.Type = CompareBox.Type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()); }
private void RamWatchNewWatch_Load(object sender, EventArgs e) { if (InitialLocation.X > 0 || InitialLocation.Y > 0) { Location = InitialLocation; } _loading = false; SetAddressBoxProperties(); switch (_mode) { default: case Mode.New: SizeDropDown.SelectedItem = MemoryDomains.First().WordSize switch { 1 => SizeDropDown.Items[0], 2 => SizeDropDown.Items[1], 4 => SizeDropDown.Items[2], _ => SizeDropDown.Items[0] }; break; case Mode.Duplicate: case Mode.Edit: SizeDropDown.SelectedItem = Watches[0].Size switch { WatchSize.Byte => SizeDropDown.Items[0], WatchSize.Word => SizeDropDown.Items[1], WatchSize.DWord => SizeDropDown.Items[2], _ => SizeDropDown.SelectedItem }; var index = DisplayTypeDropDown.Items.IndexOf(Watch.DisplayTypeToString(Watches[0].Type)); DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[index]; if (Watches.Count > 1) { NotesBox.Enabled = false; NotesBox.Text = ""; AddressBox.Enabled = false; AddressBox.Text = Watches.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => $"{addrStr},{nextStr}"); BigEndianCheckBox.ThreeState = true; if (Watches.Select(s => s.Size).Distinct().Count() > 1) { DisplayTypeDropDown.Enabled = false; } } else { NotesBox.Text = Watches[0].Notes; AddressBox.SetFromLong(Watches[0].Address); } SetBigEndianCheckBox(); DomainDropDown.Enabled = false; break; } }
private void SetDisplayTypes() { string oldType = DisplayTypeDropDown.Text; DisplayTypeDropDown.Items.Clear(); switch (SizeDropDown.SelectedIndex) { default: case 0: DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); break; case 1: DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); break; case 2: DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); break; } if (DisplayTypeDropDown.Items.Contains(oldType)) { DisplayTypeDropDown.SelectedItem = oldType; } else { DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[0]; } }
private void PopulateTypeDropdown() { DisplayTypeDropDown.Items.Clear(); switch (SizeDropDown.SelectedIndex) { default: case 0: DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); break; case 1: DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); break; case 2: DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); break; } DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[0]; }