コード例 #1
0
 private void ShowCurrentSourceDetails(FontSource fontSource)
 {
     if (fontSource != null)
     {
         SetSourceTypeToBox(fontSource.Type);
         SetSourceFormatToBox(fontSource.Format);
     }
 }
コード例 #2
0
        private void buttonAddSource_Click(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                OnButtonPressedCallback d = buttonAddSource_Click;
                Invoke(d, sender, e);
                return;
            }

            var source = new FontSource {Format = FontFormat.Unknown, Location = "Undefined", Type = SourceTypes.Local};

            var currentFont = _myDataSourceFonts.Current as CSSFont;
            if (currentFont != null)
            {
                currentFont.Sources.Add(source);
                _myDataSourceFonts.ResetCurrentItem();
            }
        }
コード例 #3
0
        private void buttonAddSource_Click(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                OnButtonPressedCallback d = buttonAddSource_Click;
                Invoke(d, sender, e);
                return;
            }

            var source = new FontSource {
                Format = FontFormat.Unknown, Location = "Undefined", Type = SourceTypes.Local
            };

            var currentFont = _myDataSourceFonts.Current as CSSFont;

            if (currentFont != null)
            {
                currentFont.Sources.Add(source);
                _myDataSourceFonts.ResetCurrentItem();
            }
        }
コード例 #4
0
 public void CopyFrom(ICSSFont cssFont)
 {
     if (cssFont == null)
     {
         throw new ArgumentNullException("cssFont");
     }
     if (cssFont == this)
     {
         return;
     }
     _width      = cssFont.FontWidth;
     FontStyle   = cssFont.FontStyle;
     FontVariant = cssFont.FontVariant;
     FontStretch = cssFont.FontStretch;
     _sources.Clear();
     foreach (var fontSource in cssFont.Sources)
     {
         var newSource = new FontSource();
         newSource.CopyFrom(fontSource);
         _sources.Add(newSource);
     }
 }
コード例 #5
0
ファイル: CSSFont.cs プロジェクト: rajeshwarn/fb2converters
        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            string styleAttribute = reader.GetAttribute(StyleAttributeName);
            if (string.IsNullOrEmpty(styleAttribute))
            {
                throw new InvalidDataException("Style attribute can't be empty");
            }
            FontStylesEnum style;
            if (!Enum.TryParse(styleAttribute, true, out style))
            {
                throw new InvalidDataException(string.Format("Invalid style value: {0}",styleAttribute));
            }
            FontStyle = style;

            string variantAttribute = reader.GetAttribute(VariantAttributeName);
            if (string.IsNullOrEmpty(variantAttribute))
            {
                throw new InvalidDataException("Variant attribute can't be empty");
            }
            FontVaiantEnum variant;
            if (!Enum.TryParse(variantAttribute, true, out variant))
            {
                throw new InvalidDataException(string.Format("Invalid variant value: {0}", variantAttribute));
            }
            FontVariant = variant;

            string widthAttribute = reader.GetAttribute(WidthAttributeName);
            if (string.IsNullOrEmpty(widthAttribute))
            {
                throw new InvalidDataException("Width attribute can't be empty");
            }
            FontBoldnessEnum width;
            if (!Enum.TryParse(widthAttribute, true, out width))
            {
                throw new InvalidDataException(string.Format("Invalid Width value: {0}", widthAttribute));
            }
            FontWidth = width;

            string stretchAttribute = reader.GetAttribute(StretchAttributeName);
            if (string.IsNullOrEmpty(stretchAttribute))
            {
                throw new InvalidDataException("Stretch attribute can't be empty");
            }
            FontStretch stretch;
            if (!Enum.TryParse(stretchAttribute, true, out stretch))
            {
                throw new InvalidDataException(string.Format("Invalid Stretch value: {0}", stretchAttribute));
            }
            FontStretch = stretch;

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                        case FontSource.SourceElementName:

                            var source = new FontSource();
                            source.ReadXml(reader);
                            _sources.Add(source);
                            continue;
                    }
                }
                reader.Read();
            }
        }
コード例 #6
0
ファイル: CSSFont.cs プロジェクト: rajeshwarn/fb2converters
 public void CopyFrom(ICSSFont cssFont)
 {
     if (cssFont == null)
     {
         throw new ArgumentNullException("cssFont");
     }
     if (cssFont == this)
     {
         return;
     }
     _width = cssFont.FontWidth;
     FontStyle = cssFont.FontStyle;
     FontVariant = cssFont.FontVariant;
     FontStretch = cssFont.FontStretch;
     _sources.Clear();
     foreach (var fontSource in cssFont.Sources)
     {
         var newSource = new FontSource();
         newSource.CopyFrom(fontSource);
         _sources.Add(newSource);
     }
 }
コード例 #7
0
        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            string styleAttribute = reader.GetAttribute(StyleAttributeName);

            if (string.IsNullOrEmpty(styleAttribute))
            {
                throw new InvalidDataException("Style attribute can't be empty");
            }
            FontStylesEnum style;

            if (!Enum.TryParse(styleAttribute, true, out style))
            {
                throw new InvalidDataException(string.Format("Invalid style value: {0}", styleAttribute));
            }
            FontStyle = style;


            string variantAttribute = reader.GetAttribute(VariantAttributeName);

            if (string.IsNullOrEmpty(variantAttribute))
            {
                throw new InvalidDataException("Variant attribute can't be empty");
            }
            FontVaiantEnum variant;

            if (!Enum.TryParse(variantAttribute, true, out variant))
            {
                throw new InvalidDataException(string.Format("Invalid variant value: {0}", variantAttribute));
            }
            FontVariant = variant;

            string widthAttribute = reader.GetAttribute(WidthAttributeName);

            if (string.IsNullOrEmpty(widthAttribute))
            {
                throw new InvalidDataException("Width attribute can't be empty");
            }
            FontBoldnessEnum width;

            if (!Enum.TryParse(widthAttribute, true, out width))
            {
                throw new InvalidDataException(string.Format("Invalid Width value: {0}", widthAttribute));
            }
            FontWidth = width;

            string stretchAttribute = reader.GetAttribute(StretchAttributeName);

            if (string.IsNullOrEmpty(stretchAttribute))
            {
                throw new InvalidDataException("Stretch attribute can't be empty");
            }
            FontStretch stretch;

            if (!Enum.TryParse(stretchAttribute, true, out stretch))
            {
                throw new InvalidDataException(string.Format("Invalid Stretch value: {0}", stretchAttribute));
            }
            FontStretch = stretch;


            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case FontSource.SourceElementName:

                        var source = new FontSource();
                        source.ReadXml(reader);
                        _sources.Add(source);
                        continue;
                    }
                }
                reader.Read();
            }
        }
コード例 #8
0
 private void ShowCurrentSourceDetails(FontSource fontSource)
 {
     if (fontSource != null)
     {
         SetSourceTypeToBox(fontSource.Type);
         SetSourceFormatToBox(fontSource.Format);
     }
 }