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


C# Color.ToString方法代码示例

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


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

示例1: ColorToVector4

 public static Vector4 ColorToVector4(Color color)
 {
     #if DEBUG
     Console.WriteLine(color.ToString() + " - (" + color.R.ToString() + ", " + color.G.ToString() + ", " + color.B.ToString() + ", " + color.A.ToString() + ") -> Vec4: " + new Vector4(((float)color.R / 255), ((float)color.G / 255), ((float)color.B / 255), ((float)color.A / 255)).ToString());
     #endif
     return new Vector4(((float)color.R / 255), ((float)color.G / 255), ((float)color.B / 255), ((float)color.A / 255));
 }
开发者ID:Erlisch,项目名称:Caliginous,代码行数:7,代码来源:Misc.cs

示例2: Route

        public Route(string s)
        {
            if (s.Length > 0)
            {
                rs = s;
                Random rndm = new Random();
                //color = RandomColor();
                color = RandomColorHSV(rndm.Next(), 0.5, 0.95);
                Console.WriteLine("RandomColor {0}", color.ToString());
                //color = Color.

                string[] ns = s.Split();
                nodes = new int[ns.Length];

                //if (ns.Length < 2) { throw new Exception("Route must have at least 2 nodes length"); }
                for (int i = 0; i < ns.Length; i++)
                {
                    nodes[i] = int.Parse(ns[i]);
                }
            }
            else {
                Console.WriteLine("Empty route");
                throw new Exception("Empty route");
            }
        }
开发者ID:autumnharmony,项目名称:GBusManager,代码行数:25,代码来源:Route+(anton-desktop's+conflicted+copy+2011-04-20).cs

示例3: ColorToString

 public static string ColorToString(Color color)
 {
     string name;
     if (!MColorNames.TryGetValue(color, out name)) {
         name = color.ToString();
     }
     return name;
 }
开发者ID:galievruslan,项目名称:mss-mobile,代码行数:8,代码来源:ColorHelper.cs

示例4: FormatColor

		private static String FormatColor(String format, Color arg)
		{
			if (String.IsNullOrWhiteSpace(format))
			{
				return arg.ToString();
			}

			var numberFormatInfo =
				new NumberFormatInfo
				{
					NumberDecimalDigits = 1,
					PercentDecimalDigits = 0,
					PercentNegativePattern = 1,
					PercentPositivePattern = 1
				};
			switch (format)
			{
				case "hex":
					{
						return String.Format(numberFormatInfo, "#{0:x2}{1:x2}{2:x2}", arg.R, arg.G, arg.B);
					}
				case "HEX":
					{
						return String.Format(numberFormatInfo, "#{0:X2}{1:X2}{2:X2}", arg.R, arg.G, arg.B);
					}
				case "rgb":
					{
						return String.Format(numberFormatInfo, "rgb({0}, {1}, {2})", arg.R, arg.G, arg.B);
					}
				case "rgb%":
					{
						return String.Format(numberFormatInfo, "rgb({0:P}, {1:P}, {2:P})", arg.R / 255d, arg.G / 255d, arg.B / 255d);
					}
				case "rgba":
					{
						return String.Format(numberFormatInfo, "rgba({0}, {1}, {2}, {3:0.#})", arg.R, arg.G, arg.B, arg.A / 255d);
					}
				case "rgba%":
					{
						return String.Format(numberFormatInfo, "rgba({0:P}, {1:P}, {2:P}, {3:0.#})", arg.R / 255d, arg.G / 255d, arg.B / 255d, arg.A / 255d);
					}
				case "hsl":
					{
						return String.Format(numberFormatInfo, "hsl({0:F0}, {1:P}, {2:P})", arg.GetHue(), arg.GetSaturation(), arg.GetBrightness());
					}
				case "hsla":
					{
						return String.Format(numberFormatInfo, "hsla({0:F0}, {1:P}, {2:P}, {3:0.#})", arg.GetHue(), arg.GetSaturation(), arg.GetBrightness(), arg.A / 255d);
					}
				default:
					{
						throw new FormatException(String.Format("Invalid format specified: \"{0}\".", format));
					}
			}
		}
开发者ID:Happy-Ferret,项目名称:dotgecko,代码行数:55,代码来源:CssColorFormatInfo.cs

示例5: DrawDirectEdge

        public void DrawDirectEdge(Point p1, Point p2, Color c)
        {
            Console.WriteLine("DrawDirecEdge with p1 = {0}, p2 = {1}, color = {2}", p1.ToString(), p2.ToString(), c.ToString());
            //Graphics g = this.CreateGraphics();

            // стрелка
            Pen p = new Pen(c);
            //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            //g.ScaleTransform(
            p.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            p.CustomStartCap = new System.Drawing.Drawing2D.AdjustableArrowCap(8, 5, true);
            //p.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            //p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

            g.DrawLine(p, p1.X, p1.Y, p2.X, p2.Y);

            //g.DrawLine(new Pen(c), p)
            //g.DrawLine(new Pen(c), p)
        }
开发者ID:autumnharmony,项目名称:GBusManager,代码行数:19,代码来源:GraphViewer.cs

示例6: PaintForm

        public PaintForm()
        {
            InitializeComponent();
            //initialize event handlers
            pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown);
            pictureBox1.MouseUp += new MouseEventHandler(pictureBox1_MouseUp);
            pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);

            //set default color & thickness
            thickness = 5;
            color = Color.Red;

            //set default text
            colorLabel.Text = color.ToString();
            brushLabel.Text = "Brush Size: " + thickness;

            //create new bitmap to hold picture data this will allow us to save data
            image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
        }
