internal override void Attach(LayoutContent model)
        {
            _anchorable = model as LayoutAnchorable;
            _anchorable.IsVisibleChanged += new EventHandler(_anchorable_IsVisibleChanged);

            base.Attach(model);
        }
Ejemplo n.º 2
0
        static void CreateRegion(LayoutAnchorable element, string regionName)
        {
            if (element == null) 
                throw new ArgumentNullException("element");

            //If I'm in design mode the main window is not set
            if ((bool)DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue)
            {
                return;
            }

            try
            {
                if (Microsoft.Practices.ServiceLocation.ServiceLocator.Current == null)
                    return;

                // Build the region
                var mappings = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<RegionAdapterMappings>();
                if (mappings == null)
                    return;
                IRegionAdapter regionAdapter = mappings.GetMapping(element.GetType());
                if (regionAdapter == null)
                    return;

                regionAdapter.Initialize(element, regionName);
            }
            catch (Exception ex)
            {
                throw new RegionCreationException(string.Format("Unable to create region {0}", regionName), ex);
            }

        }
Ejemplo n.º 3
0
        internal LayoutAnchorControl(LayoutAnchorable model)
        {
            _model = model;
            _model.IsActiveChanged += new EventHandler(_model_IsActiveChanged);
            _model.IsSelectedChanged += new EventHandler(_model_IsSelectedChanged);

            SetSide(_model.FindParent<LayoutAnchorSide>().Side);
        }
Ejemplo n.º 4
0
        public Shell(
            ShellViewModel shellViewModel, 
            IEventAggregator eventAggregator, 
            IMainMenuApplicationService mainMenuApplicationService,
            ILayoutDataFactory layoutDataFactory,
            ILayoutApplicationService layoutApplicationService,
            IRestBoxStateService restBoxStateService)
        {
            this.mainMenuApplicationService = mainMenuApplicationService;
            this.layoutDataFactory = layoutDataFactory;
            this.layoutApplicationService = layoutApplicationService;
            this.restBoxStateService = restBoxStateService;
            this.eventAggregator = eventAggregator;
            this.shellViewModel = shellViewModel;
            DataContext = shellViewModel;
            shellViewModel.ApplicationTitle = "REST Box";

            InitializeComponent();

            layoutApplicationService.Load(dockingManager);

            httpRequestFilesLayout = GetLayoutAnchorableById("HttpRequestFilesLayoutId");
            environmentsLayout = GetLayoutAnchorableById("EnvironmentsLayoutId");
            requestExtensions = GetLayoutAnchorableById("RequestExtensionsId");
            sequenceFiles = GetLayoutAnchorableById("SequenceFilesId");
            interceptorFiles = GetLayoutAnchorableById("InterceptorFilesId");

            httpRequestFilesLayout.Content = ServiceLocator.Current.GetInstance<HttpRequestFiles>();
            environmentsLayout.Content = ServiceLocator.Current.GetInstance<RequestEnvironments>();
            requestExtensions.Content = ServiceLocator.Current.GetInstance<RequestExtensions>();
            sequenceFiles.Content = ServiceLocator.Current.GetInstance<HttpRequestSequenceFiles>();
            interceptorFiles.Content = ServiceLocator.Current.GetInstance<HttpInterceptorFiles>();

            eventAggregator.GetEvent<AddInputBindingEvent>().Subscribe(AddInputBinding);
            eventAggregator.GetEvent<RemoveInputBindingEvent>().Subscribe(RemoveInputBindings);
            eventAggregator.GetEvent<RemoveTabEvent>().Subscribe(RemoveTabById);
            eventAggregator.GetEvent<IsDirtyEvent>().Subscribe(IsDirtyHandler);

            eventAggregator.GetEvent<AddLayoutDocumentEvent>().Subscribe(AddLayoutDocument);
            eventAggregator.GetEvent<UpdateTabTitleEvent>().Subscribe(UpdateTabTitle);
            eventAggregator.GetEvent<GetLayoutDataEvent>().Subscribe(GetLayoutContent);

            eventAggregator.GetEvent<ShowErrorEvent>().Subscribe(ShowError);

            eventAggregator.GetEvent<ShowLayoutEvent>().Subscribe(ShowLayout);
            eventAggregator.GetEvent<UpdateViewMenuItemChecksEvent>().Subscribe(UpdateViewMenuChecks);

            eventAggregator.GetEvent<SaveAllEvent>().Subscribe(SaveAllHandler);

            eventAggregator.GetEvent<ResetLayoutEvent>().Subscribe(ResetLayoutOnRestart);
            eventAggregator.GetEvent<SaveRestBoxStateEvent>().Subscribe(SaveRestBoxState);
            eventAggregator.GetEvent<CreateStartPageEvent>().Subscribe(CreateStartPage);
            eventAggregator.GetEvent<UpdateStatusBarEvent>().Subscribe(UpdateStatusBar);

            Closing += OnClosing;
            CreateStartPage(true);
        }
