当前位置: 首页>>代码示例>>C#>>正文


C# DockableContent.FirstOrDefault方法代码示例

本文整理汇总了C#中AvalonDock.DockableContent.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# DockableContent.FirstOrDefault方法的具体用法?C# DockableContent.FirstOrDefault怎么用?C# DockableContent.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AvalonDock.DockableContent的用法示例。


在下文中一共展示了DockableContent.FirstOrDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RestoreDocumentPaneLayout

        ///// <summary>
        ///// Restore from xml a document pane
        ///// </summary>
        ///// <param name="childElement"></param>
        ///// <param name="mainExistingDocumentPane"></param>
        ///// <param name="existingDocumentPanel"></param>
        ///// <param name="dockableContents"></param>
        //void RestoreDocumentPaneLayout(XmlElement childElement, out DocumentPane mainExistingDocumentPane, out DocumentPaneResizingPanel existingDocumentPanel, DockableContent[] dockableContents)
        //{
        //    mainExistingDocumentPane = (Content is DocumentPane) ? Content as DocumentPane : GetMainDocumentPane(Content as ResizingPanel);
        //    if (mainExistingDocumentPane != null)
        //    {
        //        existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel();
        //    }
        //    else
        //    {
        //        existingDocumentPanel = null;
        //    }
        //    if (existingDocumentPanel != null)
        //    {
        //        if (existingDocumentPanel.Parent is ResizingPanel)
        //        {
        //            ((ResizingPanel)existingDocumentPanel.Parent).RemoveChild(existingDocumentPanel);
        //        }
        //        else if (existingDocumentPanel.Parent is DockingManager)
        //        {
        //            ((DockingManager)existingDocumentPanel.Parent).Content = null;
        //        }
        //    }
        //    else if (mainExistingDocumentPane != null)
        //    {
        //        if (mainExistingDocumentPane.Parent is ResizingPanel)
        //        {
        //            ((ResizingPanel)mainExistingDocumentPane.Parent).RemoveChild(mainExistingDocumentPane);
        //        }
        //        else if (mainExistingDocumentPane.Parent is DockingManager)
        //        {
        //            ((DockingManager)mainExistingDocumentPane.Parent).Content = null;
        //        }
        //    }
        //    foreach (XmlElement contentElement in childElement.ChildNodes)
        //    {
        //        if (contentElement.HasAttribute("Name"))
        //        {
        //            DockableContent foundContent = null;
        //            string contentName = contentElement.GetAttribute("Name");
        //            foreach (DockableContent content in dockableContents)
        //            {
        //                if (content.Name == contentName)
        //                {
        //                    foundContent = content;
        //                    break;
        //                }
        //            }
        //            if (foundContent == null &&
        //                DeserializationCallback != null)
        //            {
        //                DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName);
        //                DeserializationCallback(this, e);
        //                foundContent = e.Content as DockableContent;
        //            }
        //            if (foundContent != null)
        //            {
        //                DetachContentFromDockingManager(foundContent);
        //                mainExistingDocumentPane.Items.Add(foundContent);
        //                foundContent.SetStateToDocument();
        //                //call custom layout persistence method
        //                foundContent.RestoreLayout(contentElement);
        //            }
        //        }
        //    }
        //}
        DocumentPane RestoreDocumentPaneLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments)
        {
            var documentPane = new DocumentPane();

            if (mainElement.HasAttribute("ResizeWidth"))
                ResizingPanel.SetResizeWidth(documentPane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth")));
            if (mainElement.HasAttribute("ResizeHeight"))
                ResizingPanel.SetResizeHeight(documentPane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight")));
            if (mainElement.HasAttribute("EffectiveSize"))
                ResizingPanel.SetEffectiveSize(documentPane, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize")));

            foreach (XmlElement contentElement in mainElement.ChildNodes)
            {
                if (contentElement.Name == "DockableContent" &&
                                            contentElement.HasAttribute("Name"))
                {
                    DockableContent foundContent = null;
                    string contentName = contentElement.GetAttribute("Name");

                    foundContent = actualContents.FirstOrDefault(c => c.Name == contentName);

                    if (foundContent == null &&
                        DeserializationCallback != null)
                    {
                        DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName);
                        DeserializationCallback(this, e);

                        foundContent = e.Content as DockableContent;
//.........这里部分代码省略.........
开发者ID:alexcepoi,项目名称:ShareTabWin,代码行数:101,代码来源:DockingManager.cs

示例2: RestoreDockablePaneLayout

        DockablePane RestoreDockablePaneLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments)
        {
            DockablePane pane = new DockablePane();

            if (mainElement.HasAttribute("Anchor"))
                pane.Anchor = (AnchorStyle)Enum.Parse(typeof(AnchorStyle), mainElement.GetAttribute("Anchor"));
            if (mainElement.HasAttribute("ResizeWidth"))
                ResizingPanel.SetResizeWidth(pane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth")));
            if (mainElement.HasAttribute("ResizeHeight"))
                ResizingPanel.SetResizeHeight(pane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight")));
            if (mainElement.HasAttribute("EffectiveSize"))
                ResizingPanel.SetEffectiveSize(pane, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize")));
            if (mainElement.HasAttribute("ID"))
                pane.ID = new Guid(mainElement.GetAttribute("ID"));

            bool toggleAutoHide = false;
            if (mainElement.HasAttribute("IsAutoHidden"))
                toggleAutoHide = XmlConvert.ToBoolean(mainElement.GetAttribute("IsAutoHidden"));

            foreach (XmlElement contentElement in mainElement.ChildNodes)
            {
                if (contentElement.HasAttribute("Name"))
                {
                    DockableContent foundContent = null;
                    string contentName = contentElement.GetAttribute("Name");

                    foundContent = actualContents.FirstOrDefault(c => c.Name == contentName);

                    if (foundContent == null &&
                        DeserializationCallback != null)
                    {
                        DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName);
                        DeserializationCallback(this, e);

                        foundContent = e.Content as DockableContent;
                    }

                    if (foundContent != null)
                    {
                        DetachContentFromDockingManager(foundContent);
                        pane.Items.Add(foundContent);
                        foundContent.SetStateToDock();

                        //call custom layout persistence method
                        foundContent.RestoreLayout(contentElement);
                    }
                }
            }

            if (toggleAutoHide && pane.Items.Count > 0)
                ToggleAutoHide(pane);

            if (mainElement.HasAttribute("SelectedIndex"))
                pane.SelectedIndex = XmlConvert.ToInt32(mainElement.GetAttribute("SelectedIndex"));

            return pane;
        }
开发者ID:alexcepoi,项目名称:ShareTabWin,代码行数:57,代码来源:DockingManager.cs


注:本文中的AvalonDock.DockableContent.FirstOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。