예제 #1
0
        //
        void Manager_Loaded(object sender, RoutedEventArgs e)
        {
            bool fileExist = File.Exists(_configFile);

            if (fileExist)
            {
                // Be careful with the XmlLayoutSerizlizer.Deserialize(DockingManager),
                // the children inside it will be reconstructed.
                // The original children will be disregarded.
                // If a name is put on a child, the child will not work properly any more.
                // You must search inside the reconstructed DockingManager to find the proper one.
                // Call FindLayoutContentByID() to find the LayoutContent.
                DockingManager      manager  = sender as DockingManager;
                XmlLayoutSerializer instance =
                    new XmlLayoutSerializer(manager);
                instance.Deserialize(_configFile);

                // Because LayoutDocument are regenerated,
                // we need to re-attach the Closed() method to each LayoutDocument.
                foreach (IView view in _views)
                {
                    LayoutContent  content   = FindLayoutContentByID(view.eMap.MapID);
                    LayoutDocument layoutDoc = content as LayoutDocument;
                    if (layoutDoc != null)
                    {
                        layoutDoc.Closed += LayoutDoc_Closed;
                    }
                }
            }
        }
예제 #2
0
        private static void thumbnail_TabbedThumbnailClosed(object sender, TabbedThumbnailClosedEventArgs e)
        {
            //var layoutDoc = LayoutPane.Children.Where(x => x.Content == e.WindowsControl).SingleOrDefault();
            LayoutDocumentPaneGroup paneGroup = (LayoutDocumentPaneGroup)((LayoutPanel)dockManager.Layout.Children.ElementAt(0)).Children[0];
            LayoutContent           layoutDoc = null;

            foreach (LayoutDocumentPane a in paneGroup.Children)
            {
                layoutDoc = a.Children.Where(x => x.Content == e.WindowsControl).SingleOrDefault();
                if (layoutDoc != null)
                {
                    break;
                }
            }
            if (layoutDoc == null)
            {
                return;
            }
            var controlView = layoutDoc.Content as IControlView;

            if (controlView == null)
            {
                controlView = ((Frame)layoutDoc.Content).Content as IControlView;
            }
            if (controlView != null && controlView.IsModified)
            {
                BAMessageBox.ShowInfo(Strings.Message_MainWindow_ShowPage_ModifiedView);
            }
            layoutDoc.ContentId = "CodeRemoval";
            layoutDoc.Parent.RemoveChild(layoutDoc);
            SetActivePreview((UIElement)dockManager.ActiveContent);
        }
예제 #3
0
 public static void DockHorizontal(LayoutContent layoutContent, ILayoutElement paneRelativeTo, GridLength dockHeight, bool dockBefore = false)
 {
     if (paneRelativeTo is ILayoutDocumentPane parentDocumentPane)
     {
         var parentDocumentGroup = paneRelativeTo.FindParent <LayoutDocumentPaneGroup>();
         if (parentDocumentGroup == null)
         {
             var grandParent = parentDocumentPane.Parent as ILayoutContainer;
             parentDocumentGroup = new LayoutDocumentPaneGroup()
             {
                 Orientation = System.Windows.Controls.Orientation.Vertical
             };
             grandParent.ReplaceChild(paneRelativeTo, parentDocumentGroup);
             parentDocumentGroup.Children.Add(parentDocumentPane);
         }
         parentDocumentGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
         int indexOfParentPane  = parentDocumentGroup.IndexOfChild(parentDocumentPane);
         var layoutDocumentPane = new LayoutDocumentPane(layoutContent)
         {
             DockHeight = dockHeight
         };
         parentDocumentGroup.InsertChildAt(dockBefore ? indexOfParentPane : indexOfParentPane + 1, layoutDocumentPane);
         layoutContent.IsActive = true;
         layoutContent.Root.CollectGarbage();
         Application.Current.MainWindow.Dispatcher.Invoke(() => {
             layoutDocumentPane.DockHeight = dockHeight;
         }, System.Windows.Threading.DispatcherPriority.Loaded);
     }
 }
