Free cookie consent management tool by TermsFeed Policy Generator

Changes between Initial Version and Version 1 of Documentation/DevelopmentCenter/CreateNewViews


Ignore:
Timestamp:
11/18/10 20:55:31 (14 years ago)
Author:
mkofler
Comment:

Tried to document Michael Kommenda's View HowTo

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/DevelopmentCenter/CreateNewViews

    v1 v1  
     1= Views in HL3 =
     2
     3== Attributes ==
     4 * View
     5 * Content
     6
     7== Methods to override: ==
     8
     9{{{#!java
     10public new Algorithm Content {
     11get { return (T)base.Content; }
     12set { base.Content = value; }
     13}
     14
     15protected override void OnContentChanged() {
     16  base.OnContentChanged();
     17  if (Content != null) {
     18    // set controls to Content values
     19  } else {
     20    // set default values in controls
     21  }
     22}
     23
     24protected override void RegisterContentEvents() {
     25 
     26}
     27
     28protected override void DeRegisterContentEvents() {
     29 
     30}
     31}}}
     32
     33Events happen asynchronous --> Invoke required.
     34
     35Views must still work if content is NULL.
     36{{{#!java
     37private void Content_XYZChanged(object sender, System.EventArgs e) {
     38  if (InvokeRequired) {
     39    Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
     40  } else {
     41    // set controls
     42    SetEnabledStateControls();
     43  }
     44}
     45}}}
     46
     47=== SetEnabledStateOfControls: ===
     48
     49In principle all Views have 2 possible states:
     50* Locked:
     51* ReadOnly: cf. Results --> those can't be changed; this is not configured in the object graph but in the views
     52
     53* Either via ViewHost or manually
     54
     55OnContentChanged --> update content here
     56SetEnabledStateOfControls --> only update enabled and readonly here
     57
     58=== Default Views: ===
     59 * The most specific default view is used for inherited classes.
     60
     61
     62protected override void SetEnabledStateOfControls() {
     63
     64}
     65
     66=== NamedItems: ===
     67You should make sure that if CanChangeName is false --> ReadOnly
     68
     69private void Content_NameChanged(object sender, EventArgs e) {
     70  if (InvokeRequired) {
     71    Invoke(...);
     72  } else {
     73   
     74  }
     75}
     76
     77AsynchronosContentView, ItemView --> derive from those, not from ContentView or other views in MainForm.WindowsForm (uses Invoke synchronous --> can get messy).
     78
     79Andreas has prepared a useful snippet that you may use to easily create a template for your view.
     80
     81
     82== General advice: ==
     83If you program views that are not sealed --> make everything protected to allow inheritance.