Exemple #1
0
		public override void Launch(Form parentForm, ProjectInfo projectInfo)
		{
			string htmlPath = CreateFileToOpen(projectInfo, true, false);
			if (string.IsNullOrEmpty(htmlPath))
			{
				return; // get this when the user cancels
			}
			try
			{
				string pdfPath = Path.Combine(projectInfo.PathToExportDirectory,
											  projectInfo.Name + ".pdf");

				string layoutCssPath =
						projectInfo.LocateFile(Path.Combine("Templates", "basicDictionary.css"));
				PrinceXmlWrapper.CreatePdf(htmlPath, new string[] {layoutCssPath}, pdfPath);
				Process.Start(pdfPath);
			}
			catch (Exception e)
			{
				ErrorReport.ReportNonFatalMessage(e.Message);
			}
		}
Exemple #2
0
		protected string CreateFileToOpen(ProjectInfo projectInfo,
										  bool includeXmlDirective,
										  bool linkToUserCss)
		{
			//the problem we're addressing here is that when this is launched from the wesay configuration
			//that won't (and doesn't want to) have locked up the db4o db by making a record list manager,
			//which it normally has no need for.
			//So if we're in that situation, we temporarily try to make one and then release it,
			//so it isn't locked when the user says "open wesay"

			LexEntryRepository lexEntryRepository = projectInfo.ServiceProvider.GetService(typeof(LexEntryRepository)) as LexEntryRepository;
		  //  using(lexEntryRepository.GetRightToAccessLiftExternally())
			{
				string pliftPath;
				using (LameProgressDialog dlg = new LameProgressDialog("Exporting to PLift..."))
				{
					dlg.Show();
					PLiftMaker maker = new PLiftMaker();
					pliftPath = maker.MakePLiftTempFile(lexEntryRepository, projectInfo.ServiceProvider.GetService(typeof(ViewTemplate)) as ViewTemplate);
				}

				projectInfo.PathToLIFT = pliftPath;

				XsltArgumentList arguments = new XsltArgumentList();
				arguments.AddParam("writing-system-info-file",
								   string.Empty,
								   projectInfo.LocateFile("WritingSystemPrefs.xml"));
				arguments.AddParam("grammatical-info-optionslist-file",
								   string.Empty,
								   projectInfo.LocateFile("PartsOfSpeech.xml"));
				arguments.AddParam("link-to-usercss", string.Empty, linkToUserCss + "()");

				return TransformLift(projectInfo,
									 "plift2html.xsl",
									 ".htm",
									 arguments,
									 //word doesn't notice that is is html if the <xml> directive is in there
									 includeXmlDirective);
			}
		}
Exemple #3
0
		public static Stream GetXsltStream(ProjectInfo projectInfo, string xsltName)
		{
			//xslt can be in one of the project/wesay locations, (so user can override with their own copy)
			//or just in a resource (helps with forgetting to put it in the installer)
			string xsltPath = projectInfo.LocateFile(xsltName);
			if (String.IsNullOrEmpty(xsltPath))
			{
				return
						Assembly.GetExecutingAssembly().GetManifestResourceStream(
								"Addin.Transform." + xsltName);
			}
			return File.OpenRead(xsltPath);
		}