예제 #4
0
        static void SetStronglyRecommendedDefaults(ILayoutElement element)
        {
            //Debug.Write(element);

            LayoutContent content = element as LayoutContent;

            if (content == null)
            {
                //Debug.Write(" not");
            }
            else
            {
                SetLayoutContentDefaults(content);

                // subclasses of LayoutContent
                LayoutAnchorable anchorable = content as LayoutAnchorable;
                if (anchorable != null)
                {
                    SetLayoutAnchorableDefaults(anchorable);
                }
            }

            //Debug.WriteLine(" a LayoutContent");

            //Debug.Indent();
            foreach (ILayoutElement desc in element.Descendents())
            {
                SetStronglyRecommendedDefaults(desc);
            }
            //Debug.Unindent();
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            LayoutContent itemAsLayoutContent = item as LayoutContent;

            if (item is CanvasViewModel)
            {
                return(CanvasViewTemplate);
            }
            if (item is PropertyViewModel)
            {
                return(ContViewTemplate);
            }
            if (item is ContextViewModel)
            {
                return(ContViewTemplate);
            }
            if (item is LinksViewModel)
            {
                return(ContViewTemplate);
            }
            if (item is ImageViewModel)
            {
                return(ContViewTemplate);
            }
            return(base.SelectTemplate(item, container));
        }
