当前位置: 首页>>代码示例>>C#>>正文


C# System.ToArgb方法代码示例

本文整理汇总了C#中System.ToArgb方法的典型用法代码示例。如果您正苦于以下问题:C# System.ToArgb方法的具体用法?C# System.ToArgb怎么用?C# System.ToArgb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System的用法示例。


在下文中一共展示了System.ToArgb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawLine

        public static void DrawLine(Vector3 from, Vector3 to, System.Drawing.Color color)
        {
            var vertices = new PositionColored[2];
            vertices[0] = new PositionColored(Vector3.Zero, color.ToArgb());
            from = from.SwitchYZ();
            to = to.SwitchYZ();
            vertices[1] = new PositionColored(to - from, color.ToArgb());

            InternalRender(from);

            Drawing.Direct3DDevice.DrawUserPrimitives(PrimitiveType.LineList, vertices.Length / 2, vertices);
        }
开发者ID:hhhmmm2,项目名称:SAwareness,代码行数:12,代码来源:Utils.cs

示例2: InternalSetColor

 private void InternalSetColor(System.Drawing.Color value)
 {
     int status = SafeNativeMethods.Gdip.GdipSetSolidFillColor(new HandleRef(this, base.NativeBrush), value.ToArgb());
     if (status != 0)
     {
         throw SafeNativeMethods.Gdip.StatusException(status);
     }
     this.color = value;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:SolidBrush.cs

示例3: ConvertColor

        /// <summary>
        /// Convert a color to a string
        /// </summary>
        /// <param name="color">the windows forms color</param>
        /// <returns>the color in a string</returns>
        private static string ConvertColor(System.Drawing.Color color)
        {
            int i = color.ToArgb();
            byte r = (byte)((i >> 16) & 255);
            byte g = (byte)((i >> 8) & 255);
            byte b = (byte)(i & 255);

            RgbColor rgbColor = new RgbColor(r, g, b);
            return rgbColor.ToString();
        }
开发者ID:AnthonySteele,项目名称:Netsy,代码行数:15,代码来源:ColorDialog.cs

示例4: Get

 /// <summary>
 ///  ��ȡָ���������ļ���ָ��Key��ֵ
 /// </summary>
 /// <param name="szKeyName">��ȡ��Key����</param>
 /// <param name="defaultValue">ָ����Key������ʱ,���ص�ֵ</param>
 /// <returns>Keyֵ</returns>
 public System.Drawing.Color Get(string szKeyName, System.Drawing.Color defaultValue)
 {
     try
     {
         int nColorValue = this.Get(szKeyName, defaultValue.ToArgb());
         return System.Drawing.Color.FromArgb(nColorValue);
     }
     catch
     {
         return defaultValue;
     }
 }
开发者ID:zuifengke,项目名称:windy-common,代码行数:18,代码来源:SystemConfig.cs

示例5: PathLine

		Vector3[] sphericalCoordinates = new Vector3[0]; // x = lat, y = lon, z = height

		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.PathLine"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="terrainfileName"></param>
		/// <param name="heightAboveSurface"></param>
		/// <param name="lineColor"></param>
		public PathLine(string name, World parentWorld, string terrainfileName, float heightAboveSurface, 
			System.Drawing.Color lineColor) 
			: base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			this._parentWorld = parentWorld;
			//this.terrainManager = terrainManager;
			this.terrainFileName = terrainfileName;
			this.heightAboveSurface = heightAboveSurface;
			this.lineColor = lineColor.ToArgb();
			
			if(this.terrainFileName == null)
			{
				this.isInitialized = true;
				this.isLoaded = true;
				this.linePoints = new CustomVertex.PositionColored[0];
				return;
			}
			
			FileInfo inFile = new FileInfo(this.terrainFileName);
			if(!inFile.Exists)
			{
				this.isInitialized = true;
				this.isLoaded = true;
				this.linePoints = new CustomVertex.PositionColored[0];
				return;
			}
			
			if(inFile.FullName.IndexOf('_') == -1)
			{
				return;
			}

			string[] parsedFileName = inFile.Name.Replace(".wwb","").Split('_');

			if(parsedFileName.Length < 5)
			{
				return;
			}
			else
			{
				this.north = (float)Int32.Parse(parsedFileName[1], CultureInfo.InvariantCulture);
				this.south = (float)Int32.Parse(parsedFileName[2], CultureInfo.InvariantCulture);
				this.west = (float)Int32.Parse(parsedFileName[3], CultureInfo.InvariantCulture);
				this.east = (float)Int32.Parse(parsedFileName[4], CultureInfo.InvariantCulture);
			}

			this.boundingBox = new BoundingBox( this.south, this.north, this.west, this.east, 
				(float)this._parentWorld.EquatorialRadius, 
				(float)this._parentWorld.EquatorialRadius + this.heightAboveSurface );
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:60,代码来源:PathLine.cs

示例6: GetImage

        /// <summary>
        /// Get the image based on the moniker, backColor and dimensions
        /// </summary>
        public static Bitmap GetImage(ImageMoniker moniker, System.Drawing.Color backColor, int height, int width, bool scalingRequired)
        {
            m_attributes.Background = (uint)backColor.ToArgb();
            m_attributes.LogicalHeight = height;
            m_attributes.LogicalWidth = width;

            if (scalingRequired)
            {
                m_attributes.LogicalHeight = (int)(height * DpiHelper.LogicalToDeviceUnitsScalingFactorY);
                m_attributes.LogicalWidth = (int)(width * DpiHelper.LogicalToDeviceUnitsScalingFactorX);
            }

            IVsUIObject uIObjOK = ImageService.GetImage(moniker, m_attributes);
            Bitmap bitmap = (Bitmap)UIUtilities.GetObjectData(uIObjOK);
            bitmap.MakeTransparent(System.Drawing.Color.Magenta);

            return bitmap;
        }
开发者ID:digideskio,项目名称:NuGet.PackageIndex,代码行数:21,代码来源:ImageHelper.cs

示例7: DrawPolylineFeature

        internal void DrawPolylineFeature(Graphics g, System.Drawing.Point[] Points_array,
            int LinePattern, System.Drawing.Color LineColor, int LineWidth)
        {
            IntPtr drawPen;		// gdi pen
            IntPtr drawPen_old;		// gdi pen

            if (LinePattern == 2)
            {
                drawPen = (IntPtr)Win32.GDI.CreatePen(Win32.GDI.PS_GEOMETRIC, LineWidth, LineColor.ToArgb());
                drawPen_old = (IntPtr)Win32.GDI.SelectObject(m_hdc, drawPen);

                int count = Points_array.GetLength(0);
                Win32.GDI.Polyline(m_hdc, ref Points_array[0], count);

                Win32.GDI.SelectObject(m_hdc, drawPen_old);
                Win32.GDI.DeleteObject(drawPen);
            }
        }
开发者ID:ravcio,项目名称:MapNet,代码行数:18,代码来源:RenderGDI.cs

示例8: TerrainPath

		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.TerrainPath"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="minDisplayAltitude"></param>
		/// <param name="maxDisplayAltitude"></param>
		/// <param name="terrainFileName"></param>
		/// <param name="heightAboveSurface"></param>
		/// <param name="lineColor"></param>
		/// <param name="terrainAccessor"></param>
		public TerrainPath(
			string name, 
			World parentWorld, 
			double minDisplayAltitude, 
			double maxDisplayAltitude, 
			string terrainFileName, 
			float heightAboveSurface, 
			System.Drawing.Color lineColor,
			TerrainAccessor terrainAccessor) 
			: base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			this._parentWorld = parentWorld;
			this._minDisplayAltitude = minDisplayAltitude;
			this._maxDisplayAltitude = maxDisplayAltitude;
			this.terrainFileName = terrainFileName;
			this.heightAboveSurface = heightAboveSurface;
			//this.terrainMapped = terrainMapped;
			this.lineColor = lineColor.ToArgb();
			this._terrainAccessor = terrainAccessor;
			this.RenderPriority = RenderPriority.LinePaths;
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:32,代码来源:TerrainPath.cs

示例9: Message

 public Message(uint account, string message, string to, string from, System.Drawing.Color color, uint type)
 {
     Buffer = new byte[32 + message.Length + to.Length + from.Length];
     fixed (byte* arg = Buffer)
     {
         *((ushort*)(arg)) = (ushort)(Buffer.Length);
         *((ushort*)(arg + 2)) = 1004;
         *((uint*)(arg + 4)) = (uint)color.ToArgb();
         *((uint*)(arg + 8)) = type;
         *((uint*)(arg + 12)) = account;
         *((byte*)(arg + 24)) = 4;
         *((byte*)(arg + 25)) = (byte)from.Length;
         for (ushort i = 0; i < from.Length; i++)
             *((byte*)(arg + 26 + i)) = (byte)from[i];
         *((byte*)(arg + 26) + from.Length) = (byte)to.Length;
         for (ushort i = 0; i < to.Length; i++)
             *((byte*)(arg + 27 + from.Length + i)) = (byte)to[i];
         *((byte*)(arg + 28) + from.Length + to.Length) = (byte)message.Length;
         for (ushort i = 0; i < message.Length; i++)
             *((byte*)(arg + 29 + from.Length + to.Length + i)) = (byte)message[i];
     }
     Text = message;
 }
开发者ID:halo779,项目名称:EoEmu,代码行数:23,代码来源:[1004]+Message.cs

示例10: ShapeLayer

		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.ShapeLayer"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="Altitude"></param>
		/// <param name="masterFilePath"></param>
		/// <param name="minDisplayAltitude"></param>
		/// <param name="maxDisplayAltitude"></param>
		/// <param name="font"></param>
		/// <param name="color"></param>
		/// <param name="scalarKey"></param>
		/// <param name="showBoundaries"></param>
		/// <param name="showFilledPolygons"></param>
		public ShapeLayer(
			string name,
			World parentWorld,
			double Altitude,
			string masterFilePath,
			double minDisplayAltitude,
			double maxDisplayAltitude,
			Font font,
			System.Drawing.Color color,
			string scalarKey,
			bool showBoundaries,
			bool showFilledPolygons) : base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0))
		{
			this._parentWorld = parentWorld;
			this._Altitude = Altitude;
			this._masterFilePath = masterFilePath;
			this._minDisplayAltitude = minDisplayAltitude;
			this._maxDisplayAltitude = maxDisplayAltitude;
			this.drawingFont = font;
			this._color = color.ToArgb();
			this._scalarKey = scalarKey;
			this._showBoundaries = showBoundaries;
			this._showFilledPolygons = showFilledPolygons;
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:38,代码来源:ShapeLayer.cs

示例11: DrawImage

        /// <summary>
        /// Draws an image using the specified flags and state on XP systems.
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        /// <param name="foreColor">Fore colour to blend with when using the 
        /// ILD_SELECTED or ILD_BLEND25 flags</param>
        /// <param name="stateFlags">State flags</param>
        /// <param name="glowOrShadowColor">If stateFlags include ILS_GLOW, then
        /// the colour to use for the glow effect.  Otherwise if stateFlags includes 
        /// ILS_SHADOW, then the colour to use for the shadow.</param>
        /// <param name="saturateColorOrAlpha">If stateFlags includes ILS_ALPHA,
        /// then the alpha component is applied to the icon. Otherwise if 
        /// ILS_SATURATE is included, then the (R,G,B) components are used
        /// to saturate the image.</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags,
            int cx,
            int cy,
            System.Drawing.Color foreColor,
            ImageListDrawStateConstants stateFlags,
            System.Drawing.Color saturateColorOrAlpha,
            System.Drawing.Color glowOrShadowColor
            )
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
            pimldp.hdcDst = hdc;
            pimldp.cbSize = Marshal.SizeOf(pimldp.GetType());
            pimldp.i = index;
            pimldp.x = x;
            pimldp.y = y;
            pimldp.cx = cx;
            pimldp.cy = cy;
            pimldp.rgbFg = Color.FromArgb(0,
                foreColor.R, foreColor.G, foreColor.B).ToArgb();
            Console.WriteLine("{0}", pimldp.rgbFg);
            pimldp.fStyle = (int)flags;
            pimldp.fState = (int)stateFlags;
            if ((stateFlags & ImageListDrawStateConstants.ILS_ALPHA) ==
                ImageListDrawStateConstants.ILS_ALPHA)
            {
                // Set the alpha:
                pimldp.Frame = (int)saturateColorOrAlpha.A;
            }
            else if ((stateFlags & ImageListDrawStateConstants.ILS_SATURATE) ==
                ImageListDrawStateConstants.ILS_SATURATE)
            {
                // discard alpha channel:
                saturateColorOrAlpha = Color.FromArgb(0,
                    saturateColorOrAlpha.R,
                    saturateColorOrAlpha.G,
                    saturateColorOrAlpha.B);
                // set the saturate color
                pimldp.Frame = saturateColorOrAlpha.ToArgb();
            }
            glowOrShadowColor = Color.FromArgb(0,
                glowOrShadowColor.R,
                glowOrShadowColor.G,
                glowOrShadowColor.B);
            pimldp.crEffect = glowOrShadowColor.ToArgb();
            if (iImageList == null)
            {
                pimldp.himl = hIml;
                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {

                iImageList.Draw(ref pimldp);
            }
        }