Ejemplo n.º 5
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            if (anchorableToShow.Content is ITool)
            {
                var preferredLocation = ((ITool)anchorableToShow.Content).PreferredLocation;
                string paneName = GetPaneName(preferredLocation);
                var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
                if (toolsPane == null)
                {
                    switch (preferredLocation)
                    {
                        case Dock.Left:
                            {
                                var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
                                toolsPane = new LayoutAnchorablePane { DockWidth = new GridLength(200, GridUnitType.Pixel) };
                                parent.InsertChildAt(0, toolsPane);
                            }
                            break;
                        case Dock.Right:
                            {
                                var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
                                toolsPane = new LayoutAnchorablePane { DockWidth = new GridLength(200, GridUnitType.Pixel) };
                                parent.Children.Add(toolsPane);
                            }
                            break;
                        case Dock.Bottom:
                            {
                                var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Vertical);
                                toolsPane = new LayoutAnchorablePane { DockHeight = new GridLength(200, GridUnitType.Pixel) };
                                parent.Children.Add(toolsPane);
                            }
                            break;
                        case Dock.Top:
                            {
                                var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Vertical);
                                toolsPane = new LayoutAnchorablePane { DockHeight = new GridLength(200, GridUnitType.Pixel) };
                                parent.InsertChildAt(0, toolsPane);
                            }
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
                toolsPane.Children.Add(anchorableToShow);
                return true;
            }

            return false;
        }
        internal LayoutAutoHideWindowControl(LayoutAnchorControl anchor)
        {
            _anchor = anchor;
            _model = anchor.Model as LayoutAnchorable;
            _side = (anchor.Model.Parent.Parent as LayoutAnchorSide).Side;
            this.Unloaded += (s, e) =>
                {
                    if (_closeTimer != null)
                    {
                        _closeTimer.Stop();
                        _closeTimer = null;
                    }

                    _manager.HideAutoHideWindow(_anchor);
                };
        }
Ejemplo n.º 7
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow,
                                           ILayoutContainer destinationContainer)
        {
            var destPane = destinationContainer as LayoutAnchorablePane;
            if (destinationContainer != null &&
                destinationContainer.FindParent<LayoutFloatingWindow>() != null)
                return false;

            LayoutAnchorablePane toolsPane =
                layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(
                    d => d.GetType() == typeof (IContentView));
            if (toolsPane != null)
            {
                toolsPane.Children.Add(anchorableToShow);
                return true;
            }

            return false;
        }
Ejemplo n.º 8
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            //AD wants to add the anchorable into destinationContainer
            //just for test provide a new anchorablepane
            //if the pane is floating let the manager go ahead
            LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane;
            if (destinationContainer != null &&
                destinationContainer.FindParent<LayoutFloatingWindow>() != null)
                return false;

            var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane");
            if (toolsPane != null)
            {
                toolsPane.Children.Add(anchorableToShow);
                return true;
            }

            return false;
        }
Ejemplo n.º 9
0
 internal void _ExecuteAutoHideCommand(LayoutAnchorable _anchorable)
 {
     _anchorable.ToggleAutoHide();
 }
Ejemplo n.º 10
0
 private LayoutAnchorable Factory(string name, object content)
 {
     var layout = new LayoutAnchorable { Title = name, Content = content };
     layout.Hiding +=
         (s, e) => OnDockManagerUserChanged(new DockChangedEventArgs(DockChangedType.Remove, content));
     layout.Closing +=
         (s, e) => OnDockManagerUserChanged(new DockChangedEventArgs(DockChangedType.Remove, content));
     return layout;
 }
Ejemplo n.º 11
0
 public void Add(LayoutAnchorable anchorable)
 {
     AnchorableList.Add(anchorable);
     AnchorablePane.Children.Add(anchorable);
 }
