示例#1
0
        public void ReplaceWith(BackgroundPage source)
        {
            if (Enabled != source.Enabled)
            {
                Enabled = source.Enabled;
            }

            if (File != source.File)
            {
                File = source.File;
            }

            if (FitToPage != source.FitToPage)
            {
                FitToPage = source.FitToPage;
            }

            if (Opacity != source.Opacity)
            {
                Opacity = source.Opacity;
            }

            if (Repetition != source.Repetition)
            {
                Repetition = source.Repetition;
            }
        }
示例#2
0
 public void ReadValues(Data data, string path = "")
 {
     Enabled = bool.TryParse(data.GetValue(@"" + path + @"Enabled"), out var tmpEnabled) ? tmpEnabled : false;
     try { File = Data.UnescapeString(data.GetValue(@"" + path + @"File")); } catch { File = ""; }
     FitToPage  = bool.TryParse(data.GetValue(@"" + path + @"FitToPage"), out var tmpFitToPage) ? tmpFitToPage : true;
     Opacity    = int.TryParse(data.GetValue(@"" + path + @"Opacity"), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out var tmpOpacity) ? tmpOpacity : 100;
     Repetition = Enum.TryParse <BackgroundRepetition>(data.GetValue(@"" + path + @"Repetition"), out var tmpRepetition) ? tmpRepetition : BackgroundRepetition.RepeatLastPage;
 }
示例#3
0
 public void ReadValues(Data data, string path)
 {
     try { Enabled = bool.Parse(data.GetValue(@"" + path + @"Enabled")); } catch { Enabled = false; }
     try { File = Data.UnescapeString(data.GetValue(@"" + path + @"File")); } catch { File = ""; }
     try { OnAttachment = bool.Parse(data.GetValue(@"" + path + @"OnAttachment")); } catch { OnAttachment = false; }
     try { OnCover = bool.Parse(data.GetValue(@"" + path + @"OnCover")); } catch { OnCover = false; }
     try { Repetition = (BackgroundRepetition)Enum.Parse(typeof(BackgroundRepetition), data.GetValue(@"" + path + @"Repetition")); } catch { Repetition = BackgroundRepetition.RepeatLastPage; }
 }
示例#4
0
 private void Init()
 {
     Enabled      = false;
     File         = "";
     OnAttachment = false;
     OnCover      = false;
     Repetition   = BackgroundRepetition.RepeatLastPage;
 }
示例#5
0
 public void ReadValues(Data data, string path = "")
 {
     Enabled = bool.TryParse(data.GetValue(@"" + path + @"Enabled"), out var tmpEnabled) ? tmpEnabled : false;
     try { File = Data.UnescapeString(data.GetValue(@"" + path + @"File")); } catch { File = ""; }
     OnAttachment = bool.TryParse(data.GetValue(@"" + path + @"OnAttachment"), out var tmpOnAttachment) ? tmpOnAttachment : false;
     OnCover      = bool.TryParse(data.GetValue(@"" + path + @"OnCover"), out var tmpOnCover) ? tmpOnCover : false;
     Repetition   = Enum.TryParse <BackgroundRepetition>(data.GetValue(@"" + path + @"Repetition"), out var tmpRepetition) ? tmpRepetition : BackgroundRepetition.RepeatLastPage;
 }
示例#6
0
        public void ReplaceWith(BackgroundPage source)
        {
            if (Enabled != source.Enabled)
            {
                Enabled = source.Enabled;
            }

            if (File != source.File)
            {
                File = source.File;
            }

            if (FitToPage != source.FitToPage)
            {
                FitToPage = source.FitToPage;
            }

            if (OnAttachment != source.OnAttachment)
            {
                OnAttachment = source.OnAttachment;
            }

            if (OnCover != source.OnCover)
            {
                OnCover = source.OnCover;
            }

            if (Opacity != source.Opacity)
            {
                Opacity = source.Opacity;
            }

            if (Repetition != source.Repetition)
            {
                Repetition = source.Repetition;
            }
        }
示例#7
0
        /// <summary>
        ///     Determine the background page for the current document page.
        /// </summary>
        /// <param name="currentDocumentPage">Current page of the document</param>
        /// <param name="numberOfBackgroundpages">Number of backgroundpages</param>
        /// <param name="repeat">Repetition of the background</param>
        /// <param name="startOffset">Number of pages that do not get a background at the beginning of the document</param>
        /// <param name="endPage">Last page that gets a background</param>
        /// <returns>Number of the backgroundpage or -1 if no background must be set</returns>
        private static int GetBackgroundPageNumber(int currentDocumentPage, int numberOfBackgroundpages,
                                                   BackgroundRepetition repeat, int startOffset, int endPage)
        {
            if (currentDocumentPage <= startOffset)
            {
                return(-1);
            }
            if (currentDocumentPage > endPage)
            {
                return(-1);
            }

            switch (repeat)
            {
            case BackgroundRepetition.RepeatAllPages:
                return((currentDocumentPage - startOffset - 1) % numberOfBackgroundpages + 1);

            case BackgroundRepetition.RepeatLastPage:
                if (currentDocumentPage - startOffset < numberOfBackgroundpages)
                {
                    return(currentDocumentPage - startOffset);
                }
                //else if (currentDocumentPage - startOffset >= numberOfBackgroundpages)
                return(numberOfBackgroundpages);

            case BackgroundRepetition.NoRepetition:
                if (currentDocumentPage - startOffset <= numberOfBackgroundpages)
                {
                    return(currentDocumentPage - startOffset);
                }
                //else
                return(-1);
            }

            return(-1); //default
        }