예제 #6
0
        private void InitExe(string parentid, System.Data.DataTable dts, IList <LayoutContent> ls)
        {
            DataRow[] rows = dts.Select(string.Format("parentid='{0}'", parentid));

            foreach (DataRow row in rows)
            {
                LayoutContent lc = new LayoutContent();
                lc.ChapterName = row["ChapterName"].ToString();
                try
                {
                    if (row["Contents"] != DBNull.Value)
                    {
                        byte[] bt = null;
                        try { bt = (byte[])row["Contents"]; }
                        catch { }
                        if (bt != null)
                        {
                            //ls.Add(bt);
                            lc.Contents = bt;
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                ls.Add(lc);
                InitExe(row["UID"].ToString(), dts, ls);
            }
        }
예제 #7
0
        void _application_OnShowDockableWindow(IDockableWindow window)
        {
            if (!_anchorables.ContainsKey(window))
                return;

            LayoutAnchorable anchorable = _anchorables[window];
            if (anchorable != null)
            {
                if (anchorable.IsAutoHidden)
                {
                    anchorable.ToggleAutoHide();
                }
                else
                {
                    LayoutContent content = anchorable;
                    while (content != null && content.Parent is ILayoutContentSelector)
                    {
                        ILayoutContentSelector selector = (ILayoutContentSelector)content.Parent;
                        int index = selector.IndexOf(content);
                        if (index != selector.SelectedContentIndex)
                            selector.SelectedContentIndex = index;
                        content = content.Parent as LayoutContent;
                    }

                    anchorable.Show();
                    if (anchorable.IsVisible == false)
                    {
                        //if (anchorable.CanFloat)
                        //    anchorable.Float();
                        //else
                            anchorable.Dock();
                    }
                }
            }
        }
예제 #8
0
        private static void AddWindowBehaviour <TView>(TView view, LayoutContent layoutContent)
            where TView : class, IView
        {
            if (!(view.ViewModel is ViewModelBase baseViewModel))
            {
                return;
            }

            baseViewModel
            .WhenAnyValue(x => x.IsEnabled)
            .Subscribe(x => layoutContent.IsEnabled = x)
            .DisposeWith(baseViewModel.Disposables);

            baseViewModel
            .WhenAnyValue(x => x.CanClose)
            .Subscribe(x => layoutContent.CanClose = x)
            .DisposeWith(baseViewModel.Disposables);

            if (layoutContent is LayoutAnchorable layoutAnchorable)
            {
                baseViewModel
                .WhenAnyValue(x => x.CanHide)
                .Subscribe(x => layoutAnchorable.CanHide = x)
                .DisposeWith(baseViewModel.Disposables);
            }
        }
예제 #9
0
        private void dockManager_ActiveContentChanged(object sender, EventArgs e)
        {
            if (documentManager.SelectedContentIndex != _lastDocumentIndex)
            {
                // Selection Changed, lets do dis
                LayoutContent tab = documentManager.SelectedContent;

                if (tab != null)
                {
                    UpdateTitleText(tab.Title.Replace("__", "_").Replace(".map", ""));
                }

                if (tab != null && tab.Title == "Start Page")
                {
                    ((StartPage)tab.Content).UpdateRecents();
                }

                if (tab == null)
                {
                    documentManager.SelectedContentIndex = 0;
                    UpdateTitleText("");
                }

                _lastDocumentIndex = documentManager.SelectedContentIndex;
            }
        }
예제 #10
0
 /// <summary>
 /// Class constructor from <see cref="LayoutContent"/> and <paramref name="previousContent"/> object.
 /// </summary>
 /// <param name="model">The model of the view that has been deserialized.</param>
 /// <param name="previousContent">The content if it was available in previous layout.</param>
 public LayoutRestoreEventArgs(LayoutContent model, object previousContent)
 {
     Cancel  = false;            // reloading an item is not by cancelled by default
     Handled = false;            // an item is not handled by default
     Model   = model;
     Content = previousContent;
 }
예제 #11
0
        /// <summary>
        ///		Muestra un documento
        /// </summary>
        public void ShowDocument(string windowID, string title, System.Windows.Controls.UserControl control)
        {
            LayoutContent previous = GetLayoutPrevious(windowID);

            if (previous != null && previous.Parent != null)
            {
                previous.IsActive = true;
            }
            else
            {
                LayoutDocumentPane documentPane   = DockManager.Layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault();
                LayoutDocument     layoutDocument = new LayoutDocument {
                    Title = title, ToolTip = title
                };

                // Crea un documento y le asigna el control de contenido
                if (documentPane != null)
                {
                    // Asigna el control
                    layoutDocument.Content   = control;
                    layoutDocument.ContentId = windowID;
                    // Añade el nuevo LayoutDocument al array existente
                    documentPane.Children.Add(layoutDocument);
                    // Activa el documento
                    layoutDocument.IsActive   = true;
                    layoutDocument.IsSelected = true;
                    // Cambia el foco al control
                    control.Focus();
                    // Añade el documento al controlador
                    AddDocument(new DocumentViewModel(windowID, title, layoutDocument, control));
                }
            }
        }
예제 #12
0
        internal override void Attach(LayoutContent model)
        {
            _anchorable = model as LayoutAnchorable;
            _anchorable.IsVisibleChanged += new EventHandler(_anchorable_IsVisibleChanged);

            base.Attach(model);
        }
예제 #13
0
        private void RefreshTestMesthodsList()
        {
            TestMethodListViewModel testMethodRespository = this.testMethodRespositoryView.DataContext as TestMethodListViewModel;

            if (testMethodRespository != null)
            {
                testMethodRespository.QueryTestMethodsCommand.Execute(null);
            }

            LayoutDocumentPane firstDocumentPane = dockManager.Layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault();
            LayoutContent      temp = firstDocumentPane.Children.FirstOrDefault(o => o.Title == "测试用例仓库");

            if (temp == null)
            {
                temp = new LayoutDocument
                {
                    Title   = "测试用例仓库",
                    Content = this.testMethodRespositoryView
                };

                firstDocumentPane.Children.Add(temp);
            }

            temp.IsActive = true;
        }
예제 #14
0
        private void ShowWindow(Type type)
        {
            LayoutContent panel = Windows.FirstOrDefault(p => p.GetType() == type);

            if (panel != null)
            {
                panel.IsSelected = true;
                panel.IsActive   = true;
                if (m_dockingManager != null)
                {
                    m_dockingManager.ActiveContent = panel;
                }
                return;
            }

            if (type == typeof(ProjectOverviewVM))
            {
                panel = new ProjectOverviewVM(m_project);
            }
            else if (type == typeof(LogPanelVM))
            {
                panel = new LogPanelVM();
            }
            else
            {
                Logging.Logger.Warn($"Tried to show unknown panel: {type.FullName}");
                return;
            }

            Logging.Logger.Info($"Adding new panel '{panel.Title}' based on requested type: {type.FullName}");
            Windows.Add(panel);
        }
예제 #15
0
        private bool BeforeInsertContent(LayoutRoot layout, LayoutContent anchorableToShow)
        {
            var viewModel     = (ViewModelBase)anchorableToShow.Content;
            var layoutContent =
                layout.Descendents().OfType <LayoutContent>().FirstOrDefault(x => x.ContentId == viewModel.ContextId);

            if (layoutContent == null)
            {
                return(false);
            }
            layoutContent.Content = anchorableToShow.Content;
            // Add layoutContent to it's previous container
            var layoutContainer =
                layoutContent.GetType()
                .GetProperty("PreviousContainer", BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue(layoutContent, null) as ILayoutContainer;

            if (layoutContainer is LayoutAnchorablePane)
            {
                (layoutContainer as LayoutAnchorablePane).Children.Add(layoutContent as LayoutAnchorable);
            }
            else if (layoutContainer is LayoutDocumentPane)
            {
                (layoutContainer as LayoutDocumentPane).Children.Add(layoutContent);
            }
            else
            {
                throw new NotSupportedException();
            }
            return(true);
        }
예제 #16
0
        /// <summary>
        ///		Muestra un panel
        /// </summary>
        public void ShowPane(string windowID, string title, System.Windows.Controls.UserControl control,
                             SystemControllerEnums.DockPosition position = SystemControllerEnums.DockPosition.Bottomm)
        {
            LayoutContent previous = GetLayoutPrevious(windowID);

            if (previous != null)
            {
                previous.IsActive = true;
            }
            else
            {
                LayoutAnchorGroup layoutGroup = GetGroupPane(DockManager.Layout, position);
                LayoutAnchorable  layoutPane  = new LayoutAnchorable {
                    Title = title, ToolTip = title
                };

                // Añade el contenido
                layoutPane.Content   = control;
                layoutPane.ContentId = windowID;
                // Añade el contenido al grupo
                layoutGroup.Children.Add(layoutPane);
                // Añade el panel a la lista de documentos del controlador
                AddDocument(new ToolViewModel(windowID, title, layoutPane, control, position));
            }
        }
        internal override void Attach(LayoutContent model)
        {
            _anchorable = model as LayoutAnchorable;
            _anchorable.IsVisibleChanged += new EventHandler(_anchorable_IsVisibleChanged);

            base.Attach(model);
        }
예제 #18
0
        private void barAdd1item_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string parentid = "";

            if (treeList1.FocusedNode == null)
            {
                return;
            }
            parentid = treeList1.FocusedNode["UID"].ToString();


            LayoutContent obj = new LayoutContent();

            obj.UID        = obj.UID + "|" + Itop.Client.MIS.ProgUID;
            obj.LayoutID   = layoutUID;
            obj.ParentID   = parentid;
            obj.CreateDate = DateTime.Now;
            FrmLayoutContentDialog dlg = new FrmLayoutContentDialog();

            dlg.Object   = obj;
            dlg.IsCreate = true;

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
        }
예제 #19
0
        private void barEdititem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }
            string        uid = treeList1.FocusedNode["UID"].ToString();
            LayoutContent obj = Services.BaseService.GetOneByKey <LayoutContent>(uid);

            LayoutContent objCopy = new LayoutContent();

            DataConverter.CopyTo <LayoutContent>(obj, objCopy);

            FrmLayoutContentDialog dlg = new FrmLayoutContentDialog();

            dlg.Object = objCopy;

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DataConverter.CopyTo <LayoutContent>(objCopy, obj);
            treeList1.FocusedNode.SetValue("ChapterName", obj.ChapterName);
            treeList1.FocusedNode.SetValue("Remark", obj.Remark);
        }
예제 #20
0
        private void SaveText()
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }
            string        uid = treeList1.FocusedNode["UID"].ToString();
            LayoutContent obj = Services.BaseService.GetOneByKey <LayoutContent>(uid);

            obj.Contents = dsoFramerWordControl1.FileDataGzip;
            WaitDialogForm wait = null;

            try
            {
                wait = new WaitDialogForm("", "正在保存数据, 请稍候...");
                Services.BaseService.Update("UpdateLayoutContentByte", obj);
                wait.Close();
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                wait.Close();
                return;
            }
        }
