Пример #1
0
        public MNReferencedStyle CreateCopy()
        {
            byte[] data = null;
            using (MemoryStream ms = new MemoryStream())
            {
                using (BinaryWriter bw = new BinaryWriter(ms))
                {
                    RSFileWriter fw = new RSFileWriter(bw);
                    this.Save(fw);
                }
                data = ms.GetBuffer();
            }

            using (MemoryStream ms = new MemoryStream(data))
            {
                MNReferencedStyle ns = new MNReferencedStyle();
                using (BinaryReader br = new BinaryReader(ms))
                {
                    RSFileReader fr = new RSFileReader(br);
                    ns.Load(fr);
                }

                ns.Name += " (copy)";
                return(ns);
            }
        }
Пример #2
0
        public MNReferencedStyle FindStyle(string styleName)
        {
            MNReferencedStyle s = null;

            if (CurrentLanguage != null)
            {
                s = CurrentLanguage.FindStyle(styleName);
            }
            if (s != null)
            {
                return(s);
            }
            if (DefaultLanguage != null)
            {
                s = DefaultLanguage.FindStyle(styleName);
            }
            return(s);
        }
Пример #3
0
        public void ReapplyStyles()
        {
            foreach (MNPage p in Data.Pages)
            {
                foreach (SMControl c in p.Objects)
                {
                    MNReferencedStyle style = DefaultLanguage.FindStyle(c.StyleName);
                    if (style != null)
                    {
                        c.ApplyStyle(style);
                    }
                    else
                    {
                        c.Font.Size = Math.Max(c.Font.Size, 12);
                    }
                }
            }

            foreach (MNPage p in Data.Templates)
            {
                foreach (SMControl c in p.Objects)
                {
                    MNReferencedStyle style = DefaultLanguage.FindStyle(c.StyleName);
                    if (style != null)
                    {
                        c.ApplyStyle(style);
                    }
                    else
                    {
                        c.Font.Size = Math.Max(c.Font.Size, 12);
                    }
                }
            }

            Book.Version = Math.Max(2, Book.Version);
        }
