-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Control Panel view state * State more in-line with React's model * Listing all blocks from the terminal system * Calls to modify the block properties * Reasonable printing of block properties for initial testing
- Loading branch information
1 parent
ba792c0
commit 3f20e06
Showing
20 changed files
with
428 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,88 @@ | ||
var state = ''; | ||
var blockStates = null; | ||
|
||
async function clearContent() { | ||
$('#blocks').empty(); | ||
async function stateUpdated() { | ||
const blockViews = $('#blocks'); | ||
blockViews.empty(); | ||
|
||
blockStates = await state.GetBlockStates(); | ||
for (const entityId in blockStates) { | ||
renderBlock(blockViews, blockStates[entityId]); | ||
} | ||
} | ||
|
||
function renderBlock(parent, blockState) { | ||
let blockView = $('<div />'); | ||
blockView.addClass('block'); | ||
blockView.attr('id', 'block-' + blockState.EntityId); | ||
renderBlockInner(blockView, blockState); | ||
parent.append(blockView); | ||
} | ||
|
||
function renderBlockInner(blockView, blockState) { | ||
let id = $('<div />'); | ||
id.addClass('entityId'); | ||
id.text(blockState.EntityId); | ||
blockView.append(id); | ||
|
||
let type = $('<div />'); | ||
type.addClass('type'); | ||
type.text(blockState.ClassName + ' | ' + blockState.TypeId + ' | ' + blockState.SubtypeName); | ||
blockView.append(type); | ||
|
||
let name = $('<div />'); | ||
name.addClass('name'); | ||
name.text(blockState.Name); | ||
blockView.append(name); | ||
|
||
let properties = $('<div />') | ||
properties.addClass('properties'); | ||
for (const propertyId in blockState.PropertyStates) { | ||
renderBlockProperty(properties, blockState.PropertyStates[propertyId]) | ||
} | ||
blockView.append(properties) | ||
|
||
blockView.append($('<hr />')) | ||
} | ||
|
||
function renderBlockProperty(parent, propertyState) { | ||
let propertyView= $('<div />'); | ||
propertyView.addClass('property'); | ||
|
||
let value = $('<div />'); | ||
value.addClass('value'); | ||
switch(propertyState.TypeName) { | ||
case "Boolean": | ||
cb = $('<input />') | ||
cb.attr('type', 'checkbox'); | ||
cb.attr('id', propertyState.Id); | ||
if (propertyState.BoolValue) { | ||
cb.attr('checked', 'checked'); | ||
} | ||
value.append(cb); | ||
label = $('<label />'); | ||
label.attr('for', propertyState.Id); | ||
label.text(propertyState.Id); | ||
value.append(label); | ||
break; | ||
case "Int64": | ||
value.text(propertyState.Id + ': ' + propertyState.LongValue.toString()); | ||
break; | ||
case "Single": | ||
value.text(propertyState.Id + ': ' + propertyState.FloatValue.toString()); | ||
break; | ||
default: | ||
value.text(propertyState.Id + ' ' + propertyState.TypeName + ': ' + propertyState.BoolValue.toString() + " | " + propertyState.LongValue.toString() + " | " + propertyState.FloatValue.toString()); | ||
} | ||
|
||
propertyView.append(value); | ||
|
||
parent.append(propertyView); | ||
} | ||
|
||
async function updateContent() { | ||
const blocks = await model.GetBlocks(); | ||
const ul = $('#blocks'); | ||
ul.empty(); | ||
blocks.forEach(block => { | ||
let li = $('<li>'); | ||
li.append(document.createTextNode(block.Name)); | ||
ul.append(li); | ||
}); | ||
async function blockStateUpdated(entityId) { | ||
// let blockState = await state.GetBlockState(entityId); | ||
// let blockView = $('#block-' + entityId); | ||
// if (blockView.length > 0) { | ||
// renderBlockInner(blockView, blockState); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
async function loadItems() { | ||
const result = await model.TestAdd(1, 2); | ||
$('#result').text(result.toString()); | ||
async function stateUpdated() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
$(document).ready(function () { | ||
$("#window-size").text(`${window.innerWidth}x${window.innerHeight}`); | ||
initializeProxy().then(_ => null); | ||
}); | ||
$(document).ready(async function () { | ||
await CefSharp.BindObjectAsync("state"); | ||
state.NotifyBound(); | ||
|
||
async function initializeProxy() { | ||
await CefSharp.BindObjectAsync("model"); | ||
model.MarkLoaded(); | ||
} | ||
$("#window-size").text(`${window.innerWidth}x${window.innerHeight}`); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using CefSharp; | ||
using CefSharp.OffScreen; | ||
|
||
namespace EnhancedUI.Gui | ||
{ | ||
public class PanelState : IPanelState | ||
{ | ||
// Stores a reference to the browser, required to invoke JavaScript code (send events from C# to JS) | ||
protected ChromiumWebBrowser? Browser; | ||
|
||
// True value indicates that the state has been bound to a JS accessible global variable already | ||
private bool bound; | ||
|
||
public void SetBrowser(ChromiumWebBrowser? browser) | ||
{ | ||
Browser = browser; | ||
} | ||
|
||
// Checks whether the state has been bound to a JS accessible global variable already | ||
public bool HasBound() | ||
{ | ||
return bound && Browser?.IsBrowserInitialized == true; | ||
} | ||
|
||
// Invoked by JS code after the state is bound to a global variable | ||
public virtual void NotifyBound() | ||
{ | ||
bound = true; | ||
} | ||
|
||
// Reloads the page, which requires re-binding the state to a JS global variable | ||
public virtual void Reload() | ||
{ | ||
bound = false; | ||
Browser?.Reload(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.