예제 #21
0
        private void OpenTestProject(TestProjectInfo testProjectInfo)
        {
            if (testProjectInfo != null)
            {
                LayoutDocumentPane firstDocumentPane = dockManager.Layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault();
                LayoutDocument     doc = new LayoutDocument();
                doc.Title   = testProjectInfo.Name;
                doc.ToolTip = testProjectInfo.Location;
                LayoutContent temp = firstDocumentPane.Children.FirstOrDefault(o => o.Title == doc.Title && o.ToolTip.ToString() == doc.ToolTip.ToString());
                if (temp != null && temp is LayoutDocument)
                {
                    doc = temp as LayoutDocument;
                }
                else
                {
                    TestMethodListView listView = new TestMethodListView();
                    //listView.ComboBoxRespository.Visibility = Visibility.Collapsed;
                    (listView.DataContext as TestMethodListViewModel).CurrentTestProject = testProjectInfo;
                    doc.Content = listView;
                    firstDocumentPane.Children.Add(doc);
                }

                doc.IsActive = true;
                doc.Closing += this.Doc_Closing;
            }
        }
예제 #22
0
        // Find LayoutDocumentPane where IS3View can be add.
        public LayoutDocumentPane FindViewHolder()
        {
            if (_prj == null)
            {
                return(null);
            }

            EngineeringMap baseMap = _prj.projDef.EngineeringMaps.FirstOrDefault();

            if (baseMap == null)
            {
                return(null);
            }
            LayoutContent layoutContent = FindLayoutContentByID(baseMap.MapID);

            if (layoutContent == null)
            {
                return(null);
            }

            LayoutDocumentPane docPane = layoutContent.Parent as LayoutDocumentPane;

            if (docPane == null)
            {
                LayoutRoot              root         = layoutContent.Root as LayoutRoot;
                LayoutPanel             panel        = root.Children.First() as LayoutPanel;
                LayoutDocumentPaneGroup docPaneGroup =
                    panel.Children.ElementAt(1) as LayoutDocumentPaneGroup;
                docPane = docPaneGroup.Children.First()
                          as LayoutDocumentPane;
            }
            return(docPane);
        }
