I create a new floating window with my plugin in the view. I want the user to be able to close the whole window using a button in the ViewItem plugin. What’s the best way to do this?
In the Smart Client View and Windows tool plugin sample in the Multi Window tab you can explore using the CloseSelectedWindow message command. This command is my best bet.
I don’t seem to be able to get this working… I’m doing this:
ClientControl.Instance.CallOnUiThread((() =>
{
dataWindowFQID = (FQID)EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data))[0];
})); // creating the window
and then
ClientControl.Instance.CallOnUiThread((() =>
{
EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MultiWindowCommand.SelectWindow, dataWindowFQID));
EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MultiWindowCommand.CloseSelectedWindow, dataWindowFQID));
}));
But nothing is happening..
When you do
EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MultiWindowCommand.CloseSelectedWindow, dataWindowFQID));
You are not using a MultiWindowCommandData class only a FQID class, I suspect this is the fault.
My guess is this is all the info you need to solve the issue, if not, perhaps you can single step debug the Smart Client View and Windows tool when it does the CloseSelectedWindow and learn more.
Now I’m doing
data.Window = (FQID)EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data))[0];
and then naturally
ClientControl.Instance.CallOnUiThread((() =>
{
EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MultiWindowCommand.SelectWindow,data.Window));
EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MultiWindowCommand.CloseSelectedWindow, data.Window));
}));
I’ve also tried just sendin data as a parameter (without .Window), that gives nothing.
I cannot run the Window tool, it throws an error and the Smart Client crashes. The exception is thrown since these 3 variables are all null.
viewCommandUserControl1.ClickEvent += new EventHandler(OnClick);
playbackUControl1.ClickEvent += new EventHandler(OnClick);
lensUserControl1.ClickEvent += new EventHandler(OnClick);
Something must have gone horribly wrong with the sample code… All the tabs in SCViewAndWindowViewItemUserControl are empty, but the variables are all there in the designer class, except they’re never initialized or assigned to anything.
Back to the issue, now Im doing
data.MultiWindowCommand = MultiWindowCommand.CloseSelectedWindow;
EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data), null, null);
and it’s still not working. It’s kinda wierd though, I loop through the windows and no window match the returned window FQID..
List<Item> list = Configuration.Instance.GetItemsByKind(Kind.Window);
foreach(Item item in list)
{
if(item.FQID == data.Window)
{
string lonely = "I'm never reached :(";
}
}
I cannot reproduce the behavior you observe. Trying to reproduce this code works for me:
private void buttonCreate_Click(object sender, System.Windows.RoutedEventArgs e)
{
ItemPickerForm form = new ItemPickerForm();
form.AutoAccept = false;
form.KindFilter = Kind.View;
form.Init(ClientControl.Instance.GetViewGroupItems());
if (form.ShowDialog() == DialogResult.OK)
{
_selectedView = form.SelectedItem;
}
List<Item> list = Configuration.Instance.GetItemsByKind(Kind.Window);
Item win = list.FirstOrDefault<Item>();
MultiWindowCommandData data = new MultiWindowCommandData();
data.Screen = null;
data.Window = win.FQID;
data.View = _selectedView != null ? _selectedView.FQID : null;
data.X = 200;
data.Y = 200;
data.Height = 400;
data.Width = 400;
data.MultiWindowCommand = "OpenFloatingWindow";
data.PlaybackSupportedInFloatingWindow = true;
var collection = EnvironmentManager.Instance.SendMessage(
new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data),
null,
null);
_myWin = (FQID)collection[0];
}
private void buttonRemove_Click(object sender, System.Windows.RoutedEventArgs e)
{
MultiWindowCommandData data = new MultiWindowCommandData();
data.Screen = null;
data.Window = _myWin;
data.View = null;// _selectedView != null ? _selectedView.FQID : null;
data.X = 200;
data.Y = 200;
data.Height = 400;
data.Width = 400;
data.MultiWindowCommand = "CloseSelectedWindow";
data.PlaybackSupportedInFloatingWindow = true;
EnvironmentManager.Instance.SendMessage(
new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data),
null,
null);
}
What version is your MIP SDK and your Smart Client?
I tried this and it didn’t work, but now after lunch it works all of a sudden.. The trick was to make a new instance of the MultiWindowCommandData object and assign the original window to that. Thanks a lot!