Hello
In a plugin we display various views on different screens:
Dictionary<FQID, FQID> _screens = new Dictionary<FQID, FQID>();
private void ShowView(Item screen, Item view)
{
var windows = Configuration.Instance.GetItemsByKind(Kind.Window);
if (!_screens.ContainsKey(screen.FQID) || !windows.Any(w => w.FQID.ObjectId == _screens[screen.FQID].ObjectId))
{
var openFullScreenData = new MultiWindowCommandData();
openFullScreenData.MultiWindowCommand = MultiWindowCommand.OpenFullScreenWindow;
openFullScreenData.Screen = screen.FQID;
openFullScreenData.Window = windows[0].FQID;
openFullScreenData.View = view.FQID;
var objects = SendMessageOnUiThread(new Message(MessageId.SmartClient.MultiWindowCommand, openFullScreenData));
_screens[screen.FQID] = objects[0] as FQID;
}
var windowFQID = _screens[screen.FQID];
var setViewInWindowData = new MultiWindowCommandData();
setViewInWindowData.MultiWindowCommand = MultiWindowCommand.SetViewInWindow;
setViewInWindowData.Screen = screen.FQID;
setViewInWindowData.Window = windowFQID;
setViewInWindowData.View = view.FQID;
SendMessageOnUiThread(new Message(MessageId.SmartClient.MultiWindowCommand, setViewInWindowData));
var selectWindowData = new MultiWindowCommandData();
selectWindowData.MultiWindowCommand = MultiWindowCommand.SelectWindow;
selectWindowData.Screen = screen.FQID;
selectWindowData.Window = windowFQID;
selectWindowData.View = view.FQID;
SendMessageOnUiThread(new Message(MessageId.SmartClient.MultiWindowCommand, selectWindowData));
var moveCommandData = new SetSelectedViewItemData() { MoveCommand = MoveCommand.Deselect };
SendMessageOnUiThread(new Message(MessageId.SmartClient.SetSelectedViewItemCommand, moveCommandData));
}
private System.Collections.ObjectModel.Collection<object> SendMessageOnUiThread(VideoOS.Platform.Messaging.Message message)
{
System.Collections.ObjectModel.Collection<object> objects = null;
ClientControl.Instance.CallOnUiThread(() => { objects = EnvironmentManager.Instance.SendMessage(message); });
return objects;
}
For me this is the only way to figure out which windows is display on which screen (by keeping track of it after its creation).
It looks like when you do Configuration.Instance.GetItemsByKind(Kind.Window), you only can know about it’s size and position but you don’t have access to its name (only “Floating window”) nor can you figure out which view is displayed on it.
I find it very weird that with GetItemsByKind() you can have a List for screens, a List for windows, and no way of knowing which maps to which, when obviously a window is only displayed on one screen.
So here is my question: is there a better way?
Bonus question: do you know why these two FQID are different? One is the one returned by SendMessage(), the other is the one returned by GetItemsByKind()
windows[1].FQID
{Server:SC:localhost Id:00000000-0000-0000-0000-000000000000, ObjectId:0d7925ea-4ea2-4162-9079-678a1c519b9e, Type:15da80d4-7595-431f-9866-674d2b80acc5}
FolderType: No
Kind: {15da80d4-7595-431f-9866-674d2b80acc5}
ObjectId: {0d7925ea-4ea2-4162-9079-678a1c519b9e}
ObjectIdString: null
ParentId: {00000000-0000-0000-0000-000000000000}
ServerId: {VideoOS.Platform.ServerId}
_screens[screen.FQID]
{Server:SC:localhost Id:00000000-0000-0000-0000-000000000000, ObjectId:0d7925ea-4ea2-4162-9079-678a1c519b9e, Type:15da80d4-7595-431f-9866-674d2b80acc5}
FolderType: No
Kind: {15da80d4-7595-431f-9866-674d2b80acc5}
ObjectId: {0d7925ea-4ea2-4162-9079-678a1c519b9e}
ObjectIdString: null
ParentId: {00000000-0000-0000-0000-000000000000}
ServerId: {VideoOS.Platform.ServerId}
_screens[screen.FQID] == windows[1].FQID
false
_screens[screen.FQID].ObjectId == windows[1].FQID.ObjectId
true