コード例 #1
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += Trace.CurrentDomain_UnhandledExceptionHandler;
            Application.ThreadException += Trace.Application_UnhandledThreadExceptionHandler;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var startupMode = StartupArgs.GetMode(args != null && args.Length > 0 ? args[0] : string.Empty);

            string[] remainingArgs = null;
            if (args != null && args.Length > 1 && startupMode != StartupMode.None)
            {
                remainingArgs = args.Skip(1).ToArray();
            }
            using (var sync = new CrossApplicationSynchronizer(CrossApplicationIndentifiers.NToolbox))
            {
                if (!sync.IsLockObtained)
                {
                    sync.ShowFirstInstance();
                    return;
                }

                HidConnector.Instance.StartUSBConnectionMonitoring();
                ApplicationService.ApplicationName = "NFE Toolbox";
                ApplicationService.SetProcessDPIAware();
                Application.Run(new MainWindow(startupMode, remainingArgs));
                HidConnector.Instance.StopUSBConnectionMonitoring();
            }
        }
コード例 #2
0
ファイル: CommandLineService.cs プロジェクト: Davidblkx/MOP
 public CommandLineService(StartupArgs args, CommandLineFacilitator cmd)
 {
     _startupArgs = args;
     _parser      = cmd
                    .GetCommandLineBuilder()
                    .UseVersionOption()
                    .UseHelp()
                    .UseEnvironmentVariableDirective()
                    .UseParseDirective()
                    .UseDebugDirective()
                    .UseSuggestDirective()
                    .RegisterWithDotnetSuggest()
                    .UseTypoCorrections()
                    .UseExceptionHandler()
                    .CancelOnProcessTermination()
                    .UseMiddleware(async(context, next) =>
     {
         if (context.ParseResult.Errors.Count > 0)
         {
             // TODO: EMIT ERROR MESSAGE
             context.InvocationResult = new ParseErrorResult();
         }
         else
         {
             await next(context);
         }
     }, MiddlewareOrder.ErrorReporting)
                    .Build();
     _root = new();
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: GibHaltmannKill/sa_tools
        private static int CLISplit(StartupArgs startupArgs)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(startupArgs.filePath);

            return((fileInfo.Extension.ToLower().Contains("dll")) ? SA_Tools.SplitDLL.SplitDLL.SplitDLLFile(startupArgs.filePath, startupArgs.dataMappingPath, startupArgs.outputFolder) :
                   SA_Tools.Split.Split.SplitFile(startupArgs.filePath, startupArgs.dataMappingPath, startupArgs.outputFolder));
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: joyjones/fire-terminator
        public static string GetStartupArgValue(string key)
        {
            string val;

            if (StartupArgs.TryGetValue(key, out val))
            {
                return(val);
            }
            return("");
        }
コード例 #5
0
        public MainForm(StartupArgs startupArgs)
        {
            if (startupArgs == null)
            {
                throw new ArgumentNullException("startupArgs");
            }

            this.startupArgs = startupArgs;

            InitializeComponent();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: StardustMotion/sa_tools
        private static int CLISplit(StartupArgs args)
        {
            Environment.CurrentDirectory = Path.GetDirectoryName(args.dataMappingPath);

            if (!File.Exists(args.filePath))
            {
                Console.WriteLine(args.filePath + " not found. Aborting.");
                Console.WriteLine("Press any key to exit.");
                Console.ReadLine();

                return((int)ERRORVALUE.NoSourceFile);
            }

            if (!File.Exists(args.dataMappingPath))
            {
                Console.WriteLine(args.dataMappingPath + " not found. Aborting.");
                Console.WriteLine("Press any key to exit.");
                Console.ReadLine();

                return((int)ERRORVALUE.NoDataMapping);
            }

            if (!Directory.Exists(args.outputFolder))
            {
                // try creating the directory
                bool created = true;

                try
                {
                    // check to see if trailing charcter closes
                    Directory.CreateDirectory(args.outputFolder);
                }
                catch
                {
                    created = false;
                }

                if (!created)
                {
                    // couldn't create directory.
                    Console.WriteLine("Output folder did not exist and couldn't be created.");
                    Console.WriteLine("Press any key to exit.");
                    Console.ReadLine();

                    return((int)ERRORVALUE.InvalidProject);
                }
            }

            System.IO.FileInfo fileInfo = new System.IO.FileInfo(args.filePath);

            return((fileInfo.Extension.ToLower().Contains("dll")) ? SplitDLL.SplitDLL.SplitDLLFile(args.filePath, args.dataMappingPath, args.outputFolder) :
                   Split.Split.SplitFile(args.filePath, args.dataMappingPath, args.outputFolder));
        }
コード例 #7
0
        private static void RestartAsAdmin(IEnumerable <ManifestFileGridItem> value)
        {
            //выбор загруженных файлов среди переданных (только те, у которых есть пути)
            var filesArray = value == null ? new string[0] : value.Where(i => i != null && !string.IsNullOrEmpty(i.FullPatName)).Select(i => i.FullPatName).ToArray();

            StartupArgs args = new StartupArgs()
            {
                LoadFiles = filesArray
            };

            App.RunAs(args);
        }
コード例 #8
0
ファイル: App.xaml.cs プロジェクト: asdlei99/ZtiPlayer
        private void StartApplication(StartupArgs argsObj)
        {
            MainWindow main;

            if (argsObj.ArgsCount == 0)
            {
                main = new ZtiPlayer.MainWindow();
            }
            else
            {
                main = new ZtiPlayer.MainWindow(argsObj);
            }
            main.Show();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: SlimeNull/AudioTest
        static void InitializeApplication(string[] sysargs)
        {
            NArgsAnalyzer argsAnalyzers = new NArgsAnalyzer()
            {
                new CommandAnalyzer()
                {
                    new FieldAnalyzer()
                }
            };

            argsAnalyzers.IgnoreCases = true;
            argsAnalyzers.Analysis(sysargs);
            args = argsAnalyzers.ToObject <StartupArgs>();
        }
コード例 #10
0
        /// <summary>
        /// Initialize
        /// </summary>
        public override void Init()
        {
            Logger.Info("\r\n\r\n==================================");
            Logger.Info("Example_AppTemplate Init() called.");
            Logger.Info("Initializing application from command line args.");

            StartupArgs args = Settings.ArgsReciever as StartupArgs;

            // 1. Configure logging : Append a new file logger to default logger.
            Logger.Default.Append(new LogFile("Example_AppTemplate_LogFile", args.LogFile));

            // 2. Configure configuration data.
            Config.Init(new IniDocument(args.Config, GetSampleContents("dev"), false));
        }
コード例 #11
0
        public SettingsLoaderService(StartupArgs args)
        {
            // Select the file to use
            _file = string.IsNullOrEmpty(args.SettingsFile)
                ? GetDefaultFile()
                : new FileInfo(args.SettingsFile);

            // Init loader
            _settingsLoader = UserSettingsFactory
                              .Create <T>()
                              .SetDefaultValue(new T())
                              .SetFile(_file)
                              .Build();
        }
コード例 #12
0
        /// <summary>
        /// Run the application.
        /// </summary>
        public override BoolMessageItem  Execute()
        {
            //<doc:example>
            Args.InitServices((textargs) => ComLib.LexArgs.ParseList(textargs), (arg) => ComLib.Subs.Substitutor.Substitute(arg));

            // Sample raw command line args.
            string[] rawArgs = new string[] { "-config:prod.xml", "-date:${t-1}", "-readonly:true", "myApplicationId" };

            // Option 1. Statically parse using -, : as prefix/separator.
            Args args = Args.Parse(rawArgs, "-", ":").Item;

            Console.WriteLine("Config : {0},  BusinessDate : {1}, [0] : {2}", args.Named["config"], args.Named["date"], args.Positional[0]);

            // Option 2. Statically parse args and apply them on an object.
            StartupArgs reciever = new StartupArgs();
            bool        accepted = Args.Accept(rawArgs, "-", ":", reciever);

            Console.WriteLine(string.Format("Accepted config : {0}, date : {1}, readonly : {2}, settingsId: {3}",
                                            reciever.Config, reciever.BusinessDate, reciever.ReadonlyMode, reciever.DefaultSettingsId));

            // Option 3: Instance based parsing with Fluent-like Schema population.
            Args args2 = new Args("-", ":").Schema.AddNamed <string>("config").Required.DefaultsTo("dev.xml").Describe("Configuration file")
                         .AddNamed <bool>("readonly").Required.DefaultsTo(false).Describe("Run app in readonly mode")
                         .AddNamed <DateTime>("date").Required.DefaultsTo(DateTime.Today).Interpret.Describe("Business date").Examples("${t-1}", "${today} | ${t-1}")
                         .AddPositional <int>(0).Optional.Describe("Application Id").Args;

            args2.DoParse(rawArgs);

            // Check for -help, -version -info
            rawArgs = new string[] { "-help" };
            Args args3 = new Args(rawArgs, "-", ":");

            if (args3.IsHelp)
            {
                // Usage Option 1. Show usage of the arguments.
                Console.WriteLine(args2.GetUsage("My Sample Application"));

                // Usage Option 2. Display usage using reciever.
                // ( NOTE: -help is automatically interpreted to display args usage).
                ArgsUsage.ShowUsingReciever(Settings.ArgsReciever, Settings.ArgsPrefix, Settings.ArgsSeparator);
            }
            //</doc:example>
            return(BoolMessageItem.True);
        }
コード例 #13
0
ファイル: Startup.cs プロジェクト: zuifengke/MedQCSys
        private static bool SendStartArgs(IntPtr hMainWnd, string[] args)
        {
            StartupArgs argsHelper = new StartupArgs();

            try
            {
                if (argsHelper.ParseArrArgs(args) != SystemData.ReturnValue.OK)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("Startup.SendStartArgs", ex);
            }
            IntPtr lParam = argsHelper.ArgsDataHandle;

            return(NativeMethods.User32.SendMessage(hMainWnd, NativeConstants.WM_COPYDATA, IntPtr.Zero, lParam) == 1);
        }
コード例 #14
0
        /// <summary>
        /// Validate arguments passed, if they are valid, accept them.
        /// </summary>
        /// <remarks>This is the first method called in the workflow,
        /// because the arguments supplied can determine how to initialize
        /// the application.</remarks>
        /// <param name="args">Command line arguments supplied.</param>
        /// <returns>True if args are valid, false otherwise.</returns>
        public override bool Accept(string[] args)
        {
            Logger.Info("\r\n\r\n==================================");
            Logger.Info("Example_AppTemplate Accept(args) called.");
            Logger.Info("Validating & Accepting arguments passed");
            bool accepted = base.Accept(args);

            if (accepted)
            {
                StartupArgs startupArgs = Settings.ArgsReciever as StartupArgs;
                Logger.Info("Using Arguments ===========================");
                Logger.Info("Environment         : " + startupArgs.Envrionment);
                Logger.Info("BusinessDate        : " + startupArgs.BusinessDate);
                Logger.Info("Config              : " + startupArgs.Config);
                Logger.Info("Log                 : " + startupArgs.LogFile);
                Logger.Info("ReadonlyMode        : " + startupArgs.ReadonlyMode);
                Logger.Info("CategoriesToDisplay : " + startupArgs.CategoriesToDisplay);
                Logger.Info("DefaultSettingsId   : " + startupArgs.DefaultSettingsId);
            }
            return(accepted);
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: joyjones/fire-terminator
        static void Main(string[] args)
        {
            try
            {
                DevExpress.UserSkins.BonusSkins.Register();
                DevExpress.Skins.SkinManager.EnableFormSkins();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                ProjectDoc.Instance.Option = Option;

                CurConfigFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                StartUpTransService();

                StartupArgs.Clear();
                if (args != null)
                {
                    foreach (var arg in args)
                    {
                        var mat = Regex.Match(arg, @"(?'K'.+)=(?'V'.*)");
                        if (mat.Success)
                        {
                            StartupArgs[mat.Groups["K"].Value] = mat.Groups["V"].Value;
                        }
                    }
                }
                using (Graphic = new GraphicPainter())
                {
                    Graphic.IsFixedTimeStep   = false;
                    Graphic.TargetElapsedTime = new System.TimeSpan(0, 0, 0, 0, 30);
                    Graphic.Run();
                }

                TransServerHost.StopService();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
コード例 #16
0
        /// <summary>
        /// Run the application.
        /// </summary>
        public override BoolMessageItem  Execute()
        {
            // Sample command line args.
            string[] argList = new string[] { "-config:prod.xml", "-date:${t-1}", "-readonly:true", "myApplicationId" };

            // Option 1. Parse using -, : as prefix/separator.
            Args args = Args.Parse(argList, "-", ":").Item;

            Console.WriteLine("Config : {0},  BusinessDate : {1}, [0] : {2}", args.Named["config"], args.Named["date"], args.Positional[0]);

            // Option 2. Parse args and apply them on an object.
            StartupArgs reciever = new StartupArgs();
            bool        accepted = Args.Accept(argList, "-", ":", reciever);

            Console.WriteLine(string.Format("Accepted config : {0}, date : {1}, readonly : {2}, settingsId: {3}",
                                            reciever.Config, reciever.BusinessDate, reciever.ReadonlyMode, reciever.DefaultSettingsId));

            // Display -help text.
            // ( NOTE: -help is automatically interpreted to display args usage).
            ArgsUsage.ShowUsingReciever(Settings.ArgsReciever);
            return(BoolMessageItem.True);
        }
コード例 #17
0
 private void ParseArgs(StartupArgs args)
 {
     if (args.ArgsCount > 0)
     {
         //TODO
         try
         {
             if (args.Width > 500 && args.Width < SystemParameters.PrimaryScreenWidth)
             {
                 this.Width = args.Width;
             }
             if (args.Height > 300 && args.Height < SystemParameters.PrimaryScreenHeight)
             {
                 this.Height = args.Height;
             }
             if (args.Volume >= 0 && args.Volume <= 100)
             {
                 this.player.SetVolume(args.Volume);
             }
             if (!string.IsNullOrEmpty(args.Path))
             {
                 var tempPath = args.Path.ToLower();
                 if (tempPath.StartsWith("http") || tempPath.StartsWith("https") || tempPath.StartsWith("ftp"))
                 {
                     OpenNetworkFile(tempPath);
                 }
                 else
                 {
                     OpenLocalFile(tempPath);
                 }
             }
         }
         catch (Exception ex)
         {
             //TODO
         }
     }
 }
コード例 #18
0
 public MainWindow(StartupArgs args)
 {
     InitializeComponent();
     Init();
     ParseArgs(args);
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: SlimeNull/AudioTest
        static void Main(string[] sysargs)
        {
            WaveFormat  format = WaveFormat.CreateIeeeFloatWaveFormat(1000000, 2);
            StartupArgs args   = Initialize(sysargs);

            if (args.Host)
            {
                if (!int.TryParse(args.Port, out int port) || port < 0)
                {
                    ErrorExit(-1, "Invalid port specified.");
                }

                using WasapiLoopbackCapture capture = new WasapiLoopbackCapture();
                EventedListener      listener = new EventedListener(IPAddress.Any, port);
                List <EventedClient> clients  = new List <EventedClient>();
                try
                {
                    listener.Start();
                }
                catch (Exception e)
                {
                    ErrorExit(-1, $"{e.GetType().Name}: {e.Message}");
                }
                listener.StartAcceptClient();
                listener.ClientConnected += (s, args) =>
                {
                    lock (clients)
                    {
                        EventedClient client = args.Client;
                        clients.Add(client);
                        Console.WriteLine($"Client connected: {client.BaseSocket.RemoteEndPoint}");
                    }
                };
                capture.DataAvailable += (sender, args) =>
                {
                    lock (clients)
                    {
                        List <EventedClient> clientsToRemove = new List <EventedClient>();
                        foreach (var client in clients)
                        {
                            try
                            {
                                client.SendData(args.Buffer, 0, args.BytesRecorded);
                            }
                            catch
                            {
                                clientsToRemove.Add(client);
                                Console.WriteLine($"Client disconnected: {client.BaseSocket.RemoteEndPoint}");
                            }
                        }
                        foreach (var client in clientsToRemove)
                        {
                            clients.Remove(client);
                        }
                    }
                };
                capture.StartRecording();

                Console.WriteLine("Syncing audio as host...");
                while (capture.CaptureState != NAudio.CoreAudioApi.CaptureState.Stopped)
                {
                    ;
                }
            }
            else if (args.Sync)
            {
                if (!TryGetAddress(args.Address, out IPAddress address))
                {
                    ErrorExit(-1, "Invalid address specified.");
                }
                if (!int.TryParse(args.Port, out int port) || port < 0)
                {
                    ErrorExit(-1, "Invalid port specified.");
                }
                EventedClient client = new EventedClient();
                try
                {
                    client.Connect(address, port);
                }
                catch
                {
                    ErrorExit(-2, "Cannot connect to host");
                }
                NetSampleProvider src = new NetSampleProvider(client);
                client.StartReceiveData();
                WaveOut wout = new WaveOut();
                wout.Init(src);
                wout.Play();

                Console.WriteLine("Syncing audio as client...");
                while (wout.PlaybackState != PlaybackState.Stopped)
                {
                    ;
                }
            }
            else if (args.Help)
            {
                Console.WriteLine(
                    $@"Null.AudioSync : Sync audio with another computer
  Null.AudioSync Command Arguments
    Commands:
      Host : Build a AudioSync server.
      Sync : Connect a AudioSync server.
    Arguments:
      Address : Should be specified when SyncAudio from a server.
      Port    : Port will be listened or connected. default is 10001.
");
            }
            else
            {
                Console.WriteLine("Unknown command, use 'Null.AudioSync Help' for help");
            }
        }
コード例 #20
0
        static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ProjectManager projectSelect;

            //Properties.Settings.Default.Upgrade();
            settings = ProjectManagerSettings.Load();

            StartupArgs startupArgs = new StartupArgs();

            startupArgs.mode = CLIMode.None;

            FluentCommandLineParser parser = new FluentCommandLineParser();

            // parse main options
            parser.Setup <CLIMode>('m', "mode").Callback((CLIMode mode) =>
            {
                startupArgs.mode = mode;
            });

            // parse split options
            parser.Setup <string>('f', "FileToSplit").Callback((string fileToSplit) => { startupArgs.filePath = fileToSplit; });
            parser.Setup <string>('o', "OutputFolder").Callback((string folder) => { startupArgs.outputFolder = folder; });
            parser.Setup <string>('d', "DataMappingFilePath").Callback((string mappingPath) => { startupArgs.dataMappingPath = mappingPath; });
            parser.Setup <bool>('b', "BigEndian").Callback((bool bigEndian) => { startupArgs.isBigEndian = bigEndian; });
            parser.Setup <List <string> >('a', "AnimationList").Callback((List <string> animationList) => { startupArgs.animationList = animationList.ToArray(); });
            //parser.Setup<bool>

            // parse build options
            parser.Setup <string>('p', "ProjectName").Callback((string projectName) => { startupArgs.projectName = projectName; });
            parser.Setup <SA_Tools.Game>('g', "Game").Callback((SA_Tools.Game game) => { startupArgs.game = game; });
            parser.Setup <bool>('r', "RunAfterBuild").Callback((bool runAfterbuild) => { startupArgs.runAfterBuild = runAfterbuild; });

            // do help
            parser.SetupHelp("?", "help").Callback((string text) =>
            {
                Console.WriteLine("Project Manager cmd line options:");
                Console.WriteLine(text);
                Console.WriteLine("NOTE: Not all of these options are valid in all contexts.");
                Console.WriteLine("You must set Mode. To either Split, SplitMDL, or Build.");
                Console.WriteLine("Split requires:");
                Console.WriteLine("   FileToSplit: This is the file with the data you'd like to extract.");
                Console.WriteLine("   DataMappingFilePath: This is the INI file that says where things are in the data file.");
                Console.WriteLine("   OutputFolder: This is where the split data will be placed.");
                Console.WriteLine();
                Console.WriteLine("SplitMDL requires everything Split does but also:");
                Console.WriteLine("   BigEndian: true/false. States whether or not the file is big endian.");
                Console.WriteLine("   AnimationList: (optional) a list of SAAnimation files to use. Paths are relative to the mdl file.");
                Console.WriteLine("Build requires:");
                Console.WriteLine("   ProjectName: name of the project to build.");
                Console.WriteLine("   Game: Game the project is for. Valid values are SADXPC and SA2B");
                Console.WriteLine("   RunAfterBuild: true/false. Whether or not to start the game and load the mod after build is complete");
            });

            parser.Parse(args);

            if (startupArgs.mode != CLIMode.None)            // user wants to use the CLI
            {
                switch (startupArgs.mode)
                {
                case CLIMode.Split:
                    CLISplit(startupArgs);
                    break;

                case CLIMode.SplitMDL:
                    CLISplitMDL(startupArgs);
                    break;

                case CLIMode.Build:
                    CLIBuild(startupArgs);
                    break;

                default:
                    break;
                }
            }
            else
            {
                // first check to see if we're configured properly.
                if (!AnyGamesConfigured())
                {
                    GameConfig   gameConfig   = new GameConfig();
                    DialogResult configResult = gameConfig.ShowDialog();

                    if (configResult == DialogResult.Abort)
                    {
                        return((int)ERRORVALUE.InvalidConfig);
                    }
                    gameConfig.Dispose();
                }

                // todo: catch unhandled exceptions
                projectSelect = new ProjectManager();
                Application.ThreadException += Application_ThreadException;
                Application.Run(projectSelect);
            }

            return(0);
        }
コード例 #21
0
 private static void CLIBuild(StartupArgs args)
 {
     Console.WriteLine("CLI Build is not yet implemented");
     Console.WriteLine("Press any key to exit.");
     Console.ReadLine();
 }
コード例 #22
0
 private static void CLISplitMDL(StartupArgs args)
 {
     SplitMDL.SplitMDL.Split(args.isBigEndian, args.filePath, args.outputFolder, args.animationList);
 }
コード例 #23
0
        private static int CLISplit(StartupArgs startupArgs)
        {
            bool envSwitchError = false;

            try
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(startupArgs.dataMappingPath);
            }
            catch (System.ArgumentException e)
            {
                envSwitchError = true;
                Console.WriteLine(string.Format("{0} was an invalid data mapping path", startupArgs.dataMappingPath));
            }
            catch (System.IO.DirectoryNotFoundException nullEx)
            {
                envSwitchError = true;
                Console.WriteLine(string.Format("Path to data mappilg file {0} did not exist", startupArgs.dataMappingPath));
            }

            if (envSwitchError)
            {
                Console.WriteLine("Press any key to exit.");
                Console.ReadLine();

                return((int)ERRORVALUE.InvalidDataMapping);
            }

            if (!File.Exists(startupArgs.filePath))
            {
                Console.WriteLine(startupArgs.filePath + " not found. Aborting.");
                Console.WriteLine("Press any key to exit.");
                Console.ReadLine();

                return((int)ERRORVALUE.NoSourceFile);
            }

            if (!File.Exists(startupArgs.dataMappingPath))
            {
                Console.WriteLine(startupArgs.dataMappingPath + " not found. Aborting.");
                Console.WriteLine("Press any key to exit.");
                Console.ReadLine();

                return((int)ERRORVALUE.NoDataMapping);
            }

            // check our output folder's last character for validity. Modify it if need be so that sub folders do not get created.
            char outputPathfinalChar = startupArgs.outputFolder[startupArgs.outputFolder.Length - 1];

            if (outputPathfinalChar != System.IO.Path.DirectorySeparatorChar && outputPathfinalChar != System.IO.Path.AltDirectorySeparatorChar)
            {
                startupArgs.outputFolder += System.IO.Path.DirectorySeparatorChar;
            }

            if (!Directory.Exists(startupArgs.outputFolder))
            {
                // try creating the directory
                bool created = true;

                try
                {
                    // check to see if trailing charcter closes
                    Directory.CreateDirectory(startupArgs.outputFolder);
                }
                catch
                {
                    created = false;
                }

                if (!created)
                {
                    // couldn't create directory.
                    Console.WriteLine("Output folder did not exist and couldn't be created.");
                    Console.WriteLine("Press any key to exit.");
                    Console.ReadLine();

                    return((int)ERRORVALUE.InvalidProject);
                }
            }

            System.IO.FileInfo fileInfo = new System.IO.FileInfo(startupArgs.filePath);

            return((fileInfo.Extension.ToLower().Contains("dll")) ? SplitDLL.SplitDLL.SplitDLLFile(startupArgs.filePath, startupArgs.dataMappingPath, startupArgs.outputFolder) :
                   Split.Split.SplitFile(startupArgs.filePath, startupArgs.dataMappingPath, startupArgs.outputFolder));
        }
コード例 #24
0
ファイル: App.xaml.cs プロジェクト: asdlei99/ZtiPlayer
        private void ParseArgs(string[] args)
        {
            StartupArgs startArgs = new StartupArgs()
            {
                Height   = 768,
                Width    = 1024,
                IsSilent = false,
                Path     = "",
                PlayList = new string[] { },
                Volume   = 50
            };

            if (args.Length == 0)
            {
                startArgs.ArgsCount = 0;
            }
            else
            {
                try
                {
                    startArgs.ArgsCount = args.Length / 2;
                    if (args.Contains("-help") || args.Contains("/help") || args.Contains("/?"))
                    {
                        ShowHelpMessageBox();
                    }


                    Dictionary <string, string> argsDic = new Dictionary <string, string>();
                    for (int i = 0; i < args.Length; i += 2)
                    {
                        if (argsDic.ContainsKey(args[i]))
                        {
                            continue;
                        }
                        var key = args[i].ToUpper().Trim().Replace("--", "").Replace("-", "").Replace("/", "");
                        argsDic.Add(key, args[i + 1]);
                    }

                    if (argsDic.Keys.Contains("HEIGHT"))
                    {
                        startArgs.Height = Convert.ToInt32(argsDic["HEIGHT"]);  //TODO
                    }
                    if (argsDic.Keys.Contains("WIDTH"))
                    {
                        startArgs.Width = Convert.ToInt32(argsDic["WIDTH"]);
                    }
                    //startArgs.IsSilent = Convert.ToBoolean(argsDic[startArgs.IsSilent.GetType().Name]);
                    if (argsDic.Keys.Contains("PATH"))
                    {
                        startArgs.Path = argsDic["PATH"];
                    }
                    //startArgs.PlayList = new string[] { };//TODO
                    //startArgs.Volume = Convert.ToInt32(argsDic[startArgs.Volume.GetType().Name]);
                }
                catch (Exception ex)
                {
                    //TODO
                }
            }

            StartApplication(startArgs);
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: StardustMotion/sa_tools
        static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ProjectManager projectSelect;

            //Properties.Settings.Default.Upgrade();
            settings = ProjectManagerSettings.Load();

            StartupArgs startupArgs = new StartupArgs();

            startupArgs.mode = CLIMode.None;

            FluentCommandLineParser parser = new FluentCommandLineParser();

            // parse main options
            parser.Setup <CLIMode>('m', "mode").Callback(mode => startupArgs.mode = mode);

            // parse split options
            parser.Setup <string>('f', "FileToSplit").Callback(fileToSplit => startupArgs.filePath = fileToSplit);
            parser.Setup <string>('d', "DataMappingFilePath").Callback(mappingPath => startupArgs.dataMappingPath = mappingPath);
            parser.Setup <bool>('b', "BigEndian").Callback(bigEndian => startupArgs.isBigEndian    = bigEndian);
            parser.Setup <string>('o', "OutputFolder").Callback(folder => startupArgs.outputFolder = folder);
            parser.Setup <List <string> >('a', "AnimationList").Callback(animationList => startupArgs.animationList = animationList.ToArray());
            //parser.Setup<bool>

            // parse build options
            parser.Setup <string>('p', "ProjectName").Callback(projectName => startupArgs.projectName = projectName);
            parser.Setup <SA_Tools.Game>('g', "Game").Callback(game => startupArgs.game = game);
            parser.Setup <bool>('r', "RunAfterBuild").Callback(runAfterbuild => startupArgs.runAfterBuild = runAfterbuild);

            // do help
            parser.SetupHelp("?", "help").Callback(text => Console.WriteLine(text));

            parser.Parse(args);

            if (startupArgs.mode != CLIMode.None)            // user wants to use the CLI
            {
                switch (startupArgs.mode)
                {
                case CLIMode.Split:
                    CLISplit(startupArgs);
                    break;

                case CLIMode.SplitMDL:
                    CLISplitMDL(startupArgs);
                    break;

                case CLIMode.Build:
                    CLIBuild(startupArgs);
                    break;

                default:
                    break;
                }
            }
            else
            {
                // first check to see if we're configured properly.
                if (!AnyGamesConfigured())
                {
                    GameConfig   gameConfig   = new GameConfig();
                    DialogResult configResult = gameConfig.ShowDialog();

                    if (configResult == DialogResult.Abort)
                    {
                        return((int)ERRORVALUE.InvalidConfig);
                    }
                    gameConfig.Dispose();
                }

                // todo: catch unhandled exceptions
                projectSelect = new ProjectManager();
                Application.ThreadException += Application_ThreadException;
                Application.Run(projectSelect);
            }

            return(0);
        }
コード例 #26
0
ファイル: Program.cs プロジェクト: StardustMotion/sa_tools
 private static void CLIBuild(StartupArgs args)
 {
 }
コード例 #27
0
 public EndActor()
 {
     _startup = DependencyInjector.GetInstance <StartupArgs>();
     Receive <bool>(HandleTermination);
 }