Beispiel #1
0
        private UI.UserControls.ISupportEntityEditing GetCurrentView()
        {
            UI.UserControls.ISupportEntityEditing currentView = null;

            foreach (Control control in pEdit.Controls)
            {
                if (control is UI.UserControls.ISupportEntityEditing && control is UserControl)
                {
                    currentView = (UI.UserControls.ISupportEntityEditing)control;
                }
            }

            return(currentView);
        }
Beispiel #2
0
        private bool TryToChangeView(Business.EditableEntityBase entityToBeEdited, Business.EditableEntityBase parentEntity, UI.UserControls.ISupportEntityEditing entityEditor)
        {
            UI.UserControls.ISupportEntityEditing currentView = GetCurrentView();

            bool canChangeView = true;

            // Is the view already on the object the change is requested to go to?
            if (currentView != null && entityToBeEdited == currentView.EditableEntity)
            {
                canChangeView = false;
            }
            else if (currentView != null && currentView.DoesControlHaveUnsavedChanges() == true)
            {
                canChangeView = false;
            }

            if (canChangeView == false)
            {
                // Move the selection back to the item with unapplied changes.
                if (tvManager.SelectedNode != null && tvManager.SelectedNode.Tag != currentView.EditableEntity)
                {
                    SetHighlightedTreeNodeByTag(tvManager.Nodes, currentView.EditableEntity);
                }
            }
            else
            {
                if (entityToBeEdited == null)
                {
                    entityEditor.CreateNew(parentEntity);
                }
                else
                {
                    entityEditor.Edit(entityToBeEdited, parentEntity);
                }

                if (pEdit.Controls.Contains((UserControl)entityEditor) == false)
                {
                    pEdit.Controls.Clear();
                    pEdit.Controls.Add((UserControl)entityEditor);
                }

                entityEditor.SetFocusToDefaultControl();
            }

            return(canChangeView);
        }