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); }
public override string ToString() { StringBuilder message = new(); if (Hoistable.HasValue) { message.Append($"hoisted={Hoistable} "); } if (Mentionable.HasValue) { message.Append($"mentionable={Mentionable} "); } if (Position.HasValue) { message.Append($"position={Position.Value} "); } if (Color is not null) { message.Append($"color={Color?.ToHex()} "); } return(message.ToString()[0..^ 1]);
public string Get(string propertyName) { switch (propertyName) { //ELEMENT case nameof(ClassId): return(ClassId.ToString()); case nameof(AutomationId): return(AutomationId.ToString()); case nameof(Id): return(Id.ToString()); case nameof(StyleId): return(StyleId.ToString()); //VISUAL ELEMENT case nameof(AnchorX): return(AnchorX.ToString()); case nameof(AnchorY): return(AnchorY.ToString()); case nameof(BackgroundColor): return(BackgroundColor.ToHex()); case nameof(Width): return(this.Width.ToString()); case nameof(Height): return(this.Height.ToString()); case nameof(IsEnabled): return(IsEnabled.ToString()); case nameof(WidthRequest): return(this.WidthRequest.ToString()); case nameof(HeightRequest): return(this.HeightRequest.ToString()); case nameof(IsFocused): return(IsFocused.ToString()); case nameof(IsVisible): return(IsVisible.ToString()); case nameof(InputTransparent): return(InputTransparent.ToString()); case nameof(X): return(this.X.ToString()); case nameof(Y): return(this.Y.ToString()); case nameof(Opacity): return(this.Opacity.ToString()); case nameof(TranslationX): return(this.TranslationX.ToString()); case nameof(TranslationY): return(this.TranslationY.ToString()); case nameof(Rotation): return(this.Rotation.ToString()); case nameof(RotationX): return(this.RotationX.ToString()); case nameof(RotationY): return(this.RotationY.ToString()); case nameof(Scale): return(this.Scale.ToString()); //VIEW case nameof(Margin): return(this.Margin.ToString()); case nameof(VerticalOptions): return(this.VerticalOptions.ToString()); case nameof(HorizontalOptions): return(this.HorizontalOptions.ToString()); //ACTIVITY_INDICATOR case nameof(Color): return(Color.ToHex()); case nameof(IsRunning): return(IsRunning.ToString()); default: return(string.Empty); } }
/// <summary> /// Returns a new string with the given color. /// </summary> public static string Colored(this string message, Color color) { return(string.Format("<color={0}>{1}</color>", color.ToHex(true), message)); }
/// <summary> /// Surround string with "color" tag /// </summary> public static string Colored(this string message, Color color) => $"<color={color.ToHex()}>{message}</color>";
// Color --> int(BGR) public static int ToIntBGR(this Color color) { return(color.ToHex().ToIntBGR()); }
public static string Serialize(this Color current) { return(current.ToHex(false)); }
// Activities list data retrieved from php backend private static async void generateList(Color color) { Activities = new List <Activity>(); var uri = new Uri("https://jax-apps.com/api.php"); HttpClient myClient = MsgPage.client; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("actGET", "blah"), new KeyValuePair <string, string>("pm", pm_number) }); // get outgoing packet size outgoArraySize = (await formContent.ReadAsByteArrayAsync()).Length; //start stopwatch stopwatch.Restart(); HttpResponseMessage result = new HttpResponseMessage(); try { result = await myClient.PostAsync(uri, formContent); } catch (System.Exception e) { retryCount++; if (retryCount < 11) { generateList(color); } else { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Connection Error", e.GetType().ToString(), "OK"); }); return; } } //get elapsed time and display diagnostic data stopwatch.Stop(); if (result.Content == null) { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Server Error", "Unable to reach server", "OK"); }); return; } //get incoming packet size incoArraySize = (await result.Content.ReadAsByteArrayAsync()).Length; time = stopwatch.ElapsedMilliseconds; string diag = string.Format("Outgoing Packet Length:{1}{0}Incoming Packet Length:{2}{0}Time (ms):{3}", Environment.NewLine, outgoArraySize, incoArraySize, time); await App.Current.MainPage.DisplayAlert("Generate Act List", diag, "OK"); var content = await result.Content.ReadAsStringAsync(); JArray a = JArray.Parse(content); foreach (JObject O in a.Children <JObject>()) { List <string> actdata = new List <string>(); foreach (JProperty P in O.Properties()) { actdata.Add((string)P.Value); } string dt = DateTime.Parse(actdata[3]).ToString("dd MMM yyyy"); string t = DateTime.Parse(actdata[3]).ToString("HH:mm"); Activities.Add(new Activity { activity_id = Int32.Parse(actdata[0]), pm_no = Int32.Parse(actdata[1]), content = actdata[2], activity_time = actdata[3], author = actdata[4], Date = dt, Time = t, color_text = color.ToHex() }); } ActivitiesListView.ItemsSource = Activities; }
/// <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; }
public static GUIContent Content(string text, int size, Color color) { return(new GUIContent($"<color={color.ToHex()}><size={size}>{text}</size></color")); }
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() }, }; }
public static string PUToString(this Color c) { return(c.ToHex()); }
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)); }
/// <summary> /// Convert a string to a rich text string. /// </summary> /// <param name="input">Orginal string.</param> /// <param name="color">Color to be added.</param> /// <returns>Rich text string</returns> internal static string AddColor(this string input, Color color) { return("<color=" + color.ToHex() + ">" + input + "</color>"); }
private static String HexConverter(Color c) { return(c.ToHex()); //"#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2"); }
internal static string Colorize(this string input, Color color) => $"[c/{color.ToHex()}:{input}]";
public ColorPicker(Color color) : base("color", color?.ToHex() ?? "#000000") { }
public static GUIContent Content(string text, Color color) { return(new GUIContent($"<color={color.ToHex()}>{text}</color")); }
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; } }
public static WWWForm Add(this WWWForm form, string key, Color value) { form.AddField(key, value.ToHex()); return form; }
public static TaggedString Color(this TaggedString self, Color color) => $"<color=#{color.ToHex()}>{self}</color>";
private void CreateFeature() { lock (_sync) { if (Feature == null) { // Create a new one Feature = new Feature { Geometry = Position.ToMapsui(), ["Label"] = Label, }; if (_callout != null) { _callout.Feature.Geometry = Position.ToMapsui(); } } // Check for bitmapId if (_bitmapId != -1) { // There is already a registered bitmap, so delete it _bitmapId = -1; _bitmapIdKey = string.Empty; } switch (Type) { case PinType.Svg: // Load the SVG document if (string.IsNullOrEmpty(Svg)) { return; } // Check, if it is already in cache if (_bitmapIds.ContainsKey(Svg)) { _bitmapId = _bitmapIds[Svg]; _bitmapIdKey = Svg; break; } // Save this SVG for later use _bitmapId = BitmapRegistry.Instance.Register(Svg); _bitmapIdKey = Svg; _bitmapIds.Add(Svg, _bitmapId); break; case PinType.Pin: var colorInHex = Color.ToHex(); // Check, if it is already in cache if (_bitmapIds.ContainsKey(colorInHex)) { _bitmapId = _bitmapIds[colorInHex]; _bitmapIdKey = colorInHex; break; } // First we have to create a bitmap from Svg code // Create a new SVG object var svg = new SKSvg(); // Load the SVG document var stream = Utilities.EmbeddedResourceLoader.Load("Images.Pin.svg", typeof(Pin)); if (stream == null) { return; } svg.Load(stream); Width = svg.Picture.CullRect.Width * Scale; Height = svg.Picture.CullRect.Height * Scale; // Create bitmap to hold canvas var info = new SKImageInfo((int)svg.Picture.CullRect.Width, (int)svg.Picture.CullRect.Height) { AlphaType = SKAlphaType.Premul }; var bitmap = new SKBitmap(info); var canvas = new SKCanvas(bitmap); // Now draw Svg image to bitmap using (var paint = new SKPaint() { IsAntialias = true }) { // Replace color while drawing paint.ColorFilter = SKColorFilter.CreateBlendMode(Color.ToSKColor(), SKBlendMode.SrcIn); // use the source color canvas.Clear(); canvas.DrawPicture(svg.Picture, paint); } // Now convert canvas to bitmap using (var image = SKImage.FromBitmap(bitmap)) using (var data = image.Encode(SKEncodedImageFormat.Png, 100)) { _bitmapData = data.ToArray(); } _bitmapId = BitmapRegistry.Instance.Register(new MemoryStream(_bitmapData)); _bitmapIdKey = colorInHex; _bitmapIds.Add(colorInHex, _bitmapId); break; case PinType.Icon: if (Icon != null) { using (var image = SKBitmap.Decode(Icon)) { Width = image.Width * Scale; Height = image.Height * Scale; _bitmapId = BitmapRegistry.Instance.Register(new MemoryStream(Icon)); } } break; } // If we have a bitmapId (and we should have one), than draw bitmap, otherwise nothing if (_bitmapId != -1) { // We only want to have one style Feature.Styles.Clear(); Feature.Styles.Add(new SymbolStyle { BitmapId = _bitmapId, SymbolScale = Scale, SymbolRotation = Rotation, RotateWithMap = RotateWithMap, SymbolOffset = new Offset(Anchor.X, Anchor.Y), Opacity = 1 - Transparency, Enabled = IsVisible, }); } } }
/// <summary> /// Clear the whole Screen. Calls OnScreenClear Signal /// </summary> /// <param name="color">The color to clear</param> public static void Clear(Color color) { var buffer = VBEDisplay.Framebuffer; buffer.FillRectangle(color.ToHex(), 0, 0, buffer.Width, buffer.Height);; }
/// <summary> /// Returns the hexadecimal encoding of a color. /// </summary> /// <param name="value"><see cref="T:System.Drawing.Color"/> structure to convert.</param> /// <returns> /// A hexadecimal <see cref="T:System.String" /> representing color. /// </returns> /// <example> /// The following code example, we obtain hexadecimal code for white color without chararacter <strong>#</strong>. The result is <strong>FFFFFF</strong>. /// <code lang="cs"> /// using System; /// using System.Drawing; /// /// using iTin.Export.Helper; /// /// class ColorTestClass /// { /// static int Main() /// { /// // From color name. /// string hexColorString = ColorHelper.GetColorFromString(Color.White); /// /// // Print result. /// Console.WriteLine("The hexadecimal representation of the color white is {0}", hexColorString); /// } /// } /// </code> /// </example> public static string ToHex(Color value) { return(value.ToHex()); }
public void SetPixel(uint x, uint y, Color c) { SetPixel(x, y, c.ToHex()); }
public void Clear(Color c) { Clear(c.ToHex()); }
//============================ // From //============================ public static string Serialize(this Color current, bool ignoreDefault = false, Color defaultValue = new Color()) { return(ignoreDefault && current == defaultValue ? "" : current.ToHex(false)); }
public void SetBarColor(Color color) { CrossCurrentActivity.Current?.Activity?.Window?.SetStatusBarColor(Android.Graphics.Color.ParseColor(color.ToHex())); CrossCurrentActivity.Current?.Activity?.Window?.SetNavigationBarColor(Android.Graphics.Color.ParseColor(color.ToHex())); }
/// <summary> /// Returns the hexadecimal encoding of a color. /// </summary> /// <param name="value"><see cref="Color"/> structure to convert.</param> /// <returns> /// A hexadecimal <see cref="String" /> representing color. /// </returns> /// <example> /// The following code example, we obtain hexadecimal code for white color without chararacter <b>#</b>. The result is <b>FFFFFF</b>. /// <code lang="cs"> /// using System; /// using System.Drawing; /// /// using iTin.Core.Drawing.Helpers; /// /// class ColorTestClass /// { /// static int Main() /// { /// // From color name. /// string hexColorString = ColorHelper.GetColorFromString(Color.White); /// /// // Print result. /// Console.WriteLine("The hexadecimal representation of the color white is {0}", hexColorString); /// } /// } /// </code> /// </example> public static string ToHex(Color value) => value.ToHex();
public override string AsString() { return(value.ToHex()); }
public static void Log(string message, Color color) { Log(message, color.ToHex()); }
internal override string GetValueToShow(Color color) { return(color.ToHex().Replace("#", string.Empty)); }
/// <summary> /// Wraps the supplied string in rich text color tags. /// </summary> /// <param name="color">The color to make the text.</param> /// <param name="text">The text to be colored.</param> /// <returns><paramref name="text"/> wrapped in color tags.</returns> public static string ToRichTextColorString(this Color color, string text) { return(string.Format("<color=#{0}>{1}</color>", color.ToHex(), text)); }
public void Clear(Color color) { Clear((uint)color.ToHex()); }
public static string SaveColor(Color colorAttribute) { if (colorAttribute == Color.Transparent) return string.Empty; var colorValue = colorAttribute.ToHex(); return colorValue; }
/// <summary> /// Wraps the supplied string in rich text color tags. /// </summary> /// <param name="text">The text to be colored.</param> /// <param name="color">The color to make the text.</param> /// <returns><paramref name="text"/> wrapped in color tags.</returns> public static string RichTextColor(string text, Color color) { return(string.Format("<color=#{0}>{1}</color>", color.ToHex(), text)); }
/// <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; }
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); break; default: throw new Exception("zONO"); } return new Tile(texture, imageIndex, collide, position, tileSize, Scale); }