public Room FindRoom(string roomName, string roomDescription, RoomMatcher matcher)
            {
                Room room = null;

                try { m_control.Invoke((MethodInvoker) delegate() { room = m_canvas.FindRoom(roomName, roomDescription, matcher); }); }
                catch (Exception) { }
                return(room);
            }
        Room IAutomapCanvas.FindRoom(string roomName, string roomDescription, RoomMatcher matcher)
        {
            var list = new List <Room>();

            foreach (var element in Project.Current.Elements)
            {
                if (element is Room)
                {
                    var room    = (Room)element;
                    var matches = matcher(roomName, roomDescription, room);
                    if (matches.HasValue && matches.Value)
                    {
                        // it's definitely this room
                        return(room);
                    }
                    else if (!matches.HasValue)
                    {
                        // it's ambiguous
                        list.Add(room);
                    }
                }
            }

            if (list.Count == 0)
            {
                return(null);
            }
            if (m_dontAskAboutAmbiguities)
            {
                // the user has long given up on this process;
                // use the first ambiguous room in the list.
                return(list[0]);
            }
            if ((string.IsNullOrEmpty(roomDescription) || !list[0].HasDescription) && list.Count == 1)
            {
                // technically it's ambiguous, but we don't two descriptions for the user to compare;
                // there's only one option, so use it. They probably didn't have VERBOSE on for the whole transcript.
                return(list[0]);
            }

            using (var dialog = new DisambiguateRoomsDialog())
            {
                dialog.SetTranscriptContext(roomName, roomDescription);
                dialog.AddAmbiguousRooms(list);
                dialog.ShowDialog();
                if (dialog.UserDoesntCareAnyMore)
                {
                    // The user has given up on this process! Can't say I blame them.
                    // Use the first ambiguous room on the list, as above.
                    m_dontAskAboutAmbiguities = true;
                    return(list[0]);
                }

                // Either the user picked a room, or they said "New Room" in which case we don't match, returning null.
                return(dialog.Disambiguation);
            }
        }
Beispiel #3
0
            public Room FindRoom(string roomName, string roomDescription, string line, RoomMatcher matcher)
            {
                Room room = null;

                try { mControl.Invoke((MethodInvoker) delegate { room = mCanvas.FindRoom(roomName, roomDescription, line, matcher); }); }
                catch (Exception)
                {
                    // ignored
                }
                return(room);
            }
Beispiel #4
0
        Room IAutomapCanvas.FindRoom(string roomName, string roomDescription, string line, RoomMatcher matcher)
        {
            var list = new List <Room>();

            foreach (var element in Project.Current.Elements)
            {
                if (element is Room room1)
                {
                    var room    = room1;
                    var matches = matcher(roomName, roomDescription, room);
                    if (matches.HasValue && matches.Value)
                    {
                        return(room);
                    }
                    if (!matches.HasValue)
                    {
                        list.Add(room);
                    }
                }
            }

            if (list.Count == 0)
            {
                return(null);
            }
            if (mDontAskAboutAmbiguities)
            {
                return(list[0]);
            }
            if ((string.IsNullOrEmpty(roomDescription) || !list[0].HasDescription) && list.Count == 1)
            {
                return(list[0]);
            }

            using (var dialog = new DisambiguateRoomsDialog()) {
                dialog.SetTranscriptContext(roomName, roomDescription, line);
                dialog.AddAmbiguousRooms(list);
                dialog.ShowDialog();
                if (dialog.UserDoesntCareAnyMore)
                {
                    // The user has given up on this process! Can't say I blame them.
                    // Use the first ambiguous room on the list, as above.
                    mDontAskAboutAmbiguities = true;
                    return(list[0]);
                }

                // Either the user picked a room, or they said "New Room" in which case we don't match, returning null.
                return(dialog.Disambiguation);
            }
        }
Beispiel #5
0
 public Room FindRoom(string roomName, string roomDescription, string line, RoomMatcher matcher)
 {
     Room room = null;
     try { m_control.Invoke((MethodInvoker) delegate { room = m_canvas.FindRoom(roomName, roomDescription, line, matcher); }); }
     catch (Exception)
     {
     }
     return room;
 }
Beispiel #6
0
        Room IAutomapCanvas.FindRoom(string roomName, string roomDescription, string line, RoomMatcher matcher)
        {
            var list = new List<Room>();
              foreach (var element in Project.Current.Elements)
              {
            if (element is Room)
            {
              var room = (Room) element;
              var matches = matcher(roomName, roomDescription, room);
              if (matches.HasValue && matches.Value)
              {
            // it's definitely this room
            return room;
              }
              if (!matches.HasValue)
              {
            // it's ambiguous
            list.Add(room);
              }
            }
              }

              if (list.Count == 0)
              {
            return null;
              }
              if (m_dontAskAboutAmbiguities)
              {
            // the user has long given up on this process;
            // use the first ambiguous room in the list.
            return list[0];
              }
              if ((string.IsNullOrEmpty(roomDescription) || !list[0].HasDescription) && list.Count == 1)
              {
            // technically it's ambiguous, but we don't two descriptions for the user to compare;
            // there's only one option, so use it. They probably didn't have VERBOSE on for the whole transcript.
            return list[0];
              }

              using (var dialog = new DisambiguateRoomsDialog())
              {
            dialog.SetTranscriptContext(roomName, roomDescription, line);
            dialog.AddAmbiguousRooms(list);
            dialog.ShowDialog();
            if (dialog.UserDoesntCareAnyMore)
            {
              // The user has given up on this process! Can't say I blame them.
              // Use the first ambiguous room on the list, as above.
              m_dontAskAboutAmbiguities = true;
              return list[0];
            }

            // Either the user picked a room, or they said "New Room" in which case we don't match, returning null.
            return dialog.Disambiguation;
              }
        }