zoukankan      html  css  js  c++  java
  • WPF APP 启动时增加特殊逻辑

      public partial class App : Application
        {
            public App()
            {
                this.Startup += (o1, e1)=>{
                    string commandLine = Environment.CommandLine;  
                    string appFilePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                    commandLine = commandLine.Replace(String.Format("\"{0}\" ", appFilePath), ""); 得到命令参数
    
                    MessageBox.Show(string.Format("commandLine:{0}", Environment.CommandLine));
                    MessageBox.Show("SpiltResult:" + commandLine);
                    if (!string.IsNullOrEmpty(commandLine) && commandLine.ToUpper() == "SA")//启动参数带SA则转到特殊处理页面
                    {
                        this.ShutdownMode = ShutdownMode.OnLastWindowClose;  
                        this.StartupUri = new Uri("pack://application:,,,/Views/SNPrint/SA_MODE.xaml");  //
                        MessageBox.Show("Set URI!");
                    }
    //正常App.xaml中存在StartupUri如【StartupUri="MasterWindow.xaml"】则可以省略下面代码 //else //{ // this.StartupUri = new Uri("pack://application:,,,/MasterWindow.xaml"); // MessageBox.Show("MAIN URI!"); //} }; } }

    //new Uri("pack://application:,,,/Views/SNPrint/SA_MODE.xaml"); 代表如下

    调试时加入命令参数在如下图

  • 相关阅读:
    springboot 环境搭建
    Maven工程下构建ssh项目配置
    java动态代理
    java 代理
    java反射
    Java缓存流
    java 输出流
    Java输入数据流
    使用微软 AppFabric 遇到问题
    百度文本编辑器 Ueditor for net 使用七牛存储附件的实现
  • 原文地址:https://www.cnblogs.com/wandia/p/13944223.html
Copyright © 2011-2022 走看看