Ejemplo n.º 12
0
 public void AddHaloViewport()
 {
     // select existing, if available
     foreach (var tabb in RightDockManager.Children.Where(tabb => tabb.Title == "Halo Viewport"))
     {
         RightDockManager.SelectedContentIndex = RightDockManager.IndexOfChild(tabb);
         return;
     }
     var tab = new LayoutAnchorable { Title = "Halo Viewport", Content = new HaloPage() };
     RightDockManager.Children.Add(tab);
     RightDockManager.SelectedContentIndex = RightDockManager.IndexOfChild(tab);
 }
 private void bookLoadButton_Click(object sender, RoutedEventArgs e)
 {
     LayoutAnchorable layoutDoc = new LayoutAnchorable();
     this.ExplorerPortfolio_.Children.Add(layoutDoc);
 }
Ejemplo n.º 14
0
        void AttachAnchorablesSource(LayoutRoot layout, IEnumerable anchorablesSource)
        {
            if (anchorablesSource == null)
                return;

            if (layout == null)
                return;

            //if (layout.Descendents().OfType<LayoutAnchorable>().Any())
            //    throw new InvalidOperationException("Unable to set the AnchorablesSource property if LayoutAnchorable objects are already present in the model");
            var anchorablesImported = layout.Descendents().OfType<LayoutAnchorable>().Select(d => d.Content).ToArray();
            var anchorables = anchorablesSource as IEnumerable;
            var listOfAnchorablesToImport = new List<object>(anchorables.OfType<object>());

            foreach (var document in listOfAnchorablesToImport.ToArray())
            {
                if (anchorablesImported.Contains(document))
                    listOfAnchorablesToImport.Remove(document);
            }

            LayoutAnchorablePane anchorablePane = null;
            if (layout.ActiveContent != null)
            {
                //look for active content parent pane
                anchorablePane = layout.ActiveContent.Parent as LayoutAnchorablePane;
            }

            if (anchorablePane == null)
            {
                //look for a pane on the right side
                anchorablePane = layout.Descendents().OfType<LayoutAnchorablePane>().Where(pane => !pane.IsHostedInFloatingWindow && pane.GetSide() == AnchorSide.Right).FirstOrDefault();
            }

            if (anchorablePane == null)
            {
                //look for an available pane
                anchorablePane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault();
            }

            _suspendLayoutItemCreation = true;
            foreach (var anchorableContentToImport in listOfAnchorablesToImport)
            {
                var anchorableToImport = new LayoutAnchorable()
                {
                    Content = anchorableContentToImport
                };

                bool added = false;
                if (LayoutUpdateStrategy != null)
                {
                    added = LayoutUpdateStrategy.BeforeInsertAnchorable(layout, anchorableToImport, anchorablePane);
                }

                if (!added)
                {
                    if (anchorablePane == null)
                    {
                        var mainLayoutPanel = new LayoutPanel() { Orientation = Orientation.Horizontal };
                        if (layout.RootPanel != null)
                        {
                            mainLayoutPanel.Children.Add(layout.RootPanel);
                        }

                        layout.RootPanel = mainLayoutPanel;
                        anchorablePane = new LayoutAnchorablePane() { DockWidth = new GridLength(200.0, GridUnitType.Pixel) };
                        mainLayoutPanel.Children.Add(anchorablePane);
                    }

                    anchorablePane.Children.Add(anchorableToImport);
                    added = true;
                }

                if (LayoutUpdateStrategy != null)
                    LayoutUpdateStrategy.AfterInsertAnchorable(layout, anchorableToImport);

                CreateAnchorableLayoutItem(anchorableToImport);

            }

            _suspendLayoutItemCreation = false;

            var anchorablesSourceAsNotifier = anchorablesSource as INotifyCollectionChanged;
            if (anchorablesSourceAsNotifier != null)
                anchorablesSourceAsNotifier.CollectionChanged += new NotifyCollectionChangedEventHandler(anchorablesSourceElementsChanged);
        }
Ejemplo n.º 15
0
 internal void _ExecuteHideCommand(LayoutAnchorable anchorable)
 {
     var model = anchorable as LayoutAnchorable;
     if (model != null)
     {
         //by default hide the anchorable
         model.Hide();
     }
 }
 internal override void Detach()
 {
     _anchorable.IsVisibleChanged -= new EventHandler(_anchorable_IsVisibleChanged);
     _anchorable = null;
     base.Detach();
 }
