Skip to content

Commit

Permalink
Improved results visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
enviGit committed Nov 9, 2024
1 parent 0ace198 commit 23f6466
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 18 deletions.
30 changes: 14 additions & 16 deletions OptimizationIssues/Views/KnapsackView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ private void SolveButton_Click(object sender, RoutedEventArgs e)
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD700"))
});

ResultTextBlock.Inlines.Add(new Run("\nZużyta pojemność plecaka: ")
{
Foreground = new SolidColorBrush(Colors.White)
});

double fillPercentage = ((double)usedCapacity / capacity) * 100;

ResultTextBlock.Inlines.Add(new Run($"{usedCapacity}/{capacity} ({fillPercentage:F2}%)")
{
Foreground = new SolidColorBrush(usedCapacity == capacity
? (Color)ColorConverter.ConvertFromString("#98FF98")
: (Color)ColorConverter.ConvertFromString("#FF9898"))
});

ResultTextBlock.Inlines.Add(new Run("\n\nWybrane przedmioty:\n")
{
Foreground = new SolidColorBrush(Colors.White)
Expand Down Expand Up @@ -77,22 +91,6 @@ private void SolveButton_Click(object sender, RoutedEventArgs e)
Foreground = new SolidColorBrush(Colors.White)
});
}

ResultTextBlock.Inlines.Add(new Run("\nZużyta pojemność plecaka: ")
{
Foreground = new SolidColorBrush(Colors.White)
});

if (usedCapacity == capacity)
ResultTextBlock.Inlines.Add(new Run($"{usedCapacity}/{capacity}")
{
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#98FF98"))
});
else
ResultTextBlock.Inlines.Add(new Run($"{usedCapacity}/{capacity}")
{
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF9898"))
});
}
else
ResultTextBlock.Text = "Podano błędne dane. Upewnij się, że wszystkie pola są poprawnie wypełnione.";
Expand Down
23 changes: 22 additions & 1 deletion OptimizationIssues/Views/TSPView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace OptimizationIssues.Views
Expand Down Expand Up @@ -33,7 +34,27 @@ private void SolveButton_Click(object sender, RoutedEventArgs e)
(int result, List<int> path) = viewModel.SolveTravelingSalesmanProblem();
path.Add(path[0]);
string pathString = string.Join(" -> ", path);
ResultTextBlock.Text = $"Minimalna długość trasy: {result}\nTrasa: {pathString}";
ResultTextBlock.Inlines.Clear();

ResultTextBlock.Inlines.Add(new Run("Minimalna długość trasy: ")
{
Foreground = new SolidColorBrush(Colors.White)
});

ResultTextBlock.Inlines.Add(new Run(result.ToString())
{
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#98FF98"))
});

ResultTextBlock.Inlines.Add(new Run("\nTrasa: ")
{
Foreground = new SolidColorBrush(Colors.White)
});

ResultTextBlock.Inlines.Add(new Run(pathString)
{
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD700"))
});
}
else
ResultTextBlock.Text = "Podano błędne dane. Upewnij się, że wszystkie pola są poprawnie wypełnione.";
Expand Down
23 changes: 22 additions & 1 deletion OptimizationIssues/Views/TaskAllocationView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace OptimizationIssues.Views
Expand Down Expand Up @@ -32,7 +33,27 @@ private void SolveButton_Click(object sender, RoutedEventArgs e)
viewModel.CostMatrix = costMatrix;

var (minCost, maxValue) = viewModel.SolveTaskAllocation();
ResultTextBlock.Text = $"Minimalny koszt: {minCost}\nMaksymalna wartość: {maxValue}";
ResultTextBlock.Inlines.Clear();

ResultTextBlock.Inlines.Add(new Run("Minimalny koszt: ")
{
Foreground = new SolidColorBrush(Colors.White)
});

ResultTextBlock.Inlines.Add(new Run(minCost.ToString())
{
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#98FF98"))
});

ResultTextBlock.Inlines.Add(new Run("\nMaksymalna wartość: ")
{
Foreground = new SolidColorBrush(Colors.White)
});

ResultTextBlock.Inlines.Add(new Run(maxValue.ToString())
{
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF9898"))
});
}
else
ResultTextBlock.Text = "Podano błędne dane. Upewnij się, że wszystkie pola są poprawnie wypełnione.";
Expand Down

0 comments on commit 23f6466

Please sign in to comment.