我编写了一个打印字符串的程序,该字符串包含ANSI转义序列以使文本着色.但它在默认的Windows 10控制台中无法正常工作,如屏幕截图所示.
程序输出显示为转义序列作为打印字符.如果我通过变量或管道将该字符串提供给PowerShell,则输出将按预期显示(红色文本).
如何才能实现程序打印彩色文本而无需任何解决方法?
这是我的程序源(Haskell) - 但语言不相关,只是这样你就可以看到如何编写转义序列.
main = do
let red = "\ESC[31m"
let reset = "\ESC[39m"
putStrLn $ red ++ "RED" ++ reset
Run Code Online (Sandbox Code Playgroud) 我在Visual Studio 2015中创建了一个空白的Universal Windows App项目。
我添加类似:
try {
string foo = null;
int len = foo.Length;
} catch (Exception ex) {
System.Diagnostics.Debug.WriteLine(ex);
}
Run Code Online (Sandbox Code Playgroud)
我得到如下的堆栈跟踪:
Exception thrown: 'System.NullReferenceException' in TestStackTraces.exe
System.NullReferenceException: Object reference not set to an instance of an object.
at TestStackTraces.App.OnLaunched(LaunchActivatedEventArgs e)
Run Code Online (Sandbox Code Playgroud)
即没有行号。
如何显示行号?
透明图像在Windows窗体中是纯粹的邪恶,这就是为什么我创建了一个自定义控件类来处理它们.设计师在空的时候不显示我的控制权.我想添加一个微妙的边框,但只在设计视图中(当用户没有添加边框时).我该怎么做?
我的班级是:
class TransparentImage : Control
{
public Image Image { get; set; }
protected Graphics graphics;
public string FilePath { get; set; }
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT
return cp;
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
// Don't paint background
}
protected override void OnPaint(PaintEventArgs e)
{
// Update the private member so we can use it in the OnDraw method
this.graphics = e.Graphics;
// Set the …Run Code Online (Sandbox Code Playgroud) 我想在我的通用Windows平台应用程序中将外部.xaml文件链接到网格中.
这是文件夹结构:
我想将ListView.xaml链接到一个在MainPage.xaml中声明的网格
两个文件的代码:
MainPage.xaml中:
<Page
x:Class="TodoGrocery.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TodoGrocery"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="gridView" Grid.Row="0" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Top" Height="40" Background="#3A5194">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" BorderThickness="0" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Transparent">
<SymbolIcon Symbol="Back" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Width="40" Height="40"/>
</Button>
<TextBlock x:Name="title" Grid.Column="1" HorizontalAlignment="Center" FontSize="20" VerticalAlignment="Center" Foreground="White" Text="Todo Grocery"></TextBlock>
<Button x:Name="moreButton" BorderThickness="0" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Transparent">
<SymbolIcon Symbol="More" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Width="40" Height="40"/> …Run Code Online (Sandbox Code Playgroud)