Ejemplo n.º 17
0
        private static LayoutAnchorablePane CreatePaneFromWidget(IUIWidget widget)
        {
            LayoutAnchorable anchorable = new LayoutAnchorable();
            anchorable.Content = widget.UIElement;
            anchorable.ContentId = widget.ContentGuid;
            anchorable.Title = widget.Title;
            anchorable.CanClose = false;
            anchorable.CanHide = false;

            LayoutAnchorablePane pane = new LayoutAnchorablePane(anchorable);
            return pane;
        }
Ejemplo n.º 18
0
 internal void _ExecuteHideCommand(LayoutAnchorable anchorable)
 {
     var model = anchorable as LayoutAnchorable;
     if (model != null)
     {
         //if (model.IsAutoHidden)
         //    model.ToggleAutoHide();
         //by default hide the anchorable
         model.Hide();
     }
 }
Ejemplo n.º 19
0
        public void ShowWindow(Type type)
        {
            // 查找到layout中是否存在
            var layout = dockManager.Layout.Descendents().OfType<LayoutAnchorable>().FirstOrDefault(X => X.Content != null && X.Content.GetType().Equals(type));
            if (layout == null)
            {
                var window = TypeService.CreateInstance(type) as Control;

                layout = new LayoutAnchorable();
                layout.Content  = window;
                layout.Title    = window.Tag.ToString();

                layout.AddToLayout(dockManager, AnchorableShowStrategy.Left);
            }

            // 将layout添加到root中
            layout.Float();
        }
Ejemplo n.º 20
0
        public void AddTabModule(TabGenre tabG, bool singleInstance = true)
        {
            LayoutContent tab;
            switch (tabG)
            {
                case TabGenre.StartPage:
                    tab = new LayoutAnchorable { Title = "Start Page", Content = new StartPage() };
                    break;
                case TabGenre.Welcome:
                    tab = new LayoutAnchorable { Title = "Welcome", Content = new WelcomePage() };
                    break;
                case TabGenre.Settings:
                    tab = new LayoutAnchorable { Title = "Settings", Content = new SettingsPage() };
                    break;
                default:
                    return;
            }

            // Select the single tab rather than create a new one
            if (singleInstance)
                foreach (LayoutContent tabb in DocumentManager.Children.Where(tabb => tabb.Title == tab.Title))
                {
                    DocumentManager.SelectedContentIndex = DocumentManager.IndexOfChild(tabb);
                    return;
                }

            DocumentManager.Children.Add(tab);
            DocumentManager.SelectedContentIndex = DocumentManager.IndexOfChild(tab);
        }
Ejemplo n.º 21
0
        internal void _ExecuteCloseCommand(LayoutAnchorable anchorable)
        {
            var model = anchorable as LayoutAnchorable;
            if (model != null && model.TestCanClose())
            {
                if (model.IsAutoHidden)
                    model.ToggleAutoHide();

                model.Close();
                return;
            }
        }
Ejemplo n.º 22
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     
     #line 23 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnSaveLayout);
     
     #line default
     #line hidden
     return;
     case 2:
     
     #line 24 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnSaveLayout);
     
     #line default
     #line hidden
     return;
     case 3:
     
     #line 25 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnSaveLayout);
     
     #line default
     #line hidden
     return;
     case 4:
     
     #line 26 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnSaveLayout);
     
     #line default
     #line hidden
     return;
     case 5:
     
     #line 29 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnLoadLayout);
     
     #line default
     #line hidden
     return;
     case 6:
     
     #line 30 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnLoadLayout);
     
     #line default
     #line hidden
     return;
     case 7:
     
     #line 31 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnLoadLayout);
     
     #line default
     #line hidden
     return;
     case 8:
     
     #line 32 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnLoadLayout);
     
     #line default
     #line hidden
     return;
     case 9:
     
     #line 36 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnShowWinformsWindow);
     
     #line default
     #line hidden
     return;
     case 10:
     
     #line 37 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnShowToolWindow1);
     
     #line default
     #line hidden
     return;
     case 11:
     this.dockManager = ((AvalonDock.DockingManager)(target));
     
     #line 41 "..\..\..\MainWindow.xaml"
     this.dockManager.DocumentClosing += new System.EventHandler<AvalonDock.DocumentClosingEventArgs>(this.dockManager_DocumentClosing);
     
     #line default
     #line hidden
     return;
     case 12:
     
     #line 45 "..\..\..\MainWindow.xaml"
     ((AvalonDock.Layout.LayoutRoot)(target)).PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.OnLayoutRootPropertyChanged);
     
     #line default
     #line hidden
     return;
     case 13:
     this.WinFormsWindow = ((AvalonDock.Layout.LayoutAnchorable)(target));
     return;
     case 14:
     this.winFormsHost = ((System.Windows.Forms.Integration.WindowsFormsHost)(target));
     return;
     case 15:
     
     #line 57 "..\..\..\MainWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.AddTwoDocuments_click);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }
Ejemplo n.º 23
0
 internal void _ExecuteDockCommand(LayoutAnchorable anchorable)
 {
     anchorable.Dock();
 }
        internal void Hide()
        {
            if (_model == null)
                return;

            _model.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(_model_PropertyChanged);

            RemoveInternalGrid();
            _anchor = null;
            _model = null;
            _manager = null;
            Visibility = System.Windows.Visibility.Hidden;

            Debug.WriteLine("LayoutAutoHideWindowControl.Hide()");
        }
Ejemplo n.º 25
0
        void anchorablesSourceElementsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (Layout == null)
                return;

            //When deserializing documents are created automatically by the deserializer
            if (SuspendAnchorablesSourceBinding)
                return;

            //handle remove
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
                e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
            {
                if (e.OldItems != null)
                {
                    var anchorablesToRemove = Layout.Descendents().OfType<LayoutAnchorable>().Where(d => e.OldItems.Contains(d.Content)).ToArray();
                    foreach (var anchorableToRemove in anchorablesToRemove)
                    {
                        (anchorableToRemove.Parent as ILayoutContainer).RemoveChild(
                            anchorableToRemove);
                    }
                }
            }

            //handle add
            if (e.NewItems != null &&
                (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add ||
                e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace))
            {
                if (e.NewItems != null)
                {
                    LayoutAnchorablePane anchorablePane = null;

                    if (Layout.ActiveContent != null)
                    {
                        //look for active content parent pane
                        anchorablePane = Layout.ActiveContent.Parent as LayoutAnchorablePane;
                    }

                    if (anchorablePane == null)
                    {
                        //look for a pane on the right side
                        anchorablePane = Layout.Descendents().OfType<LayoutAnchorablePane>().Where(pane => !pane.IsHostedInFloatingWindow && pane.GetSide() == AnchorSide.Right).FirstOrDefault();
                    }

                    if (anchorablePane == null)
                    {
                        //look for an available pane
                        anchorablePane = Layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault();
                    }

                    _suspendLayoutItemCreation = true;
                    foreach (var anchorableContentToImport in e.NewItems)
                    {
                        var anchorableToImport = new LayoutAnchorable()
                        {
                            Content = anchorableContentToImport
                        };

                        bool added = false;
                        if (LayoutUpdateStrategy != null)
                        {
                            added = LayoutUpdateStrategy.BeforeInsertAnchorable(Layout, anchorableToImport, anchorablePane);
                        }

                        if (!added)
                        {
                            if (anchorablePane == null)
                            {
                                var mainLayoutPanel = new LayoutPanel() { Orientation = Orientation.Horizontal };
                                if (Layout.RootPanel != null)
                                {
                                    mainLayoutPanel.Children.Add(Layout.RootPanel);
                                }

                                Layout.RootPanel = mainLayoutPanel;
                                anchorablePane = new LayoutAnchorablePane() { DockWidth = new GridLength(200.0, GridUnitType.Pixel) };
                                mainLayoutPanel.Children.Add(anchorablePane);
                            }

                            anchorablePane.Children.Add(anchorableToImport);
                            added = true;
                        }

                        if (LayoutUpdateStrategy != null)
                        {
                            LayoutUpdateStrategy.AfterInsertAnchorable(Layout, anchorableToImport);
                        }

                        var root = anchorableToImport.Root;

                        if (root != null && root.Manager == this)
                        {
                            CreateAnchorableLayoutItem(anchorableToImport);
                        }

                    }
                    _suspendLayoutItemCreation = false;
                }
            }

            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                //NOTE: I'm going to clear every anchorable present in layout but
                //some anchorable may have been added directly to the layout, for now I clear them too
                var anchorablesToRemove = Layout.Descendents().OfType<LayoutAnchorable>().ToArray();
                foreach (var anchorableToRemove in anchorablesToRemove)
                {
                    (anchorableToRemove.Parent as ILayoutContainer).RemoveChild(
                        anchorableToRemove);
                }
            }

            if (Layout != null)
                Layout.CollectGarbage();
        }
        internal void Show(LayoutAnchorControl anchor)
        {
            if (_model != null)
                throw new InvalidOperationException();

            _anchor = anchor;
            _model = anchor.Model as LayoutAnchorable;
            _side = (anchor.Model.Parent.Parent as LayoutAnchorSide).Side;
            _manager = _model.Root.Manager;
            CreateInternalGrid();

            _model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_model_PropertyChanged);

            Visibility = System.Windows.Visibility.Visible;
            InvalidateMeasure();
            UpdateWindowPos();
            Debug.WriteLine("LayoutAutoHideWindowControl.Show()");
        }
