示例#1
0
        static ArgOptions GetOptions(string[] args)
        {
            Dictionary <string, string> retval = args.ToDictionary(
                k => k.Split(new[] { ':' }, 2)[0].ToLower(),
                v => v.Split(new[] { ':' }, 2).Count() > 1
                    ? v.Split(new[] { ':' }, 2)[1]
                    : null);

            ArgOptions ops = new ArgOptions(retval);

            return(ops);
        }
示例#2
0
        static void Main(string[] args)
        {
            string configFile = "WebAssemblyViewer.cfg";


            ArgOptions argOptions = GetOptions(args);

            if (argOptions.ContainsHelp)
            {
                MessageBox.Show(IntPtr.Zero,
                                "Parameter:\n\n/f:<Path>\tset the path to config-file\n/e \t\topens the Config Editor!\n/?\t\tHelp\n\nExample:\n\nWebAssemblyViewer.exe /f:c:\\tmp\\config.cfg\n\n",
                                "Parameters", MessageBoxOptions.OkOnly | MessageBoxOptions.IconInformation);
                return;
            }

            if (argOptions.ContainsConfigFilePath)
            {
                configFile = argOptions.ConfigFilePath;
                FileInfo fi = new FileInfo(configFile);
                if (fi.Directory == null || !fi.Directory.Exists)
                {
                    MessageBox.Show("The directory of config-File cannot be found!");
                    return;
                }
            }

            BrowserOptions opetions;

            if (!LoadOptions(configFile, out opetions))
            {
                opetions = GetDefaultOptions();
                if (WriteOptions(configFile, opetions))
                {
                    if (!argOptions.ContainsEdit)
                    {
                        MessageBoxResult result = MessageBox.Show(IntPtr.Zero,
                                                                  "The Application created a configuration - file = (WebAssemblyViewer.cfg)\nDo you want to continue with emtyp configuration file?",
                                                                  "Config file created!",
                                                                  MessageBoxOptions.YesNo | MessageBoxOptions.IconQuestion | MessageBoxOptions.DefButton2);
                        if (result == MessageBoxResult.No)
                        {
                            result = MessageBox.Show(IntPtr.Zero, "Do you want to Edit the Cofig-File?",
                                                     "Want to edit Config-File?", MessageBoxOptions.OkOnly | MessageBoxOptions.YesNo);
                            if (result == MessageBoxResult.Yes)
                            {
                                argOptions.ContainsEdit = true;
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }
            }

            if (argOptions.ContainsEdit)
            {
                EditWindow ew = new EditWindow(opetions);
                NativeApp.Run(ew);


                if (ew.Result)
                {
                    if (WriteOptions(configFile, opetions))
                    {
                        AppMessageBox mg = new AppMessageBox();
                        mg.Caption = "Continue?";
                        mg.Message =
                            "The configuration has been saved.\nDo you want to start the App?\nClick Ok to start the Applicaiton.";
                        NativeApp.Run(mg);
                        var result = mg.Result;
                        if (result == MessageBoxResult.Cancel)
                        {
                            return;
                        }
                    }
                }
            }

            BrowserWindow bw = new BrowserWindow(opetions);

            NativeApp.Run(bw);
        }