예제 #23
0
 private static void ActivateContent(LayoutContent layoutContent, ViewRequest viewRequest)
 {
     layoutContent.IsActive = true;
     if (layoutContent.Content is IView view &&
         view.ViewModel is Ui.Wpf.Common.ViewModels.IActivatableViewModel activatableViewModel)
     {
         activatableViewModel.Activate(viewRequest);
     }
 }
 public DockLayoutDocument(string id, string header, DocumentType type, LayoutContent layoutContent, UserControl userControl, object tag = null)
 {
     Id            = id;
     Header        = header;
     Type          = type;
     LayoutContent = layoutContent;
     UserControl   = userControl;
     Tag           = tag;
 }
예제 #25
0
 private static void CloseContent(LayoutContent layout)
 {
     if (layout != null &&
         layout.Content is IView view &&
         view.ViewModel is ViewModelBase vm)
     {
         vm.Close();
     }
 }
예제 #26
0
 internal virtual void Attach(LayoutContent model)
 {
     this.LayoutElement = model;
     this.Model         = model.Content;
     this.InitDefaultCommands();
     this.LayoutElement.IsSelectedChanged += new EventHandler(this.LayoutElement_IsSelectedChanged);
     this.LayoutElement.IsActiveChanged   += new EventHandler(this.LayoutElement_IsActiveChanged);
     base.DataContext = this;
 }
예제 #27
0
        private void Doc_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            LayoutContent         doc              = sender as LayoutContent;
            TestMethodListView    listView         = doc.Content as TestMethodListView;
            TestProjectInfo       projectInfo      = (listView.DataContext as TestMethodListViewModel).CurrentTestProject;
            TestProjectsViewModel testProjectsView = this.testProjectView.DataContext as TestProjectsViewModel;

            testProjectsView.CloseTestProjectCommand.Execute(projectInfo);
        }
예제 #28
0
        private void ExecuteMoveToPreviousTabGroupCommand(object parameter)
        {
            LayoutContent           layoutElement           = this.LayoutElement;
            LayoutDocumentPaneGroup layoutDocumentPaneGroup = layoutElement.FindParent <LayoutDocumentPaneGroup>();
            int num = layoutDocumentPaneGroup.IndexOfChild(layoutElement.Parent as LayoutDocumentPane);

            (layoutDocumentPaneGroup.Children[num - 1] as LayoutDocumentPane).InsertChildAt(0, layoutElement);
            layoutElement.IsActive = true;
            layoutElement.Root.CollectGarbage();
        }
예제 #29
0
        internal override void Attach(LayoutContent model)
        {
            _anchorable = model as LayoutAnchorable;
            if (_anchorable != null)
            {
                _anchorable.IsVisibleChanged += _anchorable_IsVisibleChanged;
            }

            base.Attach(model);
        }
