Exemple #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            Current.Dispatcher.UnhandledException += App_DispatcherUnhandledException;

            CommandLineOptions options = Util.CommandLineOptions.Parse(new CommandLineOptions(), e.Args, out int exitCode);

            // react to options or defaults
            if (options.Profiles.Any())
            {
                StartupFile = options.Profiles.Last();
            }

            // start up Helios
            string documentPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                RunningVersion.IsDevelopmentPrototype ? options.DevDocumentPath : options.DocumentPath);

            HeliosInit.Initialize(documentPath, "ProfileEditor.log", options.LogLevel);

            // need to defer exit until after we initialize Helios or our main window will crash
            if (exitCode < 0)
            {
                Current.Shutdown();
                return;
            }

            // note that we started
            ConfigManager.LogManager.LogInfo("Starting Editor");
        }
Exemple #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            NLog.LogManager.Setup().SetupExtensions(s =>
                                                    s.RegisterTarget <StatusViewerLogTarget>("StatusViewer")
                                                    );

            base.OnStartup(e);
            Current.Dispatcher.UnhandledException += App_DispatcherUnhandledException;

            CommandLineOptions options = Util.CommonCommandLineOptions.Parse(new CommandLineOptions(), e.Args, out int exitCode);

            // react to options or defaults
            if (options.Profiles != null && options.Profiles.Any())
            {
                StartupProfile = options.Profiles.Last();
            }

            // start up Helios
            string documentPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                RunningVersion.IsDevelopmentPrototype ? options.DevDocumentPath : options.DocumentPath);

            HeliosInit.Initialize(documentPath, "ControlCenter.log", options.LogLevel, new HeliosApplication
            {
                ShowDesignTimeControls = false,
                ConnectToServers       = true,
                SettingsAreWritable    = false
            });

            // need to defer exit until after we initialize Helios or our main window will crash
            if (exitCode < 0)
            {
                Current.Shutdown();
            }
        }
Exemple #3
0
        public MinimalHelios()
        {
            HeliosInit.Initialize(FindHeliosDocuments(), "", LogLevel.Error, new HeliosApplication
            {
                AllowPlugins           = false,
                ConnectToServers       = false,
                SettingsAreWritable    = false,
                ShowDesignTimeControls = false,
                AllowLogging           = false
            });

            // we are not creating an Application object, so we have to at least static initialize this class
            // so that pack URIs will work
            _ = PackUriHelper.UriSchemePack;
        }
Exemple #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            CommandLineOptions options = new CommandLineOptions();

            if (CommandLine.Parser.Default.ParseArguments(e.Args, options))
            {
                if (options.Profiles != null && options.Profiles.Count > 0)
                {
                    StartupProfile = options.Profiles.Last();
                }
            }

            string documentPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), options.DocumentPath);

            HeliosInit.Initialize(documentPath, "ProfileEditor.log", options.LogLevel);

            ConfigManager.LogManager.LogInfo("Starting Editor");
        }
Exemple #5
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     HeliosInit.Initialize("d:\\temp\\SampleProgram", "sample.log", LogLevel.Error);
 }
Exemple #6
0
        private static void EditInstallation(string dcsRootPath, string jsonDirPath)
        {
            if (jsonDirPath == null)
            {
                if (!FileSystem.TryFindNearestDirectory("Tools\\ToolsCommon\\Data\\Viewports", out jsonDirPath))
                {
                    jsonDirPath = FileSystem.FindNearestDirectory("Data\\Viewports");
                }
            }

            // open DCS installation location
            if (!InstallationLocation.TryLoadLocation(dcsRootPath, true, out InstallationLocation dcs))
            {
                throw new Exception($"failed to open DCS installation at {dcsRootPath}");
            }

            // pick JSON file from the given ones based on version number
            string exactName         = $"ViewportTemplates_{PatchVersion.SortableString(dcs.Version)}.json";
            string versionedJsonPath = "";

            foreach (string candidate in Directory.EnumerateFiles(jsonDirPath, "ViewportTemplates_*.json",
                                                                  SearchOption.AllDirectories))
            {
                string candidateName = Path.GetFileName(candidate);
                if (string.Compare(candidateName, exactName, StringComparison.InvariantCulture) > 0)
                {
                    continue;
                }

                // applies
                if (string.Compare(candidateName, versionedJsonPath, StringComparison.InvariantCulture) > 0)
                {
                    // new best match
                    versionedJsonPath = candidate;
                }
            }

            string json = File.ReadAllText(Path.Combine(jsonDirPath, "ViewportTemplates.json"));
            List <ViewportTemplate> templates = JsonConvert.DeserializeObject <ViewportTemplate[]>(json).ToList();

            if (versionedJsonPath == "")
            {
                ConfigManager.LogManager.LogInfo($"no ViewportTemplates_*.json file found that is applicable to selected DCS version {dcs.Version}");
            }
            else
            {
                // read version specific changes and replace any entries by ModuleId
                string changesText = File.ReadAllText(versionedJsonPath);
                List <ViewportTemplate> changes = JsonConvert.DeserializeObject <ViewportTemplate[]>(changesText).ToList();
                templates = templates.GroupJoin(changes, t => t.TemplateName, c => c.TemplateName, (original, applicableChanges) => applicableChanges.FirstOrDefault() ?? original).ToList();
            }


            // get DCS location from the Helios utility that manages DCS install locations (have to use Profile Editor to configure it, either running dev build or start with --documents HeliosDev)
            string documentPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                               "HeliosDev");

            if (!Directory.Exists(documentPath))
            {
                documentPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Helios");
            }

            HeliosInit.Initialize(documentPath, "EditViewports.log", LogLevel.Debug);

            ConfigManager.LogManager.LogInfo($"Editing viewport in DCS distribution {dcs.Path} of Version {dcs.Version}");
            ConfigManager.LogManager.LogInfo($"Selected ViewportTemplates file {versionedJsonPath}");
            PatchDestination destination = new PatchDestination(dcs);

            EditFilesInDestination(templates, destination);

            HeliosInit.OnShutdown();
        }