예제 #1
0
        static void InitStyle(ShapeStyle ss, Windows.UI.Color clr, bool dark)
        {
            SolidColorBrush fill = ss.Fill as SolidColorBrush;

            if (fill == null)
            {
                try
                {
                    ss.FillAuto = ss.Fill = new SolidColorBrush(clr);
                }
                catch { }
            }
            else
            {
                fill.Color = clr;
            }
            fill = ss.Stroke as SolidColorBrush;
            Windows.UI.Color color = dark ? ColorPalette.Darken(clr) : clr;
            if (fill == null)
            {
                ss.StrokeAuto = ss.Stroke = new SolidColorBrush(color);
            }
            else
            {
                fill.Color = color;
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a circular solid colored brush that we can apply to a visual
        /// </summary>
        private CompositionEffectBrush CreateCircleBrushWithColor(Windows.UI.Color color)
        {
            var colorBrush = _compositor.CreateColorBrush(color);

            //
            // Because Windows.UI.Composition does not have a Circle visual, we will
            // work around by using a circular opacity mask
            // Create a simple Composite Effect, using DestinationIn (S * DA),
            // with a color source and a named parameter source.
            //
            var effect = new CompositeEffect
            {
                Mode    = CanvasComposite.DestinationIn,
                Sources =
                {
                    new ColorSourceEffect()
                    {
                        Color = color
                    },
                    new CompositionEffectSourceParameter("mask")
                }
            };
            var factory = _compositor.CreateEffectFactory(effect);
            var brush   = factory.CreateBrush();

            //
            // Create the mask brush using the circle mask
            //
            CompositionSurfaceBrush maskBrush = _compositor.CreateSurfaceBrush();

            maskBrush.Surface = _circleMaskSurface.Surface;
            brush.SetSourceParameter("mask", maskBrush);

            return(brush);
        }
예제 #3
0
        public ShapeStyle Next(bool dark)
        {
            ShapeStyle style2;
            ShapeStyle ss = new ShapeStyle();

            if ((CustomBrushes != null) && (_colorGen == Dt.Charts.Palette.Default))
            {
                InitStyle(ss, GetCustomBrush(_list.Count), dark);
            }
            else
            {
                Dt.Charts.Palette colorGenTheme = (_colorGen == Dt.Charts.Palette.Default) ? Dt.Charts.Palette.Apex : _colorGen;
                Windows.UI.Color  clr           = ColorPalette.GetOfficePalette(colorGenTheme).GetColor(_list.Count);
                InitStyle(ss, clr, dark);
            }
            ss.DarkOutline     = dark;
            ss.StrokeThickness = 2.0;
            _list.Add(ss);
            style2 = new ShapeStyle {
                FillAuto        = ss.FillAuto,
                Fill            = ss.FillAuto,
                StrokeAuto      = ss.StrokeAuto,
                Stroke          = ss.StrokeAuto,
                StrokeThickness = 2.0
            };
            _list2.Add(style2);
            return(ss);
        }
예제 #4
0
        void SetColors(Dt.Charts.Palette cg)
        {
            int num = _list.Count;

            if (cg == Dt.Charts.Palette.Default)
            {
                if (CustomBrushes != null)
                {
                    for (int j = 0; j < num; j++)
                    {
                        Brush customBrush = GetCustomBrush(j);
                        InitStyle(_list[j], customBrush, _list[j].DarkOutline);
                        SyncStyle(j);
                    }
                    return;
                }
                cg = Dt.Charts.Palette.Apex;
            }
            for (int i = 0; i < num; i++)
            {
                Windows.UI.Color clr = ColorPalette.GetOfficePalette(cg).GetColor(i);
                InitStyle(_list[i], clr, _list[i].DarkOutline);
                SyncStyle(i);
            }
        }
예제 #5
0
        private void UpdateGrid()
        {
            if (myMapView.Grid != null && myMapView.Grid.LevelCount > 0)
            {
                //Get proper color
                Windows.UI.Color     defaultColor          = new Windows.UI.Color();
                System.Drawing.Color convertedDefaultColor = new System.Drawing.Color();
                if (Application.Current.Resources[resourceNameGridColor] != null)
                {
                    defaultColor          = (Color)Application.Current.Resources[resourceNameGridColor];
                    convertedDefaultColor = System.Drawing.Color.FromArgb(defaultColor.A, defaultColor.R, defaultColor.G, defaultColor.B);
                }

                //Create line symbol for grid
                SimpleLineSymbol lineSym = new SimpleLineSymbol();
                lineSym.Color = convertedDefaultColor;
                lineSym.Style = SimpleLineSymbolStyle.Solid;
                lineSym.Width = 1;

                //Update for each level of grid
                for (int levels = 0; levels < myMapView.Grid.LevelCount; levels++)
                {
                    TextSymbol currentSymbol = (TextSymbol)myMapView.Grid.GetTextSymbol(levels);
                    currentSymbol.Color = convertedDefaultColor;
                    myMapView.Grid.SetTextSymbol(levels, (Esri.ArcGISRuntime.Symbology.Symbol)currentSymbol);

                    myMapView.Grid.SetLineSymbol(levels, (Esri.ArcGISRuntime.Symbology.Symbol)lineSym);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Will set the background grid of the map view
        /// NOTE: Since we can't add this code inside XAML, thanks to ESRI sdk, we need to force it here.
        /// </summary>
        public void SetBackgroundGrid()
        {
            if (myMapView.BackgroundGrid.GridLineWidth != 0)
            {
                Services.SettingsServices.SettingsService _settings = Services.SettingsServices.SettingsService.Instance;

                CustomResource customColors = new CustomResource();
                customColors.InitializeComponent();
                if (customColors.ContainsKey("MapViewBackgroundGridLightColor"))
                {
                    var appT = _settings.AppTheme;
                    if (_settings.AppTheme == ApplicationTheme.Light)
                    {
                        Windows.UI.Color lightDefault = (Windows.UI.Color)customColors["MapViewBackgroundGridLightColor"];
                        myMapView.BackgroundGrid.Color = System.Drawing.Color.FromArgb(lightDefault.A, lightDefault.R, lightDefault.G, lightDefault.B);
                        //myMapView.BackgroundGrid.GridLineColor = (Windows.UI.Color)customColors["MapViewBackgroundGridDarkColor"];
                        //myMapView.BackgroundGrid.GridLineWidth = 5;
                    }
                    else
                    {
                        Windows.UI.Color darkDefault = (Windows.UI.Color)customColors["MapViewBackgroundGridDarkColor"];
                        myMapView.BackgroundGrid.Color = System.Drawing.Color.FromArgb(darkDefault.A, darkDefault.R, darkDefault.G, darkDefault.B);


                        //myMapView.BackgroundGrid.GridLineColor = (Windows.UI.Color)customColors["MapViewBackgroundGridLightColor"];
                        //myMapView.BackgroundGrid.GridLineWidth = 5;
                    }
                }
                myMapView.BackgroundGrid.GridLineWidth = 0;
                myMapView.UpdateLayout();
            }
        }
예제 #7
0
        internal static Brush GetRichTextFill(List <TextParagraph> richText, Workbook workbook)
        {
            TextRun       firstRun       = GetFirstRun(richText);
            TextParagraph firstParagraph = GetFirstParagraph(richText);
            Brush         brush          = null;
            IFillFormat   fillFormat     = null;

            if (firstRun != null)
            {
                fillFormat = firstRun.FillFormat;
            }
            if ((fillFormat == null) && (firstParagraph != null))
            {
                fillFormat = firstParagraph.FillFormat;
            }
            if (fillFormat != null)
            {
                object fill = ExcelChartExtension.GetFill(fillFormat, workbook);
                SpreadDrawingColorSettings spreadDrawingColorSettings = ExcelChartExtension.GetSpreadDrawingColorSettings(fillFormat);
                if (fill is string)
                {
                    if (workbook != null)
                    {
                        Windows.UI.Color color = Dt.Cells.Data.ColorHelper.UpdateColor(workbook.GetThemeColor((string)(fill as string)), spreadDrawingColorSettings, false);
                        return(new SolidColorBrush(color));
                    }
                    return(brush);
                }
                if (fill is Brush)
                {
                    brush = fill as Brush;
                }
            }
            return(brush);
        }
예제 #8
0
        /// <summary>
        /// Converts a <see cref="Color"/> to a premultiplied Int32 - 4 byte ARGB structure.
        /// </summary>
        /// <param name="color">The color to convert.</param>
        /// <returns>The int representation of the color.</returns>
        public static int ToInt(this Color color)
        {
            var a   = color.A + 1;
            var col = (color.A << 24) | ((byte)((color.R * a) >> 8) << 16) | ((byte)((color.G * a) >> 8) << 8) | (byte)((color.B * a) >> 8);

            return(col);
        }
예제 #9
0
 public static IColorSequence Dipolar(Color negativeColor, Color positiveColor, int halfStepCount)
 {
     return new Ir1ColorSequence(
             new ColorSequenceImpl(positiveColor.LessFadingSpread(halfStepCount)),
             new ColorSequenceImpl(negativeColor.LessFadingSpread(halfStepCount))
         );
 }
예제 #10
0
파일: DataBarRule.cs 프로젝트: Daoting/dt
        /// <summary>
        /// Returns a drawing object based on a specified parameter.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The base row.</param>
        /// <param name="baseColumn">The base column.</param>
        /// <param name="actual">The current value.</param>
        /// <returns>The data bar object.</returns>
        public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            this.lastActualValue = actual;
            object val = actual.GetValue(baseRow, baseColumn);

            if (val != null)
            {
                double?nullable = ConditionValueConverter.TryDouble(val);
                if (!nullable.HasValue)
                {
                    return(null);
                }
                double currentValue = nullable.Value;
                double?nullable2    = this.CalcuteMinValue(evaluator, baseRow, baseColumn, 0, actual);
                double?nullable3    = this.CalcuteMaxValue(evaluator, baseRow, baseColumn, 2, actual);
                if (nullable2.HasValue && nullable3.HasValue)
                {
                    double?nullable5 = nullable2;
                    double?nullable6 = nullable3;
                    if ((((double)nullable5.GetValueOrDefault()) > ((double)nullable6.GetValueOrDefault())) && (nullable5.HasValue & nullable6.HasValue))
                    {
                        double?nullable4 = nullable3;
                        nullable3 = nullable2;
                        nullable2 = nullable4;
                    }
                    double           axisScale = -1.0;
                    double           scale     = this.EvaluateScale(currentValue, nullable2.Value, nullable3.Value, out axisScale);
                    Windows.UI.Color fillColor = ((currentValue < 0.0) && this.useNegativeFillColor) ? this.negativeFillColor : this.color;
                    return(new DataBarDrawingObject(baseRow, baseColumn, fillColor, ((currentValue < 0.0) && this.useNegativeBorderColor) ? this.negativeBorderColor : this.borderColor, this.showBorder, this.axisColor, this.gradient, this.direction, axisScale, scale, this.showBarOnly));
                }
            }
            return(null);
        }
예제 #11
0
        public static Color GetApplicationColor(ColoringBookColors Color)
        {
            Color color = new Windows.UI.Color();

            switch (Color)
            {
            case ColoringBookColors.Red:
                color = GetApplicationColor(RED);
                break;

            case ColoringBookColors.Blue:
                color = GetApplicationColor(BLUE);
                break;

            case ColoringBookColors.Teal:
                color = GetApplicationColor(TEAL);
                break;

            case ColoringBookColors.Orange:
                color = GetApplicationColor(ORANGE);
                break;

            case ColoringBookColors.Purple:
                color = GetApplicationColor(PURPLE);
                break;

            default:
                break;
            }
            return(color);
        }
예제 #12
0
        /// <summary>
        /// Constructor. Creates rendering brush; initializes graphics
        /// </summary>
        /// <param name="swapChainPanel">SwapChainPanel on which to render captured ink</param>
        /// <param name="brushType">Type of brush to use</param>
        /// <param name="thickness">Relative thickness of brush</param>
        /// <param name="color">Color of ink</param>
        /// <param name="style">Shape of brush (VectorBrush only)</param>
        public Renderer(SwapChainPanel swapChainPanel, VectorBrushStyle style, MediaColor color)
        {
            StrokeHandler = new VectorStrokeHandler(this, style, color);

            mSwapChainPanel         = swapChainPanel;
            Graphics.GraphicsReady += OnGraphicsReady;
            Graphics.Initialize(mSwapChainPanel, false);
        }
예제 #13
0
파일: ComboLine.cs 프로젝트: Daoting/dt
 public void SetColor(SolidColorBrush brush, Windows.UI.Color color)
 {
     if (color != _cachedColor)
     {
         _cachedColor = color;
         _line.Stroke = brush;
     }
 }
예제 #14
0
        public static Windows.UI.Color GetContrastingColor(this Windows.UI.Color color)
        {
            var nThreshold  = 105;
            int bgLuminance = Convert.ToInt32(color.R * 0.2 + color.G * 0.7 + color.B * 0.1);

            Windows.UI.Color contrastingColor = 255 - bgLuminance < nThreshold ? Colors.Black : Colors.White;
            return(contrastingColor);
        }
예제 #15
0
파일: ColorPalette.cs 프로젝트: Daoting/dt
        public static Windows.UI.Color Darken(Windows.UI.Color clr)
        {
            float hue        = GetHue(clr);
            float saturation = GetSaturation(clr);
            float num3       = GetBrightness(clr) * 0.5f;

            return(ColorFromHSL((double)hue, (double)saturation, (double)num3));
        }
예제 #16
0
        public void Start(Windows.UI.Color color, Rect initialBounds, Rect finalBounds)
        {
            var colorVisual = CreateVisualWithColorAndPosition(color, initialBounds, finalBounds);

            _containerForVisuals.Children.InsertAtTop(colorVisual);

            TriggerBloomAnimation(colorVisual);
        }
예제 #17
0
파일: BorderLine.cs 프로젝트: Daoting/dt
 /// <summary>
 /// Creates a border line with a specified color and style.
 /// </summary>
 /// <param name="color">The border color.</param>
 /// <param name="styleType">The border style type.</param>
 public BorderLine(Windows.UI.Color color, BorderLineStyle styleType)
 {
     this._context    = null;
     this._themeColor = null;
     this._color      = color;
     this._style      = styleType;
     this._builtIn    = false;
 }
예제 #18
0
파일: BorderLine.cs 프로젝트: Daoting/dt
 /// <summary>
 /// Caution, only use for built-in borders creating.
 /// </summary>
 internal BorderLine(Windows.UI.Color color, BorderLineData style)
 {
     this._context   = null;
     this._style     = BorderLineStyle.None;
     this._color     = color;
     this._styleData = style;
     this._builtIn   = true;
 }
예제 #19
0
 public static void ChangeTitlebarButtonColor(Color backGround,Color foreGround)
 {
     var view = ApplicationView.GetForCurrentView();
     var otherB = backGround;
     var otherF = foreGround;
     view.TitleBar.ButtonBackgroundColor = backGround;
     view.TitleBar.ButtonForegroundColor = foreGround;
 }
예제 #20
0
        public static Windows.UI.Color GetIdealForegroundForBackgroundColor(this Windows.UI.Color backgroundColor)
        {
            var nThreshold  = 105;
            int bgLuminance = Convert.ToInt32(backgroundColor.R * 0.2 + backgroundColor.G * 0.7 + backgroundColor.B * 0.1);

            Windows.UI.Color foregroundColor = 255 - bgLuminance < nThreshold ? Colors.Black : Colors.White;
            return(foregroundColor);
        }
예제 #21
0
 public InkingPreference()
 {
     penSize = 1;
     highlighterSize = 10;
     penColor = Colors.Red;
     highlighterColor = Colors.Yellow;
     drawingDevice = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen;
     this.version = CURRENT_INKING_PREF_VERSION;
 }
        private CompositionMaskBrush CreateMaskBrush(int width, int height, Windows.UI.Color rateColor)
        {
            var _maskBrush = compositor.CreateMaskBrush();
            LoadedImageSurface loadedSurface = LoadedImageSurface.StartLoadFromUri(new Uri("ms-appx:///Assets/CircleMask.png"), new Windows.Foundation.Size(width, height));

            _maskBrush.Source = compositor.CreateColorBrush(rateColor);
            _maskBrush.Mask   = compositor.CreateSurfaceBrush(loadedSurface);
            return(_maskBrush);
        }
예제 #23
0
        public void SetLEDColor(int index, String cssColor)
        {
            byte r = byte.Parse(cssColor.Substring(1, 2), NumberStyles.HexNumber);
            byte g = byte.Parse(cssColor.Substring(3, 2), NumberStyles.HexNumber);
            byte b = byte.Parse(cssColor.Substring(5, 2), NumberStyles.HexNumber);

            Windows.UI.Color color = Color.FromArgb(0, r, g, b);
            SetLEDColor(index, color);
        }
예제 #24
0
 public Block(float x1, float y1, Windows.UI.Color color1, int height1, int width1)
 {
     x      = x1;
     y      = y1;
     color  = color1;
     height = height1;
     width  = width1;
     rect   = new Rectangle((int)x1 - 20, (int)y1 - 20, height1 + 40, width1 + 40);
 }
예제 #25
0
        /// <summary>
        /// Creates a <see cref="Color"/> from the specified hue, saturation, value, and alpha values.
        /// </summary>
        /// <param name="hue">0..360 range hue</param>
        /// <param name="saturation">0..1 range saturation</param>
        /// <param name="value">0..1 range value</param>
        /// <param name="alpha">0..1 alpha</param>
        /// <returns>The created <see cref="Color"/>.</returns>
        public static Color FromHsv(double hue, double saturation, double value, double alpha = 1.0)
        {
            if (hue < 0 || hue > 360)
            {
                throw new ArgumentOutOfRangeException(nameof(hue));
            }

            double chroma = value * saturation;
            double h1 = hue / 60;
            double x = chroma * (1 - Math.Abs((h1 % 2) - 1));
            double m = value - chroma;
            double r1, g1, b1;

            if (h1 < 1)
            {
                r1 = chroma;
                g1 = x;
                b1 = 0;
            }
            else if (h1 < 2)
            {
                r1 = x;
                g1 = chroma;
                b1 = 0;
            }
            else if (h1 < 3)
            {
                r1 = 0;
                g1 = chroma;
                b1 = x;
            }
            else if (h1 < 4)
            {
                r1 = 0;
                g1 = x;
                b1 = chroma;
            }
            else if (h1 < 5)
            {
                r1 = x;
                g1 = 0;
                b1 = chroma;
            }
            else
            {
                r1 = chroma;
                g1 = 0;
                b1 = x;
            }

            byte r = (byte)(255 * (r1 + m));
            byte g = (byte)(255 * (g1 + m));
            byte b = (byte)(255 * (b1 + m));
            byte a = (byte)(255 * alpha);

            return(Color.FromArgb(a, r, g, b));
        }
예제 #26
0
 /// <summary>
 /// Assigns the default values to core.
 /// </summary>
 /// <param name="core">The core.</param>
 protected override void AssignDefaultValuesToSceneNode(SceneNode core)
 {
     material.Width       = (float)Size.Width;
     material.Height      = (float)Size.Height;
     material.Figure      = Figure;
     material.FigureRatio = (float)FigureRatio;
     material.PointColor  = Color.ToColor4();
     material.FixedSize   = FixedSize;
     base.AssignDefaultValuesToSceneNode(core);
 }
예제 #27
0
        public static Block GenerateBlock(Windows.UI.Color color)
        {
            Random random = new Random();
            int    x      = random.Next(700);
            int    y      = random.Next(700);

            Block block = new Block(x, y, color, 60, 60);

            return(block);
        }
예제 #28
0
        public static Color AsColor(ColorARGB colorArgb)
        {
            Color color = new Color();
            color.A = colorArgb.A;
            color.R = colorArgb.R;
            color.G = colorArgb.G;
            color.B = colorArgb.B;

            return color;
        }
        /// <summary>
        /// Starts the color bloom transition using the specified color and boundary sizes.
        ///
        /// The bloom is achieved by creating a circular solid colored visual whose scale is progressively
        /// animated to fully flood a given area.
        ///
        /// <param name="color">Using the specified color</param>
        /// <param name="initialBounds">The transition begins with a visual with these bounds and position</param>
        /// <param name="finalBounds">The transition ends when the visual has "bloomed" to an area of this bounding size</param>
        /// </summary>
        public void Start(Windows.UI.Color color, Rect initialBounds, Rect finalBounds)
        {
            var colorVisual = CreateVisualWithColorAndPosition(color, initialBounds, finalBounds);

            // add our solid colored circle visual to the live visual tree via the container
            _containerForVisuals.Children.InsertAtTop(colorVisual);

            // now that we have a visual, let's run the animation
            TriggerBloomAnimation(colorVisual);
        }
 public Blob(Blob source)
 {
     id = source.id;
     rect = source.rect;
     cog = source.cog;
     area = source.area;
     fullness = source.fullness;
     colorMean = source.colorMean;
     colorStdDev = source.colorStdDev;
 }
 public override void StopSelectionMode()
 {
     if (IsSelecting)
     {
         mActiveTool = null;
         BrushColor  = mSavedColor;
         mSelectTool = null;
         mRenderer.InvokeRedrawAllStrokes();
     }
 }
예제 #32
0
        //颜色选择器变化
        private void ColorPicker_ColorChanged(Windows.UI.Color Color, SolidColorBrush Brush)
        {
            isSalf     = true;
            this.Color = Color.FromArgb(Color.A, Color.R, Color.G, Color.B);  //改变颜色
            ColorChanged?.Invoke(this.Color);

            isSalf = false;

            Border.Background = Brush;
        }
예제 #33
0
        public PathInfo(ICanvasResourceCreator rc, Windows.UI.Color color, System.Single strokeWidth, CanvasStrokeStyle strokeStyle) //Pen pen, bool fill, int shapeType)
        {
            Vector2 offset = new Vector2(0.0f, 0.0f);

            _cpb = new CanvasPathBuilder(rc);
            //_cpb.SetSegmentOptions(CanvasFigureSegmentOptions.ForceRoundLineJoin);
            _color = color;
            //_fill = fill;
            //_type = shapeType;
        }
예제 #34
0
 public void FillEllipse(Vector2 center, float radiusX, float radiusY, Color color)
 {
     if (m_renderingType == TestSceneRenderingType.Default)
     {
         m_drawingSession.FillEllipse(center, radiusX, radiusY, color);
     }
     else
     {
         m_drawingSession.DrawEllipse(center, radiusX, radiusY, Colors.Black);
     }
 }
예제 #35
0
 public void FillRectangle(Rect rect, Color color)
 {
     if (m_renderingType == TestSceneRenderingType.Default)
     {
         m_drawingSession.FillRectangle(rect, color);
     }
     else
     {
         m_drawingSession.DrawRectangle(rect, Colors.Black);
     }
 }
예제 #36
0
 public void Clear(Color color)
 {
     if (m_renderingType == TestSceneRenderingType.Default)
     {
         m_drawingSession.Clear(color);
     }
     else
     {
         m_drawingSession.Clear(Colors.White);
     }
 }
예제 #37
0
 public static ColorAnimation CreateColor(Color to, Duration duration, string targetProperty)
 {
     var animation = new ColorAnimation
     {
         To = to,
         Duration = duration,
         EnableDependentAnimation = true
     };
     Storyboard.SetTargetProperty(animation, targetProperty);
     return animation;
 }
예제 #38
0
 public void DrawLine(Vector2 p1, Vector2 p2, Color color, float strokeWidth, CanvasStrokeStyle strokeStyle)
 {
     if (m_renderingType == TestSceneRenderingType.Default)
     {
         m_drawingSession.DrawLine(p1, p2, color, strokeWidth, strokeStyle);
     }
     else
     {
         m_drawingSession.DrawLine(p1, p2, Colors.Black);
     }
 }
예제 #39
0
        public ImageMarkupPage()
        {
            this.InitializeComponent();


            this._inkManager = new InkManager();

            //#FF003f82
            this._brushColor = Colors.Blue;
            this.Loaded     += DrawImageView_Loaded;
        }
예제 #40
0
 public Brush(int oldX, int oldY, int currentX, int currentY, Windows.UI.Color brushColor, int brushSize, WriteableBitmap bmp, BrushModifierPanel mod)
 {
     OldX       = oldX;
     OldY       = oldY;
     CurrentX   = currentX;
     CurrentY   = currentY;
     BrushColor = brushColor;
     BrushSize  = brushSize;
     Bmp        = bmp;
     Mod        = mod;
 }
예제 #41
0
 public static Color Lerp(this Color color, Color target, float amount)
 {
     float sr = color.R,
         sg = color.G,
         sb = color.B;
     float er = target.R,
         eg = target.G,
         eb = target.B;
     byte r = (byte)sr.Lerp(er, amount),
          g = (byte)sg.Lerp(eg, amount),
          b = (byte)sb.Lerp(eb, amount);
     return Color.FromArgb(255, r, g, b);
 }
 /// <summary>
 /// Outputs text with formating.
 /// </summary>
 /// <param name="target">The target <see cref="TextBlock"/>.</param>
 /// <param name="toOutput">String to output.</param>
 /// <param name="fontStyle">The font style.</param>
 /// <param name="fontWeight">The font weight.</param>
 /// <param name="fontColor">Color of the font.</param>
 public static void OutputWithFormat(this TextBlock target, string toOutput,
     FontStyle fontStyle = FontStyle.Normal,
     FontWeight fontWeight = default(FontWeight),
     Color fontColor = default(Color))
 {
     var formatted = new Run
     {
         Text = toOutput,
         FontStyle = fontStyle,
         FontWeight = fontWeight.Equals(default(FontWeight)) ? FontWeights.Normal : fontWeight,
         Foreground = fontColor.Equals(default(Color)) ? new SolidColorBrush(Colors.Black) : new SolidColorBrush(fontColor)
     };
     target.Inlines.Add(formatted);
 }
예제 #43
0
        static int ToInt(Color color)
        {
            var col = 0;

            if (color.A != 0)
            {
                var a = color.A + 1;
                col = (color.A << 24)
                  | ((byte)((color.R * a) >> 8) << 16)
                  | ((byte)((color.G * a) >> 8) << 8)
                  | ((byte)((color.B * a) >> 8));
            }

            return col;
        }
예제 #44
0
 public static IColorSequence Quadrupolar(
     Color color1,
     Color color2,
     Color color3,
     Color color4,
     int quarterStepCount)
 {
     return new ColorSequenceImpl
         (
             ColorEx.UniformSpread(color1, color2, quarterStepCount)
                 .Concat(ColorEx.UniformSpread(color2, color3, quarterStepCount))
                 .Concat(ColorEx.UniformSpread(color3, color4, quarterStepCount))
                 .Concat(ColorEx.UniformSpread(color4, color1, quarterStepCount))
         );
 }
예제 #45
0
        public static MapPolygon DrawCircle(List<BasicGeoposition> points, Color fillColor, Color strokeColor, int strokeThickness = 2, byte alpha = 80)
        {
            fillColor.A = alpha;
            strokeColor.A = alpha;

            var circle = new MapPolygon
            {
                StrokeThickness = strokeThickness,
                FillColor = fillColor,
                StrokeColor = strokeColor,
                Path = new Geopath(points)
            };

            return circle;
        }
예제 #46
0
        public static void SetThemeColor(Color color)
        {
            foreach (var brushKey in brushKeys)
            {
                if (Application.Current.Resources.ContainsKey(brushKey))
                {
                    var solidColorBrush = Application.Current.Resources[brushKey] as SolidColorBrush;
                    if (solidColorBrush != null)
                        solidColorBrush.Color = color;
                }
            }

#if WINDOWS_PHONE_APP
            var statusBar = StatusBar.GetForCurrentView();
            statusBar.ForegroundColor = color;
#endif
        }
예제 #47
0
        static Color ChangeColorBrightness(Color color, float correctionFactor)
        {
            float red = (float)color.R;
            float green = (float)color.G;
            float blue = (float)color.B;

            if (correctionFactor < 0)
            {
                correctionFactor = 1 + correctionFactor;
                red *= correctionFactor;
                green *= correctionFactor;
                blue *= correctionFactor;
            }
            else
            {
                red = (255 - red) * correctionFactor + red;
                green = (255 - green) * correctionFactor + green;
                blue = (255 - blue) * correctionFactor + blue;
            }

            return Color.FromArgb(color.A, (byte)red, (byte)green, (byte)blue);
        }
예제 #48
0
        public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
        {
            Canvas.SetTop(Rectangle, current.ChartLocation.Y);
            Canvas.SetLeft(Rectangle, current.ChartLocation.X);

            Rectangle.Width = Width;
            Rectangle.Height = Height;

            if (IsNew)
            {
                Rectangle.Fill = new SolidColorBrush(Colors.Transparent);
            }

            if (HoverShape != null)
            {
                HoverShape.Width = Width;
                HoverShape.Height = Height;
                Canvas.SetLeft(HoverShape, current.ChartLocation.X);
                Canvas.SetTop(HoverShape, current.ChartLocation.Y);
            }

            if (DataLabel != null)
            {
                DataLabel.UpdateLayout();
                Canvas.SetTop(DataLabel, current.ChartLocation.Y + (Height/2) - DataLabel.ActualHeight*.5);
                Canvas.SetLeft(DataLabel, current.ChartLocation.X + (Width/2) - DataLabel.ActualWidth*.5);
            }

            var targetColor = new Color
            {
                A = ColorComponents.A,
                R = ColorComponents.R,
                G = ColorComponents.G,
                B = ColorComponents.B
            };

            if (chart.View.DisableAnimations)
            {
                Rectangle.Fill = new SolidColorBrush(targetColor);
                return;
            }

            var animSpeed = chart.View.AnimationsSpeed;

            Rectangle.Fill.BeginColorAnimation(nameof(SolidColorBrush.Color), targetColor, animSpeed);
        }
예제 #49
0
 private Windows.UI.Xaml.UIElement CreateSymbol(string symbol, Color colour)
 {
     return new TextBlock
     {
         Text = symbol,
         FontSize = 40,
         Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(colour),
         HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
         VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center
     };
 }
예제 #50
0
 private void FireSelectedColorChangingEvent(Color selectedColor)
 {
     if (SelectedColorChanging != null)
     {
         SelectedColorEventArgs args = new SelectedColorEventArgs(selectedColor);
         SelectedColorChanging(this, args);
     }
 }
예제 #51
0
 private static WordRenderData CreateText(PageRenderData context, TextElement element, bool bold, bool italic,
                                          double fontSize, double left, double top, Color? color)
 {
     return new WordRenderData
                {
                    Text = element.Text,
                    Bold = bold,
                    Italic = italic,
                    FontSize = fontSize,
                    Left = left + context.OffsetX,
                    Top = top + context.OffsetY,
                    Color = color
                };
 }
예제 #52
0
 private static Color darkerColor(Color oldColor)
 {
     Color newColor = new Color();
     newColor.A = 255;
     if (oldColor.R > 80) newColor.R = (byte)(oldColor.R - 32); else newColor.R = 0;
     if (oldColor.G > 80) newColor.G = (byte)(oldColor.G - 32); else newColor.G = 0;
     if (oldColor.B > 80) newColor.B = (byte)(oldColor.B - 32); else newColor.B = 0;
     return newColor;
 }
예제 #53
0
 private Windows.UI.Xaml.UIElement CreateHighLightedSymbol(string symbol, Color colour)
 {
     return new Border
     {
         CornerRadius = new Windows.UI.Xaml.CornerRadius(40),
         BorderThickness = new Windows.UI.Xaml.Thickness(1),
         BorderBrush = new Windows.UI.Xaml.Media.SolidColorBrush(Colors.Red),
         Background = new Windows.UI.Xaml.Media.SolidColorBrush(Color.FromArgb(255, 96, 96, 96)),
         Padding = new Windows.UI.Xaml.Thickness(2, 5, 2, 2),
         Width = 80,
         Height = 80,
         Child = CreateSymbol(symbol, colour)
     };
 }
        /// <summary>
        /// Occurs when the range value of one of the color sliders changes.
        /// </summary>
        /// <param name="sender">The object where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void ColorSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
        {
            if (this.ignoreScreenColorListBoxSelectionChanging)
            {
                return;
            }

            var color = new Color()
            {
                R = (byte)this.RedSlider.Value,
                G = (byte)this.GreenSlider.Value,
                B = (byte)this.BlueSlider.Value,
                A = 255,
            };

            ListBoxItem item = (ListBoxItem)this.ScreenColorListBox.SelectedItem;
            ((SolidColorBrush)item.BorderBrush).Color = color;
            ((SolidColorBrush)this.ColorPreviewRectangle.Fill).Color = color;

            int screenColor = this.ScreenColorListBox.SelectedIndex - 4;

            if (this.customTheme.ColorTable[(ScreenColor)screenColor] == color)
            {
                return;
            }
            this.customTheme.ColorTable[(ScreenColor)screenColor] = color;

            TerminalPageForceRender(fontChanged: false);
        }
예제 #55
0
 public ColorRange(Color from, Color to)
 {
     this.From = from;
     this.To = to;
 }
예제 #56
0
 public RichStringPart(string str, Color color)
 {
     String = str;
     Color = color;
 }
예제 #57
0
        private RadialMenuButton CreateColorRadialMenuButtonWithSubMenu(Color sourceColor, double subMenuButtonCount)
        {
            var colorButton = CreateColorRadialMenuButton(sourceColor);
            colorButton.Submenu = new RadialMenu();

            for (var i = 0; i < subMenuButtonCount; i++)
            {
                var lightenFactor = (float) i/10;
                colorButton.Submenu.AddButton(CreateColorRadialMenuButton(sourceColor.Lighten(lightenFactor)));
            }

            return colorButton;
        }
예제 #58
0
 public void SetPixel(int x, int y, Color color)
 {
     SetPixel(x, y, ToInt(color));
 }
예제 #59
0
 /// <summary>${core_RawTheme_constructor_None_D}</summary>
 public RawTheme( )
 {
     this.Fill = new SolidColorBrush(new Color() { A = 0x40 , R = 0x42 , G = 0x72 , B = 0xd7 });
     this.Stroke = new SolidColorBrush(new Color() { A = 0xff , R = 0x50 , G = 0x82 , B = 0xe5 });
     this.StrokeThickness = 2;
     this.Opacity = 1;
     this.Size = 8;
     this.Color = new SolidColorBrush(new Color() { A = 0xff , R = 0x42 , G = 0x72 , B = 0xd7 });
     this.HoverVertexStyle = new PredefinedMarkerStyle()
     {
         Size = 12 ,
         Symbol = PredefinedMarkerStyle.MarkerSymbol.Circle ,
         //暂时找不到RadialGradientBrush的API,暂时设置为单一颜色
         Color=new SolidColorBrush(Colors.Red)
         //Color = new RadialGradientBrush()
         //{
         //    GradientStops = new GradientStopCollection() 
         //    {
         //        new GradientStop(){ Color=new Color(){ A=0xff,R=0xc2,G=0xc2,B=0xc2}, Offset=0.45},
         //        new GradientStop(){ Color=new Color(){ A=0xff,R=0x42,G=0x42,B=0x42}, Offset=0.703},
         //        new GradientStop(){ Color=new Color(){ A=0xff,R=0x8f,G=0x8e,B=0x8e}, Offset=0.687},
         //        new GradientStop(){ Color=new Color(){ A=0x00,R=0xff,G=0xff,B=0xff}, Offset=1},
         //    }
         //}
     };
     this.SnapStyle = new PredefinedMarkerStyle()
     {
         Size = 12 ,
         Symbol = PredefinedMarkerStyle.MarkerSymbol.Circle ,
         //暂时找不到RadialGradientBrush的API,暂时设置为单一颜色
         Color = new SolidColorBrush(Colors.Red)
         //Color = new RadialGradientBrush()
         // {
         //     GradientStops = new GradientStopCollection() 
         //    {
         //        new GradientStop(){ Color=new Color(){ A=0xff,R=0x2f,G=0x61,B=0xb2}, Offset=1},
         //        new GradientStop(){ Color=new Color(){ A=0xff,R=0x70,G=0xce,B=0x71}, Offset=0.631},
         //        new GradientStop(){ Color=new Color(){ A=0xff,R=0xe5,G=0xe4,B=0xe4}, Offset=0.558},
         //        new GradientStop(){ Color=new Color(){ A=0xff,R=0x9c,G=0xb1,B=0xd3}, Offset=0.944},
         //    }
         // }
     };
     this.HoverCenterStyle = new PredefinedMarkerStyle
     {
         Size = 12 ,
         Symbol = PredefinedMarkerStyle.MarkerSymbol.Circle ,
         //暂时找不到RadialGradientBrush的API,暂时设置为单一颜色
         Color = new SolidColorBrush(Colors.Red)
         //Color = new RadialGradientBrush()
         //{
         //    GradientStops = new GradientStopCollection() 
         //        {
         //            new GradientStop(){ Color=new Color(){ A=0xff,R=0xea,G=0xee,B=0xf0}, Offset=0},
         //            new GradientStop(){ Color=new Color(){ A=0xff,R=0xf4,G=0xf6,B=0xf0}, Offset=0.66},
         //            new GradientStop(){ Color=new Color(){ A=0xff,R=0x4c,G=0xd5,B=0xef}, Offset=0.45},
         //            new GradientStop(){ Color=new Color(){ A=0xff,R=0x64,G=0xc8,B=0xf0}, Offset=0.65},             
         //            new GradientStop(){ Color=new Color(){ A=0xff,R=0xef,G=0xf5,B=0xea}, Offset=0.44},  
         //            new GradientStop(){ Color=new Color(){ A=0xff,R=0x64,G=0xc8,B=0xf0}, Offset=1},
         //            new GradientStop(){ Color=new Color(){ A=0xff,R=0xf3,G=0xf3,B=0xf3}, Offset=0.89},
         //            new GradientStop(){ Color=new Color(){ A=0xff,R=0x64,G=0xc8,B=0xf0}, Offset=0.9},
         //        }
         //}
     };
     FCGreen = new Color { A = 0xff , R = 0x99 , G = 0xcc , B = 0x66 };
     FCOrange = new Color { A = 0xff , R = 0xd9 , G = 0x82 , B = 0x57 };
     FCBlue = new Color { A = 0xff , R = 0x95 , G = 0xd1 , B = 0xe5 };
     FCYollew = new Color { A = 0xff , R = 0xe5 , G = 0xe5 , B = 0x45 };
 }
예제 #60
0
        private void SetOption(string symbol, Color colour, bool cellFixed = false)
        {
            if (!isSet)
            {
                isSet = true;
                Border border = new Border
                {
                    Margin = margin,
                    Background = background,
                    Child = cellFixed ? CreateHighLightedSymbol(symbol, colour) : CreateSymbol(symbol, colour)
                };

                this.Children.Add(border);
                Grid.SetColumnSpan(border, columns);
                Grid.SetRowSpan(border, rows);
            }
        }