Class Page
public class Page
Inheritance
Inherited Members
Namespace: HomeSeer.Jui.Views
Assembly: PluginSdk.dll
A page is the primary container used to define a view for the user interface.
Constructors
View SourcePage(String, String, EPageType)
Create a new instance of a Page of the specified type with an ID and Name
Declaration
[JsonConstructor]
Page(string id, string name, EPageType type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | The unique ID of the page |
| System.String | name | The name of the page; the title shown to the user |
| EPageType | type | The type of the page |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if a Page is created with an invalid ID or Name |
Fields
View Source_viewIds
A set of IDs for the views on this page. This is used to ensure that there are no duplicate IDs used.
Declaration
[JsonIgnore]
Dictionary<string, int> _viewIds
Field Value
| Type | Description |
|---|---|
| System.Collections.Generic.Dictionary<System.String, System.Int32> |
_views
The collection of views that are on this page.
Declaration
[JsonProperty("views")]
List<AbstractView> _views
Field Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<AbstractView> |
Properties
View SourceId
A unique identifier for the page
Declaration
[JsonProperty("id")]
public string Id { get; protected set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Image
A Base64 encoded image used as an icon for this page
Declaration
[JsonProperty("image")]
public string Image { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Name
The name that is displayed to the user for this page
Declaration
[JsonProperty("name")]
public string Name { get; protected set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Type
The page's type; this determines where this page will present itself to the user.
Declaration
[JsonProperty("type")]
public EPageType Type { get; protected set; }
Property Value
| Type | Description |
|---|---|
| EPageType |
ViewCount
The number of views that are on this page.
Declaration
[JsonIgnore]
public int ViewCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
ViewIds
A list of the IDs of the views in this group
Declaration
[JsonIgnore]
public ReadOnlyCollection<string> ViewIds { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.ObjectModel.ReadOnlyCollection<System.String> |
Views
The collection of views that are on this page. This is for access only. Use AddView(AbstractView) and UpdateViewById(AbstractView) for setting views/updating them
Declaration
[JsonIgnore]
public ReadOnlyCollection<AbstractView> Views { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.ObjectModel.ReadOnlyCollection<AbstractView> |
Methods
View SourceAddView(AbstractView)
Add a view to the page
Declaration
public void AddView(AbstractView view)
Parameters
| Type | Name | Description |
|---|---|---|
| AbstractView | view |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The view or its ID is null |
| System.ArgumentException | There is already a view with the same ID present in the collection |
| System.InvalidOperationException | Thrown when trying to add a ViewGroup to another ViewGroup |
| ViewTypeMismatchException | Thrown when a view group's type does not match its class |
AddViewDelta(AbstractView, Object)
Add a view change to the page
Used to log value changes for views on settings, device config, event trigger and event action pages. This method performs a shallow copy of the original view and update it with the new value before adding it to the page.
Declaration
public void AddViewDelta(AbstractView originalView, object newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| AbstractView | originalView | The original view before the change |
| System.Object | newValue | The new value for the view |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | A valid original view was not specified |
| System.ArgumentOutOfRangeException | The type or integer value is invalid |
| System.ArgumentException | The value type doesn't match the view type |
AddViewDelta(String, Int32, Object)
Add a view change to the page
Used to log value changes for views on settings pages. All names are left blank
Declaration
public void AddViewDelta(string id, int type, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | The id of the view |
| System.Int32 | type | The EViewType of the view |
| System.Object | value | The new value for the view |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | A valid ID was not specified |
| System.ArgumentOutOfRangeException | The type or integer value is invalid |
| System.ArgumentException | The value type doesn't match the view type |
AddViews(IEnumerable<AbstractView>)
Add multiple views to the page
Declaration
public void AddViews(IEnumerable<AbstractView> views)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<AbstractView> | views |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The list of views is null |
ContainsViewWithId(String)
Check to see if a view with a specific ID is present in a collection
Declaration
public bool ContainsViewWithId(string viewId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | viewId |
Returns
| Type | Description |
|---|---|
| System.Boolean | TRUE if the view exists in the collection; FALSE if it does not exist in the collection |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The viewId to look for is NULL |
| System.IndexOutOfRangeException | The ID was found, but the view is not in the collection |
Equals(Object)
Compares the Id, Name, and the number of views
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Overrides
FromJsonString(String)
Deserialize a JSON string to a page
This should always be wrapped in a try/catch in case the data received is malformed
Declaration
public static Page FromJsonString(string jsonString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | jsonString | The JSON string containing the page |
Returns
| Type | Description |
|---|---|
| Page | A Page |
Exceptions
| Type | Condition |
|---|---|
| JsonDataException | Thrown when there was a problem deserializing the page |
GetHashCode()
Compares the Id, Name, and the number of views
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Overrides
GetViewById(String)
Get the view on the page with the given ID
Declaration
public AbstractView GetViewById(string viewId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | viewId | The ID of the view to get |
Returns
| Type | Description |
|---|---|
| AbstractView | The view with the specified ID as an AbstractView. This should be cast to the appropriate view type before use. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | An invalid view ID was entered |
| System.ArgumentException | No views are on the page to get |
| System.IndexOutOfRangeException | The ID was found, but the view was not. The page is probably malformed and should be recreated. |
| System.Collections.Generic.KeyNotFoundException | No views with that ID were found |
GetViewById<TViewType>(String)
Get the view with a specific ID from a collection cast as the target type
Declaration
public TViewType GetViewById<TViewType>(string viewId)
where TViewType : AbstractView
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | viewId | The ID of the view to get |
Returns
| Type | Description |
|---|---|
| TViewType | The view with the specified ID cast as the target type. |
Type Parameters
| Name | Description |
|---|---|
| TViewType |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | An invalid view ID was entered |
| System.ArgumentException | No views are on the page to get |
| System.IndexOutOfRangeException | The ID was found, but the view was not. The page is probably malformed and should be recreated. |
| System.Collections.Generic.KeyNotFoundException | No views with that ID were found |
ListFromJson(String)
Deserialize a JSON string to a List of Pages
Declaration
public static List<Page> ListFromJson(string jsonString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | jsonString | The JSON string containing the list of pages |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<Page> | A List of Jui.Page objects |
Exceptions
| Type | Condition |
|---|---|
| JsonDataException | Thrown when there was a problem deserializing the page |
MapViewIds()
Build a map of view IDs and list indexes for a collection of views
Declaration
void MapViewIds()
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The list of views to map is null |
RemoveAllViews()
Clear a collection of views
Declaration
public void RemoveAllViews()
RemoveViewById(String)
Remove a view with the specified ID from the collection.
Remaining views at indexes greater than the specified view will be moved down one index to fill the empty space
Declaration
public void RemoveViewById(string viewId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | viewId |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when any of the supplied parameters is null of empty |
| System.ArgumentException | Thrown when the number of items in the |
| System.Collections.Generic.KeyNotFoundException | Thrown when a view with the specified ID was not found |
RemoveViewsAfterId(String)
Trim all views in the collection following the view with the specified ID
Declaration
public void RemoveViewsAfterId(string viewId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | viewId |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when any of the supplied parameters is null of empty |
| System.ArgumentException | Thrown when the number of items in the |
SetViews(IEnumerable<AbstractView>)
Set the list of views on this page
Declaration
public void SetViews(IEnumerable<AbstractView> views)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<AbstractView> | views |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The list of views is null |
ToHtml(Int32)
Get a string representation of this page converted into HTML
Declaration
public string ToHtml(int indent = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | indent |
Returns
| Type | Description |
|---|---|
| System.String | An HTML representation of the page as a string |
ToJsonString()
Serialize the page as JSON
Declaration
public string ToJsonString()
Returns
| Type | Description |
|---|---|
| System.String | A string containing the page formatted as JSON |
ToValueMap()
Get a dictionary mapping IDs to values for the views on this page with mutable values.
These include: InputViews, SelectListViews, and ToggleViews
Declaration
public Dictionary<string, string> ToValueMap()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.Dictionary<System.String, System.String> | A Dictionary of view IDs to view values |
UpdateViewById(AbstractView)
Perform a soft update to a view in a collection with a particular ID
Declaration
public void UpdateViewById(AbstractView view)
Parameters
| Type | Name | Description |
|---|---|---|
| AbstractView | view |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The viewId to look for is NULL |
| System.IndexOutOfRangeException | The ID was found, but the view is not in the collection |
| System.ArgumentException | There are no views in the collection |
| ViewNotFoundException | No views with that ID were found in the collection |
UpdateViewValueById(String, String)
Declaration
public void UpdateViewValueById(string id, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | |
| System.String | value |