// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
using Tango.Scripting.Editors.Document;
namespace Tango.Scripting.Editors.Rendering
{
/// <summary>
/// Represents a collapsed line section.
/// Use the Uncollapse() method to uncollapse the section.
/// </summary>
public sealed class CollapsedLineSection
{
DocumentLine start, end;
HeightTree heightTree;
#if DEBUG
internal string ID;
static int nextId;
#else
const string ID = "";
#endif
internal CollapsedLineSection(HeightTree heightTree, DocumentLine start, DocumentLine end)
{
this.heightTree = heightTree;
this.start = start;
this.end = end;
#if DEBUG
unchecked {
this.ID = " #" + (nextId++);
}
#endif
}
/// <summary>
/// Gets if the document line is collapsed.
/// This property initially is true and turns to false when uncollapsing the section.
/// </summary>
public bool IsCollapsed {
get { return start != null; }
}
/// <summary>
/// Gets the start line of the section.
/// When the section is uncollapsed or the text containing it is deleted,
/// this property returns null.
/// </summary>
public DocumentLine Start {
get { return start; }
internal set { start = value; }
}
/// <summary>
/// Gets the end line of the section.
/// When the section is uncollapsed or the text containing it is deleted,
/// this property returns null.
/// </summary>
public DocumentLine End {
get { return end; }
internal set { end = value; }
}
/// <summary>
/// Uncollapses the section.
/// This causes the Start and End properties to be set to null!
/// Does nothing if the section is already uncollapsed.
/// </summary>
public void Uncollapse()
{
if (start == null)
return;
heightTree.Uncollapse(this);
#if DEBUG
heightTree.CheckProperties();
#endif
start = null;
end = null;
}
/// <summary>
/// Gets a string representation of the collapsed section.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Int32.ToString")]
public override string ToString()
{
return "[CollapsedSection" + ID + " Start=" + (start != null ? start.LineNumber.ToString() : "null")
+ " End=" + (end != null ? end.LineNumber.ToString() : "null") + "]";
}
}
}
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid>
<Grid>
<Grid>
<DataGrid x:Name="grid" SelectedCellsChanged="grid_SelectedCellsChanged" Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Logs}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" />
<Setter Property="Cursor" Value="Hand"></Setter>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
</Trigger>
<!--<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup">
<Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter>
<Setter Property="Foreground" Value="White" />
<Setter Property="FontWeight" Value="SemiBold"></Setter>
<Setter Property="Cursor" Value="Arrow"></Setter>
</DataTrigger>-->
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
</Trigger>
<!--<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup">
<Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter>
<Setter Property="Foreground" Value="White" />
<Setter Property="FontWeight" Value="SemiBold"></Setter>
<Setter Property="Cursor" Value="Arrow"></Setter>
</DataTrigger>-->
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTemplateColumn Header="#">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<materialDesign:PackIcon Width="16" Height="16">
<materialDesign:PackIcon.Style>
<Style TargetType="materialDesign:PackIcon">
<Setter Property="Kind" Value="Alert"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Category}" Value="Info">
<Setter Property="Kind" Value="Information"></Setter>
<Setter Property="Foreground" Value="DimGray"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Warning">
<Setter Property="Kind" Value="Alert"></Setter>
<Setter Property="Foreground" Value="{StaticResource OrangeBrush}"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Error">
<Setter Property="Kind" Value="AlertOctagon"></Setter>
<Setter Property="Foreground" Value="{StaticResource RedBrush100}"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Critical">
<Setter Property="Kind" Value="BellPlus"></Setter>
<Setter Property="Foreground" Value="Red"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Debug">
<Setter Property="Kind" Value="Bug"></Setter>
<Setter Property="Foreground" Value="{StaticResource GrayBrush300}"></Setter>
</DataTrigger>
<!--<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup">
<Setter Property="Kind" Value="ClockFast"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
</DataTrigger>-->
</Style.Triggers>
</Style>
</materialDesign:PackIcon.Style>
</materialDesign:PackIcon>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,StringFormat='MM/dd/yyyy HH:mm:ss.ff'}" />
<DataGridTextColumn Header="FILE" Binding="{Binding DebugLogResponse.FileName}" />
<DataGridTextColumn Header="LINE" Binding="{Binding DebugLogResponse.LineNumber}" />
<DataGridTextColumn Header="MODULE" Binding="{Binding DebugLogResponse.ModuleId}" />
<DataGridTextColumn Header="FILTER" Binding="{Binding DebugLogResponse.Filter}" />
<DataGridTemplateColumn Header="MESSAGE" Width="1*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding MessagePlusRepeated}" TextTrimming="CharacterEllipsis"></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Grid>
</Grid>
</Grid>
</Grid>
</Grid>
</Grid>
</UserControl>