Skip to content

Commit

Permalink
Improved functionality of the execution result display window & xaml …
Browse files Browse the repository at this point in the history
…format
  • Loading branch information
yt3trees committed Nov 12, 2023
1 parent 35e9cba commit 7f313f3
Show file tree
Hide file tree
Showing 7 changed files with 475 additions and 247 deletions.
119 changes: 82 additions & 37 deletions msbuild-gui/Console.xaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<Window x:Class="msbuild_gui.Console"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:msbuild_gui"
xmlns:ui="http://schemas.modernwpf.com/2019"
ui:WindowHelper.UseModernWindowStyle="True"
FocusManager.FocusedElement="{Binding ElementName=CmdResult}"
mc:Ignorable="d"
xmlns:app="clr-namespace:msbuild_gui"
xmlns:properties="clr-namespace:msbuild_gui.Properties"
Title="{Binding Resources.ExecutionResult, Source={x:Static app:ResourceService.Current}, Mode=OneWay}"
Height="650"
Width="1000"
WindowStartupLocation="Manual"
KeyDown="Window_KeyDown"
ShowInTaskbar="False">
<!-- <Window.Resources>
<Window
x:Class="msbuild_gui.Console"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:app="clr-namespace:msbuild_gui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:msbuild_gui"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:properties="clr-namespace:msbuild_gui.Properties"
xmlns:ui="http://schemas.modernwpf.com/2019"
Title="{Binding Resources.ExecutionResult, Source={x:Static app:ResourceService.Current}, Mode=OneWay}"
Width="1000"
Height="650"
ui:WindowHelper.UseModernWindowStyle="True"
FocusManager.FocusedElement="{Binding ElementName=CmdResult}"
KeyDown="Window_KeyDown"
ShowInTaskbar="False"
WindowStartupLocation="Manual"
mc:Ignorable="d">
<!-- <Window.Resources>
<Style x:Key="DefaultTextbox"
TargetType="{x:Type TextBox}">
<Setter Property="BorderThickness"
Expand All @@ -36,9 +37,10 @@
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<TabControl x:Name="ResultTabControl"
Margin="1,1,1,5"
Style="{StaticResource TabControlPivotStyle}">
<TabControl
x:Name="ResultTabControl"
Margin="1,1,1,5"
Style="{StaticResource TabControlPivotStyle}">
<!--<TabControl.Template>
<ControlTemplate TargetType="TabControl">
<Grid>
Expand All @@ -64,22 +66,65 @@
</Grid>
</ControlTemplate>
</TabControl.Template>-->
<TabItem x:Name="ErrorTab"
Header="{Binding Resources.ErrorLog, Source={x:Static app:ResourceService.Current}, Mode=OneWay}">
<TextBox x:Name="ErrorResult"
TextWrapping="Wrap"
Text="TextBox"
IsReadOnly="True"
VerticalScrollBarVisibility="Auto"
Padding="5,5,15,5"
FontFamily="BIZ UDGothic"
FontSize="14"
FontWeight="Normal"
KeyDown="ErrorResult_KeyDown"
BorderBrush="#99000000"
BorderThickness="1,1,1,1"
Margin="0,0,0,5" />
<TabItem x:Name="ErrorTab" Header="{Binding Resources.ErrorLog, Source={x:Static app:ResourceService.Current}, Mode=OneWay}">
<TextBox
x:Name="ErrorResult"
Margin="0,0,0,5"
Padding="5,5,15,5"
BorderBrush="#99000000"
BorderThickness="1,1,1,1"
FontFamily="BIZ UDGothic"
FontSize="14"
FontWeight="Normal"
IsReadOnly="True"
KeyDown="ErrorResult_KeyDown"
Text="TextBox"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</TabItem>
</TabControl>
<Border
x:Name="ButtonBorder"
Width="83"
Height="35"
Margin="0,7,25,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
BorderThickness="0"
CornerRadius="5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button
Grid.Column="0"
Width="45"
Height="30"
Margin="0,0,0,0"
Padding="2,5,5,5"
Background="Transparent"
Click="ShowTabList">
<ui:SymbolIcon Symbol="List" />
</Button>
<Button
x:Name="CommandButton"
Grid.Column="1"
Width="45"
Height="30"
Margin="0,0,0,0"
Padding="5,4,5,5"
HorizontalAlignment="Right"
Background="Transparent"
Click="CommandButton_Click"
Content="CMD">
<!--<ui:SymbolIcon Symbol="AlignLeft" />-->
</Button>
</Grid>
</Border>
<ListBox
x:Name="TabList"
SelectionChanged="TabList_SelectionChanged"
Visibility="Collapsed" />
</Grid>
</Window>
59 changes: 56 additions & 3 deletions msbuild-gui/Console.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ModernWpf;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -17,7 +18,8 @@ public partial class Console : Window
{
private int searchIndex { get; set; }
private int searchIndexMAX { get; set; }
public Console(string result , int maxCount, string[,] list, string errorLog)
private string command;
public Console(string result, int maxCount, string[,] list, string errorLog)

Check warning on line 22 in msbuild-gui/Console.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'command' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
InitializeComponent();
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
Expand All @@ -34,12 +36,25 @@ public Console(string result , int maxCount, string[,] list, string errorLog)
{
ResultTabControl.Items.Remove(ErrorTab);
}

Brush black = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF111111"));
Brush gray = new SolidColorBrush((Color)ColorConverter.ConvertFromString("LightGray"));
Brush white = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
Brush black80 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#CC111111"));
Brush white80 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#CCFFFFFF"));
ErrorResult.Text = errorLog;

if (ThemeManager.Current.ApplicationTheme == ApplicationTheme.Dark
|| ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Dark)
{
ButtonBorder.Background = black80;
}
else if (ThemeManager.Current.ApplicationTheme == ApplicationTheme.Light
|| ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Light)
{
ButtonBorder.Background = white80;
}

for (int count = 0; count < searchIndexMAX; count++)
{
TabItem item = new TabItem();
Expand Down Expand Up @@ -80,9 +95,10 @@ public Console(string result , int maxCount, string[,] list, string errorLog)

item.Content = text;
ResultTabControl.Items.Add(item);
command += list[count, 2].ToString() + "\r\n\r\n";
}

if (ThemeManager.Current.ApplicationTheme == ApplicationTheme.Dark
if (ThemeManager.Current.ApplicationTheme == ApplicationTheme.Dark
|| ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Dark)
{
ErrorResult.Background = black;
Expand Down Expand Up @@ -155,5 +171,42 @@ private void ErrorResult_KeyDown(object sender, KeyEventArgs e)
}
}
}
private void CommandButton_Click(object sender, RoutedEventArgs e)
{
var window = new Messagebox("Execution command", command);
window.Owner = this;
window.ShowDialog();
}
private void ShowTabList(object sender, RoutedEventArgs e)
{
TabList.Items.Clear();
foreach (TabItem tabItem in ResultTabControl.Items)
{
if (tabItem.Header is TextBlock textBlock)
{
string text = textBlock.Text;
TreeViewItem item = new TreeViewItem();
item.Header = text;
TabList.Items.Add(item);
}
else
{
string text = tabItem.Header.ToString();

Check warning on line 194 in msbuild-gui/Console.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
TreeViewItem item = new TreeViewItem();
item.Header = text;
TabList.Items.Add(item);
}
}
TabList.Visibility = Visibility.Visible;
}
private void TabList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int selectedIndex = TabList.SelectedIndex;
if (selectedIndex != -1)
{
ResultTabControl.SelectedIndex = selectedIndex;
TabList.Visibility = Visibility.Collapsed;
}
}
}
}
Loading

0 comments on commit 7f313f3

Please sign in to comment.