Beispiel #1
0
 /// <summary>
 /// Overwrites the properties in this HighlightingColor with those from the given color;
 /// but maintains the current values where the properties of the given color return <c>null</c>.
 /// </summary>
 public void MergeWith(HighlightingColor color)
 {
     FreezableHelper.ThrowIfFrozen(this);
     if (color.fontWeight != null)
     {
         this.fontWeight = color.fontWeight;
     }
     if (color.fontStyle != null)
     {
         this.fontStyle = color.fontStyle;
     }
     if (color.foreground != null)
     {
         this.foreground = color.foreground;
     }
     if (color.background != null)
     {
         this.background = color.background;
     }
     if (color.underline != null)
     {
         this.underline = color.underline;
     }
     if (color.fontFamily != null)
     {
         this.fontFamily = color.fontFamily;
     }
     if (color.fontSize != null)
     {
         this.fontSize = color.fontSize;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Deserializes a HighlightingColor.
 /// </summary>
 protected HighlightingColor(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     this.Name = info.GetString("Name");
     if (info.GetBoolean("HasWeight"))
     {
         this.FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
     }
     if (info.GetBoolean("HasStyle"))
     {
         this.FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style"));
     }
     if (info.GetBoolean("HasUnderline"))
     {
         this.Underline = info.GetBoolean("Underline");
     }
     if (info.GetBoolean("HasStrikethrough"))
     {
         this.Strikethrough = info.GetBoolean("Strikethrough");
     }
     this.Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(SimpleHighlightingBrush));
     this.Background = (HighlightingBrush)info.GetValue("Background", typeof(SimpleHighlightingBrush));
     if (info.GetBoolean("HasFamily"))
     {
         this.FontFamily = new FontFamily(info.GetString("Family"));
     }
     if (info.GetBoolean("HasSize"))
     {
         this.FontSize = info.GetInt32("Size");
     }
 }
        /// <summary>
        /// Sets the background brush on the specified text segment.
        /// </summary>
        public void SetBackground(int offset, int length, HighlightingBrush brush)
        {
            int startIndex = GetIndexForOffset(offset);
            int endIndex   = GetIndexForOffset(offset + length);

            for (int i = startIndex; i < endIndex; i++)
            {
                stateChanges[i].Background = brush;
            }
        }
Beispiel #4
0
		/// <summary>
		/// Deserializes a HighlightingColor.
		/// </summary>
		protected HighlightingColor(SerializationInfo info, StreamingContext context)
		{
			if (info == null)
				throw new ArgumentNullException("info");
			this.Name = info.GetString("Name");
			if (info.GetBoolean("HasWeight"))
				this.FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
			if (info.GetBoolean("HasStyle"))
				this.FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style"));
			this.Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(HighlightingBrush));
		}
Beispiel #5
0
        /// <summary>
        /// Deserializes a HighlightingColor.
        /// </summary>
        protected HighlightingColor(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            Name = info.GetString("Name");

            if (info.GetBoolean("HasWeight"))
            {
                FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
            }

            if (info.GetBoolean("HasStyle"))
            {
                FontStyle = (FontStyle?)new FontStyleConverter().ConvertFromInvariantString(info.GetString("Style"));
            }

            Foreground = (HighlightingBrush)info.GetValue("Foreground", typeof(HighlightingBrush));
            Background = (HighlightingBrush)info.GetValue("Background", typeof(HighlightingBrush));
        }
Beispiel #6
0
		/// <summary>
		/// Sets the background brush on the specified text segment.
		/// </summary>
		public void SetBackground(int offset, int length, HighlightingBrush brush)
		{
			int startIndex = GetIndexForOffset(offset);
			int endIndex = GetIndexForOffset(offset + length);
			for (int i = startIndex; i < endIndex; i++) {
				stateChanges[i].Background = brush;
			}
		}
Beispiel #7
0
		static Brush GetBrush(HighlightingBrush b) {
			return b == null ? Brushes.Transparent : b.GetBrush(null);
		}