Exemplo n.º 1
0
 private void _colorPicker_ChangeColor(object sender, RoutedEventArgs e)
 {
     SearchViewModel.SelectedFolderItem.FolderContext.Color    = _argbColorViewModel.ToHexString();
     SearchViewModel.SelectedFolderItem.bLabelColor.Background = new SolidColorBrush(ColorHelpers.FromHexColor(_argbColorViewModel.ToHexString()));
 }
Exemplo n.º 2
0
 public static int ToInt(Color color)
 {
     return(ColorHelpers.ARGB(color.A, color.R, color.G, color.B));
 }
Exemplo n.º 3
0
 public void SetBackgroundColor(ScrollViewer view, uint?color)
 {
     view.Background = color.HasValue
         ? new SolidColorBrush(ColorHelpers.Parse(color.Value))
         : null;
 }
Exemplo n.º 4
0
 public void SetBackgroundColor(ScrollViewer view, uint color)
 {
     view.Background = new SolidColorBrush(ColorHelpers.Parse(color));
 }
Exemplo n.º 5
0
        private string GetInfoText()
        {
            if (ScreenColorPickerMode || Config.UseCustomInfoText)
            {
                Color color = CurrentColor;

                if (!ScreenColorPickerMode && !string.IsNullOrEmpty(Config.CustomInfoText))
                {
                    return(Config.CustomInfoText.Replace("$r", color.R.ToString(), StringComparison.InvariantCultureIgnoreCase).
                           Replace("$g", color.G.ToString(), StringComparison.InvariantCultureIgnoreCase).
                           Replace("$b", color.B.ToString(), StringComparison.InvariantCultureIgnoreCase).
                           Replace("$hex", ColorHelpers.ColorToHex(color), StringComparison.InvariantCultureIgnoreCase).
                           Replace("$x", CurrentPosition.X.ToString(), StringComparison.InvariantCultureIgnoreCase).
                           Replace("$y", CurrentPosition.Y.ToString(), StringComparison.InvariantCultureIgnoreCase));
                }

                return(string.Format(Resources.RectangleRegion_GetColorPickerText, color.R, color.G, color.B, ColorHelpers.ColorToHex(color), CurrentPosition.X, CurrentPosition.Y));
            }

            return(string.Format("X: {0} Y: {1}", CurrentPosition.X, CurrentPosition.Y));
        }
 public void SetBorderColor(Border view, uint?color)
 {
     view.BorderBrush = color.HasValue
         ? new SolidColorBrush(ColorHelpers.Parse(color.Value))
         : null;
 }
Exemplo n.º 7
0
 public void SetBackgroundColor(ReactTextBox view, uint?color)
 {
     view.Background = color.HasValue
         ? new SolidColorBrush(ColorHelpers.Parse(color.Value))
         : new SolidColorBrush(Colors.White);
 }
Exemplo n.º 8
0
 protected override void PrepareColors()
 {
     gradient = ColorHelpers.FromKeys(points.Select(x => new GradientColorKey(x.palette.GetColor(x.shade), x.time))).ToUnityGradient();
 }
