Ejemplo n.º 1
0
 public static Result ExportPDF(ExternalCommandData cData)
 {
     try
     {
         PDFExporterForm ef = new PDFExporterForm(cData);
         ef.ShowDialog();
         mySettings.Default.Save();
         return(Result.Succeeded);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Ejemplo n.º 2
0
        protected bool InitConsts(TaskList tasks, string destFilePath, bool silent, Preferences prefs, string sKey)
        {
            // Create base font
            var  installedFontFile = prefs.GetProfileString(sKey, "InstalledFontFile", "");
            var  otherFontFile     = prefs.GetProfileString(sKey, "OtherFontFile", "");
            bool useOtherFont      = prefs.GetProfileBool(sKey, "UseOtherFont", false);

            int fontSize = prefs.GetProfileInt("Preferences", "HtmlFontSize", 2);

            m_BaseFontSize = HtmlFontConversion.PointsFromHtml((HtmlFontSize)fontSize);

            var htmlFont = prefs.GetProfileString("Preferences", "HtmlFont", "Verdana");
            var defaultInstalledFontFile = PDFExporterForm.GetFileNameFromFont(htmlFont);

            if (string.IsNullOrEmpty(installedFontFile))
            {
                installedFontFile = defaultInstalledFontFile;
            }

            var fontDlg = new PDFExporterForm(installedFontFile, otherFontFile, useOtherFont);

            if (!silent && (fontDlg.ShowDialog() == DialogResult.Cancel))
            {
                return(false);
            }

            // Clear the installed font setting if it's the same
            // as the default so changes to the default will be picked up
            if (string.Compare(fontDlg.InstalledFontPath, defaultInstalledFontFile, true) == 0)
            {
                prefs.DeleteProfileEntry(sKey, "InstalledFontFile");
            }
            else
            {
                prefs.WriteProfileString(sKey, "InstalledFontFile", fontDlg.InstalledFontPath);
            }

            prefs.WriteProfileString(sKey, "OtherFontFile", fontDlg.OtherFontPath);
            prefs.WriteProfileBool(sKey, "UseOtherFont", fontDlg.UseOtherFont);

            m_BaseFont = BaseFont.CreateFont(fontDlg.SelectedFontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            // Build attribute list
            m_AvailAttributes = new List <TaskAttribute>();

            var attribs = tasks.GetAvailableAttributes();

            foreach (var attrib in attribs)
            {
                switch (attrib)
                {
                case Task.Attribute.Comments:
                    m_WantComments = true;
                    break;

                case Task.Attribute.HtmlComments:
                    m_WantComments = true;
                    break;

                case Task.Attribute.Position:
                    m_WantPosition = true;
                    break;

//              case Task.Attribute.CustomAttribute:
//                  // TODO
//                  break;

                case Task.Attribute.MetaData:
                    // Not a user attribute
                    break;

                case Task.Attribute.ProjectName:
                    // Not a task attribute
                    break;

                case Task.Attribute.Color:
                    // handled separately
                    break;

                case Task.Attribute.Title:
                    // handled separately
                    break;

                default:
                    m_AvailAttributes.Add(new TaskAttribute(attrib, m_Trans.Translate(TaskList.GetAttributeName(attrib))));
                    break;
                }
            }

            m_AvailAttributes.Sort((a, b) => String.Compare(a.Name, b.Name));

            return(true);
        }