开发者ID:chris84948,项目名称:WPF-File-Dialog-Control,代码行数:80,代码来源:SysImageList.cs

示例12: Draw

 internal virtual void Draw(Display.DisplayPipeline pipeline, System.Drawing.Color color, int thickness)
 {
   IntPtr pDisplayPipeline = pipeline.NonConstPointer();
   IntPtr ptr = ConstPointer();
   int argb = color.ToArgb();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawCurve(pDisplayPipeline, ptr, argb, thickness);
 }
开发者ID:JohannesKu,项目名称:rhinocommon,代码行数:7,代码来源:opennurbs_curve.cs

示例13: SetValue

 public void SetValue(System.Drawing.Color v)
 { UnsafeNativeMethods.Rdk_Variant_SetOnColorValue(NonConstPointer(), v.ToArgb()); }
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:2,代码来源:rdk_variant.cs

示例14: DrawTextScaled

    /// <summary>
    /// Draws scaled 2D text.  Note that x and y are in viewport coordinates
    /// (ranging from -1 to +1).  fXScale and fYScale are the size fraction 
    /// relative to the entire viewport.  For example, a fXScale of 0.25 is
    /// 1/8th of the screen width.  This allows you to output text at a fixed
    /// fraction of the viewport, even if the screen or window size changes.
    /// </summary>
    public void DrawTextScaled(float x, float y, float z, 
        float fXScale, float fYScale,
        System.Drawing.Color color,
        string text, RenderFlags flags)
    {
        if (device == null)
            throw new System.ArgumentNullException();

        // Set up renderstate
        savedStateBlock.Capture();
        drawTextStateBlock.Apply();
        device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
        device.PixelShader = null;
        device.SetStreamSource(0, vertexBuffer, 0);

        // Set filter states
        if ((flags & RenderFlags.Filtered) != 0) {
            samplerState0.MinFilter = TextureFilter.Linear;
            samplerState0.MagFilter = TextureFilter.Linear;
        }

        Viewport vp = device.Viewport;
        float xpos = (x+1.0f)*vp.Width/2;
        float ypos = (y+1.0f)*vp.Height/2;
        float sz = z;
        float rhw = 1.0f;
        float fLineHeight = (textureCoords[0,3] - textureCoords[0,1]) * textureHeight;

        // Adjust for character spacing
        xpos -= spacingPerChar * (fXScale*vp.Height)/fLineHeight;
        float fStartX = xpos;

        // Fill vertex buffer
        int numTriangles = 0;
        int realColor = color.ToArgb();
        int iv = 0;

        foreach (char c in text) {
            if (c == '\n') {
                xpos  = fStartX;
                ypos += fYScale*vp.Height;
            }

            if ((c-32) < 0 || (c-32) >= 128-32)
                continue;

            float tx1 = textureCoords[c-32,0];
            float ty1 = textureCoords[c-32,1];
            float tx2 = textureCoords[c-32,2];
            float ty2 = textureCoords[c-32,3];

            float w = (tx2-tx1)*textureWidth;
            float h = (ty2-ty1)*textureHeight;

            w *= (fXScale*vp.Height)/fLineHeight;
            h *= (fYScale*vp.Height)/fLineHeight;

            if (c != ' ') {
                fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+h-0.5f,sz,rhw), realColor, tx1, ty2);
                fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+0-0.5f,sz,rhw), realColor, tx1, ty1);
                fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+h-0.5f,sz,rhw), realColor, tx2, ty2);
                fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+0-0.5f,sz,rhw), realColor, tx2, ty1);
                fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+h-0.5f,sz,rhw), realColor, tx2, ty2);
                fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+0-0.5f,sz,rhw), realColor, tx1, ty1);
                numTriangles += 2;

                if (numTriangles*3 > (MaxNumfontVertices-6)) {
                    // Unlock, render, and relock the vertex buffer
                    vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard);
                    device.DrawPrimitives(PrimitiveType.TriangleList , 0, numTriangles);
                    numTriangles = 0;
                    iv = 0;
                }
            }

            xpos += w - (2 * spacingPerChar) * (fXScale*vp.Height)/fLineHeight;
        }

        // Unlock and render the vertex buffer
        vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard);
        if (numTriangles > 0)
            device.DrawPrimitives(PrimitiveType.TriangleList , 0, numTriangles);

        // Restore the modified renderstates
        savedStateBlock.Apply();
    }
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:93,代码来源:d3dfont.cs

