예제 #1
0
		public ActionItemControl(IWeSayAddin addin, bool inAdminMode, ProjectInfo projectInfo)
		{
			_addin = addin;
			_inAdminMode = inAdminMode;
			_projectInfo = projectInfo;
			InitializeComponent();
			_description.Font = StringCatalog.ModifyFontForLocalization(_description.Font);

			_toggleShowInWeSay.Visible = inAdminMode;
			_setupButton.Visible = inAdminMode;

			if (addin.ButtonImage != null)
			{
				//review: will these be disposed when the button is disposed?
				_launchButton.Image = addin.ButtonImage.GetThumbnailImage(_launchButton.Width - 10,
																		  _launchButton.Height - 10,
																		  ReturnFalse,
																		  IntPtr.Zero);
			}
			LoadSettings();

			UpdateVisualThings();

			//nb: we do want to show the setup, even if the addin says unavailable.
			//Maybe that's *why it's unavailable*.. it may need to be set up first.

			_setupButton.Visible = inAdminMode && _addin is IWeSayAddinHasSettings &&
								   ((IWeSayAddinHasSettings) _addin).Settings != null;
		}
예제 #2
0
		public void Launch(Form parentForm, ProjectInfo projectInfo)
		{
			string dest = Path.Combine(Path.GetTempPath(), projectInfo.Name + "_wesay.zip");
			BackupMaker.BackupToExternal(projectInfo.PathToTopLevelDirectory,
										 dest,
										 projectInfo.FilesBelongingToProject);

			MAPI msg = new MAPI();
			msg.AddAttachment(dest);
			msg.AddRecipientTo(_settings.Email);
			subject =
					String.Format(
							StringCatalog.Get("{0} WeSay Project Data",
											  "The subject line of the email send by the 'Send Email' Action. The {0} will be replaced by the name of the project, as in 'Greek WeSay Project Data'"),
							projectInfo.Name);
			string body = StringCatalog.Get("The latest WeSay project data is attached.");

			//I tried hard to get this to run in a thread so it wouldn't block wesay,
			//but when called in a thread we always just get the generic '2' back.

			//            EmailMessage emailWorker =
			//                new EmailMessage(
			//                    subject,
			//                    body,
			//                    msg);

			///emailWorker.SendMail();
			///

			msg.SendMailPopup(subject, body);
		}
예제 #3
0
		public BackupDialog(ProjectInfo projectInfo)
		{
			_projectInfo = projectInfo;
			InitializeComponent();
			_topLabel.Text = "~Looking for USB Keys...";
			pictureBox1.Image = Resources.backupToDeviceImage;
			_cancelButton.Text = StringCatalog.Get(_cancelButton.Text);
			_cancelButton.Font = StringCatalog.ModifyFontForLocalization(_cancelButton.Font);
		}
예제 #4
0
		public SynchronizeDialog(ProjectInfo projectInfo, SynchronizeSettings settings)
		{
			_projectInfo = projectInfo;
			_settings = settings;
			InitializeComponent();
			_topLabel.Text = "~Synchronizing...";
			pictureBox1.Image = Resources.backupToDeviceImage;
			_cancelButton.Text = StringCatalog.Get(_cancelButton.Text);
			_cancelButton.Font = StringCatalog.ModifyFontForLocalization(_cancelButton.Font);
		}
예제 #5
0
		public override void Launch(Form parentForm, ProjectInfo projectInfo)
		{
			string output = CreateFileToOpen(projectInfo, true, true);
			if (string.IsNullOrEmpty(output))
			{
				return; // get this when the user cancels
			}
			if (_launchAfterTransform)
			{
				Process.Start(output);
			}
		}
예제 #6
0
		public SFMChangesDialog(SfmTransformSettings settings, ProjectInfo projectInfo)
		{
			_settings = settings;
			_projectInfo = projectInfo;
			InitializeComponent();
			//the xml serialization process seems to convert the \r\n we need (on windows) to \n
			_pairsText.Text = settings.SfmTagConversions.Replace("\n", Environment.NewLine);

			_settings.FillEmptySettingsWithGuesses(projectInfo);
			FillLanguageCombos(_vernacularLanguage, settings.VernacularLanguageWritingSystemId);
			FillLanguageCombos(_englishLanguage, settings.EnglishLanguageWritingSystemId);
			FillLanguageCombos(_nationalLanguage, settings.NationalLanguageWritingSystemId);
			FillLanguageCombos(_regionalLanguage, settings.RegionalLanguageWritingSystemId);
		}
