Exemplo n.º 1
0
        /// <summary>
        /// Adds the Folder to the Project xml file
        /// </summary>
        /// <param name="folderNameWithPath">Folder with full path</param>
        /// <param name="destPathParent">Parent of current folder - used for recursive copy</param>
        /// <returns>Returns True/False</returns>
        private bool AddFolderToXML(string folderNameWithPath, string destPathParent)
        {
            try
            {
                if (Directory.Exists(folderNameWithPath))
                {
                    return(false);
                }
                Directory.CreateDirectory(folderNameWithPath);
            }
            catch (Exception ex)
            {
                var msg = new[] { ex.Message };
                LocDB.Message("defErrMsg", ex.Message, msg, LocDB.MessageTypes.Error, LocDB.MessageDefault.First);
                return(false);
            }

            string folderName  = Path.GetFileName(folderNameWithPath);
            bool   returnValue = XMLOperation(folderName, 'D', "", false, "", destPathParent, true);

            if (destPathParent == "")
            {
                PopulateDicExplorer(_dictExplorer);
            }
            return(returnValue);
        }
Exemplo n.º 2
0
        private void PublicationTask_Load(object sender, EventArgs e)
        {
            LocDB.Localize(this, null);
            Param.SetupHelp(this);
            try
            {
                if (Param.Value.ContainsKey(Param.InputType))
                {
                    Param.SetValue(Param.InputType, "");
                }
                Param.LoadSettings();
                ScreenAdjustment();
                BtConfigure.Visible = Param.UserRole != "Output User";

                if (Param.Value.ContainsKey(Param.InputType))
                {
                    Param.SetValue(Param.InputType, InputType);
                }
                Param.LoadSettings();
                TaskAdjustment();

                DoLoad();
            }
            catch (InvalidStyleSettingsException err)
            {
                var msg = new[] { err.FullFilePath };
                LocDB.Message("errNotValidXml", err.ToString(), msg, LocDB.MessageTypes.Warning, LocDB.MessageDefault.First);
                return;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add files to an existing Zip archive,
        /// </summary>
        /// <param name="filename">Array of path / filenames to add to the archive</param>
        /// <param name="archive">Zip archive that we want to add the file to</param>
        public void AddToZip(string[] filename, string archive)
        {
            if (!File.Exists(archive))
            {
                return;
            }

            try
            {
                ZipFile zf = new ZipFile(archive);
                zf.BeginUpdate();
                // path relative to the archive
                zf.NameTransform = new ZipNameTransform(Path.GetDirectoryName(archive));
                foreach (var file in filename)
                {
                    // skip if this isn't a real file
                    if (!File.Exists(file))
                    {
                        continue;
                    }
                    zf.Add(file, CompressionMethod.Deflated);
                }
                zf.CommitUpdate();
                zf.Close();
            }
            catch (Exception e)
            {
                if (e.Message != null)
                {
                    var msg = new[] { e.Message };
                    LocDB.Message("defErrMsg", e.Message, msg, LocDB.MessageTypes.Error, LocDB.MessageDefault.First);
                }
            }
        }
Exemplo n.º 4
0
        public string CreatePreview()
        {
            Debug.Assert(ParentForm != null);
            if (inProcess)
            {
                return(string.Empty);
            }
            inProcess = true;
            var cr = ParentForm.Cursor;

            ParentForm.Cursor = Cursors.WaitCursor;
            Debug.Assert(!string.IsNullOrEmpty(Param.Value[Param.CurrentInput]), "The given key was not present in the dictionary.");
            var xhtml = Param.Value[Param.CurrentInput];

            if (string.IsNullOrEmpty(xhtml) || !File.Exists(xhtml))
            {
                return(string.Empty);
            }
            string PreviewCSSPath = Param.StylePath(Sheet);
            var    mergedCss      = new MergeCss();
            string cssCombine     = mergedCss.Make(PreviewCSSPath, "Temp1.css");

            var returnXhtml = CreatePreviewFile(xhtml, cssCombine, "preview", true);
            var pdf         = new Pdf(returnXhtml, cssCombine);
            var outName     = Common.PathCombine(Param.Value[Param.OutputPath], Path.GetFileNameWithoutExtension(xhtml) + ".pdf");

            try
            {
                pdf.Create(outName);
            }
            catch (Pdf.MISSINGPRINCE)
            {
                LocDB.Message("errInstallPrinceXML", "PrinceXML must be downloaded and installed from www.PrinceXML.com", null, LocDB.MessageTypes.Error,
                              LocDB.MessageDefault.First);
                ParentForm.Cursor = cr;
                inProcess         = false;
                return(string.Empty);
            }
            ParentForm.Cursor = cr;
            inProcess         = false;
            return(outName);
        }
Exemplo n.º 5
0
        private void Launch(string ldmlFullName)
        {
            try
            {
                Common.OpenOutput(ldmlFullName);
            }
            catch (System.ComponentModel.Win32Exception ex)
            {
                if (ex.NativeErrorCode == 1155)
                {
                    string installedLocation = string.Empty;

                    if (File.Exists(ldmlFullName))
                    {
                        installedLocation = ldmlFullName;

                        var msg = new[] { "Indesign application." };
                        LocDB.Message("errInstallFile", "The output has been saved in " + installedLocation, "Please install " + msg, msg, LocDB.MessageTypes.Error, LocDB.MessageDefault.First);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void ExportDlg_Load(object sender, EventArgs e)
        {
            LocDB.Localize(this, null);     // Form Controls
            _helpTopic = "Exporting.htm";
            ShowHelp.ShowHelpTopic(this, _helpTopic, Common.IsUnixOS(), false);
            ArrayList exportType = Backend.GetExportType(ExportType);

            if (exportType.Count > 0)
            {
                foreach (string item in exportType)
                {
                    cmbExportType.Items.Add(item);
                }
                cmbExportType.SelectedIndex = 0;
            }
            else
            {
                var msg = new[] { "Please Install the Plugin Backends" };
                LocDB.Message("defErrMsg", "Please Install the Plugin Backends", msg, LocDB.MessageTypes.Error, LocDB.MessageDefault.First);
                this.Close();
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// To sets the projects type/version and date of creation/modification
 /// </summary>
 /// <param name="mode">The Project mode (new / open)</param>
 public void ProjectProperty(string mode)
 {
     try
     {
         XmlNode      propertyCreated;
         XmlNode      propertyCreatedOn;
         XmlNode      searchNode = null;
         XmlNode      modifyNode = null;
         XmlAttribute xattribute;
         XmlElement   root  = _DeXml.DocumentElement;
         string       xPath = "PropertyGroup";
         if (root != null)
         {
             searchNode = root.SelectSingleNode(xPath);
             if (searchNode == null)
             {
                 searchNode = _DeXml.CreateNode("element", "PropertyGroup", "");
                 root.AppendChild(searchNode);
                 mode = "new";
             }
             if (mode == "new")
             {
                 //Setting Project Type and Version.
                 xattribute       = _DeXml.CreateAttribute("Type");
                 xattribute.Value = _projectInputType;
                 root.Attributes.Append(xattribute);
                 xattribute       = _DeXml.CreateAttribute("Version");
                 xattribute.Value = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                 root.Attributes.Append(xattribute);
                 xattribute       = _DeXml.CreateAttribute("ShowError");
                 xattribute.Value = "True";
                 root.Attributes.Append(xattribute);
                 // Setting User, Date
                 propertyCreated             = _DeXml.CreateNode("element", "Creation", "");
                 propertyCreatedOn           = _DeXml.CreateNode("element", "CreatedOn", "");
                 propertyCreatedOn.InnerText = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
                 propertyCreated.AppendChild(propertyCreatedOn);
                 propertyCreatedOn           = _DeXml.CreateNode("element", "CreatedBy", "");
                 propertyCreatedOn.InnerText = Environment.UserName;
                 propertyCreated.AppendChild(propertyCreatedOn);
                 searchNode.AppendChild(propertyCreated);
             }
         }
         xPath = "/Project/PropertyGroup/Modification";
         if (root != null)
         {
             modifyNode = root.SelectSingleNode(xPath);
         }
         if (modifyNode != null)
         {
             searchNode.RemoveChild(modifyNode);
         }
         propertyCreated             = _DeXml.CreateNode("element", "Modification", "");
         propertyCreatedOn           = _DeXml.CreateNode("element", "ModifiedOn", "");
         propertyCreatedOn.InnerText = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
         propertyCreated.AppendChild(propertyCreatedOn);
         propertyCreatedOn           = _DeXml.CreateNode("element", "ModifiedBy", "");
         propertyCreatedOn.InnerText = Environment.UserName;
         propertyCreated.AppendChild(propertyCreatedOn);
         if (searchNode != null)
         {
             searchNode.AppendChild(propertyCreated);
         }
         _DeXml.Save(_projectFileWithPath);
     }
     catch (Exception ex)
     {
         var msg = new[] { ex.Message };
         LocDB.Message("defErrMsg", ex.Message, msg, LocDB.MessageTypes.Error, LocDB.MessageDefault.First);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Add the given file to the Project xml file
        /// </summary>
        /// <param name="fullFileName">File with full path</param>
        /// <param name="setDefault">Used to set default css</param>
        /// <param name="addToParentFolder">Forced to add in root of Solution Explorer</param>
        /// <param name="destPathParent">Parent of current folder - used for recursive copy</param>
        /// <param name="showFileExist">To Show the information about file already exist</param>
        /// <param name="visible"></param>
        /// <returns>Returns True/False</returns>
        public bool AddFileToXML(string fullFileName, string setDefault, bool addToParentFolder, string destPathParent, bool showFileExist, bool visible)
        {
            if (!File.Exists(fullFileName))
            {
                return(false);
            }

            string fileName = Path.GetFileName(fullFileName);
            string fileNamePath;

            // Root directory
            if (addToParentFolder)
            {
                fileNamePath = Common.PathCombine(_dictionaryPath, fileName);
            }
            else
            {
                if (destPathParent != "")
                {
                    // used for recursive copy
                    fileNamePath = Common.PathCombine(_fullPath + destPathParent, fileName);
                }
                else
                {
                    // sub directory
                    fileNamePath = Common.PathCombine(_fullPath, fileName);
                }
            }

            if (IsFileExist(Path.GetFileName(fileNamePath), "True"))
            {
                if (showFileExist)
                {
                    var msg = new[] { "File Already Exist in Dictionary Express." };
                    LocDB.Message("defErrMsg", "File Already Exist in Dictionary Express.", msg, LocDB.MessageTypes.Info, LocDB.MessageDefault.First);
                }
            }
            else
            {
                try
                {
                    // Remove if file Visible="False"
                    if (IsFileExist(Path.GetFileName(fileNamePath), "False"))
                    {
                        RemoveFile(Path.GetFileName(fileNamePath));
                    }
                    if (fullFileName != fileNamePath)
                    {
                        File.Copy(fullFileName, fileNamePath, true);
                    }
                    // File
                    bool returnValue = XMLOperation(fileName, 'F', setDefault, addToParentFolder, "", destPathParent, visible);
                    if (destPathParent == "")
                    {
                        PopulateDicExplorer(_dictExplorer);
                    }
                    return(returnValue);
                }
                catch
                {
                }
            }
            return(false);
        }