Пример #1
0
 //
 public static void Do(IColor first, IColor second)
 {
     Do(first.GetRed(), second.GetRed());
     Do(first.GetRed(), second.GetGreen());
     Do(first.GetGreen(), second.GetRed());
     Do(first.GetGreen(), second.GetGreen());
 }
Пример #2
0
 //
 public static void Do(IColor first, IColor second)
 {
     var mixer = new ColorMixer();
     first.Mix(0,mixer);
     second.Mix(1,mixer);
     mixer.Do();
 }
Пример #3
0
        public void Processor_TwoColorValues_ShouldPass(TypeOfProcess typeCode, IColor colorOne, IColor colorTwo)
        {
            var processor = new ColorsProcessor();
            processor.Process(colorOne, colorTwo);

            Assert.Equal(typeCode, processor.LastProcess);
        }
Пример #4
0
        /// <summary>
        /// 简单渲染
        /// </summary>
        /// <param name="layerName">图层名字</param>
        /// <param name="FillStyle">FillStyle</param>
        /// <param name="pColor">FillColor</param>
        /// <param name="OutLineColor">OutLineColor</param>
        /// <param name="RenderLabel">样式名称注释</param>
        /// <param name="Descripition">描述</param>
        public void createSimpleFillSymbol(string layerName, esriSimpleFillStyle FillStyle, IColor pColor, IColor OutLineColor, string RenderLabel, string Descripition)
        {
            //简单填充符号
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            //可以用符号选择器进行
            simpleFillSymbol.Style = FillStyle;
            simpleFillSymbol.Color = pColor;
            //创建边线符号
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            simpleLineSymbol.Color = OutLineColor;
            ISymbol symbol = simpleLineSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            simpleFillSymbol.Outline = simpleLineSymbol;

            ISimpleRenderer simpleRender = new SimpleRendererClass();
            simpleRender.Symbol = simpleFillSymbol as ISymbol;
            simpleRender.Label = RenderLabel;
            simpleRender.Description = Descripition;

            IGeoFeatureLayer geoFeatureLayer;
            geoFeatureLayer = getGeoLayer(layerName);
            if (geoFeatureLayer != null)
            {
                geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
            }
        }
Пример #5
0
 public override Image<Gray, byte> DetectSkin(Image<Bgr, byte> Img, IColor min, IColor max)
 {
     Image<Hsv, Byte> currentHsvFrame = Img.Convert<Hsv, Byte>();
     Image<Gray, byte> skin = new Image<Gray, byte>(Img.Width, Img.Height);
     skin = currentHsvFrame.InRange((Hsv)min, (Hsv)max);
     return skin;
 }
Пример #6
0
        protected override bool OnDeactivate()
        {
            selectedColor = null;
            selectedValue = null;

            return base.OnDeactivate();
        }
Пример #7
0
 public static ISimpleFillSymbol get_SimplePolygonSymbol(IColor color, esriSimpleFillStyle style, ILineSymbol outline)
 {
     ISimpleFillSymbol theReturn = new SimpleFillSymbolClass();
     theReturn.Color = color;
     theReturn.Style = style;
     theReturn.Outline = outline;
     return theReturn;
 }
Пример #8
0
 public Color(IColor color)
 {
     if (null == color)
     {
         throw new ArgumentNullException("color");
     }
     _innerColor = color;
 }
Пример #9
0
 public static ISimpleLineSymbol get_SimpleLineSymbol(IColor color, double width, esriSimpleLineStyle style)
 {
     ISimpleLineSymbol theReturn = new SimpleLineSymbolClass();
     theReturn.Color = color;
     theReturn.Style = style;
     theReturn.Width = width;
     return theReturn;
 }
Пример #10
0
 public static ISimpleMarkerSymbol get_SimplePointSymbol(IColor color, double size, esriSimpleMarkerStyle style)
 {
     ISimpleMarkerSymbol theReturn = new SimpleMarkerSymbolClass();
     theReturn.Color = color;
     theReturn.Style = style;
     theReturn.Size = size;
     return theReturn;
 }
Пример #11
0
        /// <summary>
        /// Indicates whether a IColor class and a Color class represent the same color.
        /// </summary>
        /// <param name="color1"></param>
        /// <param name="color2"></param>
        /// <returns></returns>
        public static bool Compare(IColor color1, Color color2)
        {
            IRgbColor rgbColor1 = (IRgbColor)color1;

            return (rgbColor1.Red == color2.R) &&
                   (rgbColor1.Green == color2.G) &&
                   (rgbColor1.Blue == color2.B) &&
                   (rgbColor1.NullColor == color2.IsEmpty);
        }
