예제 #1
0
        public static void LogLine(string line)
        {
            if (instance.window.CheckAccess())
            {
                if (line.StartsWith("[INFO]"))
                {
                    line = "~b~[INFO]~0~" + line.Substring(6);
                }
                else if (line.StartsWith("[WARN]"))
                {
                    line = "~o~[WARN]~0~" + line.Substring(6);
                }
                else if (line.StartsWith("[ERROR]"))
                {
                    line = "~r~[ERROR]~0~" + line.Substring(7);
                }

                instance.window.Output.Inlines.AddRange(ColorFormatter.GetFormattedText(line + '\n'));
                instance.window.OutputBox.ScrollToEnd();
            }
            else
            {
                instance.window.Dispatcher.Invoke(new LogCallback(LogLine), line);
            }
        }
예제 #2
0
        public IEnumerable <ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
        {
            HexColorValue hex = (HexColorValue)item;

            if (!item.IsValid)
            {
                yield break;
            }

            ColorModel model = ColorParser.TryParseColor(hex.Text, ColorParser.Options.None);

            if (model != null)
            {
                if (ColorConverterSmartTagAction.GetNamedColor(model.Color) != null)
                {
                    yield return(new ColorConverterSmartTagAction(itemTrackingSpan, model, ColorFormat.Name));
                }

                if (model.Format == ColorFormat.RgbHex6)
                {
                    model.Format = ColorFormat.RgbHex3;
                    string hex3 = ColorFormatter.FormatColor(model, ColorFormat.RgbHex3);

                    if (hex3.Length == 4)
                    {
                        yield return(new ColorConverterSmartTagAction(itemTrackingSpan, model, ColorFormat.RgbHex3));
                    }
                }

                yield return(new ColorConverterSmartTagAction(itemTrackingSpan, model, ColorFormat.Rgb));

                yield return(new ColorConverterSmartTagAction(itemTrackingSpan, model, ColorFormat.Hsl));
            }
        }
예제 #3
0
 /// <summary>
 /// Sets the background color and writes the test name.
 /// </summary>
 internal virtual void WriteTestResult(TestResult testResult)
 {
     ColorFormatter.SetBackgroundColor(
         testResult.Success ? SuccessColor : FailureColor
         );
     WriteObject(string.Format(LineTemplate, testResult.TestName));
 }
예제 #4
0
        public override void Invoke()
        {
            var value = _item.Text;

            switch (_format)
            {
            case ColorFormat.Name:
                value = GetNamedColor(_colorModel.Color);
                break;

            case ColorFormat.Hsl:
                value = FormatHslColor(_colorModel);     //ColorFormatter.FormatColorAs(_colorModel, ColorFormat.Hsl);
                break;

            case ColorFormat.Rgb:
                _colorModel.Format = ColorFormat.Rgb;
                value = ColorFormatter.FormatColorAs(_colorModel, ColorFormat.Rgb);
                break;

            case ColorFormat.RgbHex3:
            case ColorFormat.RgbHex6:
                _colorModel.Format = ColorFormat.RgbHex3;
                value = ColorFormatter.FormatColorAs(_colorModel, ColorFormat.RgbHex3);
                break;
            }

            _span.TextBuffer.Replace(_span.GetSpan(_span.TextBuffer.CurrentSnapshot), value);
        }
예제 #5
0
        private void SetDisplayText()
        {
            string format = "Convert to {0}";

            switch (_format)
            {
            case ColorFormat.Rgb:
                _colorModel.Format = ColorFormat.Rgb;
                _displayText       = string.Format(CultureInfo.InvariantCulture, format, ColorFormatter.FormatColor(_colorModel, ColorFormat.Rgb));
                break;

            case ColorFormat.Hsl:
                _displayText = string.Format(CultureInfo.InvariantCulture, format, FormatHslColor(_colorModel));     //string.Format(CultureInfo.InvariantCulture, format, ColorFormatter.FormatColorAs(_colorModel, ColorFormat.Hsl));
                break;

            case ColorFormat.Name:
                _displayText = string.Format(CultureInfo.InvariantCulture, format, GetNamedColor(_colorModel.Color));
                break;

            case ColorFormat.RgbHex3:
            case ColorFormat.RgbHex6:
                _displayText = string.Format(CultureInfo.InvariantCulture, format, ColorFormatter.FormatColor(_colorModel, ColorFormat.RgbHex3));
                break;
            }
        }