Пример #4
0
        public void InitialiseDefaultStyles()
        {
            MNReferencedStyle ds = new MNReferencedStyle();

            ds.Name                     = "Default";
            ds.Font.Size                = 14f;
            ds.NormalState.ForeColor    = Color.Black;
            ds.NormalState.BackColor    = Color.Transparent;
            ds.NormalState.BorderStyle  = SMBorderStyle.None;
            ds.Paragraph.Align          = SMHorizontalAlign.Left;
            ds.Paragraph.VertAlign      = SMVerticalAlign.Top;
            ds.HighlightState.ForeColor = Color.Blue;
            ds.HighlightState.BackColor = Color.LightBlue;
            ds.ContentPadding.Bottom    = 5;
            ds.ContentPadding.Left      = 5;
            ds.ContentPadding.Right     = 5;
            ds.ContentPadding.Top       = 5;
            DefaultLanguage.Styles.Add(ds);

            ds                          = new MNReferencedStyle();
            ds.Name                     = "Default Centered";
            ds.Font.Size                = 14f;
            ds.NormalState.ForeColor    = Color.Black;
            ds.NormalState.BackColor    = Color.Transparent;
            ds.NormalState.BorderStyle  = SMBorderStyle.None;
            ds.Paragraph.Align          = SMHorizontalAlign.Left;
            ds.Paragraph.VertAlign      = SMVerticalAlign.Top;
            ds.HighlightState.ForeColor = Color.Blue;
            ds.HighlightState.BackColor = Color.LightBlue;
            ds.ContentPadding.Bottom    = 5;
            ds.ContentPadding.Left      = 5;
            ds.ContentPadding.Right     = 5;
            ds.ContentPadding.Top       = 5;
            DefaultLanguage.Styles.Add(ds);

            ds                            = new MNReferencedStyle();
            ds.Name                       = "NavigationButton White";
            ds.Font.Size                  = 20f;
            ds.NormalState.ForeColor      = Color.Black;
            ds.NormalState.BackColor      = Color.White;
            ds.NormalState.BorderStyle    = SMBorderStyle.RoundRectangle;
            ds.NormalState.BorderColor    = Color.Black;
            ds.NormalState.BorderWidth    = 1f;
            ds.HighlightState.BackColor   = Color.Gray;
            ds.HighlightState.BorderColor = Color.DarkGreen;
            ds.HighlightState.BorderStyle = SMBorderStyle.RoundRectangle;
            ds.HighlightState.BorderWidth = 2f;
            ds.HighlightState.ForeColor   = Color.DarkGreen;
            ds.Paragraph.Align            = SMHorizontalAlign.Center;
            ds.Paragraph.VertAlign        = SMVerticalAlign.Center;
            DefaultLanguage.Styles.Add(ds);

            ds                             = new MNReferencedStyle();
            ds.Name                        = "NavigationButton2";
            ds.Font.Size                   = 20f;
            ds.NormalState.ForeColor       = Color.White;
            ds.NormalState.BackColor       = Color.FromArgb(255, 192, 128);
            ds.NormalState.BorderStyle     = SMBorderStyle.RoundRectangle;
            ds.NormalState.BorderColor     = Color.FromArgb(255, 128, 0);
            ds.NormalState.BorderWidth     = 2f;
            ds.NormalState.CornerRadius    = 15;
            ds.HighlightState.BackColor    = Color.FromArgb(255, 128, 0);
            ds.HighlightState.BorderColor  = Color.FromArgb(255, 192, 128);
            ds.HighlightState.BorderStyle  = SMBorderStyle.RoundRectangle;
            ds.HighlightState.BorderWidth  = 2f;
            ds.HighlightState.CornerRadius = 15;
            ds.HighlightState.ForeColor    = Color.White;
            ds.Paragraph.Align             = SMHorizontalAlign.Center;
            ds.Paragraph.VertAlign         = SMVerticalAlign.Center;
            DefaultLanguage.Styles.Add(ds);


            ds                             = new MNReferencedStyle();
            ds.Name                        = "Footnote";
            ds.Font.Size                   = 16f;
            ds.NormalState.ForeColor       = Color.Black;
            ds.NormalState.BackColor       = Color.Silver;
            ds.NormalState.BorderStyle     = SMBorderStyle.RoundRectangle;
            ds.NormalState.CornerRadius    = 10;
            ds.ContentPadding.Bottom       = 20;
            ds.ContentPadding.Left         = 25;
            ds.ContentPadding.Right        = 25;
            ds.ContentPadding.Top          = 10;
            ds.Paragraph.Align             = SMHorizontalAlign.Left;
            ds.Paragraph.VertAlign         = SMVerticalAlign.Top;
            ds.HighlightState.ForeColor    = Color.Blue;
            ds.HighlightState.BackColor    = Color.LightBlue;
            ds.HighlightState.CornerRadius = 10;
            DefaultLanguage.Styles.Add(ds);

            ds                          = new MNReferencedStyle();
            ds.Name                     = "BigLetters";
            ds.Font.Size                = 50f;
            ds.NormalState.ForeColor    = Color.Black;
            ds.NormalState.BackColor    = Color.Transparent;
            ds.NormalState.BorderStyle  = SMBorderStyle.None;
            ds.Paragraph.Align          = SMHorizontalAlign.Center;
            ds.Paragraph.VertAlign      = SMVerticalAlign.Center;
            ds.HighlightState.ForeColor = Color.Blue;
            ds.HighlightState.BackColor = Color.LightBlue;
            DefaultLanguage.Styles.Add(ds);

            ds                          = new MNReferencedStyle();
            ds.Name                     = "ChildrenText Centered";
            ds.Font.Size                = 30f;
            ds.NormalState.ForeColor    = Color.Black;
            ds.NormalState.BackColor    = Color.Transparent;
            ds.NormalState.BorderStyle  = SMBorderStyle.None;
            ds.Paragraph.Align          = SMHorizontalAlign.Center;
            ds.Paragraph.VertAlign      = SMVerticalAlign.Center;
            ds.HighlightState.ForeColor = Color.Blue;
            ds.HighlightState.BackColor = Color.LightBlue;
            DefaultLanguage.Styles.Add(ds);

            ds                          = new MNReferencedStyle();
            ds.Name                     = "ChildrenText";
            ds.Font.Size                = 30f;
            ds.NormalState.ForeColor    = Color.Black;
            ds.NormalState.BackColor    = Color.Transparent;
            ds.NormalState.BorderStyle  = SMBorderStyle.None;
            ds.Paragraph.Align          = SMHorizontalAlign.Left;
            ds.Paragraph.VertAlign      = SMVerticalAlign.Top;
            ds.HighlightState.ForeColor = Color.Blue;
            ds.HighlightState.BackColor = Color.LightBlue;
            DefaultLanguage.Styles.Add(ds);

            DefaultLanguage.Modified = true;
        }
Пример #5
0
        public bool Load(RSFileReader br, bool fullRead)
        {
            if (!br.ReadHeader(p_FileHeader))
            {
                return(false);
            }

            Clear();
            byte tag;

            while ((tag = br.ReadByte()) != 0)
            {
                switch (tag)
                {
                case 10:
                    string key   = br.ReadString();
                    string value = br.ReadString();
                    Properties.Add(key, value);
                    if (key.Equals("TotalWork"))
                    {
                        long la;
                        if (long.TryParse(value, out la))
                        {
                            WorkTime.SetTotalWorkTime(la);
                        }
                    }
                    break;

                case 100:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedText rt = new MNReferencedText();
                    rt.Load(br);
                    Texts.Add(rt);
                    break;

                case 101:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedImage ri = new MNReferencedImage();
                    ri.Load(br);
                    Images.Add(ri);
                    break;

                case 102:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedSound rs = new MNReferencedSound();
                    rs.Load(br);
                    Sounds.Add(rs);
                    break;

                case 103:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedAudioText ra = new MNReferencedAudioText();
                    ra.Load(br);
                    AudioTexts.Add(ra);
                    break;

                case 104:
                    if (!fullRead)
                    {
                        return(true);
                    }
                    MNReferencedStyle rsa = new MNReferencedStyle();
                    rsa.Load(br);
                    Styles.Add(rsa);
                    break;

                default:
                    LoadMessage = string.Format("Unknown tag {0} at position {1} in the file.", tag, br.Position);
                    return(false);
                }
            }

            Modified = false;
            return(true);
        }