Пример #12
0
 public IFont GetFont(short fontSize, string fontName, IColor fontColor)
 {
     var font = Workbook.CreateFont();
     font.Boldweight = 100;
     font.FontName = fontName;
     font.FontHeightInPoints = fontSize;
     font.Color = fontColor.Indexed;
     return font;
 }
Пример #13
0
 private void btncolor_Click(object sender, EventArgs e)
 {
     ColorDialog colorD = new ColorDialog();
     colorD.ShowDialog();
     if (colorD.Color != null)
     {
         m_color = GetRGBColor(colorD.Color.R, colorD.Color.G, colorD.Color.B);
     }
 }
        public static void SetColor(int red, int green, int blue)
        {
            IRgbColor rgbColor = new RgbColorClass();
            rgbColor.Red = red;
            rgbColor.Green = green;
            rgbColor.Blue = blue;

            _color = rgbColor as IColor;
        }
Пример #15
0
 public IFont GetFont(short fontSize, string fontName, IColor fontColor)
 {
     var font = Workbook.CreateFont();
     font.Boldweight = 100;
     ((XSSFFont)font).SetColor((XSSFColor)fontColor);
     font.FontName = fontName;
     font.FontHeightInPoints = fontSize;
     return font;
 }
Пример #16
0
        public void SetFromColor(IColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException(nameof(color), "The color parameter can not be null.");
            }

            this.Color = color.Color;
        }
Пример #17
0
        public void Processor_OneColorValue_ShouldPass(TypeOfProcess typeCode, IColor color)
        {
            var processor = new Processor();
               var processHelper = new ProcessHelper<IProcessor>(processor);

               processHelper.Process(color);

               Assert.Equal(typeCode, processor.LastProcess);
        }
        public static void AddOutlineToGraphicsLayer3D(IGraphicsContainer3D graphicsContainer3D, IGeometryCollection geometryCollection, IColor color, esriSimple3DLineStyle style, double width)
        {
            for (int i = 0; i < geometryCollection.GeometryCount; i++)
            {
                IGeometry geometry = geometryCollection.get_Geometry(i);

                graphicsContainer3D.AddElement(ElementUtilities.ConstructPolylineElement(geometry, color, style, width));
            }
        }
Пример #19
0
        public XYZColor ToXYZColor(IColor color)
        {
            var xyYColor = color as xyYColor;

            var X = xyYColor.x * (xyYColor.Y / xyYColor.y);
            var Z = (1 - xyYColor.x - xyYColor.y) * (xyYColor.Y / xyYColor.y);

            return new XYZColor(xyYColor.Alpha, X, xyYColor.Y, Z);
        }
Пример #20
0
        public void Process(IColor colorOne, IColor colorTwo)
        {
            var helper = new ProcessHelper();
            colorOne.Accept(helper);
            colorTwo.Accept(helper);

            helper.Process(this);
            //через конструтор копирования
            helper.ProcessByConstructor(this);
        }
Пример #21
0
        public XYZColor ToXYZColor(IColor color)
        {
            var rgbColor = color as RGBColor;

            var rgbVector = new double[3] { rgbColor.R.Value, rgbColor.G.Value, rgbColor.B.Value };

            var xyzVector = Multiply(M_RGBToXYZ, rgbVector);

            return new XYZColor(color.Channels["Alpha"].Value, xyzVector[0], xyzVector[1], xyzVector[2]);
        }
Пример #22
0
        /// <summary>
        /// Get the paint symble of painted pixel.
        /// </summary>
        /// <param name="filledColor">Fill color for the symbol</param>
        /// <returns></returns>
        public static ISimpleFillSymbol GetPaintSymbol(IColor filledColor)
        {
            ISimpleFillSymbol selectionSymbol = new SimpleFillSymbolClass();
            selectionSymbol.Color = filledColor;
            ISimpleLineSymbol selectionOutlineSymbol = new SimpleLineSymbolClass();
            selectionOutlineSymbol.Color = new RgbColorClass() { Red = 255, Green = 255, Blue = 0 };
            selectionOutlineSymbol.Width = 2;
            selectionSymbol.Outline = selectionOutlineSymbol;

            return selectionSymbol;
        }
        private static void DrawAxis(IGraphicsContainer3D axesGraphicsContainer3D, IPoint axisFromPoint, IPoint axisToPoint, IColor axisColor, esriSimple3DLineStyle axisStyle, double axisWidth)
        {
            IPointCollection axisPointCollection = new PolylineClass();

            axisPointCollection.AddPoint(axisFromPoint, ref _missing, ref _missing);
            axisPointCollection.AddPoint(axisToPoint, ref _missing, ref _missing);

            GeometryUtilities.MakeZAware(axisPointCollection as IGeometry);

            GraphicsLayer3DUtilities.AddAxisToGraphicsLayer3D(axesGraphicsContainer3D, axisPointCollection as IGeometry, axisColor, axisStyle, axisWidth);
        }