Exemplo n.º 9
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            // values[0]: model
            // values[1]: opt or mesh
            // values[2]: show or hide
            // values[3]: selected engine glow

            if (values.Take(4).Any(t => t == System.Windows.DependencyProperty.UnsetValue))
            {
                return(null);
            }

            if (values[0] == null)
            {
                return(null);
            }

            var model = (ModelVisual3D)values[0];

            model.Children.Clear();

            if (values[1] == null || (bool)values[2] == false)
            {
                return(null);
            }

            IEnumerable <EngineGlow> engineGlows;

            if (values[1] is OptFile)
            {
                engineGlows = ((OptFile)values[1]).Meshes.SelectMany(t => t.EngineGlows);
            }
            else if (values[1] is Mesh)
            {
                engineGlows = ((Mesh)values[1]).EngineGlows;
            }
            else
            {
                return(null);
            }

            var visuals = new List <ModelVisual3D>();

            foreach (var engine in engineGlows)
            {
                var transform = new Transform3DGroup();

                transform.Children.Add(new ScaleTransform3D(
                                           Math.Max(engine.Format.X, engine.Format.Y) * engine.Format.Z * .5,
                                           engine.Format.X,
                                           engine.Format.Y));

                transform.Children.Add(new TranslateTransform3D(
                                           -engine.Position.Y,
                                           -engine.Position.X,
                                           engine.Position.Z));

                visuals.Add(new TruncatedConeVisual3D
                {
                    BaseRadius = .4,
                    Height     = .8,
                    Normal     = new Vector3D(-engine.Look.Y, -engine.Look.X, engine.Look.Z),
                    Material   = new DiffuseMaterial(new SolidColorBrush(ColorHelpers.FromUint(engine.CoreColor))),
                    BaseCap    = false,
                    Transform  = transform
                });

                visuals.Add(new TruncatedConeVisual3D
                {
                    BaseRadius = .5,
                    Height     = 1,
                    Normal     = new Vector3D(-engine.Look.Y, -engine.Look.X, engine.Look.Z),
                    Material   = new DiffuseMaterial(new SolidColorBrush(ColorHelpers.FromUint(engine.OuterColor))),
                    BaseCap    = false,
                    Transform  = transform
                });
            }

            if (values[3] != null)
            {
                var engine = (EngineGlow)values[3];

                double depth  = Math.Max(engine.Format.X, engine.Format.Y) * engine.Format.Z * 2.0;
                double width  = engine.Format.X * 2.0;
                double height = engine.Format.Y * 2.0;

                Vector3D position = new Vector3D(-engine.Position.Y, -engine.Position.X, engine.Position.Z);
                Vector3D look     = new Vector3D(-engine.Look.Y, -engine.Look.X, engine.Look.Z);
                Vector3D up       = new Vector3D(-engine.Up.Y, -engine.Up.X, engine.Up.Z);
                Vector3D right    = new Vector3D(-engine.Right.Y, -engine.Right.X, engine.Right.Z);

                var points = new Point3DCollection();

                points.Add(new Point3D(position.X, position.Y, position.Z));
                points.Add(new Point3D(
                               position.X + look.X * depth,
                               position.Y + look.Y * depth,
                               position.Z + look.Z * depth));

                points.Add(new Point3D(
                               position.X - right.X * width,
                               position.Y - right.Y * width,
                               position.Z - right.Z * width));
                points.Add(new Point3D(
                               position.X + right.X * width,
                               position.Y + right.Y * width,
                               position.Z + right.Z * width));

                points.Add(new Point3D(
                               position.X - up.X * height,
                               position.Y - up.Y * height,
                               position.Z - up.Z * height));
                points.Add(new Point3D(
                               position.X + up.X * height,
                               position.Y + up.Y * height,
                               position.Z + up.Z * height));

                visuals.Add(new LinesVisual3D()
                {
                    Color  = Colors.White,
                    Points = points
                });
            }

            visuals.ForEach(t => model.Children.Add(t));

            return(null);
        }
Exemplo n.º 10
0
 public override Color GetColor(double rate, double zoom)
 {
     return(ColorHelpers.FromHSV(240, 1.0 - rate, 1));
 }