예제 #7
0
		public void FillEmptySettingsWithGuesses(ProjectInfo projectInfo)
		{
			if (String.IsNullOrEmpty(VernacularLanguageWritingSystemId))
			{
				if (projectInfo.WritingSystems.ContainsKey("v"))
				{
					VernacularLanguageWritingSystemId = "v";
				}
				else //guess
				{
					foreach (string id in projectInfo.WritingSystems.Keys)
					{
						if (!"en fr chn th tpi".Contains(id))
						{
							VernacularLanguageWritingSystemId = id;
							break;
						}
					}
				}
			}

			if (String.IsNullOrEmpty(NationalLanguageWritingSystemId))
			{
				if (projectInfo.WritingSystems.ContainsKey("tpi")) //melanesian pidgin
				{
					NationalLanguageWritingSystemId = "tpi";
				}
				if (projectInfo.WritingSystems.ContainsKey("TPI")) //melanesian pidgin
				{
					NationalLanguageWritingSystemId = "TPI";
				}
				if (projectInfo.WritingSystems.ContainsKey("th")) //thai
				{
					NationalLanguageWritingSystemId = "th";
				}
				if (projectInfo.WritingSystems.ContainsKey("fr")) //french
				{
					NationalLanguageWritingSystemId = "fr";
				}
			}
		}
예제 #8
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);
			}
		}
예제 #9
0
파일: PdfMaker.cs 프로젝트: bbriggs/wesay
		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);
			}
		}
예제 #10
0
파일: HtmlInWord.cs 프로젝트: bbriggs/wesay
		public override void Launch(Form parentForm, ProjectInfo projectInfo)
		{
			string output = CreateFileToOpen(projectInfo, false, false);
			if (string.IsNullOrEmpty(output))
			{
				return; // get this when the user cancels
			}
			if (_launchAfterTransform)
			{
				try
				{
					ProcessStartInfo si = new ProcessStartInfo();
					si.FileName = "WinWord.exe";
					//this flag f makes word create a new, untitled file
					//enhance: so, it would be nice to create this in temp (and deleting it later?)
					si.Arguments = "/f \"" + output + "\"";
					Process.Start(si);
				}
				catch (Exception e)
				{
					ErrorReport.ReportNonFatalMessage(e.Message);
				}
			}
		}
예제 #11
0
		public void Launch(Form parentForm, ProjectInfo projectInfo)
		{
			HtmlReport r = new HtmlReport();
			_pathToOutput = r.GenerateReport(projectInfo.PathToLIFT);
			if (_launchAfterTransform)
			{
				Process.Start(_pathToOutput);
			}
		}
예제 #12
0
		public void Launch(Form parentForm, ProjectInfo projectInfo) {}
예제 #13
0
		protected string TransformLift(ProjectInfo projectInfo,
									   string xsltName,
									   string outputFileSuffix,
									   XsltArgumentList arguments,
									   bool outputToXml)
		{
			_pathToOutput = Path.Combine(projectInfo.PathToExportDirectory,
										 projectInfo.Name + outputFileSuffix);
			if (File.Exists(_pathToOutput))
			{
				File.Delete(_pathToOutput);
			}

			TransformWorkerArguments targs = new TransformWorkerArguments();
			targs.postTransformMethod = _postTransformMethod;
			targs.postTransformArgument = _postTransformArgument;
			targs.postTransformSteps = _postTransformWorkSteps;
			targs.outputFilePath = _pathToOutput;
			targs.outputToXml = outputToXml;
			using (targs.outputStream = File.Create(_pathToOutput))
			{
				targs.inputDocument = new XmlDocument();
				targs.inputDocument.PreserveWhitespace = true;
				targs.inputDocument.Load(projectInfo.PathToLIFT);
				targs.xsltStream = GetXsltStream(projectInfo, xsltName);
				targs.xsltArguments = arguments;
				if (!DoTransformWithProgressDialog(targs))
				{
					return null;
				}
			}

			return _pathToOutput;
		}