开发者ID:dsestak777,项目名称:Paint-Program,代码行数:19,代码来源:PaintForm.cs

示例7: FromSystemColor

 public static Brush FromSystemColor(Color c)
 {
     if (!c.IsSystemColor)
     {
         throw new ArgumentException(System.Drawing.SR.GetString("ColorNotSystemColor", new object[] { c.ToString() }));
     }
     Brush[] brushArray = (Brush[]) SafeNativeMethods.Gdip.ThreadData[SystemBrushesKey];
     if (brushArray == null)
     {
         brushArray = new Brush[0x21];
         SafeNativeMethods.Gdip.ThreadData[SystemBrushesKey] = brushArray;
     }
     int index = (int) c.ToKnownColor();
     if (index > 0xa7)
     {
         index -= 0x8d;
     }
     index--;
     if (brushArray[index] == null)
     {
         brushArray[index] = new SolidBrush(c, true);
     }
     return brushArray[index];
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:SystemBrushes.cs

示例8: FromSystemColor

 public static Pen FromSystemColor(Color c)
 {
     if (!c.IsSystemColor)
     {
         throw new ArgumentException(System.Drawing.SR.GetString("ColorNotSystemColor", new object[] { c.ToString() }));
     }
     Pen[] penArray = (Pen[]) SafeNativeMethods.Gdip.ThreadData[SystemPensKey];
     if (penArray == null)
     {
         penArray = new Pen[0x21];
         SafeNativeMethods.Gdip.ThreadData[SystemPensKey] = penArray;
     }
     int index = (int) c.ToKnownColor();
     if (index > 0xa7)
     {
         index -= 0x8d;
     }
     index--;
     if (penArray[index] == null)
     {
         penArray[index] = new Pen(c, true);
     }
     return penArray[index];
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:SystemPens.cs

示例9: LogSensorData

        public void LogSensorData(string sensorlog, Color data)
        {
            string standardfilename = sensorlog + DateTime.Now.ToString("_d MMM y") + ".txt";
            string sensorfilename = MakeNameUnique(standardfilename);

            string filepath = System.IO.Path.Combine(activeDir, sensorfilename);

            if (!File.Exists(filepath))
            {
                FileStream fs = File.Create(filepath);
                fs.Close();
            }
            else
            {
            }//end else

            File.AppendAllText(filepath, data.ToString() + System.Environment.NewLine);
        }
开发者ID:x-yang,项目名称:rover-sim,代码行数:18,代码来源:ImageProcessingResultForm.cs

示例10: DrawChartLabel

 /// <summary>
 /// draws text label on a chart.
 /// if price is less than zero (MinPrice), all labels are cleared.
 /// </summary>
 /// <param name="price"></param>
 /// <param name="bar"></param>
 /// <param name="label"></param>
 public void DrawChartLabel(decimal price, int time, string label, Color color)
 {
     // reject if we don't have bars yet
     if (bl == null)
     {
         debug("No bars, ignoring draw label "+price+" at "+time+" "+label+" color: "+color.ToString());
         return;
     }
     // test whether this is an oscilator
     if (isosccolor(color))
     {
         DrawOscLabel(price, time, label, color);
         return;
     }
     // otherwise treat as a price
     // invalid price allows user to clear all price labels
     if (price < MinPrice)
     {
         _colpoints.Remove(color);
         _collineend.Remove(color);
         return;
     }
     List<Label> tmp;
     // setup this label if we don't have points for it already
     if (!_colpoints.TryGetValue(color, out tmp))
     {
         tmp = new List<Label>();
         _colpoints.Add(color, tmp);
         _collineend.Add(color,new List<int>());
     }
     // create new point for this label
     Label l = new Label(time, price, label, color);
     // mark whether it has text labels
     hastextlabels |= !l.isLine;
     // add it so it can be drawn with DrawLabels
     _colpoints[color].Add(l);
     // if label represents a line (rather than text), add it to label's line
     if (l.isLine)
         _collineend[color].Add(_colpoints[color].Count-1);
 }
开发者ID:bluejack2000,项目名称:core,代码行数:47,代码来源:ChartControl.cs

示例11: GetColor

 public Color GetColor(XmlNode parentNode, String id, Color default_val)
 {
     XmlNode nd = FindChildElement(parentNode, id);
     Color result;
     if (nd == null)
     {
         AddParameter(parentNode, id, default_val.ToString());
         return default_val;
     }
     try
     {
         result = ParseColor(nd.InnerText);
     }
     catch (Exception)
     {
         LogParamErr(parentNode, id, "color value");
         result = default_val;
     }
     return result;
 }
开发者ID:RFranta,项目名称:UVDLPSlicerController,代码行数:20,代码来源:XmlHelper.cs

示例12: GetColourDescription

        public static string GetColourDescription(Color c, bool orig)
        {
            if (c.Equals(Color.Transparent))
            {
                return "Transparent";
            }

            //get matching
            var bc = Beads.AllBeadColours.Where(s => ColorExtras.Equals(s.Value, c)).ToList();
            if (!bc.Any())
                return c.ToString();
            var bcf = bc.First();
            return bcf.Key + " " + bcf.Value;
        }
开发者ID:andreigec,项目名称:BeadSprite-Pro,代码行数:14,代码来源:controller.cs

示例13: LoadTreeViewAdvResourceImage

        private Image LoadTreeViewAdvResourceImage(String name, String type, Color color)
        {
            String key = String.Format("{0};{1};{2}", name, type, color.ToString());
            if (_cached_icons.ContainsKey(key))
                return _cached_icons[key];

            Bitmap bm = null;
            if (name == "FolderClosed")
                bm = new Bitmap(DicomDumpResources.FolderClosed);
            else if (name == "Folder")
                bm = new Bitmap(DicomDumpResources.Folder);
            else
                bm = new Bitmap(DicomDumpResources.Leaf);

            bm.MakeTransparent();
            Graphics g = Graphics.FromImage(bm);
            Brush b = new SolidBrush(color);
            if (_cached_font == null) {
                _cached_font = new Font(FontFamily.GenericSansSerif, 7, FontStyle.Regular);
            }
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            sf.Trimming = StringTrimming.None;
            g.DrawString(type, _cached_font, b, new RectangleF(-2, 0, bm.Width + 5, bm.Height), sf);
            _cached_icons.Add(key, bm);
            return bm;
        }
开发者ID:vigilant,项目名称:mdcm,代码行数:28,代码来源:DicomDumpForm.cs

示例14: CreateColorListItem

		private ListViewItem CreateColorListItem(Color colorItem)
		{
			Bitmap result = new Bitmap(48, 48);
			Graphics gfx = Graphics.FromImage(result);
			using (SolidBrush brush = new SolidBrush(colorItem))
			{
				using (var p = new Pen(ThemeColorTable.BorderColor, 2))
				{
					gfx.FillRectangle(brush, 0, 0, 48, 48);
					gfx.DrawRectangle(p, 0, 0, 48, 48);
				}
			}
			gfx.Dispose();
			listViewColors.LargeImageList.Images.Add(colorItem.ToString(), result);

			ListViewItem item = new ListViewItem
			{
				ToolTipText = string.Format("R: {0} G: {1} B: {2}", colorItem.R, colorItem.G, colorItem.B),
				ImageKey = colorItem.ToString(),
				Tag = colorItem,
				ForeColor = ThemeColorTable.ForeColor
			};
			return item;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:24,代码来源:Form_ToolPalette.cs

示例15: GetDashPen

		public Pen GetDashPen (Color color, DashStyle dashStyle)
		{
			string hash = color.ToString() + dashStyle;

			lock (dashpens) {
				Pen res = dashpens [hash] as Pen;
				if (res != null)
					return res;
			
				Pen pen = new Pen (color);
				pen.DashStyle = dashStyle;
				dashpens [hash] = pen;
				return pen;
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:15,代码来源:Theme.cs


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