Exemplo n.º 11
0
        private static bool ValidateFormat(string format, string value)
        {
            switch (format)
            {
            case Constants.Formats.Uuid:
            {
#if NET35
                return(UuidRegex.IsMatch(value));
#else
                return(Guid.TryParseExact(value, "D", out _));
#endif
            }

            case Constants.Formats.Color:
            {
                return(ColorHelpers.IsValid(value));
            }

            case Constants.Formats.Hostname:
            case Constants.Formats.Draft3Hostname:
            {
                // http://stackoverflow.com/questions/1418423/the-hostname-regex
                return(HostnameRegex.IsMatch(value));
            }

            case Constants.Formats.IPv4:
            case Constants.Formats.Draft3IPv4:
            {
                return(FormatHelpers.ValidateIPv4(value));
            }

            case Constants.Formats.IPv6:
            {
                return(FormatHelpers.ValidateIPv6(value));
            }

            case Constants.Formats.Email:
            {
                return(EmailHelpers.Validate(value, true));
            }

            case Constants.Formats.Uri:
            {
                return(Uri.IsWellFormedUriString(value, UriKind.Absolute));
            }

            case Constants.Formats.UriReference:
            {
                return(FormatHelpers.ValidateUriReference(value));
            }

            case Constants.Formats.Duration:
            {
                return(FormatHelpers.ValidateDuration(value));
            }

            case Constants.Formats.UriTemplate:
            {
                return(FormatHelpers.ValidateUriTemplate(value));
            }

            case Constants.Formats.JsonPointer:
            {
                return(FormatHelpers.ValidateJsonPointer(value));
            }

            case Constants.Formats.Date:
            {
                return(DateTime.TryParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime _));
            }

            case Constants.Formats.Time:
            {
                return(DateTime.TryParseExact(value, "HH:mm:ss.FFFFFFFK", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime _));
            }

            case Constants.Formats.DateTime:
            {
                // RFC 3339 states that the T and Z characters in the "date-time" format are case insensitive.
                if (value.IndexOfAny(CaseInsensitiveDateTimeChars) != -1)
                {
                    value = value.ToUpperInvariant();
                }
                return(DateTime.TryParseExact(value, @"yyyy-MM-dd\THH:mm:ss.FFFFFFFK", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime _));
            }

            case Constants.Formats.UtcMilliseconds:
            {
                return(double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out double _));
            }

            case Constants.Formats.Regex:
            {
                try
                {
                    new Regex(value);
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }

            default:
            {
                return(true);
            }
            }
        }
Exemplo n.º 12
0
        public RenderedPrimitives GetRenderedPrimitives(PerspectiveType perspectiveType, RenderTarget renderTarget)
        {
            // todo: fixme
            _aspectRatio = (float)renderTarget.OutputBitmap.PixelWidth
                           / renderTarget.OutputBitmap.PixelHeight;

            var projection = GetProjectionMatrix(perspectiveType);
            var viewProj   = projection * Scene.Camera.GetViewMatrix();

            var rasterizedLines          = new List <Line2D>();
            var perspectiveColorOverride =
                GetPerspectiveColorOverride(perspectiveType);

            foreach (var worldObject in Scene.Objects)
            {
                worldObject.PrerenderUpdate();
            }

            if (Scene.GrabbedObjects.Count > 0)
            {
                Scene.Manipulator.Position =
                    Scene.GrabbedObjects.First().WorldPosition;
            }

            foreach (var worldObject in Scene.Objects)
            {
                var shape          = worldObject.Shape;
                var transformation = viewProj * worldObject.GetWorldMatrix();

                var dynamicShape = shape as IDynamicShape;
                dynamicShape?.UpdateGeometry(

                    /*(p1, p2) => // calculate with clip (only visible length)
                     * {
                     *  var v1 = ((Vector3D) p1).ExtendTo4D();
                     *  var v2 = ((Vector3D) p2).ExtendTo4D();
                     *  if (!TransformLineWithClip(transformation, ref v1, ref v2))
                     *      return 0.0;
                     *  var pt1 = renderTarget.ConvertPointToPixelSpace((Point) v1);
                     *  var pt2 = renderTarget.ConvertPointToPixelSpace((Point) v2);
                     *  return (pt1-pt2).Length;
                     * },*/
                    (p1, p2) =>
                {
                    var v1 = (Point)((Vector3D)p1).ExtendTo4D().Transform(transformation).WDivide();
                    var v2 = (Point)((Vector3D)p2).ExtendTo4D().Transform(transformation).WDivide();
                    return((renderTarget.ConvertPointToPixelSpace(v1) - renderTarget.ConvertPointToPixelSpace(v2)).Length);
                },
                    p => IsPositionInsideProjectiveCube(((Vector3D)p).ExtendTo4D().Transform(transformation))
                    );

                foreach (var segment in shape.Lines)
                {
                    var firstIndex  = segment.First;
                    var secondIndex = segment.Second;

                    var v1 = shape.Vertices[firstIndex];
                    var v2 = shape.Vertices[secondIndex];

                    var segmentColor = ColorHelpers.Lerp(v1.Color, v2.Color, 0.5);

                    var firstPos  = ((Vector3D)v1.Position).ExtendTo4D();
                    var secondPos = ((Vector3D)v2.Position).ExtendTo4D();
                    if (!TransformLineWithClip(transformation, ref firstPos, ref secondPos))
                    {
                        continue;
                    }

                    rasterizedLines.Add(new Line2D((Point)firstPos, (Point)secondPos, perspectiveColorOverride ?? segmentColor));
                }
            }

            var rasterizedMarkerPoints = RasterizePoints(viewProj, perspectiveColorOverride, t => t.MarkerPoints);
            var rasterizedRawPixels    = RasterizePoints(viewProj, perspectiveColorOverride, t => t.RawPoints);

            return(new RenderedPrimitives()
            {
                Points = rasterizedMarkerPoints,
                Lines = rasterizedLines,
                RawPixels = rasterizedRawPixels,
            });
        }