예제 #14
0
		public void Launch(Form parentForm, ProjectInfo projectInfo)
		{
			SynchronizeDialog d = new SynchronizeDialog(projectInfo, _settings);
			d.ShowDialog(parentForm);
		}
예제 #15
0
		public bool DoShowSettingsDialog(Form parentForm, ProjectInfo projectInfo)
		{
			return false;
		}
예제 #16
0
		public string GetRuntimeArguments(ProjectInfo info)
		{
			return _arguments.Replace("$projectPath", info.PathToTopLevelDirectory);
		}
예제 #17
0
		public string GetRuntimeProcessPath(ProjectInfo info)
		{
			return _pathToExecutable.Replace("$wesayApplicationDirectory",
											 info.PathToApplicationRootDirectory);
		}
예제 #18
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);
		}
예제 #19
0
		public abstract void Launch(Form parentForm, ProjectInfo projectInfo);
예제 #20
0
		public override void Launch(Form parentForm, ProjectInfo projectInfo)
		{
			_settings.FillEmptySettingsWithGuesses(projectInfo);
			SetupPostTransformMethod(OnDoGrepWork, _settings, 10 /*has some cushion*/);
			LexEntryRepository repo = projectInfo.ServiceProvider.GetService(typeof (LexEntryRepository)) as LexEntryRepository;
			using (repo.GetRightToAccessLiftExternally())
			{
				string output = TransformLiftToText(projectInfo, "lift2sfm.xsl", "-sfm.txt");
				if (string.IsNullOrEmpty(output))
				{
					return; // get this when the user cancels
				}
				//GrepFile(output, _settings);

				if (_launchAfterTransform)
				{
					Process.Start(output);
				}
			}
		}
예제 #21
0
		protected string TransformLiftToText(ProjectInfo projectInfo,
											 string xsltName,
											 string outputFileSuffix)
		{
			return TransformLift(projectInfo,
								 xsltName,
								 outputFileSuffix,
								 new XsltArgumentList(),
								 false);
		}
예제 #22
0
		/// <summary>
		/// all this is just so that wesay doesn't hang waiting for this to happen.
		/// </summary>
		//        class EmailMessage: System.ComponentModel.BackgroundWorker
		//        {
		//            private string subject;
		//            private string contents;
		//            private MAPI msg;
		//
		//            public EmailMessage(string subject, string contents, MAPI msg)
		//            {
		//                this.subject = subject;
		//                this.msg = msg;
		//                this.contents = contents;
		//            }
		//
		////            protected override void  OnDoWork(System.ComponentModel.DoWorkEventArgs e)
		////            {
		////                base.OnDoWork(e);
		////                 msg.SendMailPopup(subject,contents);
		////            }
		//            protected void  Start()
		//            {
		//                 msg.SendMailPopup(subject,contents);
		//            }
		//            public void SendMail()
		//            {
		//                System.Threading.Thread t = new Thread(Start);
		//                t.IsBackground = false;
		//                t.Start();
		//
		//            }
		//        }

		#region IWeSayAddinHasSettings Members

		public bool DoShowSettingsDialog(Form parentForm, ProjectInfo projectInfo)
		{
			SendProjectEmailSettingsDialog dlg = new SendProjectEmailSettingsDialog(_settings);
			return dlg.ShowDialog(parentForm) == DialogResult.OK;
		}
예제 #23
0
		public bool DoShowSettingsDialog(Form parentForm, ProjectInfo projectInfo)
		{
			SFMChangesDialog dlg = new SFMChangesDialog(_settings, projectInfo);
			return dlg.ShowDialog(parentForm) == DialogResult.OK;
		}
예제 #24
0
		public void Launch(Form parentForm, ProjectInfo projectInfo)
		{
			BackupDialog d = new BackupDialog(projectInfo);
			d.ShowDialog(parentForm);
		}