public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { BrushX s = null != o ? (BrushX)o : new BrushX(Color.Black); s._brushType = (BrushType)info.GetValue("Type", s); switch (s._brushType) { case BrushType.SolidBrush: s._foreColor = (Color)info.GetValue("ForeColor", s); break; case BrushType.HatchBrush: s._foreColor = (Color)info.GetValue("ForeColor", s); s._backColor = (Color)info.GetValue("BackColor", s); s._hatchStyle = (HatchStyle)info.GetEnum("HatchStyle", typeof(HatchStyle)); break; case BrushType.LinearGradientBrush: s._foreColor = (Color)info.GetValue("ForeColor", s); s._backColor = (Color)info.GetValue("BackColor", s); s._wrapMode = (WrapMode)info.GetEnum("WrapMode", typeof(WrapMode)); LinearGradientModeEx gm = (LinearGradientModeEx)info.GetEnum("GradientMode", typeof(LinearGradientModeEx)); string gmname = Enum.GetName(typeof(LinearGradientModeEx), gm); if (gmname.StartsWith("Rev")) { s._exchangeColors = true; s._gradientMode = (LinearGradientMode)Enum.Parse(typeof(LinearGradientMode), gmname.Substring(3)); } else { s._gradientMode = (LinearGradientMode)Enum.Parse(typeof(LinearGradientMode), gmname); } s._gradientShape = (LinearGradientShape)info.GetEnum("GradientShape", typeof(LinearGradientShape)); s._scale = info.GetSingle("Scale"); s._focus = info.GetSingle("Focus"); break; case BrushType.PathGradientBrush: s._foreColor = (Color)info.GetValue("ForeColor", s); s._backColor = (Color)info.GetValue("BackColor", s); s._wrapMode = (WrapMode)info.GetEnum("WrapMode", typeof(WrapMode)); break; case BrushType.TextureBrush: s.TextureImage = (ImageProxy)info.GetValue("Texture", s); s._wrapMode = (WrapMode)info.GetEnum("WrapMode", typeof(WrapMode)); s._scale = info.GetSingle("Scale"); break; } return(s); }
public static void ToLinearGradientMode(LinearGradientModeEx mode, out LinearGradientMode lgm, out bool reverse) { switch (mode) { case LinearGradientModeEx.BackwardDiagonal: lgm = LinearGradientMode.BackwardDiagonal; reverse = false; break; case LinearGradientModeEx.ForwardDiagonal: lgm = LinearGradientMode.ForwardDiagonal; reverse = false; break; default: case LinearGradientModeEx.Horizontal: lgm = LinearGradientMode.Horizontal; reverse = false; break; case LinearGradientModeEx.Vertical: lgm = LinearGradientMode.Vertical; reverse = false; break; case LinearGradientModeEx.RevBackwardDiagonal: lgm = LinearGradientMode.BackwardDiagonal; reverse = true; break; case LinearGradientModeEx.RevForwardDiagonal: lgm = LinearGradientMode.ForwardDiagonal; reverse = true; break; case LinearGradientModeEx.RevHorizontal: lgm = LinearGradientMode.Horizontal; reverse = true; break; case LinearGradientModeEx.RevVertical: lgm = LinearGradientMode.Vertical; reverse = true; break; } }
public static void ToLinearGradientMode(LinearGradientModeEx mode, out LinearGradientMode lgm, out bool reverse) { switch (mode) { case LinearGradientModeEx.BackwardDiagonal: lgm = LinearGradientMode.BackwardDiagonal; reverse = false; break; case LinearGradientModeEx.ForwardDiagonal: lgm = LinearGradientMode.ForwardDiagonal; reverse = false; break; default: case LinearGradientModeEx.Horizontal: lgm = LinearGradientMode.Horizontal; reverse = false; break; case LinearGradientModeEx.Vertical: lgm = LinearGradientMode.Vertical; reverse = false; break; case LinearGradientModeEx.RevBackwardDiagonal: lgm = LinearGradientMode.BackwardDiagonal; reverse = true; break; case LinearGradientModeEx.RevForwardDiagonal: lgm = LinearGradientMode.ForwardDiagonal; reverse = true; break; case LinearGradientModeEx.RevHorizontal: lgm = LinearGradientMode.Horizontal; reverse = true; break; case LinearGradientModeEx.RevVertical: lgm = LinearGradientMode.Vertical; reverse = true; break; } }