Exemplo n.º 13
0
        private static bool ValidateFormat(string format, string value)
        {
            switch (format)
            {
            case Constants.Formats.Color:
            {
                return(ColorHelpers.IsValid(value));
            }

            case Constants.Formats.Hostname:
            case Constants.Formats.Draft3Hostname:
            {
                // http://stackoverflow.com/questions/1418423/the-hostname-regex
                return(Regex.IsMatch(value, @"^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$", RegexOptions.CultureInvariant));
            }

            case Constants.Formats.IPv4:
            case Constants.Formats.Draft3IPv4:
            {
                string[] parts = value.Split('.');
                if (parts.Length != 4)
                {
                    return(false);
                }

                for (int i = 0; i < parts.Length; i++)
                {
                    int num;
                    if (!int.TryParse(parts[i], NumberStyles.Integer, CultureInfo.InvariantCulture, out num) ||
                        (num < 0 || num > 255))
                    {
                        return(false);
                    }
                }
                return(true);
            }

            case Constants.Formats.IPv6:
            {
                return(Uri.CheckHostName(value) == UriHostNameType.IPv6);
            }

            case Constants.Formats.Email:
            {
                return(EmailHelpers.Validate(value, true));
            }

            case Constants.Formats.Uri:
            {
                return(Uri.IsWellFormedUriString(value, UriKind.Absolute));
            }

            case Constants.Formats.Date:
            {
                DateTime temp;
                return(DateTime.TryParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp));
            }

            case Constants.Formats.Time:
            {
                DateTime temp;
                return(DateTime.TryParseExact(value, "hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp));
            }

            case Constants.Formats.DateTime:
            {
                DateTime temp;
                return(DateTime.TryParseExact(value, @"yyyy-MM-dd\THH:mm:ss.FFFFFFFK", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp));
            }

            case Constants.Formats.UtcMilliseconds:
            {
                double temp;
                return(Double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out temp));
            }

            case Constants.Formats.Regex:
            {
                try
                {
                    new Regex(value);
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }

            default:
            {
                return(true);
            }
            }
        }
Exemplo n.º 14
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="scheme"></param>
 /// <param name="colorIndex1"></param>
 /// <param name="colorIndex2"></param>
 public void WriteColor(StringBuilder builder, Scheme scheme, int colorIndex1, int colorIndex2)
 {
     builder.Append($"{Labels[colorIndex1]}={ColorHelpers.ColorToHexLowercase(scheme.Colors[colorIndex1])}\n");
     builder.Append($"{Labels[colorIndex1]}(bold)={ColorHelpers.ColorToHexLowercase(scheme.Colors[colorIndex2])}\n");
 }
Exemplo n.º 15
0
 public Color GetColor() =>
 ColorHelpers.HsvToRgb(_hue / 100 * 360, _saturation / 100, _value / 100);
Exemplo n.º 16
0
        public void Render(VirtualCanvas canvas)
        {
            var SendContext = new BasicTypeSerializerContext();
            var ComPort     = new SerialMessenger();

            ComPort.Messenger += OnMessage;
            ComPort.Initialize(bufferSize: 1024);

            int contentSize = 0;

            BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.Reset);
            var buffer = SendContext.GetBuffer(out contentSize);

            ComPort.Send(buffer, 0, (byte)contentSize);

            DrawPlayground(canvas);
            canvas.Touch += TouchEventHandler;
            var    exit = false;
            ushort r = 127, g = 0, b = 0;

            while (!exit)
            {
                LastTouchIsValid = 0;
                canvas.TouchscreenWaitForEvent(TouchScreenEventMode.NonBlocking);
                if (LastTouchIsValid != 0)
                {
                    if (LastTouchX >= 260 && LastTouchY >= 42 && LastTouchX <= 290 && LastTouchY <= 72)   // red
                    {
                        r         = 127;
                        g         = 0;
                        b         = 0;
                        LastColor = ColorHelpers.GetRGB24toRGB565(255, 0, 0);
                    }
                    else if (LastTouchX >= 260 && LastTouchY >= 77 && LastTouchX <= 290 && LastTouchY <= 107)   // green
                    {
                        r         = 0;
                        g         = 127;
                        b         = 0;
                        LastColor = ColorHelpers.GetRGB24toRGB565(0, 255, 0);
                    }
                    else if (LastTouchX >= 260 && LastTouchY >= 112 && LastTouchX <= 290 && LastTouchY <= 142)   // blue
                    {
                        r         = 0;
                        g         = 0;
                        b         = 127;
                        LastColor = ColorHelpers.GetRGB24toRGB565(0, 0, 255);
                    }
                    else if (LastTouchX >= 80 && LastTouchY >= 150 && LastTouchX <= 80 + 160 && LastTouchY <= 170)   // reset
                    {
                        canvas.DrawRectangleFilled(
                            79, 40,
                            241, 141,
                            ColorHelpers.GetRGB24toRGB565(255, 255, 255));
                        DrawGrid(canvas);
                        BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.Reset);
                        buffer = SendContext.GetBuffer(out contentSize);
                        ComPort.Send(buffer, 0, (byte)contentSize);
                        Thread.Sleep(250);
                    }
                    else if (LastTouchX >= 80 && LastTouchY >= 42 && LastTouchX < 240 && LastTouchY < 140)   // canvas
                    {
                        var x = (LastTouchX - 80) / 10;
                        var y = (LastTouchY - 42) / 10;
                        if (LastSquareX != x || LastSquareY != y)
                        {
                            LastSquareX = x;
                            LastSquareY = y;
                            canvas.DrawRectangleFilled(80 + (x * 10) + 1, 42 + (y * 10) + 1, 80 + (x * 10) + 1 + 8, 42 + (y * 10) + 1 + 8, LastColor);
                            canvas.Execute();
                            BasicTypeSerializer.Put(SendContext, (UInt16)RGBLedDisplayCommand.SetPixel);
                            BasicTypeSerializer.Put(SendContext, (ushort)x);
                            BasicTypeSerializer.Put(SendContext, (ushort)y);
                            BasicTypeSerializer.Put(SendContext, r);
                            BasicTypeSerializer.Put(SendContext, g);
                            BasicTypeSerializer.Put(SendContext, b);
                            buffer = SendContext.GetBuffer(out contentSize);
                            ComPort.Send(buffer, 0, (byte)contentSize);
                        }
                    }
                    else if (LastTouchX >= 32 && LastTouchY >= 197 && LastTouchX <= 32 + 250 && LastTouchY <= 197 + 36)   // exit
                    {
                        exit = true;
                    }
                }
            }
            canvas.Touch -= TouchEventHandler;
            ComPort.Dispose();
        }
