Exemple #1
0
        public AppointmentViewModel(
            IMedicalSpecializationDataService medicalSpecializationDataService,
            IBuildingDataService buildingDataService,
            IProfileDataService profileDataService,
            ISuggestionProvider geoSuggestionProvider,
            IEventAggregator eventAggregator)
        {
            this.MedicalSpecializationDataService = medicalSpecializationDataService;
            this.GeoSuggestionProvider            = geoSuggestionProvider;
            this.BuildingDataService = buildingDataService;
            this.ProfileDataService  = profileDataService;
            this.EventAggregator     = eventAggregator;

            this.PageContract = new PageControlContract(default(int), this.MedicalSpecializationDataService);

            this.PageSizes = new ObservableCollection <int> {
                2, 10, 20, 50, 100, 200
            };

            this.LoadedCommand             = AsyncCommand.Create(this.OnLoadedAsync);
            this.OpenSpecializationCommand = new RelayCommand(
                parameter =>
            {
                var args = (List <int>)parameter;
                this.EventAggregator.GetEvent <OpenSpecializationDoctorsEvent>().Publish(
                    new OpenSpecializationDoctorsArgs {
                    PolyclinicId = args[1], SpecializationId = args[0], ParentViewModel = this
                });
            });
        }
 /// <summary>
 /// Creates a new CLI output usage printer
 /// </summary>
 /// <param name="console"></param>
 /// <param name="container"></param>
 /// <param name="builder"></param>
 /// <param name="environmentVariablesService"></param>
 /// <param name="suggestionProvider"></param>
 public UsagePrinter(IConsole console, ICommandLineCommandContainer container, IUsageBuilder builder, IEnvironmentVariablesService environmentVariablesService, ISuggestionProvider suggestionProvider)
 {
     this.console = console ?? throw new ArgumentNullException(nameof(console));
     Container    = container ?? throw new ArgumentNullException(nameof(container));
     Builder      = builder ?? throw new ArgumentNullException(nameof(builder));
     this.environmentVariablesService = environmentVariablesService ?? throw new ArgumentNullException(nameof(environmentVariablesService));
     this.suggestionProvider          = suggestionProvider ?? throw new ArgumentNullException(nameof(suggestionProvider));
 }
Exemple #3
0
            private void GetSuggestionsAsync(object param)
            {
                object[]            args       = param as object[];
                string              searchText = Convert.ToString(args[0]);
                ISuggestionProvider provider   = args[1] as ISuggestionProvider;
                IEnumerable         list       = provider.GetSuggestions(searchText);

                _actb.Dispatcher.BeginInvoke(new Action <IEnumerable, string>(DisplaySuggestions), DispatcherPriority.Background, new object[] {
                    list,
                    searchText
                });
            }
