Ejemplo n.º 1
0
        private void updateSelectionAfterCommand(CommandBase command)
        {
            try
            {
                if (command.AssociatedElements.Count > 0 && Diagram != null &&
                    command.AssociatedElements.Any(element => Diagram.IsElementPresent(element)))
                {
                    IEnumerable <ISelectable> newSelection =
                        from element in command.AssociatedElements
                        where ElementRepresentations.IsElementPresent(element) &&
                        ElementRepresentations[element] is ISelectable
                        select(ISelectable) ElementRepresentations[element];

                    SelectedItems.SetSelection(newSelection);
                }
                else
                {
                    Debug.WriteLine("WARNING: no associated elements for command " + command);
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("ERROR: selected items update failed after command was executed.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Prepares the command that include hidden elements in the diagram
        /// </summary>
        private void IncludeDependentElements()
        {
            List <Element> candidates = ElementDependencies.FindHiddenElements(ElementRepresentations.PresentElements, Controller.ModelController.Model);

            IncludeElementsDialog dialog = new IncludeElementsDialog {
                NoElementsContent = "There are no hidden dependent elements on the diagram", Items = candidates
            };

            if (dialog.ShowDialog() == true && dialog.SelectedElements.Count > 0)
            {
                IncludeElementsCommand command = (IncludeElementsCommand)IncludeElementsCommandFactory.Factory().Create(Controller);
                foreach (Element element in dialog.SelectedElements)
                {
                    if (ElementRepresentations.CanRepresentElement(element))
                    {
                        command.IncludedElements.Add(element, ElementRepresentations.CreateNewViewHelper(element, Diagram));
                    }
                }
                command.Execute();
            }
        }