-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AdminUI #1
base: master
Are you sure you want to change the base?
AdminUI #1
Conversation
…e code back to DebugUI funtion of the same name works fine.
…odel. Working code state, can send admin commands via text console. "Show Object" command results sucessfully parsed and displayed.
{ | ||
public partial class ObjectEditor : Form | ||
{ | ||
public ObjectEditor(AdminObject obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not pass the datasource as a constructor parameter.
Instead define a property "DataSource" on your UI (view), according to MVC pattern the type of this property of course would be the one of the according underlying model providing the data for the view (your "AdminData" class for example if you need all of it - or in this case probably just "AdminObject")
Please have a look at "RoomInfoView.cs" or "RoomObjectsView.cs" for examples for "DataSource" property.
You can adopt their definition of a "DataSource" property. Don't forget the [DesignerSerialization...] attributes above the signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not completed yet. There are a lof of ways I can work better within your design/architecture. I'll work on that slowly. I feel like now that I have AdminData class in Meridian59 I might need an AdminUIController in DebugUI that handles talking to AdminData.
I probably need to define some Interfaces for AdminObject and AdminProperty, INotifyProeprtyChanged is probably not going to work in the long run.
…odel. Working code state, can send admin commands via text console. "Show Object" command results sucessfully parsed and displayed.
…into AdminUI Conflicts: Meridian59.DebugUI/Meridian59.DebugUI.csproj Meridian59/Data/DataController.cs Meridian59/Meridian59.csproj
DataController: Moved Handle....() from DataController to AdminData AdminData: Renamed "watched" object list, functions, etc to "tracked" added PacketSend event HandleAdminMessage() moved here HandleAdminShowObjectMessage(): resolved weird regex logic fixed regex to properly parse RESOURCEs now handles objects that already exist on the tracked list AdminObject: Properties's PropertyChanged events are subscribed to Sends its own PropertyChanged event when needed AdminObjectProperty: PropertyValue changed to private-backed field to add set logic to raise PropertyChanged events. added constructor that sets PropertyChanged event subscribers constructors do not trigger PropertyChanged by setting the backing field Added GetOwner() Clean up ObjectEditor: dataGridView now uses a BindingSource to properly send changes to the list RefreshData() to redraw the dataGridView on change event handler to call RefreshData() GetTrackedObject() DebugForm: added event handler for passing packets on to datacontroller added event handler for removing tracked objects on window close
DataController: Moved Handle....() from DataController to AdminData AdminData: Renamed "watched" object list, functions, etc to "tracked" added PacketSend event added LogAdminMessage event to pass text back to AdminUI Log HandleAdminMessage() moved here HandleAdminShowObjectMessage(): resolved weird regex logic fixed regex to properly parse RESOURCEs now handles objects that already exist on the tracked list AdminObject: Properties's PropertyChanged events are subscribed to Sends its own PropertyChanged event when needed AdminObjectProperty: PropertyValue changed to private-backed field to add set logic to raise PropertyChanged events. added constructor that sets PropertyChanged event subscribers constructors do not trigger PropertyChanged by setting the backing field Added GetOwner() Clean up ObjectEditor: dataGridView now uses a BindingSource to properly send changes to the list RefreshData() to redraw the dataGridView on change event handler to call RefreshData() GetTrackedObject() DebugForm: added event handler for passing packets on to datacontroller added event handler for removing tracked objects on window close
…into AdminUI Conflicts: Meridian59.DebugUI/ObjectEditor.cs Meridian59/Data/Models/AdminData/AdminData.cs
} | ||
else | ||
{ | ||
Properties = new BaseList<AdminObjectProperty>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer initialising collection instances once and define them readonly, to make sure they are correctly cleared/etc. rather than overwritten with a new instance (important for databinding!).
To achieve this, you should add the following field declaration to your class:
protected readonly BaseList< AdminObjectProperty > properties = new BaseList<..>();
Then return this instance in the getter of your:
public BaseList< AdminObjectProperty > Properties { get { return properties; } }
In your constructor, you would then have something like:
public AdminObject(string classname, int objectnumber, IEnumerable< AdminObjectProperty > props = null)
And in its implementation, you add the items to your own collection:
for(.... in props) ..[addtoownpropertieslist]
|
||
void adminObjectProperty_ValueChanged(object sender, PropertyChangedEventArgs e) | ||
{ | ||
if (sender.GetType() == typeof (AdminObjectProperty)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm usually using the "is" keyword to check class, however there is a difference to your variant here.
This expression will probably return "false" for a class deriving from 'AdminObjectProperty'?
If this is what you want, it's OK. But usually you would "accept" any "more specialized" class too.
So this could be:
if (sender is AdminObjectProperty)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't even know that was a keyword in C#.
TIL.
Will change, thanks. It wouldn't matter I think in this case, (as nothing should ever inherit AdminObjectProperty) but it won't hurt do it it right!
DebugUI has a new tab "AdminUI"
Currently works just like the $ window, type a command, see the output.
Launches New DebugUI.ObjectEditor Form from parsed return data of "show object X" commands.
DebugUI.ObjectEditor Form for displaying and eventually editing AdminObjects.
New namespace Meridian59.Data.Models.AdminData:
class AdminObject represents the object after being parsed, contains list of AdminObjectProperty
class AdminObjectProperty represents a property of an AdminObject, has a name, tag, value.
DataController handles the List of AdminObjects. this still feels sloppy. I am considering writing AdminObjectList and AdminObjectPropertyList to bind everything together easier.