Exemplo n.º 17
0
        public void SetBackgroundColor(BorderedCanvas view, uint color)
        {
            var border = GetOrCreateBorder(view);

            border.Background = new SolidColorBrush(ColorHelpers.Parse(color));
        }
 public void SetBackgroundColor(BorderedCanvas view, uint?color)
 {
     view.Background = color.HasValue
         ? new SolidColorBrush(ColorHelpers.Parse(color.Value))
         : null;
 }
Exemplo n.º 19
0
 public void SetColor(ReactTextBox view, uint?color)
 {
     view.Foreground = color.HasValue
         ? new SolidColorBrush(ColorHelpers.Parse(color.Value))
         : null;
 }
 public void SetBorderColor(PasswordBox view, uint?color)
 {
     view.BorderBrush = color.HasValue
         ? new SolidColorBrush(ColorHelpers.Parse(color.Value))
         : new SolidColorBrush(ReactTextInputManager.DefaultTextBoxBorder);
 }
Exemplo n.º 21
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="scheme"></param>
 /// <param name="colorIndex1"></param>
 /// <param name="colorIndex2"></param>
 public void WriteColor(StringBuilder builder, Scheme scheme, int colorIndex1, int colorIndex2)
 {
     builder.Append($"! {Labels[colorIndex1]}\n");
     builder.Append($"*.color{colorIndex1} {ColorHelpers.ColorToHex(scheme.Colors[colorIndex1])}\n");
     builder.Append($"*.color{colorIndex2} {ColorHelpers.ColorToHex(scheme.Colors[colorIndex2])}\n\n");
 }
 public void SetSelectionColor(PasswordBox view, uint color)
 {
     view.SelectionBrush = new SolidColorBrush(ColorHelpers.Parse(color));
     view.CaretBrush     = new SolidColorBrush(ColorHelpers.Parse(color));
 }
