示例#1
0
 protected void ctlGrid_Widget(object o, Gtk.WidgetEventArgs args)
 {
     if (args.Event.Type == Gdk.EventType.ButtonRelease)
     {
         // In this case, the user used the mouse to click on a row in the grid
         var user = ctlGrid.FocusedItem as YamsterUser;
         if (user != null)
         {
             this.chosenUser = user;
             this.Destroy();
         }
     }
 }
示例#2
0
        protected override bool OnKeyPressEvent(Gdk.EventKey evnt)
        {
            if (evnt.Key == Gdk.Key.Escape)
            {
                this.Destroy();
            }

            if (evnt.Key == Gdk.Key.Return)
            {
                // If something is focused in the grid, return that
                var user = ctlGrid.FocusedItem as YamsterUser;
                if (user != null)
                {
                    this.chosenUser = user;
                    this.Destroy();
                    return(true);
                }
            }

            return(base.OnKeyPressEvent(evnt));
        }
示例#3
0
        /// <summary>
        /// Given an input such as " @alias1 @alias2 @alias3 ", this returns
        /// the list of referenced users.  If the string contains a syntax error, or
        /// if the users cannot be found, then null is returned.
        /// </summary>
        public List <YamsterUser> ParseUserList()
        {
            Match match = atMentionRegex.Match(txtEntry.Text);

            if (!match.Success)
            {
                throw new InvalidOperationException("The user list is not in the correct format."
                                                    + " It should be a list of Yammer user aliases such as \"@alias1 @alias2 @alias3\".");
            }

            HashSet <long>     matchedIds   = new HashSet <long>();
            List <YamsterUser> matchedUsers = new List <YamsterUser>();

            foreach (Capture capture in match.Groups[1].Captures)
            {
                YamsterUser user = this.appContext.YamsterCache.GetUserByAlias(capture.Value);
                if (!matchedIds.Contains(user.UserId))
                {
                    matchedIds.Add(user.UserId);
                    matchedUsers.Add(user);
                }
            }
            return(matchedUsers);
        }