Skip to content

Commit

Permalink
Bugfixes and set name button.
Browse files Browse the repository at this point in the history
  • Loading branch information
EthemAcar-Dev committed Jul 20, 2020
1 parent 211d987 commit 4516540
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 8 deletions.
35 changes: 30 additions & 5 deletions OpenYeeLightUI/Pages/LightPage.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 43 additions & 1 deletion OpenYeeLightUI/Pages/LightPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ private void UpdateBulbState()
where ts.PageGuid == _deviceViewModel.PageGuid
select ts).ToList();

subNodesList.FirstOrDefault(m => m.Tag == lightTab.FirstOrDefault()).Text = _deviceViewModel.ToString();
var node = subNodesList.FirstOrDefault(m => m.Tag == lightTab.FirstOrDefault());
if (node != null)
{
node.Text = _deviceViewModel.ToString();
}
}

private void BrightnessTrackBar_ValueChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -216,6 +220,11 @@ private void NotifyProfile(Control control, string information, bool isOk)
private void SaveProfileButton_Click(object sender, EventArgs e)
{
var profile = (Profile)ProfileComboBox.SelectedItem;
if (profile == null)
{
NotifyProfile(SaveProfileButton, "No profile selected", false);
return;
}
var updatingProfile = _settings.Profiles.FirstOrDefault(m => m.Key == profile.Key);
if (updatingProfile == null)
{
Expand All @@ -236,6 +245,11 @@ private void SaveProfileButton_Click(object sender, EventArgs e)
private void NewDeleteProfile_Click(object sender, EventArgs e)
{
var profile = (Profile)ProfileComboBox.SelectedItem;
if (profile == null)
{
NotifyProfile(NewDeleteProfile, "No profile selected", false);
return;
}
var updatingProfile = _settings.Profiles.FirstOrDefault(m => m.Key == profile.Key);
if (updatingProfile == null)
{
Expand Down Expand Up @@ -265,5 +279,33 @@ private void ProfileComboBox_SelectedIndexChanged(object sender, EventArgs e)
SetTemperature();
}
}

private async void SetNameButton_Click(object sender, EventArgs e)
{
string value = "";
if (this.InputStringDialog(ref value, true, "Light name:"))
{
await Yeelight.SetNameAsync(_deviceViewModel.Device, value);
_deviceViewModel.Name = value;

_deviceViewModel.IsOn = _deviceViewModel.Device.Properties.FirstOrDefault(m => m.Key == "power").Value.ToString();
Text = _deviceViewModel.ToString();
MainForm mainForm = (MainForm)this.Parent.Parent.Parent;
TreeNode firstNode = mainForm.FormAside.Nodes[0]; // Lights
List<TreeNode> subNodesList = firstNode.Nodes.Cast<TreeNode>().ToList(); // Lights sub nodes to list.

List<NavMenuItem> lightTab = (from t in subNodesList
let ts = t.Tag as NavMenuItem
where ts.PageGuid == _deviceViewModel.PageGuid
select ts).ToList();

var node = subNodesList.FirstOrDefault(m => m.Tag == lightTab.FirstOrDefault());
if (node != null)
{
node.Text = _deviceViewModel.ToString();
}
NotifyUser(SetNameButton, "Light name set");
}
}
}
}
4 changes: 2 additions & 2 deletions OpenYeeLightUI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.1")]
[assembly: AssemblyFileVersion("2.0.1")]
[assembly: AssemblyVersion("2.0.2")]
[assembly: AssemblyFileVersion("2.0.2")]

0 comments on commit 4516540

Please sign in to comment.