Example #1
0
        protected virtual void AreaControl_Leaving(object sender, WPFUserControl.AutoCompleteTextBoxControlEventArgs e)
        {
            if (SubAreaControl.ListBoxReadOnly)
            {
                // get the subareas and let the base class do the work
                var countrySubAreas = (CountryControl.GetCurrentObject() as Country)?.SubAreas;
                var areaSubAreas    = (e.Object as Area)?.SubAreas;

                // valid subareas
                if ((areaSubAreas != null) && (countrySubAreas != null))
                {
                    // get the subareas belong to both selected area and selected country
                    if (GetCountrySubAreas(areaSubAreas.ToList(), countrySubAreas.ToList()) is List <SubArea> matchingSubareas)
                    {
                        // refresh control
                        RefreshControl(matchingSubareas.OfType <Location>().ToList(), SubAreaControl);
                    }
                }
            }
            else
            {
                RefreshControl(_allSubAreas.OfType <Location>().ToList(), SubAreaControl);
            }

            // derived class can set the view model property
            // take area name from area object (if in database) or from UI text
            SetAreaDisplayItem(e.Object is Area area? area.Name : AreaControl.GetCurrentText());

            // set focus to the respective text box
            SubAreaControl.SetFocus();
        }
Example #2
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();
        }
Example #3
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();
        }
Example #4
0
        private void TvSiteMapNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode selectedNode = e.Node;

            selectedNode.TreeView.SelectedNode = selectedNode;
            var collec = (Dictionary <string, string>)selectedNode.Tag;

            TreeNodeHelper.AddContextMenu(e.Node, this);
            Control existingControl = panelContainer.Controls.Count > 0 ? panelContainer.Controls[0] : null;

            if (existingControl != null)
            {
                panelContainer.Controls.Remove(existingControl);
                existingControl.Dispose();
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }

            switch (selectedNode.Text.Split(' ')[0])
            {
            case "SiteMap":
            {
                var ctrl = new SiteMapControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Area":
            {
                if (collec.Count == 0)
                {
                    collec.Add("Id", string.Format("tempId_{0}", DateTime.Now.Ticks));
                }
                var ctrl = new AreaControl(collec, webResourcesImageCache, webResourcesHtmlCache, Service);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "SubArea":
            {
                if (collec.Count == 0)
                {
                    collec.Add("Id", string.Format("tempId_{0}", DateTime.Now.Ticks));
                }
                var ctrl = new SubAreaControl(collec, entityCache, webResourcesImageCache, webResourcesHtmlCache,
                                              Service);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Group":
            {
                if (collec.Count == 0)
                {
                    collec.Add("Id", string.Format("tempId_{0}", DateTime.Now.Ticks));
                }
                var ctrl = new GroupControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Privilege":
            {
                var ctrl = new PrivilegeControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Description":
            {
                var ctrl = new DescriptionControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            case "Title":
            {
                var ctrl = new TitleControl(collec);
                ctrl.Saved += CtrlSaved;

                panelContainer.Controls.Add(ctrl);
                ctrl.BringToFront();
                if (existingControl != null)
                {
                    panelContainer.Controls.Remove(existingControl);
                }
                tsbItemSave.Visible = true;
            }
            break;

            default:
            {
                panelContainer.Controls.Clear();
                tsbItemSave.Visible = false;
            }
            break;
            }

            ManageMenuDisplay();
        }
Example #5
0
 private void SubjectLocationControl_LeavingViaShift(object sender, AutoCompleteTextBoxControlEventArgs e)
 {
     SubAreaControl.SetFocus();
 }