Exemple #1
0
        public async Task <Error> DownloadInteraction()
        {
            var jsonrpc = new JsonRpcClient();

            //Ajouter le téléchargemnent et la mise a jours des interaction Jeedom
            try
            {
                var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///JeedomAppVoiceCommandes.xml"));

                await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile);

                VoiceCommandDefinition commandDefinitions;

                string countryCode = CultureInfo.CurrentCulture.Name.ToLower();
                if (countryCode.Length == 0)
                {
                    countryCode = "fr-fr";
                }

                if (VoiceCommandDefinitionManager.InstalledCommandDefinitions.TryGetValue("JeedomAppCommandSet_" + countryCode, out commandDefinitions))
                {
                    List <string> InteractsList = new List <string>();
                    if (await jsonrpc.SendRequest("interactQuery::all"))
                    {
                        InteractList.Clear();
                        var response = jsonrpc.GetRequestResponseDeserialized <Response <ObservableCollection <Interact> > >();
                        if (response != null)
                        {
                            InteractList = response.result;
                        }
                    }

                    foreach (var Iteract in InteractList)
                    {
                        InteractsList.Add(Iteract.query);
                    }
                    await commandDefinitions.SetPhraseListAsync("InteractList", InteractsList);
                }
            }
            catch (Exception ex)
            {
                // System.Diagnostics.Debug.WriteLine("Updating Phrase list for VCDs: " + ex.ToString());
            }

            return(jsonrpc.Error);
        }
 private void _eventAddIgnore(object arg1, EventArgs arg2)
 {
     EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, m_rend.Character.Name, EOResourceID.STATUS_LABEL_WILL_BE_IGNORED);
     InteractList.WriteNewIgnore(m_rend.Character.Name);
 }
Exemple #3
0
        public static void Show(PacketAPI apiHandle, bool isIgnoreList)
        {
            if (Instance != null)
            {
                return;
            }

            List <string> allLines = isIgnoreList ? InteractList.LoadAllIgnore() : InteractList.LoadAllFriend();

            string charName = OldWorld.Instance.MainPlayer.ActiveCharacter.Name;

            charName = char.ToUpper(charName[0]) + charName.Substring(1);
            string titleText = string.Format("{0}'s {2} [{1}]", charName, allLines.Count,
                                             OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));

            ScrollingListDialog dlg = new ScrollingListDialog
            {
                Title        = titleText,
                Buttons      = ScrollingListDialogButtons.AddCancel,
                ListItemType = ListDialogItem.ListItemStyle.Small
            };

            List <ListDialogItem> characters = allLines.Select(character => new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small)
            {
                Text = character
            }).ToList();

            characters.ForEach(character =>
            {
                character.OnLeftClick  += (o, e) => EOGame.Instance.Hud.SetChatText("!" + character.Text + " ");
                character.OnRightClick += (o, e) =>
                {
                    dlg.RemoveFromList(character);
                    dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
                                              OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                };
            });
            dlg.SetItemList(characters);

            dlg.DialogClosing += (o, e) =>
            {
                if (e.Result == XNADialogResult.Cancel)
                {
                    Instance = null;
                    if (isIgnoreList)
                    {
                        InteractList.WriteIgnoreList(dlg.NamesList);
                    }
                    else
                    {
                        InteractList.WriteFriendList(dlg.NamesList);
                    }
                }
                else if (e.Result == XNADialogResult.Add)
                {
                    e.CancelClose = true;
                    string          prompt   = OldWorld.GetString(isIgnoreList ? EOResourceID.DIALOG_WHO_TO_MAKE_IGNORE : EOResourceID.DIALOG_WHO_TO_MAKE_FRIEND);
                    TextInputDialog dlgInput = new TextInputDialog(prompt);
                    dlgInput.DialogClosing += (_o, _e) =>
                    {
                        if (_e.Result == XNADialogResult.Cancel)
                        {
                            return;
                        }

                        if (dlgInput.ResponseText.Length < 4)
                        {
                            _e.CancelClose = true;
                            EOMessageBox.Show(DialogResourceID.CHARACTER_CREATE_NAME_TOO_SHORT);
                            dlgInput.SetAsKeyboardSubscriber();
                            return;
                        }

                        if (dlg.NamesList.FindIndex(name => name.ToLower() == dlgInput.ResponseText.ToLower()) >= 0)
                        {
                            _e.CancelClose = true;
                            EOMessageBox.Show("You are already friends with that person!", "Invalid entry!", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                            dlgInput.SetAsKeyboardSubscriber();
                            return;
                        }

                        ListDialogItem newItem = new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small)
                        {
                            Text = dlgInput.ResponseText
                        };
                        newItem.OnLeftClick  += (oo, ee) => EOGame.Instance.Hud.SetChatText("!" + newItem.Text + " ");
                        newItem.OnRightClick += (oo, ee) =>
                        {
                            dlg.RemoveFromList(newItem);
                            dlg.Title = string.Format("{0}'s {2} [{1}]",
                                                      charName,
                                                      dlg.NamesList.Count,
                                                      OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                        };
                        dlg.AddItemToList(newItem, true);
                        dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
                                                  OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                    };
                }
            };

            Instance = dlg;

            List <OnlineEntry> onlineList;

            apiHandle.RequestOnlinePlayers(false, out onlineList);
            Instance.SetActiveItemList(onlineList.Select(_oe => _oe.Name).ToList());

            EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST,
                                               OldWorld.GetString(EOResourceID.STATUS_LABEL_USE_RIGHT_MOUSE_CLICK_DELETE));
            //show the dialog
        }