static void Main(string[] args) { Directory.SetCurrentDirectory( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); //Get directory for P4 Document Directory location. //make sure does not start with \ or / or end with them //strip ./ from start if there SourceDirectory = Regex.Replace( Settings.Default.SourceDirectory, @"(^\.[/|\\])?[\\|/]*(.*?)[\\|/]*$", "$2"); OutputDirectory = Regex.Replace( Settings.Default.OutputDirectory, @"(^\.[/|\\])?[\\|/]*(.*?)[\\|/]*$", "$2"); Language.LangID = "INT"; Language.Init( Path.Combine( SourceDirectory, Settings.Default.IncludeDirectory, Settings.Default.InternationalizationDirectory)); DoCompressImages = Settings.Default.DoCompressImages; if (DoCompressImages) { //If we are not compressing an image no need to set other conversion variables JpegCompressionRate = Settings.Default.ImageJPGCompressionValue; try { DefaultImageFillColor = ImageConversion.GetColorFromHexString(Settings.Default.ImageFillColor); } catch (Exception) { DefaultImageFillColor = default(Color); } CompressImageType = Settings.Default.CompressImageType; CompressImageFormat = ImageConversion.GetImageFormat(CompressImageType); if (CompressImageFormat == null) { log.Error(Language.Message("UnsupportedCompressImgType", CompressImageType)); return; } } SupportedLanguages = Settings.Default.SupportedLanguages.ToUpper().Split(','); MetadataErrorIfMissing = Settings.Default.MetadataErrorIfMissing.Split(','); MetadataInfoIfMissing = Settings.Default.MetadataInfoIfMissing.Split(','); MetadataCleanKeepThese = Settings.Default.MetadataCleanKeepThese.ToLower().Split(','); SupportedAvailability = Settings.Default.SupportedAvailability.ToLower().Split(','); PublicAvailabilityFlag = Settings.Default.PublicAvailabilityFlag.ToLower(); //AllSupportedAvailablities needs to include the public and supported availabilities foreach (string Availability in SupportedAvailability) { AllSupportedAvailability.Add(Availability); } AllSupportedAvailability.Add(PublicAvailabilityFlag); var config = new Configuration(SupportedAvailability, PublicAvailabilityFlag, SupportedLanguages, false); if (args.Length == 0) { config = new Configuration(SupportedAvailability, PublicAvailabilityFlag, SupportedLanguages, true); // There are no arguments, so try to obtain them from GUI. var gui = new GUI.GUI(); var wpfLogger = new WPFLogger(); gui.Init(config, wpfLogger); log = wpfLogger; HideConsole(); gui.Run(); } else { log = new LogFileLogger(); try { config.ParamsManager.Parse(args); RunUDNConversion(config, log); } catch (ParsingErrorException e) { if (e.Sender != null) { log.Error(Language.Message("ErrorParsingParam", e.Sender.Name)); } log.Error(e.Message); log.Info(config.ParamsManager.GetHelp()); } catch (Exception e) { // catching all and printing out -- finishing anyway // print out exception and exit gently rather than panic PrintUnhandledException(e); } finally { log.WriteToLog(Language.Message("UnrealDocToolFinished")); } } AppDomain.CurrentDomain.ProcessExit += (sender, e) => OnProcessExit(sender, e, config); }
public void Init(Configuration config, WPFLogger logger) { this.config = config; this.logger = logger; }