Ejemplo n.º 1
0
        private void OnReceive(JObject resp, Logger log)
        {
            // Gets the raw users as an jarray
            JArray rawUserArr = (JArray)resp["users"];

            log
            .Debug("Received users")
            .Critical($"Users={rawUserArr.ToString(Newtonsoft.Json.Formatting.None)}");

            // Creates the array
            SimpleUserEntity[] users = new SimpleUserEntity[rawUserArr.Count];

            // Parses every user
            for (int i = 0; i < users.Length; i++)
            {
                try
                {
                    // Tries to load the user
                    users[i] = new SimpleUserEntity();
                    users[i].Load((JObject)rawUserArr[i], SimpleUserEntity.ENTRYS_LIST);
                }
                catch
                {
                    // If any user failes to load, the request is invalid
                    this.OnNonsenseError?.Invoke(NonsensicalError.UNKNOWN);
                    return;
                }
            }

            // Sends all received users
            this.onReceive?.Invoke(users);
        }
        /// <summary>
        /// Executes when the user selects another user
        /// </summary>
        private void OnSelectUser(object server, SelectionChangedEventArgs e)
        {
            // Checks that an item got selected
            if (this.List.SelectedItem == null)
            {
                return;
            }

            // Closes the popup
            this.Popup.IsOpen = false;

            // Gets the selected user
            // Updates the selected user
            SimpleUserEntity user = (this.List.SelectedItem as ListViewItem).Content as SimpleUserEntity;

            // Executes the handler
            this.OnSelect?.Invoke(user);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Executes when the user selects another user with the login form
 /// </summary>
 /// <param name="user">The selected user</param>
 private void OnLoginUserSelectSelect(SimpleUserEntity user) => Task.Run(() =>
 {
     // Displays the loading
     this.DisplayLoading(Lang.main_login_select_loading);