Exemplo n.º 23
0
 public void SetSelectionColor(PasswordBox view, uint color)
 {
     view.SelectionHighlightColor = new SolidColorBrush(ColorHelpers.Parse(color));
 }
Exemplo n.º 24
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="scheme"></param>
 /// <param name="colorIndex1"></param>
 /// <param name="colorIndex2"></param>
 public void WriteColor(StringBuilder builder, Scheme scheme, int colorIndex1, int colorIndex2)
 {
     builder.Append($"  - '{ColorHelpers.ColorToHex(scheme.Colors[colorIndex1])}'\n");
 }
Exemplo n.º 25
0
 public void SetColor(ProgressBar view, uint?color)
 {
     view.Foreground = color.HasValue
         ? new SolidColorBrush(ColorHelpers.Parse(color.Value))
         : null;
 }
Exemplo n.º 26
0
 public void SetPlaceholderTextColor(ReactTextBox view, uint?color)
 {
     if (color.HasValue)
     {
         var brush = new SolidColorBrush(ColorHelpers.Parse(color.Value));
         view.Resources["TextControlPlaceholderForeground"]            = brush;
         view.Resources["TextControlPlaceholderForegroundPointerOver"] = brush;
         view.Resources["TextControlPlaceholderForegroundFocused"]     = brush;
         view.Resources["TextControlPlaceholderForegroundDisabled"]    = brush;
     }
     else
     {
         view.Resources["TextControlPlaceholderForeground"]            = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlPlaceholderForeground));
         view.Resources["TextControlPlaceholderForegroundPointerOver"] = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlPlaceholderForegroundPointerOver));
         view.Resources["TextControlPlaceholderForegroundFocused"]     = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlPlaceholderForegroundFocused));
         view.Resources["TextControlPlaceholderForegroundDisabled"]    = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlPlaceholderForegroundDisabled));
     }
 }
