Skip to content

Commit

Permalink
Merge pull request #48 from OpenIPC/fpv-model
Browse files Browse the repository at this point in the history
add nulls to dropdown to clear
  • Loading branch information
mikecarr authored Dec 14, 2024
2 parents 673d673 + 2714933 commit 17cf49d
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions OpenIPC_Config/ViewModels/CameraSettingsTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,25 @@ partial void OnSelectedFpvIntraQpChanged(string value)

private void UpdateCombinedValue()
{
CombinedFpvRoiRectValue = $"{FpvRoiRectLeft[0]}x{FpvRoiRectTop[0]}x{FpvRoiRectHeight[0]}x{FpvRoiRectWidth[0]}";
var fpvRoiRectLeft = FpvRoiRectLeft[0];
var fpvRoiRectTop = FpvRoiRectTop[0];
var fpvRoiRectHeight = FpvRoiRectHeight[0];
var fpvRoiRectWidth = FpvRoiRectWidth[0];

if (string.IsNullOrEmpty(fpvRoiRectLeft) &&
string.IsNullOrEmpty(fpvRoiRectTop) &&
string.IsNullOrEmpty(fpvRoiRectHeight) &&
string.IsNullOrEmpty(fpvRoiRectWidth)
)
{
// set to empty so that it removes the settings
CombinedFpvRoiRectValue = "";
}
else
{
CombinedFpvRoiRectValue = $"{FpvRoiRectLeft[0]}x{FpvRoiRectTop[0]}x{FpvRoiRectHeight[0]}x{FpvRoiRectWidth[0]}";
}

Log.Debug($"Combined value updated to {CombinedFpvRoiRectValue}");
UpdateYamlConfig(Majestic.FpvRoiRect, CombinedFpvRoiRectValue);
}
Expand All @@ -269,8 +287,14 @@ public void UpdateYamlConfig(string key, string newValue)
_yamlConfig[key] = newValue;
else
_yamlConfig.Add(key, newValue);

if (string.IsNullOrEmpty(newValue))
{
_yamlConfig.Remove(key);
}
}


private void InitializeCollections()
{
Resolution = new ObservableCollection<string>
Expand Down Expand Up @@ -298,17 +322,22 @@ private void InitializeCollections()
Mirror = new ObservableCollection<string> { "true", "false" };

FpvEnabled = new ObservableCollection<string> { "true", "false" };
FpvNoiseLevel = new ObservableCollection<string> { "0", "1", "2" };
FpvNoiseLevel = new ObservableCollection<string> { "","0", "1", "2" };


// Create an ObservableCollection with values from -30 to 30
FpvRoiQp = new ObservableCollection<string>(Enumerable.Range(-30, 61).Select(i => i.ToString()));
FpvRoiQp.Insert(0,"");

FpvRefEnhance = new ObservableCollection<string>(Enumerable.Range(0, 10).Select(i => i.ToString()));
FpvRefEnhance.Insert(0,"");

FpvRefPred = new ObservableCollection<string> { "true", "false" };
FpvRefPred = new ObservableCollection<string> { "", "true", "false" };

FpvIntraLine = new ObservableCollection<string>(Enumerable.Range(0, 10).Select(i => i.ToString()));
FpvIntraQp = new ObservableCollection<string>{ "true", "false" };
FpvIntraLine.Insert(0,"");

FpvIntraQp = new ObservableCollection<string>{ "","true", "false" };

FpvRoiRectLeft = new ObservableCollection<string> { "" };
}
Expand Down

0 comments on commit 17cf49d

Please sign in to comment.