private static bool TrySetColor(Color color) { try { const string uriText = "net.pipe://localhost/mailnotifier/sign"; NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); EndpointAddress endpointAddress = new EndpointAddress(uriText); using (MailNotifierServiceClient client = new MailNotifierServiceClient(binding, endpointAddress)) { byte red = color.R; byte green = color.G; byte blue = color.B; client.SetColor(red, green, blue); client.Close(); return true; } } catch (Exception e) { Console.WriteLine("Failed to set color to " + color + ": " + e.Message); return false; } }
static void Main(string[] args) { try { const string uriText = "net.pipe://localhost/mailnotifier/sign"; NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); EndpointAddress endpointAddress = new EndpointAddress(uriText); MailNotifierServiceClient client = new MailNotifierServiceClient(binding, endpointAddress); if (args.Length == 1 && args[0] == "rainbow") { var colors = new Color [] { Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple }; var colorBytes = colors .SelectMany(c => new byte[] { c.R, c.G, c.B }) .ToArray(); Console.WriteLine("Rainbow..."); client.FadeToMultiRgb(colorBytes); } else if (args.Length == 3) { byte red = byte.Parse(args[0]); byte green = byte.Parse(args[1]); byte blue = byte.Parse(args[2]); Color color = Color.FromArgb(red, green, blue); client.SetColorRgb(color.R, color.G, color.B); Console.WriteLine("Color set to " + color.Name); } else if (args.Length == 4 && args[0] == "fade") { byte red = byte.Parse(args[1]); byte green = byte.Parse(args[2]); byte blue = byte.Parse(args[3]); Console.WriteLine("Fading..."); client.FadeToRgb(red, green, blue); } else if (args.Length != 1) { return; } else { Color color = Color.FromName(args[0]); byte red = RoundToNotifierColorValue(color.R); byte green = RoundToNotifierColorValue(color.G); byte blue = RoundToNotifierColorValue(color.B); client.SetColorRgb(red, green, blue); var notifierColor = Color.FromArgb(red, green, blue); Console.WriteLine("Color set to " + notifierColor.Name); } client.Close(); } catch (Exception e) { Console.WriteLine("She broke. :(" + e); Console.ReadLine(); } }
static void DisplayLetterSpace(MailNotifierServiceClient client) { client.SetColor(0, 0, 0); System.Threading.Thread.Sleep((int)(m_dotDuration.TotalMilliseconds * 3)); }
static void DisplayLetterPause(MailNotifierServiceClient client) { client.SetColor(0, 0, 0); System.Threading.Thread.Sleep(m_dotDuration); }
static void DisplayDash(MailNotifierServiceClient client) { // a dash is equal to 2 dots client.SetColor(255, 0, 0); System.Threading.Thread.Sleep((int)(m_dotDuration.TotalMilliseconds * 3)); }
static void Main(string[] args) { try { const string uriText = "net.pipe://localhost/mailnotifier/sign"; NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); EndpointAddress endpointAddress = new EndpointAddress(uriText); MailNotifierServiceClient client = new MailNotifierServiceClient(binding, endpointAddress); string text = "the quick brown fox jumped over the lazy dogs. "; Console.WriteLine(text); //client.SetColor(255, 0, 0); for (int i = 0; i < 5000; i++) { var actions = ToBlinkAction(text).ToList(); foreach (var a in actions) a(client); client.SetColor(0, 0, 0); } client.Close(); } catch (Exception e) { Console.WriteLine("She broke. :(" + e); Console.ReadLine(); } }