Skip to content

Commit 23f6466

Browse files
committed
Improved results visualization
1 parent 0ace198 commit 23f6466

File tree

3 files changed

+58
-18
lines changed

3 files changed

+58
-18
lines changed

OptimizationIssues/Views/KnapsackView.xaml.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ private void SolveButton_Click(object sender, RoutedEventArgs e)
4545
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD700"))
4646
});
4747

48+
ResultTextBlock.Inlines.Add(new Run("\nZużyta pojemność plecaka: ")
49+
{
50+
Foreground = new SolidColorBrush(Colors.White)
51+
});
52+
53+
double fillPercentage = ((double)usedCapacity / capacity) * 100;
54+
55+
ResultTextBlock.Inlines.Add(new Run($"{usedCapacity}/{capacity} ({fillPercentage:F2}%)")
56+
{
57+
Foreground = new SolidColorBrush(usedCapacity == capacity
58+
? (Color)ColorConverter.ConvertFromString("#98FF98")
59+
: (Color)ColorConverter.ConvertFromString("#FF9898"))
60+
});
61+
4862
ResultTextBlock.Inlines.Add(new Run("\n\nWybrane przedmioty:\n")
4963
{
5064
Foreground = new SolidColorBrush(Colors.White)
@@ -77,22 +91,6 @@ private void SolveButton_Click(object sender, RoutedEventArgs e)
7791
Foreground = new SolidColorBrush(Colors.White)
7892
});
7993
}
80-
81-
ResultTextBlock.Inlines.Add(new Run("\nZużyta pojemność plecaka: ")
82-
{
83-
Foreground = new SolidColorBrush(Colors.White)
84-
});
85-
86-
if (usedCapacity == capacity)
87-
ResultTextBlock.Inlines.Add(new Run($"{usedCapacity}/{capacity}")
88-
{
89-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#98FF98"))
90-
});
91-
else
92-
ResultTextBlock.Inlines.Add(new Run($"{usedCapacity}/{capacity}")
93-
{
94-
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF9898"))
95-
});
9694
}
9795
else
9896
ResultTextBlock.Text = "Podano błędne dane. Upewnij się, że wszystkie pola są poprawnie wypełnione.";

OptimizationIssues/Views/TSPView.xaml.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Windows;
55
using System.Windows.Controls;
6+
using System.Windows.Documents;
67
using System.Windows.Media;
78

89
namespace OptimizationIssues.Views
@@ -33,7 +34,27 @@ private void SolveButton_Click(object sender, RoutedEventArgs e)
3334
(int result, List<int> path) = viewModel.SolveTravelingSalesmanProblem();
3435
path.Add(path[0]);
3536
string pathString = string.Join(" -> ", path);
36-
ResultTextBlock.Text = $"Minimalna długość trasy: {result}\nTrasa: {pathString}";
37+
ResultTextBlock.Inlines.Clear();
38+
39+
ResultTextBlock.Inlines.Add(new Run("Minimalna długość trasy: ")
40+
{
41+
Foreground = new SolidColorBrush(Colors.White)
42+
});
43+
44+
ResultTextBlock.Inlines.Add(new Run(result.ToString())
45+
{
46+
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#98FF98"))
47+
});
48+
49+
ResultTextBlock.Inlines.Add(new Run("\nTrasa: ")
50+
{
51+
Foreground = new SolidColorBrush(Colors.White)
52+
});
53+
54+
ResultTextBlock.Inlines.Add(new Run(pathString)
55+
{
56+
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD700"))
57+
});
3758
}
3859
else
3960
ResultTextBlock.Text = "Podano błędne dane. Upewnij się, że wszystkie pola są poprawnie wypełnione.";

OptimizationIssues/Views/TaskAllocationView.xaml.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Windows;
55
using System.Windows.Controls;
6+
using System.Windows.Documents;
67
using System.Windows.Media;
78

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

3435
var (minCost, maxValue) = viewModel.SolveTaskAllocation();
35-
ResultTextBlock.Text = $"Minimalny koszt: {minCost}\nMaksymalna wartość: {maxValue}";
36+
ResultTextBlock.Inlines.Clear();
37+
38+
ResultTextBlock.Inlines.Add(new Run("Minimalny koszt: ")
39+
{
40+
Foreground = new SolidColorBrush(Colors.White)
41+
});
42+
43+
ResultTextBlock.Inlines.Add(new Run(minCost.ToString())
44+
{
45+
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#98FF98"))
46+
});
47+
48+
ResultTextBlock.Inlines.Add(new Run("\nMaksymalna wartość: ")
49+
{
50+
Foreground = new SolidColorBrush(Colors.White)
51+
});
52+
53+
ResultTextBlock.Inlines.Add(new Run(maxValue.ToString())
54+
{
55+
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF9898"))
56+
});
3657
}
3758
else
3859
ResultTextBlock.Text = "Podano błędne dane. Upewnij się, że wszystkie pola są poprawnie wypełnione.";

0 commit comments

Comments
 (0)