Exemplo n.º 27
0
        private string GetInfoText()
        {
            if (Mode == RegionCaptureMode.ScreenColorPicker || Config.UseCustomInfoText)
            {
                Color color = CurrentColor;

                if (Mode != RegionCaptureMode.ScreenColorPicker && !string.IsNullOrEmpty(Config.CustomInfoText))
                {
                    return(CodeMenuEntryPixelInfo.Parse(Config.CustomInfoText, color, CurrentPosition));
                }

                return(string.Format(Resources.RectangleRegion_GetColorPickerText, color.R, color.G, color.B, ColorHelpers.ColorToHex(color), CurrentPosition.X, CurrentPosition.Y));
            }

            return(string.Format("X: {0} Y: {1}", CurrentPosition.X, CurrentPosition.Y));
        }
Exemplo n.º 28
0
 public void SetBorderColor(ReactTextBox view, uint?color)
 {
     if (color.HasValue)
     {
         var brush = new SolidColorBrush(ColorHelpers.Parse(color.Value));
         view.Resources["TextControlBorderBrush"]            = brush;
         view.Resources["TextControlBorderBrushPointerOver"] = brush;
         view.Resources["TextControlBorderBrushFocused"]     = brush;
         view.Resources["TextControlBorderBrushDisabled"]    = brush;
     }
     else
     {
         view.Resources["TextControlBorderBrush"]            = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlBorderBrush));
         view.Resources["TextControlBorderBrushPointerOver"] = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlBorderBrushPointerOver));
         view.Resources["TextControlBorderBrushFocused"]     = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlBorderBrushFocused));
         view.Resources["TextControlBorderBrushDisabled"]    = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlBorderBrushDisabled));
     }
 }
Exemplo n.º 29
0
 public void SetBackgroundColor(PasswordBox view, uint?color)
 {
     if (color.HasValue)
     {
         var brush = new SolidColorBrush(ColorHelpers.Parse(color.Value));
         view.Resources["TextControlBackground"]            = brush;
         view.Resources["TextControlBackgroundPointerOver"] = brush;
         view.Resources["TextControlBackgroundFocused"]     = brush;
         view.Resources["TextControlBackgroundDisabled"]    = brush;
     }
     else
     {
         view.Resources["TextControlBackground"]            = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlBackground));
         view.Resources["TextControlBackgroundPointerOver"] = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlBackgroundPointerOver));
         view.Resources["TextControlBackgroundFocused"]     = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlBackgroundFocused));
         view.Resources["TextControlBackgroundDisabled"]    = new SolidColorBrush(ColorHelpers.Parse(DefaultTextControlBackgroundDisabled));
     }
 }
Exemplo n.º 30
0
 private void CheckedUseColor(object sender, RoutedEventArgs e)
 {
     if (((CheckBox)sender).IsChecked ?? false)
     {
         if (!SearchViewModel.SelectedFolderItem.FolderContext.UseColor)
         {
             SearchViewModel.SelectedFolderItem.FolderContext.UseColor = true;
             SearchViewModel.SelectedFolderItem.FolderContext.Color    = ((Color)Application.Current.FindResource("ThemeSelectedControlColor")).ToString();
             SearchViewModel.SelectedFolderItem.bLabelColor.Background = new SolidColorBrush(ColorHelpers.FromHexColor(((Color)Application.Current.FindResource("ThemeSelectedControlColor")).ToString()));
         }
     }
     else
     {
         if (SearchViewModel.SelectedFolderItem.FolderContext.UseColor)
         {
             SearchViewModel.SelectedFolderItem.FolderContext.UseColor = false;
             SearchViewModel.SelectedFolderItem.FolderContext.Color    = null;
             SearchViewModel.SelectedFolderItem.bLabelColor.Background = null;
         }
     }
 }