Exemplo n.º 1
0
        //private void LoadDefaultStyle(SerializationInfo info)
        //{
        //    try
        //    {
        //        var styleStr = info.GetString("DefaultStyle");

        //        DefaultStyle = new ComplexStyleConverter().ConvertFrom(styleStr) as ComplexStyle ?? new ComplexStyle();

        //    }
        //    catch {DefaultStyle = new ComplexStyle(); }
        //}

        private void LoadComplexStyle(SerializationInfo info)
        {
            try
            {
                var styleStr = info.GetString("ComplexStyles");

                Styles       = new ComplexStylesConverter().ConvertFrom(styleStr) as ComplexStyles ?? new ComplexStyles();
                Styles.Title = COMPLEX_STYLE_TITLE;
            }
            catch
            {
                Styles = new ComplexStyles {
                    Title = COMPLEX_STYLE_TITLE
                };
            }
        }
Exemplo n.º 2
0
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            var elem = Clone() as TextFile;

            if (elem == null)
            {
                return;
            }
            using (var stream = new MemoryStream())
            {
                var cont = new TextRange(elem.Document.ContentStart, elem.Document.ContentEnd);
                cont.Save(stream, DataFormats.XamlPackage);
                info.AddValue("FlowDocument", stream.ToArray());
            }
            StoreColors(info);

            if (PageCountElement != null)
            {
                if (PageCountElement.FontFamily == null)
                {
                    PageCountElement.FontFamily = Utilities.PossibleFonts.FirstOrDefault()?.Family;
                }

                info.AddValue("FontFamilyName", PageCountElement.FontFamily?.FamilyNames.FirstOrDefault().Value);
                info.AddValue("ResultBrush", PageCountElement.ForgroundBrushString);
                info.AddValue("UseZero", PageCountElement.UseLeadingZero);
                info.AddValue("FontSize", PageCountElement.FontSize);

                PageCountElement.UseLeadingZero = info.GetBoolean("UseZero");
            }


            var    converter = new ComplexStylesConverter();
            string value     = converter.ConvertTo(Styles, typeof(string)) as string;

            info.AddValue("ComplexStyles", value);

            //var converter2 = new ComplexStyleConverter();
            //string value2 = converter2.ConvertTo(DefaultStyle, typeof(string)) as string;
            //info.AddValue("DefaultStyle", value2);

            if (!string.IsNullOrEmpty(Password))
            {
                info.AddValue("Password", Password);
            }

            if (!string.IsNullOrEmpty(PasswordQuestion))
            {
                info.AddValue("PasswordQuestion", PasswordQuestion);
            }
            SaveBrush(info);

            info.AddValue("SpellCheckEnabled", SpellCheckEnabled);
            info.AddValue("IncFontWhenPrinting", IncFontWhenPrinting);
            info.AddValue("QuotationButtonState", QuotationButtonState);


            info.AddValue("SingleOpeningQuote", SingleOpeningQuote);
            info.AddValue("SingleClosingQuote", SingleClosingQuote);
            info.AddValue("OpeningQuote", OpeningQuote);
            info.AddValue("ClosingQuote", ClosingQuote);

            info.AddValue("UseBlackAndWhite", UseBlackAndWhite);
            info.AddValue("UseOldNumbering", UseOldNumbering);
            info.AddValue("UseWatermark", UseWatermark);
            info.AddValue("UseCharacters", UseCharacters);
            info.AddValue("ShowPageNumber", ShowPageNumber);
            info.AddValue("CaretOffset", CaretOffset);
            info.AddValue("ScrollOffset", ScrollOffset);
            info.AddValue("ReadOnly", ReadOnly);

            info.AddValue("Characters", Character.ToXmlString(Characters));


            //info.AddValue("Language", Language);

            //Letzte Property... hier nach darf nichts mehr kommen!
            if (Watermark?.ImageSource != null)
            {
                var bytes = Utilities.ConvertImageToByteArray(Watermark.ImageSource);
                info.AddValue("Watermark", bytes);

                info.AddValue("WatermarkSize", Watermark.Size);
                info.AddValue("WatermarkOpacity", Watermark.Opacity);
            }

            info.AddValue("Tags", Tags);
        }