예제 #6
0
 private void closeButton_Click(object sender, EventArgs e)
 {
     style.TrainColor = ColorFormatter.FromHexString((string)colorComboBox.SelectedValue);
     style.TrainWidth = (int)widthComboBox.SelectedValue;
     style.LineStyle  = (int)dashComboBox.SelectedValue;
     style.Show       = drawCheckBox.Checked.Value;
     Close(DialogResult.Ok);
 }
예제 #7
0
        private static string ConvertColor(string value, TimetableVersion version)
        {
            var mcolor = ColorFormatter.FromString(value, null);

            if (mcolor != null)
            {
                return(ColorFormatter.ToString(mcolor, version == TimetableVersion.JTG2_x));
            }
            throw new Exception("Found unknown color string " + value);
        }
예제 #8
0
        public StationStyleEditForm(Station station, ISettings settings) : this(settings)
        {
            Station = station;
            style   = new StationStyle(station);
            var attrs = new TimetableStyle(station._parent);

            colorComboBox.SelectedValue = ColorFormatter.ToString(style.StationColor ?? attrs.StationColor);
            widthComboBox.SelectedValue = style.StationWidth ?? attrs.StationWidth;
            dashComboBox.SelectedValue  = style.LineStyle;
            drawCheckBox.Checked        = style.Show;
        }
예제 #9
0
        public TrainColorEditForm(Train train, ISettings settings) : this(settings)
        {
            Train = train;
            style = new TrainStyle(train);
            var attrs = new TimetableStyle(train._parent);

            colorComboBox.SelectedValue = ColorFormatter.ToString(style.TrainColor ?? attrs.TrainColor);
            widthComboBox.SelectedValue = style.TrainWidth ?? attrs.TrainWidth;
            dashComboBox.SelectedValue  = style.LineStyle;
            drawCheckBox.Checked        = style.Show;
        }
예제 #10
0
        public static void Color <T>(ISettings settings, DropDown dropDown, string property)
        {
            var cc = new ColorCollection(settings);

            var p = GetProperty <T>(property);

            dropDown.DataStore       = cc.ColorHexStrings;
            dropDown.ItemTextBinding = ExtBind.ColorBinding(cc);
            dropDown.SelectedValueBinding.BindDataContext <T>(a => ColorFormatter.ToString((MColor)p.GetValue(a)),
                                                              (a, val) => p.SetValue(a, ColorFormatter.FromHexString((string)val)));
        }
예제 #11
0
        /// <summary>
        /// Sets the background color and writes the test result and name.
        /// </summary>
        internal virtual void WriteTestResult(TestResult testResult)
        {
            ColorFormatter.SetColor(
                ForegroundColor,
                testResult.Success ? SuccessColor : FailureColor
                );
            WriteObject(string.Format(TestResultLineTemplate, testResult.Success ? 'P' : 'F', testResult.TestName));

            if (testResult.Exception != null)
            {
                WriteObject(testResult.Exception);
            }
        }
예제 #12
0
        /// <summary>
        /// Writes the end result of the invoked test results.
        /// </summary>
        internal virtual void WriteEndResult()
        {
            ColorFormatter.SetBackgroundColor(
                Success ? SuccessColor : FailureColor
                );
            string endResult = string.Format(
                "Passed tests: {0}/{1}.",
                NumberOfSuccessfulTestResults,
                NumberOfTestResults
                );

            WriteObject(string.Empty);
            WriteObject(string.Format(LineTemplate, endResult));
        }
