private void LoadSettings(IReadOnlyList <string> blacklist) { var type = SettingsObject.GetType(); var props = ReflectUtil.GetPropertiesCanWritePublicDeclared(type); if (ModifierKeys != Keys.Control) { props = props.Except(blacklist); } foreach (var p in props) { var state = ReflectUtil.GetValue(Settings.Default, p); switch (state) { case bool b: var chk = GetCheckBox(p, b); FLP_Settings.Controls.Add(chk); FLP_Settings.SetFlowBreak(chk, true); if (blacklist.Contains(p)) { chk.ForeColor = Color.Red; } continue; } } }
private void LoadSettings(IEnumerable <string> blacklist) { var type = SettingsObject.GetType(); var props = ReflectUtil.GetPropertiesCanWritePublicDeclared(type).Except(blacklist); foreach (var p in props) { var state = ReflectUtil.GetValue(Settings.Default, p); switch (state) { case bool b: var chk = GetCheckBox(p, b); FLP_Settings.Controls.Add(chk); FLP_Settings.SetFlowBreak(chk, true); continue; } } }
private void UpdateBlockSummaryControls() { var block = CurrentBlock; L_Detail_R.Text = GetBlockSummary(block); RTB_Hex.Text = string.Join(" ", block.Data.Select(z => $"{z:X2}")); var blockName = Metadata.GetBlockName(block, out var obj); if (blockName != null) { L_BlockName.Visible = true; L_BlockName.Text = blockName; } else { L_BlockName.Visible = false; } if (ModifierKeys != Keys.Control) { // Show a PropertyGrid to edit if (obj != null) { var props = ReflectUtil.GetPropertiesCanWritePublicDeclared(obj.GetType()); if (props.Count() > 1) { PG_BlockView.Visible = true; PG_BlockView.SelectedObject = obj; return; } } var o = SCBlockMetadata.GetEditableBlockObject(block); if (o != null) { PG_BlockView.Visible = true; PG_BlockView.SelectedObject = o; return; } } PG_BlockView.Visible = false; }
private void LoadSettings(object obj) { var type = obj.GetType(); var props = ReflectUtil.GetPropertiesCanWritePublicDeclared(type); foreach (var p in props) { var state = ReflectUtil.GetValue(obj, p); if (state is null) { continue; } var tab = new TabPage(p); var pg = new PropertyGrid { SelectedObject = state, Dock = DockStyle.Fill }; tab.Controls.Add(pg); tabControl1.TabPages.Add(tab); } }
private void B_ReadRAM_Click(object sender, EventArgs e) { var txt = RamOffset.Text; var offset = Util.GetHexValue64(txt); var valid = int.TryParse(RamSize.Text, out int size); if (offset.ToString("X16") != txt.ToUpper().PadLeft(16, '0') || !valid) { WinFormsUtil.Alert("Make sure that the RAM offset is a hex string and the size is a valid integer"); return; } try { byte[] result; if (Remote.Bot.com is not ICommunicatorNX cnx) { result = Remote.ReadRAM(offset, size); } else { if (RB_Main.Checked) { result = cnx.ReadBytesMain(offset, size); } else if (RB_Absolute.Checked) { result = cnx.ReadBytesAbsolute(offset, size); } else { result = Remote.ReadRAM(offset, size); } } bool blockview = (ModifierKeys & Keys.Control) == Keys.Control; PKM? pkm = null; if (blockview) { pkm = SAV.SAV.GetDecryptedPKM(result); if (!pkm.ChecksumValid || pkm == null) { blockview = false; } } using (var form = new SimpleHexEditor(result, Remote.Bot, offset, GetRWMethod())) { #pragma warning disable CS8602 // Dereference of a possibly null reference. var loadgrid = blockview && ReflectUtil.GetPropertiesCanWritePublicDeclared(pkm.GetType()).Count() > 1; #pragma warning restore CS8602 // Dereference of a possibly null reference. if (loadgrid) { form.PG_BlockView.Visible = true; form.PG_BlockView.SelectedObject = pkm; } var res = form.ShowDialog(); if (res == DialogResult.OK) { if (loadgrid && pkm != null) { var pkmbytes = RamOffsets.WriteBoxData(Remote.Bot.Version) ? pkm.EncryptedBoxData : pkm.EncryptedPartyData; if (pkmbytes.Count() == Remote.Bot.SlotSize) { form.Bytes = pkmbytes; } else { form.Bytes = result; WinFormsUtil.Error("Size mismatch. Please report this issue on the discord server."); } } var modifiedRAM = form.Bytes; if (Remote.Bot.com is not ICommunicatorNX nx) { Remote.WriteRAM(offset, modifiedRAM); } else { if (RB_Main.Checked) { nx.WriteBytesMain(modifiedRAM, offset); } else if (RB_Absolute.Checked) { nx.WriteBytesAbsolute(modifiedRAM, offset); } else { Remote.WriteRAM(offset, modifiedRAM); } } } }