예제 #30
0
        /// <summary>
        /// 根据拓扑数据显示布线图
        /// </summary>
        private void ShowGraph(BranchView obj)
        {
            this.Dispatcher.Invoke((Action)(() =>
            {
                LayoutDocument doc = new LayoutDocument();
                WireGraph graph = null;
                bool left = true, right = true;
                doc.Title = obj.GraphName;
                switch (obj.GraphType)
                {
                case GraphType.VccToGndGraph:
                    {
                        left = true; right = true;
                        break;
                    }

                case GraphType.VccToCFGraph:
                    {
                        left = true; right = false;
                        break;
                    }

                case GraphType.CFToGndGraph:
                    {
                        left = true; right = false;
                        break;
                    }

                case GraphType.CompleteGraph:
                    {
                        left = true; right = false;
                        break;
                    }
                }
                LayoutContent other = ShowPanel.Children.FirstOrDefault(p => p.Title.Equals(doc.Title));
                if (other != null)
                {
                    other.IsActive = true;
                    return;
                }
                ShowPanel.Children.Add(doc);
                doc.IsActive = true;
                if (obj.page == null)
                {
                    graph = new WireGraph(obj, left, right);
                    obj.page = graph;
                }
                else
                {
                    graph = (WireGraph)obj.page;
                }
                doc.Content = graph;
            }));
        }
예제 #31
0
        internal override void Attach(LayoutContent model)
        {
            _anchorable = model as LayoutAnchorable;
            _anchorable.IsVisibleChanged += new EventHandler(_anchorable_IsVisibleChanged);

            if (_anchorable.CanClose)
            {
                _anchorable.SetCanCloseInternal(true);
            }

            base.Attach(model);
        }
        internal virtual void Attach(LayoutContent model)
        { 
            LayoutElement = model;
            Model = model.Content;

            InitDefaultCommands();

            LayoutElement.IsSelectedChanged+=new EventHandler(LayoutElement_IsSelectedChanged);
            LayoutElement.IsActiveChanged+=new EventHandler(LayoutElement_IsActiveChanged);

            DataContext = this;
        }
예제 #33
0
		internal virtual void Attach(LayoutContent model)
		{
			LayoutElement = model;
			Model = model.Content;

			InitDefaultCommands();

			LayoutElement.IsSelectedChanged += new EventHandler(LayoutElement_IsSelectedChanged);
			LayoutElement.IsActiveChanged += new EventHandler(LayoutElement_IsActiveChanged);

			DataContext = this;
			System.Diagnostics.Trace.WriteLine(string.Format("Attach({0})", LayoutElement.Title));
		}
예제 #34
0
        internal virtual void Attach(LayoutContent model)
        {
            LayoutElement = model;
            Model = model.Content;

            InitDefaultCommands();

            LayoutElement.IsSelectedChanged += LayoutElement_IsSelectedChanged;
            LayoutElement.IsActiveChanged += LayoutElement_IsActiveChanged;

            DataContext = this;
            Trace.WriteLine(string.Format("Attach({0})", LayoutElement.Title));
        }
예제 #35
0
 private bool BeforeInsertContent(LayoutRoot layout, LayoutContent anchorableToShow)
 {
     var viewModel = (ViewModelBase) anchorableToShow.Content;
     var layoutContent =
         layout.Descendents().OfType<LayoutContent>().FirstOrDefault(x => x.ContentId == viewModel.ContextId);
     if (layoutContent == null)
         return false;
     layoutContent.Content = anchorableToShow.Content;
     // Add layoutContent to it's previous container
     var layoutContainer =
         layoutContent.GetType()
             .GetProperty("PreviousContainer", BindingFlags.NonPublic | BindingFlags.Instance)
             .GetValue(layoutContent, null) as ILayoutContainer;
     if (layoutContainer is LayoutAnchorablePane)
         (layoutContainer as LayoutAnchorablePane).Children.Add(layoutContent as LayoutAnchorable);
     else if (layoutContainer is LayoutDocumentPane)
         (layoutContainer as LayoutDocumentPane).Children.Add(layoutContent);
     else
         throw new NotSupportedException();
     return true;
 }
예제 #36
0
 internal void _ExecuteDockAsDocumentCommand(LayoutContent content)
 {
     content.DockAsDocument();
 }
예제 #37
0
 internal void _ExecuteContentActivateCommand(LayoutContent content)
 {
     content.IsActive = true;
 }
