Example #1
0
        private void OnSelectionChanged(object sender, EventArgs e)
        {
            ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService == null || ActiveDesigner != this)
            {
                return;
            }

            foreach (ItemInfo itemInfo in this.previewStrip.Items)
            {
                if (itemInfo.UserData[DesignerUserDataKeys.Activity] == selectionService.PrimarySelection)
                {
                    this.previewStrip.ActiveItem = itemInfo;
                    break;
                }
            }

            //We need to make sure that for preview designer; if we select the designer using property grid or
            //any other means then selection is visible
            if (selectionService.SelectionCount == 1)
            {
                ActivityDesigner selectedDesigner = ActivityDesigner.GetDesigner(selectionService.PrimarySelection as Activity);
                if (selectedDesigner != null && !selectedDesigner.IsVisible && this != selectedDesigner.ParentDesigner)
                {
                    //PLEASE NOTE:
                    //We want to search if the current designer is ancestor of selected designer
                    //We do the search till we hit the immediate child of the "this" designer in ancestor chain
                    //so that if we are in preview mode then we make sure that we make the imamediate child of "this" visible
                    ActivityDesigner designer = selectedDesigner;
                    while (designer != null)
                    {
                        CompositeActivityDesigner parentDesigner = designer.ParentDesigner;
                        if (this == parentDesigner)
                        {
                            break;
                        }
                        designer = parentDesigner;
                    }

                    if (designer != null)
                    {
                        if (this.previewWindow != null && this.previewWindow.PreviewMode)
                        {
                            designer.EnsureVisible();
                        }
                        else
                        {
                            selectedDesigner.EnsureVisible();
                        }
                    }
                }
            }
        }
Example #2
0
        private void OnSelectionChanged(object sender, EventArgs e)
        {
            ISelectionService service = base.GetService(typeof(ISelectionService)) as ISelectionService;

            if ((service != null) && (base.ActiveDesigner == this))
            {
                foreach (System.Workflow.ComponentModel.Design.ItemInfo info in this.previewStrip.Items)
                {
                    if (info.UserData[DesignerUserDataKeys.Activity] == service.PrimarySelection)
                    {
                        this.previewStrip.ActiveItem = info;
                        break;
                    }
                }
                if (service.SelectionCount == 1)
                {
                    ActivityDesigner designer = ActivityDesigner.GetDesigner(service.PrimarySelection as Activity);
                    if (((designer != null) && !designer.IsVisible) && (this != designer.ParentDesigner))
                    {
                        ActivityDesigner designer2 = designer;
                        while (designer2 != null)
                        {
                            CompositeActivityDesigner parentDesigner = designer2.ParentDesigner;
                            if (this == parentDesigner)
                            {
                                break;
                            }
                            designer2 = parentDesigner;
                        }
                        if (designer2 != null)
                        {
                            if ((this.previewWindow != null) && this.previewWindow.PreviewMode)
                            {
                                designer2.EnsureVisible();
                            }
                            else
                            {
                                designer.EnsureVisible();
                            }
                        }
                    }
                }
            }
        }