Пример #24
0
 public override Image<Gray, byte> DetectSkin(Image<Bgr, byte> Img, IColor min, IColor max)
 {
     Image<Ycc, Byte> currentYCrCbFrame = Img.Convert<Ycc, Byte>();
     Image<Gray, byte> skin = new Image<Gray, byte>(Img.Width, Img.Height);
     skin = currentYCrCbFrame.InRange((Ycc)min,(Ycc) max);
     StructuringElementEx rect_12 = new StructuringElementEx(12, 12, 6, 6, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
     CvInvoke.cvErode(skin, skin, rect_12, 1);
     StructuringElementEx rect_6 = new StructuringElementEx(6, 6, 3, 3, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
     CvInvoke.cvDilate(skin, skin, rect_6, 2);
     return skin;
 }
        public override Image<Gray, byte> DetectSkin(Image<Bgr, byte> Img, IColor min, IColor max)
        {
            Image<Hsv, Byte> currentHsvFrame = Img.Convert<Hsv, Byte>();
            Image<Gray, byte> skin = new Image<Gray, byte>(Img.Width, Img.Height);
            skin = currentHsvFrame.InRange((Hsv)min, (Hsv)max);

            StructuringElementEx rect_6 = new StructuringElementEx(3, 3,1, 1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
            CvInvoke.cvDilate(skin, skin, rect_6, 2);


            return skin;
        }
        public static IElement ConstructMultiPatchElement(IGeometry geometry, IColor color)
        {
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            simpleFillSymbol.Color = color;

            IElement element = new MultiPatchElementClass();
            element.Geometry = geometry;

            IFillShapeElement fillShapeElement = element as IFillShapeElement;
            fillShapeElement.Symbol = simpleFillSymbol;

            return element;
        }
        public static IColor GetColor()
        {
            if (_color == null)
            {
                IRgbColor rgbColor = new RgbColorClass();
                rgbColor.Red = 255;
                rgbColor.Green = 0;
                rgbColor.Blue = 0;

                _color = rgbColor as IColor;
            }
            return _color;
        }
Пример #28
0
      /// <summary>
      /// Get the names of the channels
      /// </summary>
      /// <param name="color">The color</param>
      /// <returns>The names of the channels</returns>
      public static String[] GetNamesOfChannels(IColor color)
      {
         List<String> channelNames = new List<string>();
         foreach (System.Reflection.PropertyInfo pInfo in color.GetType().GetProperties())
         {
            if (pInfo.GetCustomAttributes(typeof(DisplayColorAttribute), true).Length > 0)
               channelNames.Add(pInfo.Name);
         }
         if (channelNames.Count > 0) return channelNames.ToArray();

         //Create default channel names
         String[] res = new string[color.Dimension];
         for (int i = 0; i < res.Length; i++)
            res[i] = String.Format("Channel {0}", i);
         return res;
      }
Пример #29
0
      /// <summary>
      /// Get the display color for each channel
      /// </summary>
      public static System.Drawing.Color[] GetDisplayColorOfChannels(IColor color)
      {
         List<System.Drawing.Color> channelColor = new List<System.Drawing.Color>();
         foreach (System.Reflection.PropertyInfo pInfo in color.GetType().GetProperties())
         {
            Object[] displayAtts = pInfo.GetCustomAttributes(typeof(DisplayColorAttribute), true);
            if (displayAtts.Length > 0)
               channelColor.Add(((DisplayColorAttribute)displayAtts[0]).DisplayColor);
         }
         if (channelColor.Count > 0) return channelColor.ToArray();

         //create default color
         System.Drawing.Color[] res = new System.Drawing.Color[color.Dimension];
         for (int i = 0; i < res.Length; i++)
            res[i] = System.Drawing.Color.Gray;
         return res;
      }
Пример #30
0
        public XYZColor ToXYZColor(IColor color)
        {
            /// conversion algorithm created with help of http://en.wikipedia.org/wiki/Lab_color_space

            var labColor = color as LabColor;

            var l = (labColor.L + 16) / 116;

            var fy = f_reverse_conversion(l);
            var fx = f_reverse_conversion(l + labColor.a / 500);
            var fz = f_reverse_conversion(l - labColor.b / 200);

            var y = KnownColorSpaces.XYZ.WhitePoint.Y * fy;
            var x = KnownColorSpaces.XYZ.WhitePoint.X * fx;
            var z = KnownColorSpaces.XYZ.WhitePoint.Z * fz;

            return new XYZColor(labColor.Alpha, x, y, z);            
        }
Пример #31
0
        private IGlobeDisplay EnableSetSun(Single pAmbientLght, double platitude, double plongitude, IColor pColor)
        {
            Single    pSunred; Single pSungreen; Single pSunblue;
            IRgbColor pRgbColor = new RgbColorClass();

            pRgbColor.RGB = Convert.ToInt32(pColor.RGB);
            pSunred       = pRgbColor.Red;
            pSungreen     = pRgbColor.Green;
            pSunblue      = pRgbColor.Blue;
            IGlobeDisplayRendering pglbDispRend = (IGlobeDisplayRendering)axGlobeControl1.GlobeDisplay;

            pglbDispRend.SetSunColor(pSunred, pSungreen, pSunblue);
            pglbDispRend.SetSunPosition(platitude, plongitude);
            pglbDispRend.AmbientLight = pAmbientLght;
            return(axGlobeControl1.GlobeDisplay);
        }
Пример #32
0
 public Shape(IColor c)
 {
     this.color = c;
 }
Пример #33
0
 public static float[] ToArray(this IColor value)
 {
     return(new[] { value.R, value.G, value.B });
 }
 public ConsoleLoggerMiddleware(Printer printer, IColor color)
 {
     this.printer = printer;
     this.color   = color;
 }
Пример #35
0
 private static Boolean IsWhite(IColor color)
 {
     return(color.r == Colors.MAX_COLOR_RGBA && color.g == Colors.MAX_COLOR_RGBA && color.b == Colors.MAX_COLOR_RGBA);
 }
Пример #36
0
 private void btnSelectBackColor_Click(object sender, EventArgs e)
 {
     gColor = GetColorByColorPalette(btnSelectBackColor.Right, btnSelectBackColor.Bottom);
 }
Пример #37
0
 IDisplayable IDisplayable.SetColor(IColor color)
 {
     throw new NotImplementedException();
 }
Пример #38
0
 private static string FormatColor(IColor c)
 {
     return(string.Format("#{0:X2}{1:X2}{2:X2}", c.GetR(), c.GetG(), c.GetB()));
 }
Пример #39
0
 public void Clear(IColor clearColor)
 {
     WriteLine("<g id=\"background\"><rect x=\"{0}\" y=\"{1}\" width=\"{2}\" height=\"{3}\" fill=\"{4}\" stroke=\"none\"/></g>",
               fViewBox.Left, fViewBox.Top, fViewBox.GetWidth(), fViewBox.GetHeight(), FormatColor(clearColor));
 }
Пример #40
0
        public static Color GetFeatureColor(IMap pMap, string strLayerName, IFeature pFeaVal)
        {
            Color black;

            try
            {
                ILayer layerByFeatureClassName = GetLayerByFeatureClassName(pMap, strLayerName);
                if (layerByFeatureClassName != null)
                {
                    esriGeometryType geometryType    = pFeaVal.Shape.GeometryType;
                    ISymbol          symbolByFeature =
                        ((IGeoFeatureLayer)layerByFeatureClassName).Renderer.get_SymbolByFeature(pFeaVal);
                    IRgbColor rgbColorClass = new RgbColor();
                    IColor    color         = null;
                    if (geometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        if (symbolByFeature is ISimpleLineSymbol)
                        {
                            color = ((ISimpleLineSymbol)symbolByFeature).Color;
                        }
                        if (symbolByFeature is ILineSymbol)
                        {
                            color = ((ILineSymbol)symbolByFeature).Color;
                        }
                    }
                    if (geometryType == esriGeometryType.esriGeometryPoint)
                    {
                        if (symbolByFeature is IMarkerFillSymbol)
                        {
                            color = ((IMarkerFillSymbol)symbolByFeature).Color;
                        }
                        if (symbolByFeature is IMarkerLineSymbol)
                        {
                            color = ((IMarkerLineSymbol)symbolByFeature).Color;
                        }
                        if (symbolByFeature is IMarkerSymbol)
                        {
                            color = ((IMarkerSymbol)symbolByFeature).Color;
                        }
                    }
                    if (color != null)
                    {
                        rgbColorClass.RGB = (color.RGB);
                        int red   = rgbColorClass.Red;
                        int green = rgbColorClass.Green;
                        black = Color.FromArgb(red, green, rgbColorClass.Blue);
                    }
                    else
                    {
                        black = Color.Black;
                    }
                }
                else
                {
                    black = Color.Black;
                }
            }
            catch (Exception exception)
            {
                black = Color.Black;
            }
            return(black);
        }
Пример #41
0
 public Shape(IColor color)
 {
     this.color = color;
 }
Пример #42
0
 public static IEdge SetColor(this IEdge myIEdge, IColor myColor)
 {
     return((myIEdge as IGraphElement).SetColor(myColor) as IEdge);
 }
        public void UniqueValueRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, int pCount, string pFieldName)

        {
            IGeoFeatureLayer     pGeoFeaturelayer = pFtLayer as IGeoFeatureLayer;
            IUniqueValueRenderer pUnique          = new UniqueValueRendererClass();

            pUnique.FieldCount = 1;

            pUnique.set_Field(0, pFieldName);

            ISimpleFillSymbol pSimFill = new SimpleFillSymbolClass();

            //给颜色

            IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);
            IFeature       pFt       = pFtCursor.NextFeature();

            IFillSymbol pFillSymbol1;

            ////添加第一个符号

            //pFillSymbol1 = new SimpleFillSymbolClass();

            //pFillSymbol1.Color = GetRGBColor(103, 252, 179) as IColor;

            ////添加第二个符号

            //IFillSymbol pFillSymbol2 = new SimpleFillSymbolClass();

            //pFillSymbol2.Color = GetRGBColor(125, 155, 251) as IColor;

            //创建并设置随机色谱从上面的的图可以看出我们要给每一个值定义一种颜色,我 们可以创建色谱,但是色谱的这些参数

            IRandomColorRamp pColorRamp = new RandomColorRampClass();

            pColorRamp.StartHue = 0;

            pColorRamp.MinValue = 20;

            pColorRamp.MinSaturation = 15;

            pColorRamp.EndHue = 360;

            pColorRamp.MaxValue = 100;

            pColorRamp.MaxSaturation = 30;
            pColorRamp.Size          = pCount;

            //pColorRamp.Size = pUniqueValueRenderer.ValueCount;
            bool ok = true;

            pColorRamp.CreateRamp(out ok);
            IEnumColors pEnumRamp = pColorRamp.Colors;

            //IColor pColor = pEnumRamp.Next();

            int pIndex = pFt.Fields.FindField(pFieldName);

            //因为我只有24条记录,所以改变这些,这些都不会超过255或者为负数.求余

            int i = 0;

            while (pFt != null)

            {
                IColor pColor = pEnumRamp.Next();
                if (pColor == null)

                {
                    pEnumRamp.Reset();

                    pColor = pEnumRamp.Next();
                }

                //以下注释代码为自定义的两种颜色 ,如果不使用随机的颜色,可以采用这样的

                //if (i % 2 == 0)

                //{

                // pUnique.AddValue(Convert.ToString(pFt.get\_Value(pIndex)) , pFieldName, pFillSymbol1 as ISymbol);

                //}

                //else

                //{

                // pUnique.AddValue(Convert.ToString(pFt.get\_Value(pIndex)) , pFieldName, pFillSymbol2 as ISymbol);

                //}

                //i++;

                pFillSymbol1 = new SimpleFillSymbolClass();

                pFillSymbol1.Color = pColor;
                pUnique.AddValue(Convert.ToString(pFt.get_Value(pIndex)), pFieldName, pFillSymbol1 as ISymbol);

                pFt = pFtCursor.NextFeature();

                // pColor = pEnumRamp.Next();
            }

            pGeoFeaturelayer.Renderer = pUnique as IFeatureRenderer;

            pMapcontrol.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Пример #44
0
 public static bool HasNull(IColor first, IColor second)
 {
     return(first == null || second == null);
 }
 private Color ToNativeColor(IColor color)
 {
     return(Color.FromArgb(color.A, color.R, color.G, color.B));
 }
Пример #46
0
 public IImage GetImage(IGraphicsPath path,
                        IColor foreground)
 {
     throw new NotImplementedException();
 }
Пример #47
0
 public static bool TryParse(string str, out IColor color)
 {
     return(ColorUtils.TryParse(str, out color));
 }
 public ConsoleLoggerMiddleware(IPrinter printer, IColor red)
 {
     this.printer = printer;
     this.color   = red;
 }
Пример #49
0
        public void ParseText(List <BBTextChunk> chunksList, string text)
        {
            fChunks = chunksList;
            fChunks.Clear();

            float              lastFontSize = fDefaultFontSize;
            BBTextChunk        lastChunk    = null;
            Stack <SizeChange> stackSizes   = new Stack <SizeChange>();

            //lastChunk = SetChunkFontSize(0, lastChunk, fDefaultFontSize);

            if (string.IsNullOrEmpty(text))
            {
                text      = EMPTY_CHUNK;
                lastChunk = SetChunkText(0, lastChunk, text);
                return;
            }

            StringTokenizer strTok = new StringTokenizer(text);

            strTok.IgnoreWhiteSpace       = false;
            strTok.RecognizeDecimals      = false;
            strTok.RecognizeQuotedStrings = false;

            Token tok = strTok.Next();

            while (tok.Kind != TokenKind.EOF)
            {
                if (tok.Kind == TokenKind.Symbol && tok.Value == "[")
                {
                    string temp = tok.Value;
                    tok = strTok.Next();

                    bool closedTag;
                    if (tok.Kind == TokenKind.Symbol && tok.Value == "/")
                    {
                        closedTag = true;
                        temp     += tok.Value;
                        tok       = strTok.Next();
                    }
                    else
                    {
                        closedTag = false;
                    }

                    if (tok.Kind != TokenKind.Word)
                    {
                        // not tag
                        lastChunk = SetChunkText(tok.Line, lastChunk, temp + tok.Value);
                    }
                    else
                    {
                        string tag        = tok.Value;
                        bool   isTagToken = true;
                        //bool skipTag = false;

                        if (tag == "color")
                        {
                            // [color="{red|#ff0000}"][/color]
                            IColor color = fTextColor;
                            if (!closedTag)
                            {
                                tok = strTok.Next();
                                if (tok.Kind == TokenKind.Symbol && tok.Value == "=")
                                {
                                    tok = strTok.Next();
                                    if (tok.Kind == TokenKind.Word)
                                    {
                                        color     = fGfxProvider.CreateColor(tok.Value);
                                        lastChunk = SetChunkColor(tok.Line, lastChunk, color);
                                    }
                                }
                            }
                            else
                            {
                                // TODO: colorStack
                                color     = fTextColor;
                                lastChunk = SetChunkColor(tok.Line, lastChunk, color);
                            }
                        }
                        else if (tag == "size")
                        {
                            // [size={+/-x}][/size]
                            if (!closedTag)
                            {
                                tok = strTok.Next();
                                if (tok.Kind == TokenKind.Symbol && tok.Value == "=")
                                {
                                    tok = strTok.Next();
                                    int factor = 0;
                                    if (tok.Kind == TokenKind.Symbol)
                                    {
                                        if (tok.Value == "+")
                                        {
                                            factor = +1;
                                        }
                                        else if (tok.Value == "-")
                                        {
                                            factor = -1;
                                        }
                                        tok = strTok.Next();
                                    }
                                    if (tok.Kind == TokenKind.Number)
                                    {
                                        float newSize = lastFontSize + factor * ConvertHelper.ParseInt(tok.Value, 0);
                                        stackSizes.Push(new SizeChange(lastFontSize, newSize));
                                        lastChunk    = SetChunkFontSize(tok.Line, lastChunk, newSize);
                                        lastFontSize = newSize;
                                    }
                                }
                            }
                            else
                            {
                                if (stackSizes.Count > 0)
                                {
                                    SizeChange sizeChange = stackSizes.Pop();
                                    lastChunk    = SetChunkFontSize(tok.Line, lastChunk, sizeChange.PrevSize);
                                    lastFontSize = sizeChange.PrevSize;
                                }
                            }
                        }
                        else if (tag == "b")
                        {
                            // [b][/b]
                            lastChunk = SetChunkFontStyle(tok.Line, lastChunk, BSDTypes.FontStyle.Bold, !closedTag);
                        }
                        else if (tag == "i")
                        {
                            // [i][/i]
                            lastChunk = SetChunkFontStyle(tok.Line, lastChunk, BSDTypes.FontStyle.Italic, !closedTag);
                        }
                        else if (tag == "s")
                        {
                            // [s][/s]
                            lastChunk = SetChunkFontStyle(tok.Line, lastChunk, BSDTypes.FontStyle.Strikeout, !closedTag);
                        }
                        else if (tag == "u")
                        {
                            // [u][/u]
                            lastChunk = SetChunkFontStyle(tok.Line, lastChunk, BSDTypes.FontStyle.Underline, !closedTag);
                        }
                        else if (tag == "url")
                        {
                            // bad impementation
                            // [url][/url] and [url=...][/url], but now only [url=...][/url]
                            string url = "";

                            tok = strTok.Next();
                            if (tok.Kind == TokenKind.Symbol && tok.Value == "=")
                            {
                                tok = strTok.Next();
                                do
                                {
                                    url += tok.Value;
                                    tok  = strTok.Next();
                                } while (tok.Kind != TokenKind.Symbol || tok.Value != "]");
                            }
                            else
                            {
                                //
                            }

                            lastChunk = SetChunkFontStyle(tok.Line, lastChunk, BSDTypes.FontStyle.Underline, !closedTag);
                            IColor color = (closedTag) ? fTextColor : fLinkColor;
                            lastChunk = SetChunkColor(tok.Line, lastChunk, color);
                            if (!closedTag)
                            {
                                lastChunk.URL = url;
                            }
                        }
                        else
                        {
                            // not tag
                            lastChunk  = SetChunkText(tok.Line, lastChunk, temp + tok.Value);
                            isTagToken = false;
                        }

                        if (isTagToken && (tok.Kind != TokenKind.Symbol || tok.Value != "]"))
                        {
                            // Possible syntax error?
                            strTok.Next();
                        }
                    }
                }
                else if (tok.Kind == TokenKind.EOL)
                {
                    lastChunk = SetChunkText(tok.Line, null, EMPTY_CHUNK);
                    lastChunk = null;
                }
                else
                {
                    lastChunk = SetChunkText(tok.Line, lastChunk, tok.Value);
                }

                tok = strTok.Next();
            }

            // eof
            lastChunk = SetChunkText(tok.Line + 1, null, EMPTY_CHUNK);
        }
Пример #50
0
 private static Boolean IsBlack(IColor color)
 {
     return(color.r == 0 && color.g == 0 && color.b == 0);
 }
Пример #51
0
 public ColorMapParser(ITexture2D tex, ColorChip colorChip, IColor magenta, bool unique = false, bool ignoreTransparent = true) : base(tex, colorChip, magenta, unique, ignoreTransparent)
 {
 }
Пример #52
0
 public abstract Image <Gray, Byte> DetectSkin(Image <Bgr, Byte> Img, IColor min, IColor max);
Пример #53
0
 public Boolean IsDark(IColor color)
 {
     return(Colors.hsv2hsl(color.h, color.s, color.v).l < 50);
 }
Пример #54
0
 public static float[] Scale(this IColor value, float scale)
 {
     return(new[] { value.R *scale, value.G *scale, value.B *scale });
 }
Пример #55
0
 public static Color ConvertColor(IColor color)
 {
     return(((ColorHandler)color).Handle);
 }
Пример #56
0
        public KeyValuePair <Guid, IPoint> AddGraphicToMap(
            IGeometry geom,
            IColor color,
            int number,
            bool showNums,
            string textName,
            string guid = null,
            esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSCircle,
            int size = 5)
        {
            var emptyResult = new KeyValuePair <Guid, IPoint>();

            if ((geom == null) ||
                (geom.GeometryType != esriGeometryType.esriGeometryPoint) ||
                (geom.SpatialReference == null)
                )
            {
                return(emptyResult);
            }

            var simpleMarkerSymbol = (ISimpleMarkerSymbol) new SimpleMarkerSymbol();

            simpleMarkerSymbol.Color        = color;
            simpleMarkerSymbol.Outline      = false;
            simpleMarkerSymbol.OutlineColor = color;
            simpleMarkerSymbol.Size         = size;
            simpleMarkerSymbol.Style        = markerStyle;

            var markerElement = (IMarkerElement) new MarkerElement();

            markerElement.Symbol = simpleMarkerSymbol;

            IElement element = null;

            element = (IElement)markerElement;
            if (element == null)
            {
                return(emptyResult);
            }
            element.Geometry = geom;
            element.Geometry.SpatialReference = activeView.FocusMap.SpatialReference;

            var eprop     = (IElementProperties)element;
            var newGuid   = Guid.NewGuid().ToString();
            var pointGuid = (String.IsNullOrEmpty(guid)) ? newGuid : guid;

            eprop.Name = pointGuid + geoCalcPointsSuffix;

            var ge = new GraphicElement()
            {
                Source = geom, Name = eprop.Name, Element = element
            };

            if (allGraphics[MilSpaceGraphicsTypeEnum.GeoCalculator].Exists(el => el.Name == eprop.Name))
            {
                DeleteGraphicsElement(ge, true, true);
            }

            graphics.AddElement(element, 0);
            allGraphics[MilSpaceGraphicsTypeEnum.GeoCalculator].Add(ge);

            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            if (showNums)
            {
                var point = geom as IPoint;
                DrawText(point, number.ToString(), $"{textName}{pointGuid}", MilSpaceGraphicsTypeEnum.GeoCalculator, color);
            }

            return(new KeyValuePair <Guid, IPoint>(Guid.Parse(pointGuid), element.Geometry as IPoint));
        }
Пример #57
0
 public BorderProperties(IColor color, ExcelBorderStyle style, ExcelBorderPart part)
 {
     this.m_color = color;
     this.m_style = style;
     this.m_part  = part;
 }
Пример #58
0
 public void AddColor(IColor color)
 {
     this.Colors.Add(color);
 }
Пример #59
0
        public void DrawText(IPoint point, string text, string textName, MilSpaceGraphicsTypeEnum graphicsType, IColor textColor = null, int size = 12, int distance = 5)
        {
            var units     = GetLengthInMapUnits(activeView, distance);
            var textPoint = new Point()
            {
                X = point.X + units, Y = point.Y + units, SpatialReference = point.SpatialReference
            };

            if (textColor == null)
            {
                textColor = new RgbColorClass()
                {
                    Red = 255
                };
            }

            ITextElement textElement = new TextElementClass
            {
                Text = text
            };

            var textSymbol = new TextSymbol
            {
                Color = textColor,
                Size  = size
            };

            textElement.Symbol = textSymbol;
            IElement textElementEl = (IElement)textElement;

            textElementEl.Geometry = textPoint;

            var textPropr = (IElementProperties)textElementEl;

            textPropr.Name = textName;

            if (graphicsType == MilSpaceGraphicsTypeEnum.GeoCalculator)
            {
                textPropr.Name += geoCalcPointsSuffix;
            }

            var ge = new GraphicElement()
            {
                Source = textPoint, Name = textPropr.Name, Element = textElementEl
            };

            if (allGraphics[graphicsType].Exists(el => el.Name == textPropr.Name))
            {
                DeleteGraphicsElement(ge, true, true);
            }

            allGraphics[graphicsType].Add(ge);

            graphics.AddElement(textElementEl, 0);

            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Пример #60
0
        protected override void InternalGenerate()
        {
            try {
                #if !NETSTANDARD
                IColor clrBlack = AppHost.GfxProvider.CreateColor(0x000000);
                IColor clrBlue  = AppHost.GfxProvider.CreateColor(0x0000FF);

                fLinkFont = fWriter.CreateFont("", 8f, false, true, clrBlue);
                fTextFont = fWriter.CreateFont("", 8f, false, false, clrBlack);

                fWriter.EnablePageNumbers();

                fRenderer = fWriter.GetPageRenderer();
                if (fRenderer == null)
                {
                    // TODO: warning
                    return;
                }

                IFont titleFont = fWriter.CreateFont("", 30f, true, false, clrBlack);
                fPageSize = fWriter.GetPageSize();
                float pageHeight = fPageSize.GetHeight();
                float pageWidth  = fPageSize.GetWidth();
                float halfpage   = (pageHeight - (((PDFWriter.FontHandler)titleFont).GetTextHeight())) / 2f;
                fWriter.NewLine(0.0f, halfpage);
                fWriter.AddParagraph(fTitle, titleFont, TextAlignment.taCenter);

                var chartOptions = new TreeChartOptions();
                chartOptions.Assign(GlobalOptions.Instance.TreeChartOptions);
                chartOptions.DefaultPortraits   = false;
                chartOptions.HideUnknownSpouses = true;
                chartOptions.InvertedTree       = false;
                chartOptions.Kinship            = false;
                chartOptions.ShowPlaces         = false;

                var treeBox = AppHost.Container.Resolve <ITreeChart>();
                treeBox.SetRenderer(fRenderer);
                treeBox.Base    = fBase;
                treeBox.Options = chartOptions;
                treeBox.Height  = (int)pageHeight;
                treeBox.Width   = (int)pageWidth;

                fPatList = PatriarchsMan.GetPatriarchsList(fBase.Context, 2, false);
                fPatList.QuickSort(PatriarchsCompare);

                int num = fPatList.Count;
                for (int i = 0; i < num; i++)
                {
                    var patriarch = fPatList[i].IRec;

                    fIndiQueue.Clear();
                    fIndiQueue.Add(new IndiObj(patriarch, TreeChartKind.ckDescendants));

                    for (int q = 0; q < fIndiQueue.Count; q++)
                    {
                        fWriter.NewPage();
                        TryRenderTreeSlice(treeBox, q, patriarch);
                    }
                }
                #endif
            } catch (Exception ex) {
                Logger.WriteError("TreesAlbumExporter.InternalGenerate()", ex);
                throw;
            }
        }