예제 #38
0
        internal void _ExecuteCloseAllButThisCommand(LayoutContent contentSelected)
        {
            foreach (var contentToClose in Layout.Descendents().OfType<LayoutContent>().Where(d => d != contentSelected && (d.Parent is LayoutDocumentPane || d.Parent is LayoutDocumentFloatingWindow)).ToArray())
            {
                if (!contentToClose.CanClose)
                    continue;

                var layoutItem = GetLayoutItemFromModel(contentToClose);
                if (layoutItem.CloseCommand != null)
                {
                    if (layoutItem.CloseCommand.CanExecute(null))
                        layoutItem.CloseCommand.Execute(null);
                }
                else
                {
                    if (contentToClose is LayoutDocument)
                        _ExecuteCloseCommand(contentToClose as LayoutDocument);
                    else if (contentToClose is LayoutAnchorable)
                        _ExecuteCloseCommand(contentToClose as LayoutAnchorable);
                }
            }
        }
예제 #39
0
        internal void StartDraggingFloatingWindowForContent(LayoutContent contentModel, bool startDrag = true)
        {
            if (!contentModel.CanFloat)
                return;
            var contentModelAsAnchorable = contentModel as LayoutAnchorable;
            if (contentModelAsAnchorable != null &&
                contentModelAsAnchorable.IsAutoHidden)
                contentModelAsAnchorable.ToggleAutoHide();

            var parentPane = contentModel.Parent as ILayoutPane;
            var parentPaneAsPositionableElement = contentModel.Parent as ILayoutPositionableElement;
            var parentPaneAsWithActualSize = contentModel.Parent as ILayoutPositionableElementWithActualSize;
            var contentModelParentChildrenIndex = parentPane.Children.ToList().IndexOf(contentModel);

            if (contentModel.FindParent<LayoutFloatingWindow>() == null)
            {
                ((ILayoutPreviousContainer)contentModel).PreviousContainer = parentPane;
                contentModel.PreviousContainerIndex = contentModelParentChildrenIndex;
            }

            parentPane.RemoveChildAt(contentModelParentChildrenIndex);

            double fwWidth = contentModel.FloatingWidth;
            double fwHeight = contentModel.FloatingHeight;

            if (fwWidth == 0.0)
                fwWidth = parentPaneAsPositionableElement.FloatingWidth;
            if (fwHeight == 0.0)
                fwHeight = parentPaneAsPositionableElement.FloatingHeight;

            if (fwWidth == 0.0)
                fwWidth = parentPaneAsWithActualSize.ActualWidth;
            if (fwHeight == 0.0)
                fwHeight = parentPaneAsWithActualSize.ActualHeight;

            LayoutFloatingWindow fw;
            LayoutFloatingWindowControl fwc;
            if (contentModel is LayoutAnchorable)
            {
                var anchorableContent = contentModel as LayoutAnchorable;
                fw = new LayoutAnchorableFloatingWindow()
                {
                    RootPanel = new LayoutAnchorablePaneGroup(
                        new LayoutAnchorablePane(anchorableContent)
                        {
                            DockWidth = parentPaneAsPositionableElement.DockWidth,
                            DockHeight = parentPaneAsPositionableElement.DockHeight,
                            DockMinHeight = parentPaneAsPositionableElement.DockMinHeight,
                            DockMinWidth = parentPaneAsPositionableElement.DockMinWidth,
                            FloatingLeft = parentPaneAsPositionableElement.FloatingLeft,
                            FloatingTop = parentPaneAsPositionableElement.FloatingTop,
                            FloatingWidth = parentPaneAsPositionableElement.FloatingWidth,
                            FloatingHeight = parentPaneAsPositionableElement.FloatingHeight,
                        })
                };

                Layout.FloatingWindows.Add(fw);

                fwc = new LayoutAnchorableFloatingWindowControl(
                    fw as LayoutAnchorableFloatingWindow)
                    {
                        Width = fwWidth,
                        Height = fwHeight,
                        Left = contentModel.FloatingLeft,
                        Top = contentModel.FloatingTop
                    };
            }
            else
            {
                var anchorableDocument = contentModel as LayoutDocument;
                fw = new LayoutDocumentFloatingWindow()
                {
                    RootDocument = anchorableDocument
                };

                Layout.FloatingWindows.Add(fw);

                fwc = new LayoutDocumentFloatingWindowControl(
                    fw as LayoutDocumentFloatingWindow)
                {
                    Width = fwWidth,
                    Height = fwHeight,
                    Left = contentModel.FloatingLeft,
                    Top = contentModel.FloatingTop
                };
            }

            //fwc.Owner = Window.GetWindow(this);
            //fwc.SetParentToMainWindowOf(this);

            _fwList.Add(fwc);

            Layout.CollectGarbage();

            UpdateLayout();

            Dispatcher.BeginInvoke(new Action(() =>
            {
                if (startDrag)
                    fwc.AttachDrag();
                fwc.Show();
            }), DispatcherPriority.Send);
        }
 public void Add(string contentKey, LayoutContent content)
 {
     content.Closed += (s, e) => { Remove(contentKey); };
     m_Contents.Add(contentKey.ToSafeString().ToLower(), content);
 }
 public LayoutSerializationCallbackEventArgs(LayoutContent model, object previousContent)
 {
     Cancel = false;
     Model = model;
     Content = previousContent;
 }