Exemple #4
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="childHandlers"></param>
		protected LookupHandlerAggregator(Dictionary<ILookupHandler, Type> childHandlers)
		{
			this.ChildHandlers = childHandlers;

			// initialize the dictionary with an empty list for each handler
			this.SuggestedItemsCache = new Dictionary<ILookupHandler, List<object>>();
			foreach (var handler in childHandlers.Keys)
			{
				this.SuggestedItemsCache.Add(handler, new List<object>());
			}
			_suggestionProvider = new SuggestionProviderAggregator(this);
		}
        /// <summary>
        /// Autosuggest field for Unity Editor.
        /// </summary>
        /// <param name="suggestionProvider">Provides the list of suggestions to show based on what the user typed.</param>
        /// <param name="label">The label to render with the control.</param>
        public AutoSuggestField(ISuggestionProvider suggestionProvider, GUIContent label, Options options)
        {
            _suggestionProvider = suggestionProvider;
            _label            = label;
            _options          = options;
            _drawSpaceClaimer = new DrawSpaceClaimer(_options.DisplayMode);

            _suggestionProvider.SuggestionsChanged += SuggestionProvider_SuggestionsChanged;
            EditorApplication.update += EditorApplication_Update;

            _controlId = _controlCount++;
        }
        public void ReleaseOwnership(ISuggestionProvider provider)
        {
            if (CurrentHandler == null)
            {
                return;
            }

            if (CurrentHandler == provider)
            {
                CurrentHandler = null;
                UIRoot.SetActive(false);
            }
        }
        /// <summary>
        /// Returns an instance of popup
        /// </summary>
        private void PreparePopup()
        {
            //if already initialized then exit method
            if (isInitialized)
            {
                return;
            }

            //set the popup placement target
            suggestionPopup.PlacementTarget = sourceTextBox;
            //assign the width to textbox width
            suggestionListBox.Width = sourceTextBox.ActualWidth;

            //see if we have a suggestion provider
            if (suggestionProvider == null)
            {
                //try to retrieve it from the text box
                suggestionProvider = sourceTextBox.GetValue(SuggestionBoxBehavior.ProviderProperty) as ISuggestionProvider;

                //see if we get one
                if (suggestionProvider == null)
                {
                    //if not then create a basic string suggestion provider
                    suggestionProvider = new StringSuggestionProvider();
                }

                //get the number of results property and assign to provider
                suggestionProvider.NumberOfResults = (int)sourceTextBox.GetValue(SuggestionBoxBehavior.NumberOfResultsProperty);
            }

            //fetch the item template and apply to listbox
            suggestionListBox.ItemTemplate = sourceTextBox.GetValue(SuggestionBoxBehavior.ItemTemplateProperty) as DataTemplate;

            //see if we have datasource
            if (suggestionSource == null)
            {
                //if not then retrieve the masterlist of textbox
                IEnumerable assignedDataSource = (IEnumerable)sourceTextBox.GetValue(SuggestionBoxBehavior.MasterListProperty);

                //use provider to generate the suggestion view source
                suggestionSource = suggestionProvider.ProvideDataView(assignedDataSource);
            }

            //assign the sugegstion view to listbox
            suggestionListBox.SetValue(ListBox.ItemsSourceProperty, suggestionSource);

            //mark the flag
            isInitialized = true;
        }
        /// <summary>
        /// Returns true if the AutoCompleteModal used the navigation input, false if not.
        /// The navigation inputs are Control+Up/Down, and Control+Enter.
        /// </summary>
        public static bool CheckNavigation(ISuggestionProvider handler)
        {
            if (!Suggesting(handler))
            {
                return(false);
            }

            bool up   = InputManager.GetKey(KeyCode.UpArrow);
            bool down = InputManager.GetKey(KeyCode.DownArrow);

            if (up || down)
            {
                if (up)
                {
                    if (InputManager.GetKeyDown(KeyCode.UpArrow))
                    {
                        SetSelectedSuggestion(SelectedIndex - 1);
                        timeOfLastNavHold = Time.realtimeSinceStartup + 0.3f;
                    }
                    else if (timeOfLastNavHold.OccuredEarlierThan(0.05f))
                    {
                        SetSelectedSuggestion(SelectedIndex - 1);
                        timeOfLastNavHold = Time.realtimeSinceStartup;
                    }
                }
                else
                {
                    if (InputManager.GetKeyDown(KeyCode.DownArrow))
                    {
                        SetSelectedSuggestion(SelectedIndex + 1);
                        timeOfLastNavHold = Time.realtimeSinceStartup + 0.3f;
                    }
                    else if (timeOfLastNavHold.OccuredEarlierThan(0.05f))
                    {
                        SetSelectedSuggestion(SelectedIndex + 1);
                        timeOfLastNavHold = Time.realtimeSinceStartup;
                    }
                }

                return(true);
            }

            return(!timeOfLastNavHold.OccuredEarlierThan(0.2f));
        }
        public CreateProfileViewModel(ISuggestionProvider geoSuggestionProvider, IProfileDataService profileService, IBuildingDataService buildingService, IDialogCoordinator dialogCoordinator, IFileDialogCoordinator fileDialogCoordinator)
        {
            this.GeoSuggestionProvider = geoSuggestionProvider;
            this.ProfileService        = profileService;
            this.BuildingService       = buildingService;
            this.DialogCoordinator     = dialogCoordinator;
            this.FileDialogCoordinator = fileDialogCoordinator;

            this.Profile = new ProfileWrapper(new Profile
            {
                DateOfBirth = DateTime.Now
            });

            this.Address = new AddressWrapper(new Address());

            this.AddPhotoCommand      = new RelayCommand(this.OpenPhotoAsBytes);
            this.ValidateCommand      = AsyncCommand.Create(this.ValidateAsync);
            this.CreateProfileCommand = AsyncCommand.Create(this.CreateAndSaveProfileAsync);
        }
        /// <summary>
        /// Performs the cleanup
        /// </summary>
        public void Dispose()
        {
            //detach the listbox events
            suggestionListBox.PreviewMouseDown -= listBox_PreviewMouseDown;
            suggestionListBox.SelectionChanged -= currentListBox_SelectionChanged;

            //assure to detach the events from textbox too
            DetachEvents();

            //nullify the variables
            sourceTextBox         = null;
            suggestionProvider    = null;
            suggestionSource      = null;
            suggestionPopup.Child = null;
            suggestionPopup       = null;
            suggestionListBox     = null;

            //request gc to suppress finalize on this object
            //as we already cleaned it up
            GC.SuppressFinalize(this);
        }
