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; }
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); }
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); }
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); }
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); } }
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); }
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"; } } }
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); } }
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); } }
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); } } }
public void Launch(Form parentForm, ProjectInfo projectInfo) { HtmlReport r = new HtmlReport(); _pathToOutput = r.GenerateReport(projectInfo.PathToLIFT); if (_launchAfterTransform) { Process.Start(_pathToOutput); } }
public void Launch(Form parentForm, ProjectInfo projectInfo) {}
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; }
public void Launch(Form parentForm, ProjectInfo projectInfo) { SynchronizeDialog d = new SynchronizeDialog(projectInfo, _settings); d.ShowDialog(parentForm); }
public bool DoShowSettingsDialog(Form parentForm, ProjectInfo projectInfo) { return false; }
public string GetRuntimeArguments(ProjectInfo info) { return _arguments.Replace("$projectPath", info.PathToTopLevelDirectory); }
public string GetRuntimeProcessPath(ProjectInfo info) { return _pathToExecutable.Replace("$wesayApplicationDirectory", info.PathToApplicationRootDirectory); }
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); }
public abstract void Launch(Form parentForm, ProjectInfo projectInfo);
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); } } }
protected string TransformLiftToText(ProjectInfo projectInfo, string xsltName, string outputFileSuffix) { return TransformLift(projectInfo, xsltName, outputFileSuffix, new XsltArgumentList(), false); }
/// <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; }
public bool DoShowSettingsDialog(Form parentForm, ProjectInfo projectInfo) { SFMChangesDialog dlg = new SFMChangesDialog(_settings, projectInfo); return dlg.ShowDialog(parentForm) == DialogResult.OK; }
public void Launch(Form parentForm, ProjectInfo projectInfo) { BackupDialog d = new BackupDialog(projectInfo); d.ShowDialog(parentForm); }