예제 #42
0
 public LayoutDocumentPaneEx(LayoutContent firstChild)
     : base(firstChild)
 {
 }
예제 #43
0
 internal void _ExecuteFloatCommand(LayoutContent contentToFloat)
 {
     contentToFloat.Float();
 }
 internal override void Attach(LayoutContent model)
 {
     _document = model as LayoutDocument;
     base.Attach(model);
 }
예제 #45
0
 ViewInfo ConvertView(LayoutContent child)
 {
     var v = new ViewInfo();
     if (child is DocumentViewControl)
     {
         v.InternalName = (child as DocumentViewControl).View.InternalName;
     }
     else
         throw new NotSupportedException();
     return v;
 }
        internal override void Attach(LayoutContent model)
        {
            _anchorable = model as LayoutAnchorable;
            if (_anchorable != null)
                _anchorable.IsVisibleChanged += _anchorable_IsVisibleChanged;

            base.Attach(model);
        }
예제 #47
0
 /// <summary>
 /// Return the LayoutItem wrapper for the content passed as argument
 /// </summary>
 /// <param name="content">LayoutContent to search</param>
 /// <returns>Either a LayoutAnchorableItem or LayoutDocumentItem which contains the LayoutContent passed as argument</returns>
 public LayoutItem GetLayoutItemFromModel(LayoutContent content)
 {
     return _layoutItems.FirstOrDefault(item => item.LayoutElement == content);
 }
 internal void _ExecuteCloseAllCommand( LayoutContent contentSelected )
 {
   foreach( var contentToClose in Layout.Descendents().OfType<LayoutContent>().Where( d => ( d.Parent is LayoutDocumentPane || d.Parent is LayoutDocumentFloatingWindow ) ).ToArray() )
   {
     this.Close( contentToClose );
   }
 }
예제 #49
0
		internal void _ExecuteFloatCommand(LayoutContent contentToFloat)
		{
			contentToFloat.Float();
			OnLayoutConfigurationChanged();
		}
        private void Close( LayoutContent contentToClose )
        {
          if( !contentToClose.CanClose )
            return;

          var layoutItem = GetLayoutItemFromModel( contentToClose );
          if( layoutItem.CloseCommand != null )
          {
            if( layoutItem.CloseCommand.CanExecute( null ) )
              layoutItem.CloseCommand.Execute( null );
          }
          else
          {
            if( contentToClose is LayoutDocument )
              _ExecuteCloseCommand( contentToClose as LayoutDocument );
            else if( contentToClose is LayoutAnchorable )
              _ExecuteCloseCommand( contentToClose as LayoutAnchorable );
          }
        }
예제 #51
0
 void InternalSetActiveContent(LayoutContent currentValue, LayoutContent newActiveContent)
 {
     RaisePropertyChanging("ActiveContent");
     if (currentValue != null)
         currentValue.IsActive = false;
     _activeContent = new WeakReference(newActiveContent);
     currentValue = ActiveContent;
     if (currentValue != null)
         currentValue.IsActive = true;
     RaisePropertyChanged("ActiveContent");
     _activeContentSet = currentValue != null;
     if (currentValue != null)
     {
         if (currentValue.Parent is LayoutDocumentPane || currentValue is LayoutDocument)
             LastFocusedDocument = currentValue;
     }
     else
         LastFocusedDocument = null;
 }
예제 #52
0
		internal void _ExecuteDockAsDocumentCommand(LayoutContent content)
		{
			content.DockAsDocument();
			OnLayoutConfigurationChanged();
		}