系统加界面流程

目标:将新的三维界面加入到系统卡页中

一、涉及到的系统内容

1.app.xaml

         需要自己添加字典文件,内容由蓝色标注,红色文件也需要加入。

<Application x:Class="TestZeus02.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:TestZeus02">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <local:
Bootstrapper x:Key="bootstrapper"/>
                </ResourceDictionary>
                <ResourceDictionary Source="/TestZeus02;component/Style/
ComboBox.xaml"/>
            </ResourceDictionary.MergedDictionaries>

        </ResourceDictionary>
    </Application.Resources>
</Application>

2.Bootstrapper.cs

        Bootstrapper ( 引导程序 ) 引导程序负责引导您的应用程序。 它配置 IoC 容器,创建根 ViewModel 的新实例并使用 WindowManager 。

3.MainWindowView.xaml

        根据原框架写界面,其中最重要的是ViewTree,即树形界面。其中在Window.Resource中涉及到三个资源:资源1.树形结构每项模板的style资源资源2.树形结构本身的属性资源3.定义每项模板的具体数据。其中是涉及到的ViewTree代码:

 <TreeView x:Name="TreeViewOrg" Grid.Column="0" BorderThickness="0" BorderBrush="#707070" 
           Background="#101010" Width="280" Margin="0" HorizontalAlignment="Left" 
           ItemTemplate="{StaticResource ItemNode}" 
           Style="{StaticResource DefaultTreeView}" 
cal:Message.Attach="[Event SelectedItemChanged]=[Action SelectNIC($source,$eventArgs)]">
     <TreeView.Effect>
          <DropShadowEffect ShadowDepth="0" BlurRadius="10" Opacity="0.8" Color="#AAAAAA"/>         
     </TreeView.Effect>
 </TreeView>

其中,ItemTemplate对应的资源3,style对应的资源2,SelectNIC对应的MainWindowViewModel.cs方法的函数。

4.MainWindowViewModel.cs

        在MainWindowViewModel.cs方法中需要修改SelectNIC对应的函数。

        public void SelectNIC(object sender, EventArgs e)
        {
            TreeView treeView = sender as TreeView;
            Views.MainWindowView.OrgModel orgModel = treeView.SelectedValue as     
            Views.MainWindowView.OrgModel;
            switch (orgModel.Count)
            { 
                case 100:
                    //三维位置
                    ActivateItem(new TDLocationDeployViewModel());
                    break;
            }
        }

5.MainWindowView.xaml.cs

        在MainWindowView.xaml.cs方法中需要在构造函数中做一些准备。

第一个是各个卡页(子节点)的信息存储OrgModel 。

 public class OrgModel
        {
            public bool IsGrouping { get; set; }
            public ObservableCollection<OrgModel> Children { get; set; }
            public string DisplayName { get; set; }
            public string SurName { get; set; }
            public string Name { get; set; }
            public string Info { get; set; }
            public int Count { get; set; }
        }

第二个是存储各个卡页(OrgModel)信息的OrgList。

public ObservableCollection<OrgModel> OrgList { get; set; }//动态数据集合

第三个是存储各个卡页控制键userControlKeys字符串在这里我以三维位置图为例加入到页面中。

            List<string> userControlKeys = new List<string>();
            userControlKeys.Add("TDLocationDeployView");

第四个是遍历每一个注册的字符串,并根据此命名方式创建一个控件实例。

            foreach (string userControlKey in userControlKeys)     //遍历每一个注册的字符串并转化成合理的命名方式,
            {                                                      //根据此命名方式创建一个控件实例,并添加到字典中
                string userControlFullName = String.Format("{0}.{1}", type.Namespace, userControlKey);
                //string userControlFullName = String.Format("{0}.{1}", type.Namespace, userControlKey);
                UserControl userControl = (UserControl)assembly.CreateInstance(userControlFullName);
                _userControls.Add(userControlKey, userControl);
            }

6.FullScreenManager.cs

窗口过程(WindowProc)回调函数,WindowProc方法是一个静态方法,用于处理窗口消息。它接收了窗口句柄(hwnd)、消息ID(msg)、wParam、lParam和一个handled参数,该参数用于指示是否已经处理了该消息。

        private static IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch (msg)
            {
                case 0x0024:
                    WmGetMinMaxInfo(hwnd, lParam);
                    handled = true;
                    break;
            }

            return (IntPtr)0;
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值