示例15: DrawImage

        /// <summary>
        /// Draws an image using the specified flags and state on XP systems.
        /// </summary>
        /// <param name="hdc">Device context to draw to</param>
        /// <param name="index">Index of image to draw</param>
        /// <param name="x">X Position to draw at</param>
        /// <param name="y">Y Position to draw at</param>
        /// <param name="flags">Drawing flags</param>
        /// <param name="cx">Width to draw</param>
        /// <param name="cy">Height to draw</param>
        /// <param name="foreColor">Fore colour to blend with when using the ILD_SELECTED or ILD_BLEND25 flags</param>
        /// <param name="stateFlags">State flags</param>
        /// <param name="saturateColorOrAlpha">If stateFlags includes ILS_ALPHA, then the alpha component is applied to the icon. Otherwise if 
        /// ILS_SATURATE is included, then the (R,G,B) components are used to saturate the image.</param>
        /// <param name="glowOrShadowColor">If stateFlags include ILS_GLOW, then the colour to use for the glow effect.  Otherwise if stateFlags includes 
        /// ILS_SHADOW, then the colour to use for the shadow.</param>
        public void DrawImage(
            IntPtr hdc,
            int index,
            int x,
            int y,
            ImageListDrawItemConstants flags,
            int cx,
            int cy,
            System.Drawing.Color foreColor,
            ImageListDrawStateConstants stateFlags,
            System.Drawing.Color saturateColorOrAlpha,
            System.Drawing.Color glowOrShadowColor)
        {
            IMAGELISTDRAWPARAMS pimldp = new IMAGELISTDRAWPARAMS();
            pimldp.HdcDst = hdc;
            pimldp.Size = Marshal.SizeOf(pimldp.GetType());
            pimldp.Index = index;
            pimldp.X = x;
            pimldp.Y = y;
            pimldp.CX = cx;
            pimldp.CY = cy;
            pimldp.ForegroundRgb = Color.FromArgb(0, foreColor.R, foreColor.G, foreColor.B).ToArgb();
            pimldp.Style = (int)flags;
            pimldp.State = (int)stateFlags;
            if ((stateFlags & ImageListDrawStateConstants.ILS_ALPHA) == ImageListDrawStateConstants.ILS_ALPHA)
            {
                // Set the alpha
                pimldp.Frame = (int)saturateColorOrAlpha.A;
            }
            else if ((stateFlags & ImageListDrawStateConstants.ILS_SATURATE) == ImageListDrawStateConstants.ILS_SATURATE)
            {
                // discard alpha channel:
                saturateColorOrAlpha = Color.FromArgb(0, saturateColorOrAlpha.R, saturateColorOrAlpha.G, saturateColorOrAlpha.B);

                // set the saturate color
                pimldp.Frame = saturateColorOrAlpha.ToArgb();
            }

            glowOrShadowColor = Color.FromArgb(0, glowOrShadowColor.R, glowOrShadowColor.G, glowOrShadowColor.B);

            pimldp.Effect = glowOrShadowColor.ToArgb();

            if (this.imageList == null)
            {
                pimldp.Himl = this.himl;

                int ret = ImageList_DrawIndirect(ref pimldp);
            }
            else
            {
                this.imageList.Draw(ref pimldp);
            }
        }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:69,代码来源:SysImageList.cs


注:本文中的System.ToArgb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。