= Views in HL3 = == Attributes == * View * Content == Methods to override: == {{{#!java public new Algorithm Content { get { return (T)base.Content; } set { base.Content = value; } } protected override void OnContentChanged() { base.OnContentChanged(); if (Content != null) { // set controls to Content values } else { // set default values in controls } } protected override void RegisterContentEvents() { } protected override void DeRegisterContentEvents() { } }}} Events happen asynchronous --> Invoke required. Views must still work if content is NULL. {{{#!java private void Content_XYZChanged(object sender, System.EventArgs e) { if (InvokeRequired) { Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e); } else { // set controls SetEnabledStateControls(); } } }}} === SetEnabledStateOfControls: === In principle all Views have 2 possible states: * Locked: * ReadOnly: cf. Results --> those can't be changed; this is not configured in the object graph but in the views * Either via ViewHost or manually OnContentChanged --> update content here SetEnabledStateOfControls --> only update enabled and readonly here === Default Views: === * The most specific default view is used for inherited classes. protected override void SetEnabledStateOfControls() { } === NamedItems: === You should make sure that if CanChangeName is false --> ReadOnly private void Content_NameChanged(object sender, EventArgs e) { if (InvokeRequired) { Invoke(...); } else { } } AsynchronosContentView, ItemView --> derive from those, not from ContentView or other views in MainForm.WindowsForm (uses Invoke synchronous --> can get messy). Andreas has prepared a useful snippet that you may use to easily create a template for your view. == General advice: == If you program views that are not sealed --> make everything protected to allow inheritance.