Exemple #11
0
        public static JenkinsClient CreateClient(this ISuggestionProvider s, IComponentConfiguration config, CancellationToken token)
        {
            if (s == null)
            {
                return(null);
            }

            var(c, r) = config.GetCredentialsAndResource();
            var up     = c as Extensions.Credentials.UsernamePasswordCredentials;
            var api    = c as Extensions.Credentials.TokenCredentials;
            var client = new JenkinsClient(
                up?.UserName,
                up?.Password ?? api?.Token,
                r?.ServerUrl,
                csrfProtectionEnabled: false,
                null,
                token
                );

            return(client);
        }
 public void TakeOwnership(ISuggestionProvider provider)
 {
     CurrentHandler = provider;
     navigationTipRow.SetActive(provider.AllowNavigation);
 }
Exemple #13
0
 public WordListDictionaryService(ISuggestionProvider suggestionProvider, IEnumerable <string> words)
 {
     _suggestionProvider = suggestionProvider;
     _words = words.Where(word => !string.IsNullOrWhiteSpace(word)).OrderBy(word => word).ToList();
 }
 public static bool CheckEscape(ISuggestionProvider handler)
 {
     return(Suggesting(handler) && InputManager.GetKeyDown(KeyCode.Escape));
 }
Exemple #15
0
 public static void SetSuggestionProvider(ISuggestionProvider suggestionProvider)
 {
     m_SuggestionProvider = suggestionProvider;
 }
 public static void SetSuggestionProvider(ISuggestionProvider suggestionProvider)
 {
     m_SuggestionProvider = suggestionProvider;
 }
Exemple #17
0
        /// <summary>
        /// Registers a new console command with help text and a tab completion provider.
        /// </summary>
        /// <param name="command">The name of the command.</param>
        /// <param name="helpText">Text to display for this command when used as an argument to the 'help' command.</param>
        /// <param name="action">The delegate to invoke for the command.</param>
        /// <param name="tabCompletionProvider">The tab completion provider to use for the command arguments. Pass null to disable tab completion of arguments.</param>
        public void RegisterCommand(string command, string helpText, CommandActionDelegate action, ISuggestionProvider tabCompletionProvider)
        {
            if (string.IsNullOrEmpty(command)) throw new ArgumentNullException("command");
            if (action == null) throw new ArgumentNullException("action");
            if (string.IsNullOrEmpty(helpText)) throw new ArgumentNullException("helpText");

            commands.Add(command, new CommandInfo(command, action, helpText, tabCompletionProvider));
        }
Exemple #18
0
 public CommandInfo(string command, CommandActionDelegate action, string helpText, ISuggestionProvider tabCompletionProvider)
 {
     Command = command;
     Action = action;
     HelpText = helpText;
     TabCompletionProvider = tabCompletionProvider;
 }
Exemple #19
0
 public WordListDictionaryService(ISuggestionProvider suggestionProvider, List <string> words)
 {
     _suggestionProvider = suggestionProvider;
     _words = words;
     _words.Sort();
 }
 public static bool Suggesting(ISuggestionProvider handler) => CurrentHandler == handler && Instance.UIRoot.activeSelf;
Exemple #21
0
 /// <summary>
 /// Sets the value of Provider Property
 /// </summary>
 public static void SetProvider(DependencyObject obj, ISuggestionProvider value)
 {
     obj.SetValue(ProviderProperty, value);
 }