Wheredidigo
Community Developer
- Joined
- Dec 15, 2013
- Messages
- 417
Mastahg,
I have the following code which I'm using to information about RemoteWindows onto a Winforms Form to make it easy to gather information about those windows while devs are trying to write OrderBotProfiles.
This should dynamically build me tabs for each different type of control it gets back, but everything is coming back as an AtkAddonControl instead of the different types(ie: SelectString, SelectIconString, SelectYesNo, etc...)
Can you tell me if I'm using something incorrectly?
Also, if I were to just put a var y = SelectString.IsOpen; at the very top of that method...even when I do have the SelectString window open, it is showing false when I debug the code. The weird part is that if I do a Log(SelectString.IsOpen); in the Console, it returns false. Can you shed some light on what it's doing behind the scenes to make sure it has the correct data?
Here is a sample of what the form looks like right now with that method:
I have the following code which I'm using to information about RemoteWindows onto a Winforms Form to make it easy to gather information about those windows while devs are trying to write OrderBotProfiles.
Code:
private void RemoteWindowsGrid()
{
var remoteWindowTabIndex = tabControl1.TabPages.IndexOfKey("tabRemoteWindows");
var remoteWindowTabPage = tabControl1.TabPages[remoteWindowTabIndex];
var remoteWindowsTabControl = new TabControl { Dock = DockStyle.Fill };
foreach (var window in RaptureAtkUnitManager.GetRawControls.OrderBy(x => x.Name))
{
var thisWindowName = window.GetType().Name;
var props =
window.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public |
BindingFlags.NonPublic);
if (!remoteWindowsTabControl.TabPages.ContainsKey(thisWindowName))
{
var tabPage = new TabPage { Name = thisWindowName, Text = thisWindowName, Dock = DockStyle.Fill};
var propertyDataGrid = new DataGridView
{
Name = thisWindowName + "DataGrid",
ColumnCount = props.Count() + 1,
Dock = DockStyle.Fill
};
propertyDataGrid.Columns[0].Name = window.Name;
for (int i = 1; i <= props.Count(); i++)
{
propertyDataGrid.Columns[i].Name = props[i - 1].Name;
}
tabPage.Controls.Add(propertyDataGrid);
remoteWindowsTabControl.TabPages.Add(tabPage);
}
var row = props.Select(x => x.GetValue(window, null)).ToArray();
var insertRow = new object[row.Length + 1];
insertRow[0] = window.Name;
Array.Copy(row, 0, insertRow, 1, row.Length);
var dg = (DataGridView)remoteWindowsTabControl.TabPages[thisWindowName].Controls[thisWindowName + "DataGrid"];
dg.Rows.Add(insertRow);
}
remoteWindowTabPage.Controls.Add(remoteWindowsTabControl);
}
This should dynamically build me tabs for each different type of control it gets back, but everything is coming back as an AtkAddonControl instead of the different types(ie: SelectString, SelectIconString, SelectYesNo, etc...)
Can you tell me if I'm using something incorrectly?
Also, if I were to just put a var y = SelectString.IsOpen; at the very top of that method...even when I do have the SelectString window open, it is showing false when I debug the code. The weird part is that if I do a Log(SelectString.IsOpen); in the Console, it returns false. Can you shed some light on what it's doing behind the scenes to make sure it has the correct data?
Here is a sample of what the form looks like right now with that method:
