/// <summary> /// Event handler when a GUI property was changed /// </summary> /// <param name="tag"></param> /// <param name="tagValue"></param> void GUIPropertyManager_OnPropertyChanged(string tag, string tagValue) { if (tag.Equals("#currentmodule")) { if (tagValue != null && tagValue.Equals(localizedKeyboard)) { MessageOnscreenKeyboard keyboardMessage = new MessageOnscreenKeyboard(true); string keyboard = Newtonsoft.Json.JsonConvert.SerializeObject(keyboardMessage); socketServer.SendMessageToAllClients(keyboard); keyboardIsActive = true; } else if (keyboardIsActive) { MessageOnscreenKeyboard keyboardMessage = new MessageOnscreenKeyboard(false); string keyboard = Newtonsoft.Json.JsonConvert.SerializeObject(keyboardMessage); socketServer.SendMessageToAllClients(keyboard); keyboardIsActive = false; } IRenderLayer layer = GUILayerManager.GetLayer(GUILayerManager.LayerType.Dialog); if (layer != null && layer.GetType().IsSubclassOf(typeof(GUIDialogWindow))) { WifiRemote.LogMessage("Sending dialog open to clients", LogType.Debug); MpDialogsHelper.CurrentDialog = layer as GUIDialogWindow; MessageDialog msg = MpDialogsHelper.GetDialogMessage(MpDialogsHelper.CurrentDialog); if (msg != null && msg.Dialog != null && msg.Dialog.GetType() == typeof(MpDialogMenu)) { //TODO: this is a hack to retrieve the list items of a dialog because they are //set after initialisation of the dialog and there is no event fired up after //that. We might run into situations where the list hasn't been updated when //we try to read it Thread t = new Thread(new ParameterizedThreadStart(SendDelayed)); t.Start(msg); } else if (msg != null && msg.Dialog != null && msg.Dialog.GetType() == typeof(MpDialogProgress)) { Thread t = new Thread(new ParameterizedThreadStart(SendProgressUpdates)); t.Start(msg); } else { socketServer.SendMessageToAllClients(msg); } MpDialogsHelper.IsDialogShown = true; } else if (MpDialogsHelper.IsDialogShown) { WifiRemote.LogMessage("Sending dialog close to clients", LogType.Debug); MessageDialog message = new MessageDialog(); message.DialogShown = false; socketServer.SendMessageToAllClients(message); MpDialogsHelper.IsDialogShown = false; } } if (tag.Equals("#selecteditem") || tag.Equals("#selecteditem2") || tag.Equals("#highlightedbutton") || tag.Equals("#currentmodule")) { SendStatus(); } else if (tag.StartsWith("#Play.") || tag.StartsWith("#TV.")) { socketServer.SendPropertyToClient(tag, tagValue); } if (tag.Equals("#selectedindex") || tag.Equals("#highlightedbutton")) { socketServer.SendListViewStatusToAllClientsIfChanged(); } }
/// <summary> /// Get the WifiRemote message from the given dialog /// </summary> /// <param name="dialog">The MP dialog</param> /// <returns>WifiRemote dialog message</returns> internal static Messages.MessageDialog GetDialogMessage(GUIDialogWindow dialog) { MpDialog diag = MpDialogsHelper.GetDialog(dialog); MessageDialog message = new MessageDialog(); message.DialogShown = true; message.Dialog = diag; return message; }
/// <summary> /// Handle the dialog action /// </summary> /// <param name="message">Message from Client</param> internal static void HandleDialogAction(Newtonsoft.Json.Linq.JObject message, SocketServer server, AsyncSocket client) { String action = (string)message["ActionType"]; int dialogId = (int)message["DialogId"]; int index = (int)message["Index"]; if (action.Equals("get")) { if (MpDialogsHelper.IsDialogShown) { MessageDialog msg = MpDialogsHelper.GetDialogMessage(MpDialogsHelper.CurrentDialog); server.SendMessageToClient(msg, client); } else { MessageDialog msg = new MessageDialog(); msg.DialogShown = false; server.SendMessageToClient(msg, client); } } else { if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_MENU) { MpDialogMenu diag = MpDialogsHelper.GetDialogMenu(); diag.HandleAction(action, index); } else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_OK) { MpDialogOk diag = MpDialogsHelper.GetDialogOk(); diag.HandleAction(action, index); } else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_YES_NO) { MpDialogYesNo diag = MpDialogsHelper.GetDialogYesNo(); diag.HandleAction(action, index); } else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY) { MpDialogNotify diag = MpDialogsHelper.GetDialogNotify(); diag.HandleAction(action, index); } else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS) { MpDialogProgress diag = MpDialogsHelper.GetDialogProgress(); diag.HandleAction(action, index); } else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_RATING) { MpDialogRating diag = MpDialogsHelper.GetDialogRating(); diag.HandleAction(action, index); } else if (dialogId == MpDialogsHelper.TVSERIES_RATING_ID) { if (WifiRemote.IsAvailableTVSeries) { MpDialogTvSeriesRating diag = MpDialogsHelper.GetDialogMpTvSeriesRating(); diag.HandleAction(action, index); } } else if (dialogId == MpDialogsHelper.TVSERIES_PIN_ID) { if (WifiRemote.IsAvailableTVSeries) { MpDialogTvSeriesPin diag = MpDialogsHelper.GetDialogMpTvSeriesPin(); diag.HandleAction(action, index); } } else if (dialogId == MpDialogsHelper.MOPI_RATING_ID) { if (WifiRemote.IsAvailableMovingPictures) { MpDialogMovingPicturesRating diag = MpDialogsHelper.GetDialogMovingPicturesRating(); diag.HandleAction(action, index); } } else if (dialogId == MpDialogsHelper.MOPI_PIN_ID) { if (WifiRemote.IsAvailableMovingPictures) { MpDialogMovingPicturesPin diag = MpDialogsHelper.GetDialogMovingPicturesPin(); diag.HandleAction(action, index); } } } }