private void FinishCurrentHr() { Contract.Requires(HealthRecord == null || !HealthRecord.healthRecord.IsTransient); if (HealthRecord != null) { // завершаем теги Autocomplete.CompleteTypings(); var hr = HealthRecord.healthRecord; HealthRecord.Dispose(); hr.PropertyChanged -= hr_PropertyChanged; (hr as IEditableObject).EndEdit(); var addQuery = Autocomplete.AddQueryToSuggestions; Autocomplete.Dispose(); _autocomplete = null; // сохраняем запись OnUnloaded(hr); // сохраняем настройки редактора AuthorityController.CurrentDoctor.Settings.AddQueryToSuggestions = addQuery; session.DoSave(AuthorityController.CurrentDoctor); } }
private void CreateAutoComplete() { if (Autocomplete != null) { Autocomplete.Dispose(); } var initials = HealthRecord.healthRecord.GetOrderedCHIOs(); var sugMaker = new SuggestionsMaker(session, AuthorityController.CurrentDoctor) { ShowChildrenFirst = true, AddQueryToSuggestions = AuthorityController.CurrentDoctor.Settings.AddQueryToSuggestions, }; Autocomplete = new HrEditorAutocomplete(sugMaker, initials); Autocomplete.EntitiesChanged += (s, e) => { // меняем элементы записи var items = _autocomplete.GetCHIOs().ToList(); HealthRecord.healthRecord.SetItems(items); }; Autocomplete.ConfidencesChanged += (s, e) => { // меняем уверенность заверешенных элементов var items = _autocomplete.GetCHIOsOfCompleted().ToList(); HealthRecord.healthRecord.SetItems(items); }; Autocomplete.InputEnded += (s, e) => { // завершаем выбранное перед добавлением записи if (e.value) { var stratEdit = true; this.Send(Event.AddHr, new object[] { HealthRecord.healthRecord.Holder, stratEdit }.AsParams(MessageKeys.Holder, MessageKeys.Boolean)); } }; }