예제 #13
0
        private static string GetColorString(ColorFormat format, ColorModel model)
        {
            switch (format)
            {
            case ColorFormat.Name:
                return(GetNamedColor(model.Color));

            case ColorFormat.Hsl:
                return(FormatHslColor(model));    //ColorFormatter.FormatColorAs(_colorModel, ColorFormat.Hsl);

            case ColorFormat.Rgb:
            case ColorFormat.RgbHex3:
            case ColorFormat.RgbHex6:
                return(ColorFormatter.FormatColor(model, format));

            default:
                throw new InvalidEnumArgumentException("format", (int)format, typeof(ColorFormat));
            }
        }
        static PreventCodeStrippingViaReferences()
        {
            Bounds          bounds          = new Bounds();
            BoundsFormatter boundsFormatter = new BoundsFormatter();
            ReflectionFormatter <Bounds>   reflectionFormatter1   = new ReflectionFormatter <Bounds>();
            ComplexTypeSerializer <Bounds> complexTypeSerializer1 = new ComplexTypeSerializer <Bounds>();

            Color          color          = new Color();
            ColorFormatter colorFormatter = new ColorFormatter();
            ReflectionFormatter <Color>   reflectionFormatter3   = new ReflectionFormatter <Color>();
            ComplexTypeSerializer <Color> complexTypeSerializer3 = new ComplexTypeSerializer <Color>();

            Matrix4x4 matrix4x4 = new Matrix4x4();
            ReflectionFormatter <Matrix4x4>   reflectionFormatter4   = new ReflectionFormatter <Matrix4x4>();
            ComplexTypeSerializer <Matrix4x4> complexTypeSerializer4 = new ComplexTypeSerializer <Matrix4x4>();

            Quaternion          quaternion          = new Quaternion();
            QuaternionFormatter quaternionFormatter = new QuaternionFormatter();
            ReflectionFormatter <Quaternion>   reflectionFormatter5   = new ReflectionFormatter <Quaternion>();
            ComplexTypeSerializer <Quaternion> complexTypeSerializer5 = new ComplexTypeSerializer <Quaternion>();

            Rect          rect          = new Rect();
            RectFormatter rectFormatter = new RectFormatter();
            ReflectionFormatter <Rect>   reflectionFormatter6   = new ReflectionFormatter <Rect>();
            ComplexTypeSerializer <Rect> complexTypeSerializer6 = new ComplexTypeSerializer <Rect>();

            Vector2          vector2          = new Vector2();
            Vector2Formatter vector2Formatter = new Vector2Formatter();
            ReflectionFormatter <Vector2>   reflectionFormatter8   = new ReflectionFormatter <Vector2>();
            ComplexTypeSerializer <Vector2> complexTypeSerializer8 = new ComplexTypeSerializer <Vector2>();

            Vector3          vector3          = new Vector3();
            Vector3Formatter vector3Formatter = new Vector3Formatter();
            ReflectionFormatter <Vector3>   reflectionFormatter10   = new ReflectionFormatter <Vector3>();
            ComplexTypeSerializer <Vector3> complexTypeSerializer10 = new ComplexTypeSerializer <Vector3>();

            Vector4          vector4          = new Vector4();
            Vector4Formatter vector4Formatter = new Vector4Formatter();
            ReflectionFormatter <Vector4>   reflectionFormatter12   = new ReflectionFormatter <Vector4>();
            ComplexTypeSerializer <Vector4> complexTypeSerializer12 = new ComplexTypeSerializer <Vector4>();
        }
예제 #15
0
 /// <summary>
 /// Sets the background color back to the original and writes results.
 /// </summary>
 protected override void EndProcessing()
 {
     WriteEndResult();
     ColorFormatter.SetBackgroundColor(OriginalBackGroundColor);
 }
예제 #16
0
        public override void OutputLog(LogType type, string log)
        {
            string msg = ColorFormatter.LogFormat(type, log);

            UnityEngine.Debug.Log(msg);
        }
예제 #17
0
 /// <summary>
 /// Writes results and resets the background color back to the saved values.
 /// </summary>
 protected override void EndProcessing()
 {
     WriteEndResult();
     ColorFormatter.ResetColor();
 }
예제 #18
0
 protected string ColorToString(MColor color)
 => ColorFormatter.ToString(color);
예제 #19
0
 public static IIndirectBinding <string> ColorBinding(ColorCollection cc)
 => Binding.Property <string, string>(c => cc.ToName(ColorFormatter.FromHexString(c)));
예제 #20
0
 protected string ColorToString(MColor color)
 => ColorFormatter.ToString(color, _parent.Version == TimetableVersion.JTG2_x);
예제 #21
0
 protected MColor ParseColor(string def, MColor defaultValue)
 => ColorFormatter.FromString(def, defaultValue);