zoukankan      html  css  js  c++  java
  • How to: Access the Document Manager 如何:访问文档管理器

    This topic demonstrates how to access the Document Manager that the MdiShowViewStrategy uses to show Views in a WinForms application. You will locate tab captions to the left and orient them horizontally.

    本主题演示如何访问 MdiShowView 策略用于在 WinForms 应用程序中显示视图的文档管理器。您将在左侧找到选项卡标题,并水平定向它们。

    AccessDocumentManager

    Tip 提示
    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4027
    完整的示例项目可在 DevExpress 代码示例数据库中找到,http://www.devexpress.com/example=E4027

    .

    Here, it is assumed that you have the UI type set to TabbedMDI in the Model Editor for your Windows Forms application (see IModelOptionsWin.UIType). Perform the following steps to access the DocumentManager object and customize its default settings.

    1. Create a new WindowController in the WinForms module's Controllers folder.
    2. The Document Manager is located on the MainForm Template. Override the Controller's OnActivated method and subscribe to the main Window's Frame.TemplateChanged event to access the MainForm Template after it has been created or changed.
    3. Cast the MainForm Template by the IDocumentsHostWindow interface and access the Document Manager using the DocumentManager property.
    4. Subscribe to the DocumentManager.ViewChanged event that occurs when the Document Manager has switched to another View.
    5. Add the following CustomizeDocumentManagerView method that changes the location and orientation of tab captions if the Document Manager's View is of the TabbedView type.
    6. Call the CustomizeDocumentManagerView method from both Frame.TemplateChanged and DocumentManager.ViewChanged event handlers.
    7. Override the OnDeactivated method and unsubscribe from the Window.TemplateChanged event when the Controller is deactivated.

    此处,假定在 Windows 窗体应用程序的模型编辑器中,将 UI 类型设置为 TabbedMDI(请参阅 IModelOptionsWin.UIType)。执行以下步骤以访问 DocumentManager 对象并自定义其默认设置。

    1. 在 WinForms 模块的控制器文件夹中创建新的窗口控制器。

    2. 文档管理器位于主窗体模板上。覆盖控制器的 OnActivated 方法并订阅主窗口的 Frame.TemplateChanged 事件,以在创建或更改主窗体模板后访问该模板。

    3. 通过 IDocumentsHostWindow 界面强制转换主窗体模板,并使用文档管理器属性访问文档管理器。

    4. 订阅文档管理器.View 更改事件,该事件发生在文档管理器切换到另一个视图时。

    5. 添加以下自定义文档管理器视图方法,该方法更改选项卡标题的位置和方向(如果文档管理器的视图为 TabbedView 类型)。

    6. 从 Frame.模板更改和文档管理器.View 更改事件处理程序调用自定义文档管理器视图方法。

    7. 覆盖 OnDeon 已激活的方法,并在停用控制器时取消订阅 Window.Template 更改事件。

     

    using DevExpress.ExpressApp;
    using DevExpress.XtraBars.Docking2010;
    using DevExpress.XtraBars.Docking2010.Views;
    using DevExpress.XtraBars.Docking2010.Views.Tabbed;
    using DevExpress.ExpressApp.Templates;
    // ...
    public class TabsCustomizationWindowController : WindowController {
        public TabsCustomizationWindowController() {
            TargetWindowType = WindowType.Main;
        }
        protected override void OnActivated() {
            base.OnActivated();
            Window.TemplateChanged += Window_TemplateChanged;
        }
        private void Window_TemplateChanged(object sender, EventArgs e) {
            IFrameTemplate template = Window.Template;
            DocumentManager docManager = ((IDocumentsHostWindow)template).DocumentManager;
            docManager.ViewChanged += docManager_ViewChanged;
            CustomizeDocumentManagerView(docManager.View);
        }
        private void docManager_ViewChanged(object sender, ViewEventArgs args) {
            CustomizeDocumentManagerView(args.View);
        }
        private static void CustomizeDocumentManagerView(BaseView view) {
            if(view is TabbedView) {
                ((TabbedView)view).DocumentGroupProperties.HeaderLocation = 
                    DevExpress.XtraTab.TabHeaderLocation.Left;
                ((TabbedView)view).DocumentGroupProperties.HeaderOrientation = 
                    DevExpress.XtraTab.TabOrientation.Horizontal;
            }
        }
        protected override void OnDeactivated() {
            Window.TemplateChanged -= Window_TemplateChanged;
            base.OnDeactivated();
        }
    }

    Run the application to ensure that the tab captions location is changed.

    运行应用程序以确保更改选项卡标题位置。

  • 相关阅读:
    Mybatis plus强大的条件构造器QueryWrapper条件构造器基础方法解释
    代码一键生成
    报错:error setting certificate verify locations: CAfile: D:/Git/anz/Git/mingw64/ssl/certs/ca-bundle.crt CApath: none
    safari怎么设置开发者模式,调出审查元素
    react antd Tabs组件如何修改默认样式-友好的解决方法
    css filter属性滤镜变灰
    yarn的安装和常用命令
    react-app-rewired start 启动失败报错解决方法
    react路由5到底要怎么使用(基础向)
    react中img引入本地图片的2种方式
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Access-the-Document-Manager.html
Copyright © 2011-2022 走看看