private void RemoveGradientStop(GradientThumb toRemoveThumb) { if (toRemoveThumb == null || !(toRemoveThumb.Tag is double) || !(toRemoveThumb.Parent is Canvas)) { return; } var offsetTag = (double)toRemoveThumb.Tag; var linebrush = GradientBorder.Background as LinearGradientBrush; var removeTag = linebrush.GradientStops.FirstOrDefault(x => x.Offset == offsetTag); if (removeTag != null) { linebrush.GradientStops.Remove(removeTag); } var canvas = toRemoveThumb.Parent as Canvas; //canvas.Children.Remove(toRemoveThumb); toRemoveThumb.Opacity = 0d; var rtnStyle = new StyleColor(); rtnStyle.FillType = ColorFillType.Gradient; rtnStyle.Frames = new Dictionary <double, int>(); foreach (var gs in linebrush.GradientStops) { rtnStyle.Frames.Add(gs.Offset, gs.Color.ToArgb()); } CurrentStyle = rtnStyle; }
private void TransparentButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Border targetBox = e.OriginalSource as Border; if (targetBox == null) { return; } System.Windows.Media.Color Color16 = (targetBox.Background as SolidColorBrush).Color; System.Windows.Media.Color Color32 = System.Windows.Media.Color.FromArgb(0, Color16.R, Color16.G, Color16.B); if (this.IsSolidType()) { ColorSelected = new StyleColor(ColorFillType.Solid, Color32.ToArgb()); InvokeCommand(ColorSelected); RaiseEvent(new RibbonDismissPopupEventArgs(RibbonDismissPopupMode.Always)); } else { GradientEditor1.SelectedColor = Color32; //InvokeCommand(GradientEditor1.CurrentStyle); //RaiseEvent(new RibbonDismissPopupEventArgs(RibbonDismissPopupMode.Always)); } }
void UpdateResourceLifetimeColor(int passIndex, StyleColor colorRead, StyleColor colorWrite) { var debugData = m_CurrentRenderGraph.GetDebugData(); var pass = debugData.passList[passIndex]; if (pass.culled) { return; } for (int type = 0; type < (int)RenderGraphResourceType.Count; ++type) { foreach (int resourceRead in pass.resourceReadLists[type]) { CellElement resourceLifetime = m_ResourceElementsInfo[type][resourceRead].lifetime as CellElement; if (resourceLifetime != null) { resourceLifetime.SetColor(colorRead); } } foreach (int resourceWrite in pass.resourceWriteLists[type]) { CellElement resourceLifetime = m_ResourceElementsInfo[type][resourceWrite].lifetime as CellElement; if (resourceLifetime != null) { resourceLifetime.SetColor(colorWrite); } } } }
public VisualElementStylesData(bool isShared) { this.isShared = isShared; // Initialize non trivial properties left = StyleSheetCache.GetInitialValue(StylePropertyID.PositionLeft).ToStyleLength(); top = StyleSheetCache.GetInitialValue(StylePropertyID.PositionTop).ToStyleLength(); right = StyleSheetCache.GetInitialValue(StylePropertyID.PositionRight).ToStyleLength(); bottom = StyleSheetCache.GetInitialValue(StylePropertyID.PositionBottom).ToStyleLength(); width = StyleSheetCache.GetInitialValue(StylePropertyID.Width).ToStyleLength(); height = StyleSheetCache.GetInitialValue(StylePropertyID.Height).ToStyleLength(); minWidth = StyleSheetCache.GetInitialValue(StylePropertyID.MinWidth).ToStyleLength(); minHeight = StyleSheetCache.GetInitialValue(StylePropertyID.MinHeight).ToStyleLength(); maxWidth = StyleSheetCache.GetInitialValue(StylePropertyID.MaxWidth).ToStyleLength(); maxHeight = StyleSheetCache.GetInitialValue(StylePropertyID.MaxHeight).ToStyleLength(); alignSelf = (int)StyleSheetCache.GetInitialValue(StylePropertyID.AlignSelf).number; alignItems = (int)StyleSheetCache.GetInitialValue(StylePropertyID.AlignItems).number; alignContent = (int)StyleSheetCache.GetInitialValue(StylePropertyID.AlignContent).number; flexGrow = StyleSheetCache.GetInitialValue(StylePropertyID.FlexGrow).ToStyleFloat(); flexShrink = StyleSheetCache.GetInitialValue(StylePropertyID.FlexShrink).ToStyleFloat(); flexBasis = StyleSheetCache.GetInitialValue(StylePropertyID.FlexBasis).ToStyleLength(); color = StyleSheetCache.GetInitialValue(StylePropertyID.Color).color; borderLeftColor = StyleSheetCache.GetInitialValue(StylePropertyID.BorderLeftColor).color; borderTopColor = StyleSheetCache.GetInitialValue(StylePropertyID.BorderTopColor).color; borderRightColor = StyleSheetCache.GetInitialValue(StylePropertyID.BorderRightColor).color; borderBottomColor = StyleSheetCache.GetInitialValue(StylePropertyID.BorderBottomColor).color; opacity = StyleSheetCache.GetInitialValue(StylePropertyID.Opacity).number; unityBackgroundImageTintColor = StyleSheetCache.GetInitialValue(StylePropertyID.BackgroundImageTintColor).color; }
public override void DrawLine(GravurGIS.Styles.StylePen pen, int x1, int y1, int x2, int y2) { StyleColor color = pen.BackgroundBrush.Color; _graphics.DrawLine(new Pen(Color.FromArgb(color.R, color.G, color.B), pen.Width), x1, y1, x2, y2); }
public ReddotNode(string key, string name = "Reddot") { title = "Reddot"; inputPort = ReddotPort.Create <Edge>(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, typeof(string)); inputPort.portName = "parents"; inputContainer.Add(inputPort); outputPort = ReddotPort.Create <Edge>(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, typeof(string)); outputPort.portName = "children"; outputContainer.Add(outputPort); keyText = new TextField(); keyText.value = key; mainContainer.Add(keyText); titleContainer.RemoveAt(0); nameText = new TextField(); nameText.value = name; nameText.style.minWidth = 100; nameText.style.maxWidth = 100; var inputElement = nameText.ElementAt(0); var color = new StyleColor(Color.clear); inputElement.style.backgroundColor = color; inputElement.style.borderLeftColor = color; inputElement.style.borderRightColor = color; inputElement.style.borderTopColor = color; inputElement.style.borderBottomColor = color; titleContainer.Insert(0, nameText); }
protected virtual void OnSelectedColorChanged(Color oldSelectedColor, Color newSelectedColor) { if (this.selectedThumb == null || !(this.selectedThumb.Tag is double)) { return; } if (!(GradientBorder.Background is LinearGradientBrush)) { return; } this.selectedThumb.SetColor(newSelectedColor); var linebrush = GradientBorder.Background as LinearGradientBrush; var offset = (double)this.selectedThumb.Tag; var stop = linebrush.GradientStops.Where(x => x.Offset == offset).FirstOrDefault(); if (stop != null) { stop.Color = newSelectedColor; } var rtnStyle = new StyleColor(); rtnStyle.FillType = ColorFillType.Gradient; rtnStyle.Frames = new Dictionary <double, int>(); foreach (var gs in linebrush.GradientStops) { rtnStyle.Frames.Add(gs.Offset, gs.Color.ToArgb()); } CurrentStyle = rtnStyle; }
private void OnColorChanged() { _currentColor = ColorSelected; _orignColor = _currentColor; //Initial Color panel var solidbrush = default(SolidColorBrush); if (_currentColor.FillType == ColorFillType.Gradient && _currentColor.Frames != null && _currentColor.Frames.Count > 0) { solidbrush = _currentColor.Frames.First().Value.ToBrush() as SolidColorBrush; } else { solidbrush = _currentColor.ARGB.ToBrush() as SolidColorBrush; } //Initial color-32 information string sARGB = ColorPanelShow.Fill.ToString(); string sRGB = @"#" + sARGB.Substring(3, sARGB.Length - 3); ColorInfoShow.Text = sRGB; //Initialize the Alpha value OpacityText.Text = Convert.ToInt32(solidbrush.Color.A * 100 / 255).ToString(); OpacitySlider.UpdateLayout(); //TargetColorRec.Fill = new SolidColorBrush(Color32); //TargetColorRec.UpdateLayout(); }
public void ConvertColorToStyleColor() { Color32 c = new Color32(128, 128, 128, 1); StyleColor styleColor = new StyleColor(c); Assert.AreEqual((Color)c, (Color)styleColor); }
public static void SetBordersColor(this IStyle style, StyleColor styleColor) { style.borderBottomColor = styleColor; style.borderLeftColor = styleColor; style.borderRightColor = styleColor; style.borderTopColor = styleColor; }
public SVGWidgetViewModel(IWidget widget) { _model = new SVGModel(widget); _bSupportBorder = false; _bSupportBackground = false; _bSupportText = false; _bSupportTextVerAlign = false; _bSupportTextHorAlign = false; widgetGID = widget.Guid; Type = ObjectType.SVG; _bSupportGradientBackground = false; _bSupportGradientBorderline = false; _bSupportRotate = true; _bSupportTextRotate = false; _BackgroundColor = new StyleColor(ColorFillType.Solid, 0); _StrokeColor = new StyleColor(ColorFillType.Solid, 0); // Create conversion options and a file reader WpfDrawingSettings settings = new WpfDrawingSettings(); settings.IncludeRuntime = true; settings.TextAsGeometry = false; _converter = new FileSvgReader(settings); SVGSource = LoadSvg((_model as SVGModel).SVGStream); }
public static void StyleBorderColor(this VisualElement ui, StyleColor left, StyleColor right, StyleColor top, StyleColor bottom) { ui.style.borderLeftColor = left; ui.style.borderRightColor = right; ui.style.borderTopColor = top; ui.style.borderBottomColor = bottom; }
private StylePen interpolatePen(StylePen min, StylePen max, Double attr) { Double frac = fraction(attr); StyleColor color = StyleColor.Interpolate(min.BackgroundBrush.Color, max.BackgroundBrush.Color, frac); StylePen pen = new StylePen(color, interpolateDouble(min.Width, max.Width, attr)); pen.MiterLimit = interpolateFloat(min.MiterLimit, max.MiterLimit, attr); pen.StartCap = (frac > 0.5 ? max.StartCap : min.StartCap); pen.EndCap = (frac > 0.5 ? max.EndCap : min.EndCap); pen.LineJoin = (frac > 0.5 ? max.LineJoin : min.LineJoin); pen.DashStyle = (frac > 0.5 ? max.DashStyle : min.DashStyle); if (min.DashStyle == LineDashStyle.Custom && max.DashStyle == LineDashStyle.Custom) { pen.DashPattern = (frac > 0.5 ? max.DashPattern : min.DashPattern); } pen.DashOffset = (frac > 0.5 ? max.DashOffset : min.DashOffset); pen.DashCap = (frac > 0.5 ? max.DashCap : min.DashCap); if (min.CompoundArray.Length > 0 && max.CompoundArray.Length > 0) { pen.CompoundArray = (frac > 0.5 ? max.CompoundArray : min.CompoundArray); } pen.Alignment = (frac > 0.5 ? max.Alignment : min.Alignment); //pen.CustomStartCap = (frac > 0.5 ? max.CustomStartCap : min.CustomStartCap); //Throws ArgumentException //pen.CustomEndCap = (frac > 0.5 ? max.CustomEndCap : min.CustomEndCap); //Throws ArgumentException return(pen); }
public static System.Windows.Media.Brush ToBrush(this StyleColor sc) { if (sc.FillType == ColorFillType.Solid) { return(new System.Windows.Media.SolidColorBrush(StyleColorExtension.FromArgb(sc.ARGB))); } else if (sc.FillType == ColorFillType.Gradient) { var lineb = new System.Windows.Media.LinearGradientBrush(); var newFrames = sc.Frames; if (newFrames == null || newFrames.Count == 0) { newFrames = new Dictionary <double, int>(); newFrames[0] = -1; newFrames[1] = -16777216; } foreach (var keypair in newFrames) { var gradientStop = new System.Windows.Media.GradientStop( StyleColorExtension.FromArgb(keypair.Value), keypair.Key); lineb.GradientStops.Add(gradientStop); } var aRotateTransform = new System.Windows.Media.RotateTransform(); aRotateTransform.CenterX = 0.5; aRotateTransform.CenterY = 0.5; aRotateTransform.Angle = sc.Angle; lineb.RelativeTransform = aRotateTransform; return(lineb); } return(null); }
void gradientThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { var self = sender as Control; if (self != null && self.Parent is Canvas) { if (this.selectedThumb == null || !(this.selectedThumb.Tag is double)) { return; } if (!(GradientBorder.Background is LinearGradientBrush)) { return; } var linebrush = GradientBorder.Background as LinearGradientBrush; var offset = (double)this.selectedThumb.Tag; var stop = linebrush.GradientStops.Where(x => x.Offset == offset).FirstOrDefault(); if (stop != null) { var canvas = self.Parent as Canvas; double left = Canvas.GetLeft(self); var newOffset = Math.Round(left / canvas.ActualWidth, 2); while (linebrush.GradientStops.Except(new List <GradientStop> { stop }).Any(x => x.Offset == newOffset)) { if (offset < newOffset) { /// move to right newOffset -= 0.0001d; } else { /// move to left newOffset += 0.0001d; } } stop.Offset = newOffset; this.selectedThumb.Tag = newOffset; var rtnStyle = new StyleColor(); rtnStyle.FillType = ColorFillType.Gradient; rtnStyle.Frames = new Dictionary <double, int>(); foreach (var gs in linebrush.GradientStops) { if (!rtnStyle.Frames.ContainsKey(gs.Offset)) { rtnStyle.Frames.Add(gs.Offset, gs.Color.ToArgb()); } } CurrentStyle = rtnStyle; } } }
private void BindAssetListViewItem(VisualElement element, int index) { var sourceData = _bundleListView.itemsSource as List <DebugBundleInfo>; var bundleInfo = sourceData[index]; // Bundle Name var label1 = element.Q <Label>("Label1"); label1.text = bundleInfo.BundleName; // Ref Count var label3 = element.Q <Label>("Label3"); label3.text = bundleInfo.RefCount.ToString(); // Status StyleColor textColor; if (bundleInfo.Status == AssetBundleLoaderBase.EStatus.Failed) { textColor = new StyleColor(Color.yellow); } else { textColor = label1.style.color; } var label4 = element.Q <Label>("Label4"); label4.text = bundleInfo.Status.ToString(); label4.style.color = textColor; }
protected override void RegisterCallbacksOnTarget() { OriginalColor = target.style.backgroundColor; target.RegisterCallback <MouseDownEvent>(OnMouseDownEvent); target.RegisterCallback <MouseLeaveEvent>(OnMouseLeaveEvent); target.RegisterCallback <MouseUpEvent>(OnMouseUpEvent); }
private static void OnInitialColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { GradientEditor target = (GradientEditor)d; StyleColor oldInitialColor = (StyleColor)e.OldValue; StyleColor newInitialColor = target.InitialColor; target.OnInitialColorChanged(oldInitialColor, newInitialColor); }
private static void CompileBoxAreaNoKeyword(StylePropertyReader reader, out StyleColor top, out StyleColor right, out StyleColor bottom, out StyleColor left) { top = Color.clear; right = Color.clear; bottom = Color.clear; left = Color.clear; switch (reader.valueCount) { case 0: break; case 1: top = (right = (bottom = (left = reader.ReadStyleColor(0)))); break; case 2: top = (bottom = reader.ReadStyleColor(0)); left = (right = reader.ReadStyleColor(1)); break; case 3: top = reader.ReadStyleColor(0); left = (right = reader.ReadStyleColor(1)); bottom = reader.ReadStyleColor(2); break; default: top = reader.ReadStyleColor(0); right = reader.ReadStyleColor(1); bottom = reader.ReadStyleColor(2); left = reader.ReadStyleColor(3); break; } bool flag = top.keyword > StyleKeyword.Undefined; if (flag) { top.value = Color.clear; } bool flag2 = right.keyword > StyleKeyword.Undefined; if (flag2) { right.value = Color.clear; } bool flag3 = bottom.keyword > StyleKeyword.Undefined; if (flag3) { bottom.value = Color.clear; } bool flag4 = left.keyword > StyleKeyword.Undefined; if (flag4) { left.value = Color.clear; } }
public static StyleColor ToStyleColor(string str) { var color = new StyleColor(); var strTmp = str; if (strTmp.StartsWith("#")) { return(color.value = str.FromHex()); } if (str[0] == ' ') { str = str.Substring(1); } var numbers = new List <string>(); string start = str.Substring(str.IndexOf('(') + 1); while (true) { if (start.IndexOf(',') >= 0) { numbers.Add(start.Substring(0, start.IndexOf(','))); start = start.Substring(start.IndexOf(',') + 2); } else { numbers.Add(start.Substring(0, start.IndexOf(')'))); break; } } switch (str.Substring(0, str.IndexOf('('))) { case "rgb": color.value = new Color( float.Parse(numbers[0]) / 255.0f, float.Parse(numbers[1]) / 255.0f, float.Parse(numbers[2]) / 255.0f); break; case "rgba": color.value = new Color( float.Parse(numbers[0]) / 255.0f, float.Parse(numbers[1]) / 255.0f, float.Parse(numbers[2]) / 255.0f, float.Parse(numbers[3])); break; case "#": color.value = str.FromHex(); break; } return(color); }
private void onRequestBackgroundColorChange(StyleColor current, StyleColor requested) { EventHandler <MapViewPropertyChangeEventArgs <StyleColor> > e = BackgroundColorChangeRequested; if (e != null) { e(this, new MapViewPropertyChangeEventArgs <StyleColor>(current, requested)); } }
protected override void RegisterCallbacksOnTarget() { OriginalColor = Slab.style.backgroundColor; SecondaryColor = new StyleColor(new Color(255, 169, 140)); target.RegisterCallback <MouseDownEvent>(OnMouseDownEvent); target.RegisterCallback <MouseLeaveEvent>(OnMouseLeaveEvent); target.RegisterCallback <MouseUpEvent>(OnMouseUpEvent); }
protected virtual void OnInitialColorChanged(StyleColor oldInitialColor, StyleColor newInitialColor) { if (!(GradientBorder.Background is LinearGradientBrush)) { return; } var linebrush = GradientBorder.Background as LinearGradientBrush; linebrush.GradientStops.Clear(); var newFrames = newInitialColor.Frames; if (newFrames == null || newFrames.Count == 0) { newFrames = new Dictionary <double, int>(); newFrames[0] = -1; newFrames[1] = -16777216; } var parentCanvas = this.canvas; parentCanvas.Children.Clear(); var actualWidth = parentCanvas.ActualWidth; foreach (var keypair in newFrames) { var gradientThumb = new GradientThumb { Template = this.Resources["GradientThumbTemplate"] as ControlTemplate, Tag = keypair.Key }; gradientThumb.DragDelta += gradientThumb_DragDelta; gradientThumb.MouseClicked += gradientThumb_MouseDown; gradientThumb.ThumbRemoving += gradientThumb_ThumbRemoving; gradientThumb.ThumbRecovering += gradientThumb_ThumbRecovering; gradientThumb.ThumbRemoved += gradientThumb_ThumbRemoved; Canvas.SetLeft(gradientThumb, keypair.Key * actualWidth); parentCanvas.Children.Add(gradientThumb); var drawingColor = System.Drawing.Color.FromArgb(keypair.Value); gradientThumb.SetColor(Color.FromArgb(drawingColor.A, drawingColor.R, drawingColor.G, drawingColor.B)); var gradientStop = new GradientStop( Color.FromArgb(drawingColor.A, drawingColor.R, drawingColor.G, drawingColor.B), keypair.Key); linebrush.GradientStops.Add(gradientStop); } this.selectedThumb = parentCanvas.Children[0] as GradientThumb; this.selectedThumb.SetSelected(true); this.SelectedColor = linebrush.GradientStops[0].Color; CurrentStyle = newInitialColor; }
// ---------------------------------------------- @HoverBackground // --------------------------------------------------------------- /// <summary> /// Adds background hover capability that will not be lost like CSS:hover when programatically setting background color /// </summary> /// <example> /// <code> /// var originalColor = ColorUtil.FromHex("#BABABA"); /// var hoverBGColor = ColorUtil.FromHex("#2F569C"); /// /// label.HoverBackground(originalColor, hoverBGColor); /// </code> /// </example>> /// <param name="target">The element in which this function will be applied</param> /// <param name="original">The original color of the element being changed. Can be obtained and passed via 'visualElement.style.backgroundColor.value'</param> /// <param name="hoverColor">The color to fade to when element is hovered</param> /// <param name="condition">Create a condition to pass to this function. Example: bool Condition(VisualElement sRow) => selectedRow == packageListRow;</param> /// <param name="conditionElement">The element in which the optional condition will be evaluated. Ex. in the example of 'bool Condition(VisualElement sRow) => selectedRow == packageListRow;', the conditionalElement would be 'VisualElement selectedRow'</param> /// <param name="animate">Whether to animate the transition of the background color</param> public static void HoverBackground(this VisualElement target, StyleColor original, Color hoverColor, Func <VisualElement, bool> condition = null, VisualElement conditionElement = null, bool animate = false) { var mouseOver = new ValueAnimation <StyleValues>(); var mouseOut = new ValueAnimation <StyleValues>(); if (animate) { mouseOver = target.AnimateBackgroundColor(original.value, hoverColor, 250); mouseOver.KeepAlive(); mouseOut = target.AnimateBackgroundColor(hoverColor, original.value, 250); mouseOut.KeepAlive(); } target.RegisterCallback <MouseOverEvent>(evt => { if (condition != null && condition(conditionElement)) { return; } if (mouseOut.isRunning) { mouseOut.Stop(); } if (animate) { target.schedule.Execute(() => { mouseOver.Start(); }).StartingIn(50); } else { target.style.backgroundColor = hoverColor; } evt.StopPropagation(); }); target.RegisterCallback <MouseOutEvent>(evt => { if (condition != null && condition(conditionElement)) { return; } if (mouseOver.isRunning) { mouseOver.Stop(); } if (animate) { target.schedule.Execute(() => { mouseOut.Start(); }).StartingIn(50); } else { target.style.backgroundColor = original; } evt.StopPropagation(); }); }
internal static StyleColor?GetColor(XElement node, string nodeName) { if (node != null) { string hex = GetString(node, nodeName, false); return(StyleColor.FromString(hex)); } return(null); }
private void ApplyUnsetStyleValue(StylePropertyReader reader, InheritedStylesData inheritedStylesData) { if (inheritedStylesData == null) { ApplyInitialStyleValue(reader); } var specificity = reader.specificity; switch (reader.propertyID) { case StylePropertyID.Color: color = inheritedStylesData.color; color.specificity = specificity; break; case StylePropertyID.Font: unityFont = inheritedStylesData.font; unityFont.specificity = specificity; break; case StylePropertyID.FontSize: fontSize = inheritedStylesData.fontSize; fontSize.specificity = specificity; break; case StylePropertyID.FontStyleAndWeight: unityFontStyleAndWeight = inheritedStylesData.unityFontStyle; unityFontStyleAndWeight.specificity = specificity; break; case StylePropertyID.UnityTextAlign: unityTextAlign = inheritedStylesData.unityTextAlign; unityTextAlign.specificity = specificity; break; case StylePropertyID.Visibility: visibility = inheritedStylesData.visibility; visibility.specificity = specificity; break; case StylePropertyID.WhiteSpace: whiteSpace = inheritedStylesData.whiteSpace; whiteSpace.specificity = specificity; break; case StylePropertyID.Custom: RemoveCustomStyleProperty(reader.property.name); break; default: ApplyInitialStyleValue(reader.propertyID, specificity); break; } }
private static VisualElement MakeItem() { var label = new Label(); label.name = "history-item-label"; var stylecolor = new StyleColor(); stylecolor.value = Color.cyan; label.style.color = stylecolor; //label.style.height = 12; return(label); }
public LokiFlowPort(Orientation portOrientation, Direction portDirection, Capacity capacity, string name = "Unnamed Port") : base(portOrientation, portDirection, capacity, name) { var ss = LokiResources.Get <StyleSheet>("StyleSheets/LokiFlowPort.uss"); styleSheets.Add(ss); defaultColor = new Color(0f, 0.62f, 0.79f, 0.82f); color = defaultColor; generateVisualContent += OnGenerateVisualContent; }
void gradientThumb_ThumbRecovering(object sender, EventArgs e) { var thumb = sender as GradientThumb; if (thumb == null || !(thumb.Parent is Canvas)) { return; } thumb.Opacity = 1d; var thumbColor = thumb.GetColor(); var linebrush = GradientBorder.Background as LinearGradientBrush; var canvas = thumb.Parent as Canvas; var left = Canvas.GetLeft(thumb); var newOffset = Math.Round(left / canvas.ActualWidth, 2); while (linebrush.GradientStops.Any(x => x.Offset == newOffset)) { if (newOffset == 0d) { /// move to right newOffset += 0.0001d; } else { /// move to left newOffset -= 0.0001d; } } var gradientStop = new GradientStop( Color.FromArgb(thumbColor.A, thumbColor.R, thumbColor.G, thumbColor.B), newOffset); linebrush.GradientStops.Add(gradientStop); thumb.Tag = newOffset; var rtnStyle = new StyleColor(); rtnStyle.FillType = ColorFillType.Gradient; rtnStyle.Frames = new Dictionary <double, int>(); foreach (var gs in linebrush.GradientStops) { if (!rtnStyle.Frames.ContainsKey(gs.Offset)) { rtnStyle.Frames.Add(gs.Offset, gs.Color.ToArgb()); } } CurrentStyle = rtnStyle; }
public void CopyFrom(InheritedStylesData other) { if (other != null) { color = other.color; font = other.font; fontSize = other.fontSize; visibility = other.visibility; whiteSpace = other.whiteSpace; unityFontStyle = other.unityFontStyle; unityTextAlign = other.unityTextAlign; } }
/// <summary> /// Creates a linear gradient scale from two colors /// </summary> /// <param name="fromColor"></param> /// <param name="toColor"></param> /// <returns></returns> public static StyleColorBlend TwoColors(StyleColor fromColor, StyleColor toColor) { return new StyleColorBlend(new StyleColor[] { fromColor, toColor }, new Single[] { 0f, 1f }); }
private void onRequestBackgroundColorChange(StyleColor current, StyleColor requested) { EventHandler<MapViewPropertyChangeEventArgs<StyleColor>> e = BackgroundColorChangeRequested; if (e != null) { e(this, new MapViewPropertyChangeEventArgs<StyleColor>(current, requested)); } }
protected override void SetViewBackgroundColor(StyleColor fromColor, StyleColor toColor) { ViewControl.BackColor = ViewConverter.Convert(toColor); }
/// <summary> /// Initializes a new instance of the ColorBlend class. /// </summary> /// <param name="colors">An array of Color structures that represents the /// colors to use at corresponding positions along a gradient.</param> /// <param name="positions">An array of values that specify percentages of /// distance along the gradient line.</param> public StyleColorBlend(StyleColor[] colors, Single[] positions) { _colors = colors; _positions = positions; }
/// <summary> /// Creates an instance of a <see cref="SolidStyleBrush"/> with the given color. /// </summary> /// <param name="color">The color of the brush.</param> public SolidStyleBrush(StyleColor color) : base(color) { }
/// <summary> /// Creates a new <see cref="StylePen"/> with the given solid /// <paramref name="color"/> and <paramref name="width"/>. /// </summary> /// <param name="color">Color of the pen.</param> /// <param name="width">Width of the pen.</param> public StylePen(StyleColor color, double width) : this(new SolidStyleBrush(color), width) { }
/// <summary> /// Creates a linear gradient scale from three colors /// </summary> public static StyleColorBlend ThreeColors(StyleColor fromColor, StyleColor middleColor, StyleColor toColor) { return new StyleColorBlend(new StyleColor[] { fromColor, middleColor, toColor }, new float[] { 0f, 0.5f, 1f }); }
/// <summary> /// Initializes a new instance of the ColorBlend class. /// </summary> /// <param name="colors">An array of Color structures that represents the /// colors to use at corresponding positions along a gradient.</param> /// <param name="positions">An array of values that specify percentages of /// distance along the gradient line.</param> public StyleColorBlend(StyleColor[] colors, float[] positions) { _colors = colors; _positions = positions; }
/// <summary> /// Creates a new instance of a StyleBrush with the given <paramref name="color"/>. /// </summary> /// <param name="color">Base color of the brush.</param> public StyleBrush(StyleColor color) { _color = color; }