本文整理汇总了C#中Color.ToHex方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToHex方法的具体用法?C# Color.ToHex怎么用?C# Color.ToHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.ToHex方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTile
public string CreateTile(string name, string pathOrUrl,BitmapSource image, Color backgroundColor, bool showLabel, bool useDarkLabel)
{
var baseName = String.Join("", new Regex(@"[A-Za-z\d]").Matches(name).Cast<Match>().Select(o => o.Value));
var batName = $"{baseName}.vbs";
var batPath = Path.Combine(_folderPath, batName);
File.WriteAllText(batPath, $"CreateObject(\"Wscript.Shell\").Run \"\"\"\" & \"{pathOrUrl}\" & \"\"\"\", 0, False");
TouchFile(batPath);
var imageName = $"{baseName}.png";
var imagePath = Path.Combine(_folderPath, imageName);
using (var fileStream = new FileStream(imagePath, FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder();
var frame = BitmapFrame.Create(image);
encoder.Frames.Add(frame);
encoder.Save(fileStream);
}
TouchFile(imagePath);
var iconName = $"{baseName}.ico";
var iconPath = Path.Combine(_folderPath, iconName);
SaveIcon(image, iconPath);
TouchFile(iconPath);
var manifestName = $"{baseName}.VisualElementsManifest.xml";
var manifestPath = Path.Combine(_folderPath, manifestName);
var backgroundColorString = backgroundColor == Colors.Transparent ? "Transparent" : backgroundColor.ToHex(false);
var manifest = string.Format(Resources.Win10TP2_TemplateManifest, imageName, backgroundColorString,showLabel ?"on":"off", useDarkLabel?"dark":"light",name);
File.WriteAllText(manifestPath, manifest);
TouchFile(manifestPath);
var linkName = $"{baseName} (SteamPaver).lnk";
var linkPath = Path.Combine(_startMenuPath, linkName);
CreateShortcut(linkPath, batPath, iconPath,name);
TouchFile(linkPath);
return Path.Combine("SteamPaverLinks", linkName);
}
示例2: UnderlineColor
/// <summary>
/// For use with Append() and AppendLine()
/// </summary>
/// <param name="underlineColor">The underline color to use, if no underline is set, a single line will be used.</param>
/// <returns>This Paragraph with the last appended text underlined in a color.</returns>
/// <example>
/// Append text to this Paragraph and then underline it using a color.
/// <code>
/// // Create a document.
/// using (DocX document = DocX.Create(@"Test.docx"))
/// {
/// // Insert a new Paragraph.
/// Paragraph p = document.InsertParagraph();
///
/// p.Append("I am ")
/// .Append("color underlined").UnderlineStyle(UnderlineStyle.dotted).UnderlineColor(Color.Orange)
/// .Append(" I am not");
///
/// // Save this document.
/// document.Save();
/// }// Release this document from memory.
/// </code>
/// </example>
public Paragraph UnderlineColor(Color underlineColor)
{
foreach (XElement run in runs)
{
XElement rPr = run.Element(XName.Get("rPr", DocX.w.NamespaceName));
if (rPr == null)
{
run.AddFirst(new XElement(XName.Get("rPr", DocX.w.NamespaceName)));
rPr = run.Element(XName.Get("rPr", DocX.w.NamespaceName));
}
XElement u = rPr.Element(XName.Get("u", DocX.w.NamespaceName));
if (u == null)
{
rPr.SetElementValue(XName.Get("u", DocX.w.NamespaceName), string.Empty);
u = rPr.Element(XName.Get("u", DocX.w.NamespaceName));
u.SetAttributeValue(XName.Get("val", DocX.w.NamespaceName), "single");
}
u.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), underlineColor.ToHex());
}
return this;
}
示例3: Color
/// <summary>
/// For use with Append() and AppendLine()
/// </summary>
/// <param name="c">A color to use on the appended text.</param>
/// <returns>This Paragraph with the last appended text colored.</returns>
/// <example>
/// Append text to this Paragraph and then color it.
/// <code>
/// // Create a document.
/// using (DocX document = DocX.Create(@"Test.docx"))
/// {
/// // Insert a new Paragraph.
/// Paragraph p = document.InsertParagraph();
///
/// p.Append("I am ")
/// .Append("Blue").Color(Color.Blue)
/// .Append(" I am not");
///
/// // Save this document.
/// document.Save();
/// }// Release this document from memory.
/// </code>
/// </example>
public Paragraph Color(Color c)
{
ApplyTextFormattingProperty(XName.Get("color", DocX.w.NamespaceName), string.Empty, new XAttribute(XName.Get("val", DocX.w.NamespaceName), c.ToHex()));
return this;
}
示例4: SaveColor
public static string SaveColor(Color colorAttribute)
{
if (colorAttribute == Color.Transparent)
return string.Empty;
var colorValue = colorAttribute.ToHex();
return colorValue;
}
示例5: Add
public static WWWForm Add(this WWWForm form, string key, Color value)
{
form.AddField(key, value.ToHex());
return form;
}
示例6: PaletteColor
public PaletteColor(Color color, string stylePrefix)
{
this.Color = color;
this.StyleColors = new[]
{
new StyleColor()
{
Key = stylePrefix + ".hex",
Value = color.ToHex()
},
new StyleColor()
{
Key = stylePrefix + ".rgb",
Value = color.ToRgb()
},
new StyleColor()
{
Key = stylePrefix + ".rgbp",
Value = color.ToRgbPartial()
},
new StyleColor()
{
Key = stylePrefix + ".rgba",
Value = color.ToRgba()
},
new StyleColor()
{
Key = stylePrefix + ".rgbap",
Value = color.ToRgbaPartial()
},
};
}
示例7: ColorToInt
private int ColorToInt(Color color)
{
var hexColor = color.ToHex();
switch (hexColor)
{
case "#000000":
return 0;
case "#404040":
return 1;
case "#FF0000":
return 2;
case "#FF6A00":
return 3;
case "#FFD800":
return 4;
case "#B6FF00":
return 5;
case "#4CFF00":
return 6;
case "#00FF21":
return 7;
default:
return 0;
}
}
示例8: BuildTile
private Tile BuildTile(Color color, int i, int j)
{
Texture2D texture;
Vector2 imageIndex;
bool collide;
Vector2 position = new Vector2(i * GridMultiplier, j * GridMultiplier);
Vector2 tileSize;
var hexColor = color.ToHex();
switch (hexColor)
{
// Basic Level Tiles
case "#000000":
case "#404040":
case "#FF0000":
case "#FF6A00":
case "#FFD800":
case "#B6FF00":
case "#4CFF00":
case "#00FF21":
texture = _tileTexture;
imageIndex = new Vector2(0, GridMultiplier * ColorToInt(color));
collide = true;
tileSize = new Vector2(GridMultiplier, GridMultiplier);
break;
case "#606060": // Small Cloud
texture = _sceneryTexture;
imageIndex = new Vector2(0, 0);
position.X -= 8;
position.Y -= 3;
collide = false;
tileSize = new Vector2(32, 24);
break;
case "#808080": // Medium Cloud
texture = _sceneryTexture;
imageIndex = new Vector2(32, 0);
position.X -= 8;
position.Y -= 3;
collide = false;
tileSize = new Vector2(48, 24);
break;
case "#7F0000": // Big Cloud
texture = _sceneryTexture;
imageIndex = new Vector2(80, 0);
position.X -= 8;
position.Y -= 3;
collide = false;
tileSize = new Vector2(64, 24);
break;
case "#7F3300": // Small Bush
texture = _sceneryTexture;
imageIndex = new Vector2(0, 48);
position.X -= 8;
position.Y += 8;
collide = false;
tileSize = new Vector2(32, 24);
break;
case "#7F6A00": // Medium Bush
texture = _sceneryTexture;
imageIndex = new Vector2(32, 48);
position.X -= 8;
position.Y += 8;
collide = false;
tileSize = new Vector2(48, 24);
break;
case "#5B7F00": // Big Bush
texture = _sceneryTexture;
imageIndex = new Vector2(80, 48);
position.X -= 8;
position.Y += 8;
collide = false;
tileSize = new Vector2(64, 24);
break;
case "#267F00": // Small Hill
texture = _sceneryTexture;
imageIndex = new Vector2(0, 74);
position.Y -= 3;
collide = false;
tileSize = new Vector2(48, 36);
break;
case "#007F0E": // Big Hill
texture = _sceneryTexture;
imageIndex = new Vector2(51, 74);
position.Y -= 3;
collide = false;
tileSize = new Vector2(79, 36);
break;
case "#A0A0A0": // Tube Part
texture = _tubeTexture;
imageIndex = new Vector2(0, 16);
position.Y += 16;
collide = true;
tileSize = new Vector2(32, 16);
break;
case "#303030": // Tube Top
texture = _tubeTexture;
imageIndex = new Vector2(0, 0);
position.Y += 16;
collide = true;
tileSize = new Vector2(32, 32);
//.........这里部分代码省略.........