Ejemplo n.º 1
0
        /// <summary>
        /// Footer reference nodes inside the document
        /// </summary>
        /// <param name="type">The footer part type</param>
        /// <returns>XElement containing the part reference in the document</returns>
        private XElement GetFooterReference(FooterType type)
        {
            XDocument mainDocument       = parentDocument.GetXDocument(parentDocument.Document.MainDocumentPart);
            XName     footerReferenceTag = ns + "footerReference";
            XName     typeTag            = ns + "type";
            string    typeName           = "";

            switch (type)
            {
            case FooterType.First: typeName = "first";
                break;

            case FooterType.Even: typeName = "even";
                break;

            case FooterType.Default: typeName = "default";
                break;
            }

            XElement footerReferenceElement = mainDocument.Descendants().Where(
                tag =>
                (tag.Name == footerReferenceTag) && (tag.Attribute(typeTag).Value == typeName)
                ).FirstOrDefault();

            return(footerReferenceElement);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Footer reference nodes inside the document
        /// </summary>
        /// <param name="type">The footer part type</param>
        /// <returns>XElement containing the part reference in the document</returns>
        private static XElement GetFooterReference(WordprocessingDocument document, FooterType type, int sectionIndex)
        {
            XDocument mainDocument       = document.MainDocumentPart.GetXDocument();
            XName     footerReferenceTag = ns + "footerReference";
            XName     typeTag            = ns + "type";
            string    typeName           = "";

            switch (type)
            {
            case FooterType.First: typeName = "first";
                break;

            case FooterType.Even: typeName = "even";
                break;

            case FooterType.Default: typeName = "default";
                break;
            }

            XElement sectionPropertyElement = SectionPropertiesElements(document).Skip(sectionIndex).FirstOrDefault();

            if (sectionPropertyElement != null)
            {
                return(sectionPropertyElement.Descendants().Where(tag => (tag.Name == footerReferenceTag) && (tag.Attribute(typeTag).Value == typeName)).FirstOrDefault());
            }
            return(null);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Removes the specified footer in the document
 /// </summary>
 /// <param name="type">The footer part type</param>
 public static void RemoveFooter(WmlDocument doc, FooterType type, int sectionIndex)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
         using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
         {
             OpenXmlPart footerPart = GetFooterPart(document, type, sectionIndex);
             footerPart.RemovePart();
         }
 }
Ejemplo n.º 4
0
 public TextPrinter()
 {
     printDoc            = new PrintDocument();
     printDoc.PrintPage += new PrintPageEventHandler(pd_PrintPage);
     m_Font              = SystemFonts.DefaultFont;
     m_TitleFont         = SystemFonts.CaptionFont;
     m_TitleType         = TitleType.None;
     m_FooterType        = FooterType.None;
     FooterFormat        = "第{0}页";
 }
 /// <summary>
 /// Get the specified footer from the document
 /// </summary>
 /// <param name="type">The footer part type</param>
 /// <returns>the XDocument containing the footer</returns>
 public static XDocument GetFooter(WmlDocument doc, FooterType type, int sectionIndex)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
     using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
     {
         OpenXmlPart footer = GetFooterPart(document, type, sectionIndex);
         if (footer != null)
             return footer.GetXDocument();
         return null;
     }
 }
 /// <summary>
 /// The specified footer part from the document
 /// </summary>
 /// <param name="type">The footer part type</param>
 /// <returns>A OpenXmlPart containing the footer part</returns>
 public static OpenXmlPart GetFooterPart(WordprocessingDocument document, FooterType type, int sectionIndex)
 {
     // look in the section properties of the main document part, the respective footer
     // needed to extract
     XElement footerReferenceElement = GetFooterReference(document, type, sectionIndex);
     if (footerReferenceElement != null)
     {
         //  get the relation id of the footer part to extract from the document
         string relationshipId = footerReferenceElement.Attribute(relationshipns + "id").Value;
         return document.MainDocumentPart.GetPartById(relationshipId);
     }
     return null;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Get the specified footer from the document
        /// </summary>
        /// <param name="type">The footer part type</param>
        /// <returns>the XDocument containing the footer</returns>
        public XDocument GetFooter(FooterType type)
        {
            OpenXmlPart footer = GetFooterPart(type);

            if (footer != null)
            {
                return(parentDocument.GetXDocument(footer));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Get the specified footer from the document
 /// </summary>
 /// <param name="type">The footer part type</param>
 /// <returns>the XDocument containing the footer</returns>
 public static XDocument GetFooter(WmlDocument doc, FooterType type, int sectionIndex)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
         using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
         {
             OpenXmlPart footer = GetFooterPart(document, type, sectionIndex);
             if (footer != null)
             {
                 return(footer.GetXDocument());
             }
             return(null);
         }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// The specified footer part from the document
        /// </summary>
        /// <param name="type">The footer part type</param>
        /// <returns>A OpenXmlPart containing the footer part</returns>
        public static OpenXmlPart GetFooterPart(WordprocessingDocument document, FooterType type, int sectionIndex)
        {
            // look in the section properties of the main document part, the respective footer
            // needed to extract
            XElement footerReferenceElement = GetFooterReference(document, type, sectionIndex);

            if (footerReferenceElement != null)
            {
                //  get the relation id of the footer part to extract from the document
                string relationshipId = footerReferenceElement.Attribute(relationshipns + "id").Value;
                return(document.MainDocumentPart.GetPartById(relationshipId));
            }
            return(null);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// The specified footer part from the document
        /// </summary>
        /// <param name="type">The footer part type</param>
        /// <returns>A OpenXmlPart containing the footer part</returns>
        public OpenXmlPart GetFooterPart(FooterType type)
        {
            // look in the section properties of the main document part, the respective footer
            // needed to extract
            XElement footerReferenceElement = GetFooterReference(type);

            if (footerReferenceElement != null)
            {
                //  get the relation id of the footer part to extract from the document
                string relationshipId = footerReferenceElement.Attribute(relationshipns + "id").Value;
                return(parentDocument.Document.MainDocumentPart.GetPartById(relationshipId));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates the html footer for the image
        /// </summary>
        /// <param name="imageFile">The <see cref="FileInfo"/> object of the image</param>
        /// <param name="type">The footer type</param>
        /// <param name="count">The current count</param>
        /// <param name="totalCount">The total count</param>
        /// <returns>The html footer for the image</returns>
        /// <exception cref="ArgumentNullException"/>
        private static string CreateImageFooter(ImageModel imageFile, FooterType type, int count, int totalCount)
        {
            if (imageFile == null)
            {
                throw new ArgumentNullException(nameof(imageFile));
            }

            var stringBuilder = new StringBuilder("<br/>");

            switch (type)
            {
            case FooterType.ImageName:
                stringBuilder.Append(imageFile.File.Name);
                break;

            case FooterType.Numbering:
                stringBuilder.Append($"{count} of {totalCount}");
                break;

            case FooterType.FileDetails:
                var image       = Image.FromFile(imageFile.File.FullName);
                var detailTable = new StringBuilder("<table border='0' cellspacing='0' cellpadding='3'>");
                detailTable.AppendLine($"<tr><td align='right'>File:</td><td>{imageFile.File.Name}</td></tr>");
                detailTable.AppendLine($"<tr><td align='right'>Date:</td><td>{imageFile.File.CreationTime:g}</td></tr>");
                detailTable.AppendLine($"<tr><td align='right'>Size:</td><td>{image.Width}x{image.Height}</td></tr>");
                detailTable.AppendLine(
                    $"<tr><td align='right'>File size:</td><td>{(double) imageFile.File.Length / 1024 / 1024:N2} MB</td></tr>");
                detailTable.AppendLine("</table>");
                stringBuilder.Append(detailTable);
                break;

            case FooterType.Custom:
                stringBuilder.AppendLine($"{imageFile.Footer}");
                break;

            default:
                stringBuilder.Clear();
                break;
            }

            return(stringBuilder.ToString());
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates the html table
        /// </summary>
        /// <param name="imageFiles">The image files</param>
        /// <param name="source">The path of the source folder</param>
        /// <param name="createThumbnails">The value which indicates if the user want to use thumbnails</param>
        /// <param name="thumbHeight">The height of the thumbnail</param>
        /// <param name="thumbWidth">The width of the thumbnail</param>
        /// <param name="keepRatio">The value which indicates if the ratio should be keeped</param>
        /// <param name="headerText">The headertext</param>
        /// <param name="blankTarget">true to use a blank target</param>
        /// <param name="columnCount">The column count</param>
        /// <param name="imageFooter">The image footer id</param>
        /// <param name="createArchive">true if the user wants to create a archive</param>
        /// <param name="archiveName">The name of the archive</param>
        /// <param name="openPage">true when the pages should be opened at the end</param>
        public static void CreateHtmlTable(List <ImageModel> imageFiles, string source, bool createThumbnails, int thumbHeight, int thumbWidth,
                                           bool keepRatio, string headerText, bool blankTarget, int columnCount, FooterType imageFooter, bool createArchive, string archiveName, bool openPage)
        {
            try
            {
                archiveName = CreateArchiveName(archiveName ?? "");

                var imageSizeList = new Dictionary <string, ImageSize>();
                if (createThumbnails)
                {
                    ThumbnailManager.OnNewInfo  += ThumbnailManagerOnOnNewInfo;
                    ThumbnailManager.OnProgress += ThumbnailManager_OnProgress;
                    imageSizeList = ThumbnailManager.CreateThumbnails(imageFiles, source, thumbWidth, thumbHeight, keepRatio);
                    ThumbnailManager.OnProgress -= ThumbnailManager_OnProgress;
                    ThumbnailManager.OnNewInfo  -= ThumbnailManagerOnOnNewInfo;
                }

                var htmlTable = new StringBuilder("");
                var target    = blankTarget ? "target=\"_blank\"" : "";

                var count      = 1;
                var totalCount = 1;

                foreach (var image in imageFiles)
                {
                    OnInfo?.Invoke(GlobalHelper.InfoType.Info, $"Create image entry {totalCount} of {imageFiles.Count}");
                    OnProgress?.Invoke(GlobalHelper.CalculateCurrentProgress(totalCount, imageFiles.Count), 100);
                    if (count == 1)
                    {
                        htmlTable.AppendLine("<tr>");
                    }


                    if (!imageSizeList.TryGetValue(image.File.Name, out var imgSize))
                    {
                        imgSize = ImageSize.CreateDefault();
                    }

                    // Create the tag for the size
                    var imgSizeHtml = $"width=\"{imgSize.Width}\" height=\"{imgSize.Height}\"";

                    // Create the image tag
                    var thumbnail = createThumbnails
                        ? $"<img src=\"thumbnails/{image.File.Name}\" {imgSizeHtml} alt=\"{image.File.Name}\" title=\"{image.File.Name}\">"
                        : $"<img src=\"{image.File.Name}\" {imgSizeHtml} alt=\"{image.File.Name}\" title=\"{image.File.Name}\">";

                    htmlTable.AppendLine(
                        $"<td><a href=\"{image.File.Name}\" {target}>{thumbnail}</a>{CreateImageFooter(image, imageFooter, totalCount, imageFiles.Count)}</td>");

                    count++;
                    totalCount++;

                    if (count <= columnCount)
                    {
                        continue;
                    }
                    count = 1;
                    htmlTable.AppendLine("</tr>");
                }

                var archiveHtml = "";
                if (createArchive)
                {
                    if (CreateArchive(source, archiveName))
                    {
                        archiveHtml = $"You can download all pictures here: <a href=\"{CreateArchiveName(archiveName)}\">{CreateArchiveName(archiveName)}</a><br /><br />";
                    }
                }

                OnInfo?.Invoke(GlobalHelper.InfoType.Info, "Write data into file.");
                var indexPath = Path.Combine(source, "index.html");
                File.WriteAllText(indexPath, CreateFinaleHtml(headerText, htmlTable.ToString(), archiveHtml));

                if (File.Exists(indexPath))
                {
                    OnInfo?.Invoke(GlobalHelper.InfoType.Info, "File created.");
                    if (openPage)
                    {
                        Process.Start(indexPath);
                    }
                }
                else
                {
                    OnInfo?.Invoke(GlobalHelper.InfoType.Error, "Can't create file.");
                }
            }
            catch (Exception ex)
            {
                OnInfo?.Invoke(GlobalHelper.InfoType.Error, $"An error has occured. Message: {ex.Message}");
            }
        }
Ejemplo n.º 13
0
 public ColumnSet Add(string fieldName, string title, HorizAlignments horizontalAlignment, VertiAlignments verticalAlignment, bool hasBorder, int width, FooterType footerType = FooterType.None)
 {
     return(Add(fieldName, title, null, horizontalAlignment, verticalAlignment, hasBorder, width, footerType));
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Set a new footer in a document
        /// </summary>
        /// <param name="footer">XDocument containing the footer to add in the document</param>
        /// <param name="type">The footer part type</param>
        public static OpenXmlPowerToolsDocument SetFooter(WmlDocument doc, XDocument footer, FooterType type, int sectionIndex)
        {
            using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
            {
                using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
                {
                    //  Removes the reference in the document.xml and the footer part if those already
                    //  exist
                    XElement footerReferenceElement = GetFooterReference(document, type, sectionIndex);
                    if (footerReferenceElement != null)
                    {
                        GetFooterPart(document, type, sectionIndex).RemovePart();
                        footerReferenceElement.Remove();
                    }

                    //  Add the new footer
                    FooterPart footerPart = document.MainDocumentPart.AddNewPart <FooterPart>();
                    footerPart.PutXDocument(footer);

                    //  If the document does not have a property section a new one must be created
                    if (SectionPropertiesElements(document).Count() == 0)
                    {
                        AddDefaultSectionProperties(document);
                    }

                    //  Creates the relationship of the footer inside the section properties in the document
                    string relID    = document.MainDocumentPart.GetIdOfPart(footerPart);
                    string kindName = "";
                    switch ((FooterType)type)
                    {
                    case FooterType.First:
                        kindName = "first";
                        break;

                    case FooterType.Even:
                        kindName = "even";
                        break;

                    case FooterType.Default:
                        kindName = "default";
                        break;
                    }

                    XElement sectionPropertyElement = SectionPropertiesElements(document).Skip(sectionIndex).FirstOrDefault();
                    if (sectionPropertyElement != null)
                    {
                        sectionPropertyElement.Add(
                            new XElement(ns + "footerReference",
                                         new XAttribute(ns + "type", kindName),
                                         new XAttribute(relationshipns + "id", relID)));

                        if (sectionPropertyElement.Element(ns + "titlePg") == null)
                        {
                            sectionPropertyElement.Add(
                                new XElement(ns + "titlePg")
                                );
                        }
                    }
                    document.MainDocumentPart.PutXDocument();

                    // add in the settings part the EvendAndOddHeaders. this element
                    // allow to see the odd and even footers and headers in the document.
                    SettingAccessor.AddEvenAndOddHeadersElement(document);
                }
                return(streamDoc.GetModifiedDocument());
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Set a new footer in a document
        /// </summary>
        /// <param name="footer">XDocument containing the footer to add in the document</param>
        /// <param name="type">The footer part type</param>
        public void SetFooter(XDocument footer, FooterType type)
        {
            //  Removes the reference in the document.xml and the footer part if those already
            //  exist
            XElement footerReferenceElement = GetFooterReference(type);

            if (footerReferenceElement != null)
            {
                RemoveFooter(type);
                footerReferenceElement.Remove();
            }

            //  Add the new footer
            XDocument  newFooter;
            FooterPart footerPart = parentDocument.Document.MainDocumentPart.AddNewPart <FooterPart>();

            newFooter = parentDocument.GetXDocument(footerPart);
            newFooter.Add(footer.Root);

            //  If the document does not have a property section a new one must be created
            if (SectionPropertiesElements().Count() == 0)
            {
                AddDefaultSectionProperties();
            }

            //  Creates the relationship of the footer inside the section properties in the document
            string relID    = parentDocument.Document.MainDocumentPart.GetIdOfPart(footerPart);
            string kindName = "";

            switch ((FooterType)type)
            {
            case FooterType.First:
                kindName = "first";
                break;

            case FooterType.Even:
                kindName = "even";
                break;

            case FooterType.Default:
                kindName = "default";
                break;
            }

            XElement sectionPropertyElement = SectionPropertiesElements().First();

            sectionPropertyElement.Add(
                new XElement(ns + "footerReference",
                             new XAttribute(ns + "type", kindName),
                             new XAttribute(relationshipns + "id", relID)));

            if (sectionPropertyElement.Element(ns + "titlePg") == null)
            {
                sectionPropertyElement.Add(
                    new XElement(ns + "titlePg")
                    );
            }

            // add in the settings part the EvendAndOddHeaders. this element
            // allow to see the odd and even footers and headers in the document.
            parentDocument.Setting.AddEvendAndOddHeadersElement();
        }
        /// <summary>
        /// Footer reference nodes inside the document
        /// </summary>
        /// <param name="type">The footer part type</param>
        /// <returns>XElement containing the part reference in the document</returns>
        private static XElement GetFooterReference(WordprocessingDocument document, FooterType type, int sectionIndex)
        {
            XDocument mainDocument = document.MainDocumentPart.GetXDocument();
            XName footerReferenceTag = ns + "footerReference";
            XName typeTag = ns + "type";
            string typeName = "";

            switch (type)
            {
                case FooterType.First: typeName = "first";
                    break;
                case FooterType.Even: typeName = "even";
                    break;
                case FooterType.Default: typeName = "default";
                    break;
            }

            XElement sectionPropertyElement = SectionPropertiesElements(document).Skip(sectionIndex).FirstOrDefault();
            if (sectionPropertyElement != null)
            {
                return sectionPropertyElement.Descendants().Where(tag => (tag.Name == footerReferenceTag) && (tag.Attribute(typeTag).Value == typeName)).FirstOrDefault();
            }
            return null;
        }
        /// <summary>
        /// Set a new footer in a document
        /// </summary>
        /// <param name="footer">XDocument containing the footer to add in the document</param>
        /// <param name="type">The footer part type</param>
        public static OpenXmlPowerToolsDocument SetFooter(WmlDocument doc, XDocument footer, FooterType type, int sectionIndex)
        {
            using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
            {
                using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
                {
                    //  Removes the reference in the document.xml and the footer part if those already
                    //  exist
                    XElement footerReferenceElement = GetFooterReference(document, type, sectionIndex);
                    if (footerReferenceElement != null)
                    {
                        GetFooterPart(document, type, sectionIndex).RemovePart();
                        footerReferenceElement.Remove();
                    }

                    //  Add the new footer
                    FooterPart footerPart = document.MainDocumentPart.AddNewPart<FooterPart>();
                    footerPart.PutXDocument(footer);

                    //  If the document does not have a property section a new one must be created
                    if (SectionPropertiesElements(document).Count() == 0)
                    {
                        AddDefaultSectionProperties(document);
                    }

                    //  Creates the relationship of the footer inside the section properties in the document
                    string relID = document.MainDocumentPart.GetIdOfPart(footerPart);
                    string kindName = "";
                    switch ((FooterType)type)
                    {
                        case FooterType.First:
                            kindName = "first";
                            break;
                        case FooterType.Even:
                            kindName = "even";
                            break;
                        case FooterType.Default:
                            kindName = "default";
                            break;
                    }

                    XElement sectionPropertyElement = SectionPropertiesElements(document).Skip(sectionIndex).FirstOrDefault();
                    if (sectionPropertyElement != null)
                    {
                        sectionPropertyElement.Add(
                            new XElement(ns + "footerReference",
                                new XAttribute(ns + "type", kindName),
                                new XAttribute(relationshipns + "id", relID)));

                        if (sectionPropertyElement.Element(ns + "titlePg") == null)
                            sectionPropertyElement.Add(
                                new XElement(ns + "titlePg")
                                );
                    }
                    document.MainDocumentPart.PutXDocument();

                    // add in the settings part the EvendAndOddHeaders. this element
                    // allow to see the odd and even footers and headers in the document.
                    SettingAccessor.AddEvenAndOddHeadersElement(document);
                }
                return streamDoc.GetModifiedDocument();
            }
        }
Ejemplo n.º 18
0
        private ColumnSet Insert(int index, string fieldName, string title, string valueFormat, HorizAlignments?horizontalAlignment, VertiAlignments?verticalAlignment, bool?hasBorder, int?width, FooterType footerType = FooterType.None)
        {
            if (fieldName == null)
            {
                throw new ArgumentNullException(fieldName);
            }
            foreach (ColumnData c in this)
            {
                if (c.FieldName.ToUpper() == fieldName.ToUpper())
                {
                    throw new Exception(string.Format("Duplicated set the column with field name : {0}.", fieldName));
                }
            }
            ColumnData cols = new ColumnData
            {
                FieldName           = fieldName,
                Title               = title,
                ValueFormat         = valueFormat,
                HorizontalAlignment = horizontalAlignment,
                VerticalAlignment   = verticalAlignment,
                Width               = width,
                HasBorder           = hasBorder,
                FooterType          = footerType
            };

            this.Insert(index, cols);
            return(this);
        }
Ejemplo n.º 19
0
 public ColumnSet Insert(int index, string fieldName, string title, string valueFormat, HorizAlignments horizontalAlignment, VertiAlignments verticalAlignment, bool hasBorder, int width, FooterType footerType = FooterType.None)
 {
     return(Insert(index, fieldName, title, valueFormat, new HorizAlignments?(horizontalAlignment), new VertiAlignments?(verticalAlignment), new bool?(hasBorder), new int?(width), footerType));
 }
Ejemplo n.º 20
0
 public ColumnSet Insert(int index, string fieldName, string title, string valueFormat, HorizAlignments horizontalAlignment, VertiAlignments verticalAlignment, bool hasBorder, FooterType footerType = FooterType.None)
 {
     return(Insert(index, fieldName, title, valueFormat, horizontalAlignment, verticalAlignment, hasBorder, null, footerType));
 }
Ejemplo n.º 21
0
 public ColumnSet Insert(int index, string fieldName, string title, string valueFormat, int width, FooterType footerType = FooterType.None)
 {
     return(Insert(index, fieldName, title, valueFormat, null, null, null, width, footerType));
 }
Ejemplo n.º 22
0
 public ColumnSet Insert(int index, string fieldName, string title, FooterType footerType = FooterType.None)
 {
     return(Insert(index, fieldName, title, null, footerType));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Removes the specified footer in the document
        /// </summary>
        /// <param name="type">The footer part type</param>
        public void RemoveFooter(FooterType type)
        {
            OpenXmlPart footerPart = GetFooterPart(type);

            parentDocument.RemovePart(footerPart);
        }
Ejemplo n.º 24
0
 public ColumnSet Add(string fieldName, string title, FooterType footerType = FooterType.None)
 {
     return(Add(fieldName, title, null, footerType));
 }
Ejemplo n.º 25
0
        private ColumnSet Set(string fieldName, string title, string format, HorizAlignments?horizontalAlignment, VertiAlignments?verticalAlignment, bool?hasBorder, int?width, FooterType footerType = FooterType.None)
        {
            if (fieldName == null)
            {
                throw new ArgumentNullException(fieldName);
            }
            ColumnData c = this.FindColumnByFieldName(fieldName);

            if (c == null)
            {
                throw new Exception("There is no column with field name '" + fieldName + "'.");
            }
            if (title != null)
            {
                c.Title = title;
            }
            if (format != null)
            {
                c.ValueFormat = format;
            }
            if (horizontalAlignment.HasValue)
            {
                c.HorizontalAlignment = horizontalAlignment.Value;
            }
            if (verticalAlignment.HasValue)
            {
                c.VerticalAlignment = verticalAlignment.Value;
            }
            if (hasBorder.HasValue)
            {
                c.HasBorder = hasBorder.Value;
            }
            if (width.HasValue)
            {
                c.Width = width.Value;
            }
            c.FooterType = footerType;
            return(this);
        }
Ejemplo n.º 26
0
 /// <summary>
 /// GetFooters
 /// </summary>
 public override XDocument GetFooters(FooterType type)
 {
     return(Footer.GetFooter(type));
 }
Ejemplo n.º 27
0
 public ColumnSet Set(string fieldName, string format, HorizAlignments horizontalAlignment, VertiAlignments verticalAlignment, bool hasBorder, int width, FooterType footerType = FooterType.None)
 {
     return(Set(fieldName, null, format, new HorizAlignments?(horizontalAlignment),
                new VertiAlignments?(verticalAlignment), new bool?(hasBorder), new int?(width)));
 }
Ejemplo n.º 28
0
 public ColumnSet Set(string fieldName, string format, int width, FooterType footerType = FooterType.None)
 {
     return(Set(fieldName, null, format, null, null, null, width));
 }
Ejemplo n.º 29
0
 public ColumnSet Set(string fieldName, string format, HorizAlignments horizontalAlignment, VertiAlignments verticalAlignment, bool hasBorder, FooterType footerType = FooterType.None)
 {
     return(Set(fieldName, null, format, horizontalAlignment, verticalAlignment, hasBorder, null));
 }
Ejemplo n.º 30
0
            /// <summary>
            /// 为 GridView 插入模板列
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="id"></param>
            /// <param name="headerText"></param>
            /// <param name="templateItem"></param>
            /// <param name="fieldSet"></param>
            /// <param name="footer"></param>
            /// <returns></returns>
            public ColumnSetter TemplateField <T>(string id,
                                                  string headerText, T templateItem, Action <TemplateField> fieldSet = null,
                                                  FooterType footer = FooterType.None) where T : TemplateItem.BaseItem
            {
                if (!
                    string.IsNullOrEmpty(id))
                {
                    templateItem.Id = id;
                }
                var c = new TemplateField()
                {
                    HeaderTemplate = new TemplateItem.Label(l => { l.Text = headerText; })
                    {
                        Id = id + "_Header"
                    },
                    ItemTemplate = templateItem
                };

                c.HeaderStyle.CssClass = "gridHeader";
                c.ItemStyle.CssClass   = "gridItem-template";

                if (fieldSet != null)
                {
                    fieldSet(c);
                }
                switch (footer)
                {
                case FooterType.Button:
                    c.FooterTemplate = new TemplateItem.CheckBox()
                    {
                        Id = id + "_ft"
                    };
                    break;

                case FooterType.Image:
                    c.FooterTemplate = new TemplateItem.Image()
                    {
                        Id = id + "_ft"
                    };
                    break;

                case FooterType.Label:
                    c.FooterTemplate = new TemplateItem.Label()
                    {
                        Id = id + "_ft"
                    };
                    break;

                case FooterType.Literal:
                    c.FooterTemplate = new TemplateItem.Literal()
                    {
                        Id = id + "_ft"
                    };
                    break;

                case FooterType.LinkButton:
                    c.FooterTemplate = new TemplateItem.LinkButton()
                    {
                        Id = id + "_ft"
                    };
                    break;
                }
                _Grid.Columns.Add(c);
                return(this);
            }
 /// <summary>
 /// Removes the specified footer in the document
 /// </summary>
 /// <param name="type">The footer part type</param>
 public static void RemoveFooter(WmlDocument doc, FooterType type, int sectionIndex)
 {
     using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
     using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
     {
         OpenXmlPart footerPart = GetFooterPart(document, type, sectionIndex);
         footerPart.RemovePart();
     }
 }
Ejemplo n.º 32
0
 public ColumnSet Add(string fieldName, string title, string valueFormat, int width, FooterType footerType = FooterType.None)
 {
     return(Add(fieldName, title, valueFormat, null, null, null, width, footerType));
 }
Ejemplo n.º 33
0
 /// <summary>
 /// SetFooter
 /// </summary>
 public override void SetFooter(XDocument footer, FooterType type)
 {
     Footer.SetFooter(footer, type);
 }
Ejemplo n.º 34
0
 public ColumnSet SetFooterType(string fieldName, FooterType footerType)
 {
     return(Set(fieldName, null, null, null, null, null, null, footerType));
 }