public Task <Exception> FindBridge(string ip) { return(Task.Run <Exception>(() => { try { if (string.IsNullOrWhiteSpace(Settings.Default.BridgeApiKey)) { SharpHue.Configuration.AddUser(ip); Settings.Default.BridgeApiKey = SharpHue.Configuration.Username; Settings.Default.Save(); } else { SharpHue.Configuration.Initialize(Settings.Default.BridgeApiKey, ip); } Lights = new LightCollection(); return null; } catch (Exception x) { return x; } //var b = HueBridgeLocator.Locate(ip).Result; //if (b != null) //{ // Bridge = b; // return true; //} //return false; })); }
void _coll_ItemRemove(object sender, LightCollection <string> .LightCollectionRemoveEventArgs e) { if (ItemRemove != null) { ItemRemove(this, e); } }
public static void Main() { var client = new ElasticClient(new ConnectionSettings(new Uri(Environment.GetEnvironmentVariable("ES_LIGHT_URL")))); Configuration.Initialize("newdeveloper"); LightService.Discover(); _lights = new LightCollection(); var health = client.Health(HealthLevel.Cluster); string status = health.Status; Color esColor = Color.FromName(status); if (status == "green") { esColor = Color.DarkGreen; } if (health.RelocatingShards > 0) { esColor = Color.Purple; } SetAllLights(esColor); }
public void Refresh() { foreach (LightStatus ctl in LightContainer.Children) { ctl.LightSelected -= LightSelected; } if (lights == null) { lights = new LightCollection(); } else { lights.Refresh(); } LightContainer.Children.Clear(); foreach (var light in lights) { var status = new LightStatus(light); status.LightSelected += LightSelected; LightContainer.Children.Add(status); } }
public void GetLights() { Configuration.Initialize("36e02089265925772f085fcd3884ec9b"); LightCollection lights = new LightCollection(); Assert.IsTrue(lights.Count > 0); }
private void setupLights() { Lights = new LightCollection(); foreach (Light light in Lights) { Console.WriteLine(light.Name); Console.WriteLine("--------Enter ID of screen portion to sync with and press ENTER or 0 to skip--------"); foreach (ScreenZone screenZone in ScreenZones) { Console.WriteLine("ID: {0} Name: {1}", screenZone.ID, screenZone.Name); } int chosenID = -1; string inputString = null; while (chosenID == -1 && (inputString == null || !inputString.Trim().Equals("0"))) { inputString = Console.ReadLine(); int.TryParse(inputString, out chosenID); } if (chosenID != 0) { ScreenZone sz = ScreenZones.FirstOrDefault(x => x.ID == chosenID); if (sz != null) { sz.LightNames.Add(light.Name); } } Console.WriteLine(); } }
/// <summary> /// Initializes a new instance of the <see cref="TreeItem{T}"/> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="parent">The parent.</param> /// <param name="ownerCollection">The owner collection.</param> internal TreeItem(string id, string parent, ref TreeCollection <T> ownerCollection) { _id = id; _parent = parent; _ownerCollection = ownerCollection; _subitems = new LightCollection <string>(); }
void _coll_ItemAddRange(object sender, LightCollection <string> .LightCollectionAddRangeEventArgs e) { if (ItemAddRange != null) { ItemAddRange(this, e); } }
public FilesCache(long maxBufferSize,long maxOverrideSize) { _maxBufferSize = maxBufferSize; _maxOverrideSize = maxOverrideSize; _files = new KeyedCollection<Stream>(); _freeFiles = new LightCollection<string>(); _isOnQuotaOverride = false; }
public FilesCache(long maxBufferSize, long maxOverrideSize) { _maxBufferSize = maxBufferSize; _maxOverrideSize = maxOverrideSize; _files = new KeyedCollection <Stream>(); _freeFiles = new LightCollection <string>(); _isOnQuotaOverride = false; }
public FlowRow() { childs = new LightCollection <PrintElementBase>(); hAlign = HorizontalAlignment.Left; contentOffset = new PointF(0, 0); childs.ItemAdd += new LightCollection <PrintElementBase> .LightCollectionAddHandler(childs_ItemAdd); childs.ItemRemove += new LightCollection <PrintElementBase> .LightCollectionRemoveHandler(childs_ItemRemove); }
public FlowRow() { childs = new LightCollection<PrintElementBase>(); hAlign = HorizontalAlignment.Left; contentOffset = new PointF(0,0); childs.ItemAdd += new LightCollection<PrintElementBase>.LightCollectionAddHandler(childs_ItemAdd); childs.ItemRemove += new LightCollection<PrintElementBase>.LightCollectionRemoveHandler(childs_ItemRemove); }
private void saveSettingsButton_Click(object sender, EventArgs e) { foreach (string s in addListBox.Items) { Settings.Instance.addLight(s); } if (qualitySettingsCombobox.SelectedIndex == 0) { Settings.Instance.QualitySetting = "100"; } else if (qualitySettingsCombobox.SelectedIndex == 1) { Settings.Instance.QualitySetting = "50"; } else if (qualitySettingsCombobox.SelectedIndex == 2) { Settings.Instance.QualitySetting = "25"; } if (averageColorRadio.Checked) { Settings.Instance.AverageColor = true; Settings.Instance.ColorPalette = false; colorPaletteRadio.Checked = false; } if (colorPaletteRadio.Checked) { Settings.Instance.AverageColor = false; Settings.Instance.ColorPalette = true; averageColorRadio.Checked = false; } Settings.Instance.Brightness = (brightnessTrackbar.Value).ToString(); try { LightCollection lights = new LightCollection(); foreach (string lightNames in Settings.Instance.HueLights) { var brightness = Math.Round((int.Parse(Settings.Instance.Brightness)) * 25.5); new LightStateBuilder().For(lights[lightNames]).Brightness(Convert.ToByte(brightness)).Apply(); } } catch (Exception exception) { MessageBox.Show("An error occured. Do you have an api key registered?"); Console.WriteLine(exception); } Settings.Instance.saveSettings(@Settings.Instance.storagePath); outputLabel.Text = "Settings Saved"; if (!string.IsNullOrEmpty(Settings.Instance.APIKey)) { listLightsButton.Enabled = true; } outputLabel.ForeColor = System.Drawing.Color.DarkGreen; }
private void listLightsButton_Click(object sender, EventArgs e) { hueLightsListBox.Items.Clear(); LightCollection lights = new LightCollection(); foreach (Light light in lights) { hueLightsListBox.Items.Add(light.Name); } }
public void ResetLights() { Configuration.Initialize("36e02089265925772f085fcd3884ec9b"); LightCollection lights = new LightCollection(); new LightStateBuilder() .For(lights, 3, 4, 5) .TurnOn() .ColorTemperature(137) .Effect(LightEffect.None) .Apply(); }
public void SetLightFromColor() { Configuration.Initialize("36e02089265925772f085fcd3884ec9b"); LightCollection lights = new LightCollection(); LightStateBuilder b = new LightStateBuilder() .TurnOn() .Brightness(255) .ColorTemperature(150); lights[5].SetState(b); }
public void SetLightFromColor2() { Configuration.Initialize("36e02089265925772f085fcd3884ec9b"); LightCollection lights = new LightCollection(); new LightStateBuilder() .For(lights[1], lights[3]) .TurnOn() .ColorTemperature(153) .Brightness(255) .Apply(); }
/// <summary> /// Initializes a new instance of the <see cref="T:StringCollection"/> class. /// </summary> /// <param name="items">The items.</param> public StringCollection(string[] items) { _coll = new LightCollection <string>(items); _coll.ItemAdd += new LightCollection <string> .LightCollectionAddHandler(_coll_ItemAdd); _coll.ItemAddRange += new LightCollection <string> .LightCollectionAddRangeHandler(_coll_ItemAddRange); _coll.ItemMove += new LightCollection <string> .LightCollectionMoveHandler(_coll_ItemMove); _coll.ItemRemove += new LightCollection <string> .LightCollectionRemoveHandler(_coll_ItemRemove); _coll.CollectionClear += new EventHandler(_coll_CollectionClear); }
private unsafe int[] GetBufferUsedColorArray(int *src) { LightCollection <int> colors = new LightCollection <int>(); for (int i = 0; i < _pixelsCount; i++) { int c = *((int *)src); if (!colors.Contains(c)) { colors.Add(c); } src++; } return(colors.GetItems()); }
/// <summary> /// Gets the full path. /// </summary> /// <returns>System.String.</returns> public string GetFullPath() { LightCollection <string> paths = new LightCollection <string>(); paths.Add(_id); TreeItem <T> parent = this.Parent; while (parent != null) { paths.Add(parent.Id); parent = parent.Parent; } paths.Reverse(); string fullPath = string.Join("/", paths.GetItems()); return(fullPath); }
public void SetLightsRandom() { Configuration.Initialize("36e02089265925772f085fcd3884ec9b"); LightCollection lights = new LightCollection(); var indices = new int[] { 3, 4, 5 }; foreach (var i in indices) { new LightStateBuilder() .For(lights[i]) .TurnOn() .Brightness(255) .RandomColor() .Apply(); } }
public PluginInfo Initialise(IntPtr apiInterfacePtr) { mbApiInterface = new MusicBeeApiInterface(); mbApiInterface.Initialise(apiInterfacePtr); about.PluginInfoVersion = PluginInfoVersion; about.Name = "Philips Hue"; about.Description = "Match your Philips Hue lights to the current song album art\n More Help: github.com/TroyFernandes/MusicBee-Philips-Hue"; about.Author = "Troy Fernandes (github.com/TroyFernandes)"; about.TargetApplication = ""; // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger about.Type = PluginType.General; about.VersionMajor = 1; // your plugin version about.VersionMinor = 1; about.Revision = 1; about.MinInterfaceVersion = MinInterfaceVersion; about.MinApiRevision = MinApiRevision; about.ReceiveNotifications = (ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents); about.ConfigurationPanelHeight = 0; // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function ToolStripMenuItem mainMenuItem = (ToolStripMenuItem)mbApiInterface.MB_AddMenuItem("mnuTools/Hue Artwork", null, null); mainMenuItem.DropDown.Items.Add("Settings", null, OnOpen); mainMenuItem.DropDown.Items.Add("Stop", null, stopPlugin); mainMenuItem.DropDown.Items.Add("Resume", null, resumePlugin); Settings.Instance.storagePath = mbApiInterface.Setting_GetPersistentStoragePath(); Settings.Instance.Initialize(); Settings.Instance.loadSettings(mbApiInterface.Setting_GetPersistentStoragePath()); Configuration.Initialize(Settings.Instance.APIKey); settingsSelector.startup(); lights = new LightCollection(); try { foreach (string lightNames in Settings.Instance.HueLights) { new LightStateBuilder().For(lights[lightNames]).TurnOn().Apply(); } } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } return(about); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var collection = new LightCollection(); while (true) { // read json key. reader.Read(); var id = (string)reader.Value; // null is the end of json. if (id == null) break; // read json value. reader.Read(); var light = serializer.Deserialize<Light>(reader); // set light identifier. light.Id = id; collection.Add(light); } return collection; }
public NumericBox() { this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.EnableNotifyMessage| ControlStyles.UserPaint , true); _onError = false; _hasComma = false; _hasNumbers = false; _onFlashing = false; _flashCount = 0; _value = new decimal(); _allowError = true; _timer = new System.Timers.Timer(25); _timer.Elapsed+=new System.Timers.ElapsedEventHandler(_timer_Elapsed); _ranges = new LightCollection<NumericRange>(); _numBox = new NumericTextBox(this); _numBox.BorderStyle = BorderStyle.None; _numBox.Multiline = false; _numBox.TextChanged += new EventHandler(_textBox_TextChanged); _numBox.KeyPress += new KeyPressEventHandler(_textBox_KeyPress); this.Height = _numBox.Height + 4; this.Width = _numBox.Width + 2; _numBox.Location = new Point(1, 1); this.Controls.Add(_numBox); }
public NumericBox() { this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.EnableNotifyMessage | ControlStyles.UserPaint , true); _onError = false; _hasComma = false; _hasNumbers = false; _onFlashing = false; _flashCount = 0; _value = new decimal(); _allowError = true; _timer = new System.Timers.Timer(25); _timer.Elapsed += new System.Timers.ElapsedEventHandler(_timer_Elapsed); _ranges = new LightCollection <NumericRange>(); _numBox = new NumericTextBox(this); _numBox.BorderStyle = BorderStyle.None; _numBox.Multiline = false; _numBox.TextChanged += new EventHandler(_textBox_TextChanged); _numBox.KeyPress += new KeyPressEventHandler(_textBox_KeyPress); this.Height = _numBox.Height + 4; this.Width = _numBox.Width + 2; _numBox.Location = new Point(1, 1); this.Controls.Add(_numBox); }
private void LoadConfig() { //Load configuration try { var username = Settings.Default["Username"].ToString(); Configuration.Initialize(username); //TODO Handle this better. ToggleControls(true); pairToolStripMenuItem.Enabled = false; Username = username; LightCollection = new LightCollection(); if (LightCollection.Count != 0) { trackBarLights.Maximum = LightCollection.Count; trackBarLights.Minimum = 1; UpdateLightControlLabel(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private unsafe int[] GetBufferUsedColorArray(int* src) { LightCollection<int> colors = new LightCollection<int>(); for (int i = 0; i < _pixelsCount; i++) { int c = *((int*)src); if (!colors.Contains(c)) { colors.Add(c); } src++; } return colors.GetItems(); }
public static void PHRegister() { Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("Checking for existing PH Username"); if (iniFile.Section("PhilipsHue").Get("Username") == "?") { Console.WriteLine("[INI]: " + iniFile.Section("PhilipsHue").Get("Username")); Console.WriteLine("Need to register with Philips Hue"); Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.Green; Console.WriteLine("Please press the button on your Philips Hue to register with SharpBot"); Console.WriteLine("Press any key when the button has been pressed"); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Black; Console.ReadKey(); try { Console.ForegroundColor = ConsoleColor.Gray; Configuration.AddUser(); Console.WriteLine("Registered with Philips Hue - Username: "******"Saving to INI File"); iniFile.Section("PhilipsHue").Set("Username", Configuration.Username); Console.WriteLine("[INI]: " + iniFile.Section("PhilipsHue").Get("Username")); iniFile.Save(ini); lights = new LightCollection(); Console.WriteLine("A total of {0} lights were found on the bridge", lights.Count); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message.ToUpper()); Console.ForegroundColor = ConsoleColor.White; } } else { try { Console.WriteLine("Attempting to access bridge with Username: "******"PhilipsHue").Get("Username")); Configuration.Initialize(iniFile.Section("PhilipsHue").Get("Username")); lights = new LightCollection(); Console.ForegroundColor = ConsoleColor.White; Console.Write("A total of "); Console.ForegroundColor = ConsoleColor.Green; Console.Write(lights.Count); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" lights were found on the bridge"); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message.ToUpper()); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Username did not work, clearing out INI file"); iniFile.Section("PhilipsHue").Set("Username", "?"); iniFile.Save(ini); Console.WriteLine("Please rerun Register"); } } }
void childs_ItemAdd(object sender, LightCollection<PrintElementBase>.LightCollectionAddEventArgs e) { e.Item.SetOwnerRow(this); }
void childs_ItemRemove(object sender, LightCollection<PrintElementBase>.LightCollectionRemoveEventArgs e) { e.RemovedItem.SetOwnerRow(null); }
public void GetLightsNoAuth() { LightCollection lights = new LightCollection(); }
/// <summary> /// Constructor /// </summary> /// <param name="renderer"></param> /// <param name="lights"></param> /// <param name="webglObjects"></param> /// <param name="webglObjectsImmediate"></param> public ShadowMapPlugin(WebGLRenderer renderer, LightCollection lights, Dictionary <int, List <WebGlObject> > webglObjects, List <WebGlObject> webglObjectsImmediate) { this._renderer = renderer; }
void childs_ItemAdd(object sender, LightCollection <PrintElementBase> .LightCollectionAddEventArgs e) { e.Item.SetOwnerRow(this); }
public StringCollection() { _coll = new LightCollection <string>(); }
protected LightSystem(Selector selector) : base(selector) { lightNodes = new LightCollection(); }
void childs_ItemRemove(object sender, LightCollection <PrintElementBase> .LightCollectionRemoveEventArgs e) { e.RemovedItem.SetOwnerRow(null); }
public StringCollection(int startCapacity) { _coll = new LightCollection <string>(startCapacity); }
public StringCollection(ILightCollection <string> collection) { _coll = new LightCollection <string>(collection); }
public StringCollection(string[] items) { _coll = new LightCollection <string>(items); }
/// <summary> /// When <see cref="Apply" /> is called, applies the state information stored in this LightStateBuilder to each of the light indices passed in to this method. /// </summary> /// <param name="lights">The collection of lights that this new state applies to. To select lights, pass in one or more <paramref name="indices" />. To actually apply the new state, call <see cref="Apply" />.</param> /// <param name="indices">The indices within the <paramref name="lights" /> collection to apply to.</param> /// <returns>This LightStateBuilder instance, for method chaining.</returns> public LightStateBuilder For(LightCollection lights, params int[] indices) { foreach (var i in indices) { associatedLights.Add(lights[i]); } return this; }