Пример #1
0
        protected virtual void SubAreaControl_Leaving(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
        {
            if (SubjectLocationControl.ListBoxReadOnly)
            {
                // get the country / area / subarea names from UI
                var countryName = CountryControl.GetCurrentText();
                var areaName    = AreaControl.GetCurrentText();
                var subAreaName = SubAreaControl.GetCurrentText();

                // get country object from UI
                if (CountryControl.GetCurrentObject() is Country country)
                {
                    // find the corresponding subject location (need to match country, area and subarea)
                    var subjectLocations = country.SubjectLocations.Where(c => c.Country.Name == countryName && c.Area.Name == areaName && c.SubArea.Name == subAreaName).ToList();

                    // valid subject Locations
                    if (subjectLocations != null)
                    {
                        // refresh control
                        RefreshControl(subjectLocations?.OfType <Location>().ToList(), SubjectLocationControl);
                    }
                }
            }
            else
            {
                RefreshControl(_allSubjectLocations?.OfType <Location>().ToList(), SubjectLocationControl);
            }

            // take subarea name from subarea object (if in database) or from UI text
            SetSubAreaDisplayItem(e.Object is SubArea subArea ? subArea.Name : SubAreaControl.GetCurrentText());

            SubjectLocationControl.SetFocus();
        }
Пример #2
0
        protected virtual void CountryControl_Leaving(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
        {
            // if area control is ready only, only area of the assigned country can be selected
            if (AreaControl.ListBoxReadOnly)
            {
                RefreshControl((e.Object as Country)?.Areas?.OfType <Location>().ToList(), AreaControl);
            }
            // otherwise all existing areas can be selected (or new onces can be entered)
            else
            {
                RefreshControl(_allAreas.OfType <Location>().ToList(), AreaControl);
            }

            // clear old text
            SubAreaControl.ClearText();
            SubjectLocationControl.ClearText();
            SubjectLocationLatitudeControl.Text  = null;
            SubjectLocationLongitudeControl.Text = null;

            // derived class can set the view model property
            // take country name from country object (if in database) or from UI text
            SetCountryDisplayItem(e.Object as Country != null ? (e.Object as Country).Name : CountryControl.GetCurrentText());

            // set focus to the respective text box
            AreaControl.SetFocus();
        }
Пример #3
0
 protected virtual void SubjectLocationControl_Leaving(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
 {
     // take subject location name from subject location object (if in database) or from UI text
     SetSubjectLocationDisplayItem(e.Object is SubjectLocation subjectLocation ? subjectLocation.Name : SubjectLocationControl.GetCurrentText());
 }