Ejemplo n.º 27
0
        void CreateAnchorableLayoutItem(LayoutAnchorable contentToAttach)
        {
            if (_layoutItems.Any(item => item.LayoutElement == contentToAttach))
                return;

            var layoutItem = new LayoutAnchorableItem();
            layoutItem.Attach(contentToAttach);
            ApplyStyleToLayoutItem(layoutItem);
            _layoutItems.Add(layoutItem);

            if (contentToAttach != null &&
                contentToAttach.Content != null &&
                contentToAttach.Content is UIElement)
            {
                InternalAddLogicalChild(contentToAttach.Content);
            }
        }
Ejemplo n.º 28
0
 public void AfterInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableShown)
 {
 }
        private void initialize(BookInfoViewModel bookInfoVM)
        {
            //instExView_ = new ExplorerBookInstView(this, bookInfoVM);
            this.viewModel_ = new MainWindowViewModel(this,bookInfoVM);
            LayoutAnchorable layoutAnch = new LayoutAnchorable();
            layoutAnch.Content = this.viewModel_.ExplorerBookInstVM_.View_;

            ExplorerPortfolio_.Children.Add(layoutAnch);

            

        }
Ejemplo n.º 30
0
        /// <summary>
        /// Activates the dockable pane that contains the given control.
        /// The search is performed by matching the pane's ContentId to the
        /// controls's Name. If no dockable pane contains the control, one is
        /// created at the bottom side of the docking root; in this case, the
        /// control's ToolTip (if it is a non-null string) is used as the
        /// pane's Title.
        /// </summary>
        /// <param name="control">The control to activate.</param>
        /// <remarks>
        /// This code is partly adapted from AvalonDock samples. It's not
        /// clear how it's done, but normally it works.
        /// </remarks>
        private void ActivateToolWindow(Control control)
        {
            if (control == null)
                throw new ArgumentNullException("control");

            string contentId = control.Name;

            LayoutAnchorable pane = dockingManager.Layout.Descendents().OfType<
                LayoutAnchorable>().SingleOrDefault(a => a.ContentId == contentId);

            if (pane == null)
            {
                // The pane is not created. This can happen for example when
                // we load from an old layout configuration file, and the
                // pane is not defined in that file. In this case, we add the
                // control to a default location.
                var anchorSide = dockingManager.BottomSidePanel.Model as LayoutAnchorSide;
                LayoutAnchorGroup anchorGroup;
                if (anchorSide.ChildrenCount == 0)
                {
                    anchorGroup = new LayoutAnchorGroup();
                    anchorSide.Children.Add(anchorGroup);
                }
                else
                {
                    anchorGroup = anchorSide.Children[0];
                }

                pane = new LayoutAnchorable();
                pane.ContentId = contentId;
                pane.Content = control;
                if (control.ToolTip is string)
                {
                    pane.Title = (string)control.ToolTip;
                }
                anchorGroup.Children.Add(pane);
            }

            if (pane.IsHidden)
            {
                pane.Show();
            }
            else if (pane.IsVisible)
            {
                pane.IsActive = true;
            }
            else
            {
                pane.AddToLayout(dockingManager,
                    AnchorableShowStrategy.Bottom |
                    AnchorableShowStrategy.Most);
            }

            //control.Focus
            //if (!control.Focus())
            //    throw new InvalidOperationException();
            //Keyboard.Focus(control);
        }