private static void Main() { Settings.Instance.Load(); BridgeApi.Init(Settings.Instance.BridgeServer); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
private async void BrightnessSlider_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { this.light.Brightness = this.BrightnessSlider.Value; var success = await BridgeApi.SetBrightness(this.lightId, this.light.Brightness); if (!success) { MetroMessageBox.Show(this, "The brightness could not been set!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void FetchLights() { this.LoadingSpinner.Visible = true; var lights = await BridgeApi.GetLights(); // If new light added if (lightControls.Count != lights.Count) { this.lightControls.Clear(); this.DashbordLayout.Controls.Clear(); int rows = (int)Math.Ceiling((lights.Count / (float)GRID_COLS)); int lightIndex = 0; for (int row = 0; row < rows; row++) { this.DashbordLayout.RowCount += 1; this.DashbordLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 85f)); for (int i = 0; i < (float)GRID_COLS; i++) { if (lightIndex < lights.Count) { var lightControl = new LightDashboardControl(lights[lightIndex].Id) { Anchor = (AnchorStyles.Left | AnchorStyles.Right) }; this.lightControls.Add(lights[lightIndex].Id, lightControl); this.DashbordLayout.Controls.Add(lightControl); lightIndex++; } } } } else { // just update values foreach (var light in lights) { if (this.lightControls.ContainsKey(light.Id)) { this.lightControls[light.Id].UpdateValues(light); this.lightControls[light.Id].Invalidate(); } } this.UpdateLightsMenuStrip(lights); } this.LoadingSpinner.Visible = false; }
private void SetupApis() { Error = new ErrorApi { Client = this }; Account = new AccountApi { Client = this }; Application = new ApplicationApi { Client = this }; AvailableNumber = new AvailableNumberApi { Client = this }; Bridge = new BridgeApi { Client = this }; Domain = new DomainApi { Client = this }; Call = new CallApi { Client = this }; Conference = new ConferenceApi { Client = this }; Message = new MessageApi { Client = this }; NumberInfo = new NumberInfoApi { Client = this }; PhoneNumber = new PhoneNumberApi { Client = this }; Recording = new RecordingApi { Client = this }; Transcription = new TranscriptionApi { Client = this }; Media = new MediaApi { Client = this }; Endpoint = new EndpointApi { Client = this }; V2 = new ApiV2 { Message = new Bandwidth.Net.ApiV2.MessageApi { Client = this } }; }
private void UpdateLightsMenuStrip(List <Light> lights) { this.LightsContextMenu.Items.Clear(); foreach (var light in lights) { // Update Lights Menu ToolStripMenuItem lightItem = new ToolStripMenuItem(light.Name); lightItem.Checked = light.On; lightItem.ForeColor = Color.White; lightItem.Click += (sender, args) => { _ = BridgeApi.SetOn(light.Id, lightItem.Checked); this.FetchLights(); lightItem.Checked = !lightItem.Checked; }; this.LightsContextMenu.Items.Add(lightItem); } }
private async void ColorWheel_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { var color = this.ColorWheel.Color; await BridgeApi.SetColor(this.light.Id, color.R, color.G, color.B); }
private async void BrightnessSlider_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { await BridgeApi.SetBrightness(this.light.Id, this.BrightnessSlider.Value); }
private async void OnToggle_CheckedChanged(object sender, System.EventArgs e) { await BridgeApi.SetOn(this.light.Id, this.OnToggle.Checked); }
private async void LightDashboardControl_Load(object sender, EventArgs e) { this.light = await BridgeApi.GetLight(lightId); this.UpdateValues(light); }