Exemplo n.º 1
0
      private void SaveButton_Click(object sender, RoutedEventArgs e)
      {
         // When saving, create the output user for the caller who invoked
         // this window to use as output.
         OutputUser = CreateUserFromFields();

         // If the generated user is valid, we're done.
         if (OutputUser.IsValid())
         {
            this.Close();
            return;
         }
         
         // Don't close the window if the values are invalid.
         //FIXME: use styles to highlight the error fields.
         if (String.IsNullOrEmpty(m_nick.Text))
         {
            m_nick.Text = "unnamed.senesco";
         }
         else
         {
            // If the nick was okay, the icon must be invalid.
            // This will need better checking if there's more extensive validation.
            m_icon.Text = "0";
         }

         OutputUser = null;
      }
Exemplo n.º 2
0
      /// <summary>
      /// Call this method to update your user settings on the server.  You can
      /// update your nick, icon number, and ignore flags.  For ignoring, you
      /// can either ignore Private Messages or Private Chats, or both.  When
      /// ignoring such private requests, you can also optionally specify an
      /// automatic ignore response, which is handled by the server.
      /// </summary>
      /// <param name="newNick">Your new nick</param>
      /// <param name="newIcon">Your new icon number</param>
      /// <param name="ignorePrivMsgs">If true, ignore PM's</param>
      /// <param name="ignorePrivChat">If true, ignore PC's</param>
      /// <param name="autoIgnoreMsg">
      /// If provided, send this message to the requestor on your behalf when a request is ignored.
      /// </param>
      public Status SetUserInfo(User newUserInfo)
      {
         if (m_server == null || m_server.IsConnected == false)
         {
            string message = "Cannot set user info: not connected to server.";
            s_log.ErrorFormat(message);
            return Status.GetFailure(message);
         }

         string error;
         if (newUserInfo.IsValid(out error) == false)
         {
            string message = String.Format("Cannot set user info: {0}.", error);
            s_log.ErrorFormat(message);
            return Status.GetFailure(message);
         }

         // If not ignoring anything, don't send an ignore message.
         if (newUserInfo.IgnorePrivateMsgs == false && newUserInfo.IgnorePrivateChat == false)
         {
            newUserInfo.IgnoreAutoResponse = null;
         }

         SetUserInfo setUserInfo = new SetUserInfo(
            newUserInfo.Username,
            newUserInfo.IconId,
            newUserInfo.IgnorePrivateMsgs,
            newUserInfo.IgnorePrivateChat,
            newUserInfo.IgnoreAutoResponse);

         Status result = m_server.SendTransaction(setUserInfo);

         // Update the local values, since the server doesn't come back with a response.
         if (result == Status.Success)
            m_localUser = newUserInfo;

         return result;
      }