|
| 1 | +<UserControl x:Class="GitHub.VisualStudio.Views.Documents.IssueishCommentView" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 6 | + xmlns:ghfvs="https://github.com/github/VisualStudio" |
| 7 | + xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI" |
| 8 | + xmlns:ui="clr-namespace:GitHub.UI;assembly=GitHub.UI" |
| 9 | + xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf" |
| 10 | + xmlns:views="clr-namespace:GitHub.VisualStudio.Views" |
| 11 | + mc:Ignorable="d" d:DesignWidth="300"> |
| 12 | + <d:DesignProperties.DataContext> |
| 13 | + <ghfvs:CommentViewModelDesigner EditState="Editing"> |
| 14 | + <ghfvs:CommentViewModelDesigner.Body> |
| 15 | + You can use a `CompositeDisposable` type here, it's designed to handle disposables in an optimal way (you can just call `Dispose()` on it and it will handle disposing everything it holds). |
| 16 | + </ghfvs:CommentViewModelDesigner.Body> |
| 17 | + </ghfvs:CommentViewModelDesigner> |
| 18 | + </d:DesignProperties.DataContext> |
| 19 | + |
| 20 | + <FrameworkElement.Resources> |
| 21 | + <ResourceDictionary> |
| 22 | + <ResourceDictionary.MergedDictionaries> |
| 23 | + <cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml" /> |
| 24 | + <cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI.Reactive;component/SharedDictionary.xaml" /> |
| 25 | + <cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml" /> |
| 26 | + <cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI;component/Assets/Markdown.xaml" /> |
| 27 | + </ResourceDictionary.MergedDictionaries> |
| 28 | + |
| 29 | + <Style TargetType="Button" BasedOn="{StaticResource GitHubVsButton}"/> |
| 30 | + </ResourceDictionary> |
| 31 | + </FrameworkElement.Resources> |
| 32 | + |
| 33 | + <FrameworkElement.CommandBindings> |
| 34 | + <CommandBinding Command="{x:Static markdig:Commands.Hyperlink}" Executed="OpenHyperlink" /> |
| 35 | + </FrameworkElement.CommandBindings> |
| 36 | + |
| 37 | + <Grid> |
| 38 | + <!-- Displays an existing comment--> |
| 39 | + <Grid Margin="0 16"> |
| 40 | + <Grid.ColumnDefinitions> |
| 41 | + <ColumnDefinition Width="40" /> |
| 42 | + <ColumnDefinition Width="*" /> |
| 43 | + </Grid.ColumnDefinitions> |
| 44 | + <Grid.RowDefinitions> |
| 45 | + <RowDefinition Height="Auto"/> |
| 46 | + <RowDefinition Height="Auto"/> |
| 47 | + </Grid.RowDefinitions> |
| 48 | + |
| 49 | + <Grid.Style> |
| 50 | + <!-- Hides the grid unless EditState == None --> |
| 51 | + <Style TargetType="FrameworkElement"> |
| 52 | + <Setter Property="Visibility" Value="Collapsed"/> |
| 53 | + <Style.Triggers> |
| 54 | + <DataTrigger Binding="{Binding EditState}" Value="None"> |
| 55 | + <Setter Property="Visibility" Value="Visible"/> |
| 56 | + </DataTrigger> |
| 57 | + </Style.Triggers> |
| 58 | + </Style> |
| 59 | + </Grid.Style> |
| 60 | + |
| 61 | + <views:ActorAvatarView Width="35" |
| 62 | + Height="35" |
| 63 | + VerticalAlignment="Top" |
| 64 | + Margin="0 0 5 0" |
| 65 | + ViewModel="{Binding Author}" /> |
| 66 | + |
| 67 | + <Border BorderBrush="{DynamicResource GitHubHeaderSeparatorBrush}" BorderThickness="1" |
| 68 | + Grid.Column="1" VerticalAlignment="Top"> |
| 69 | + <StackPanel Orientation="Vertical"> |
| 70 | + <Border Padding="6" Background="{DynamicResource GitHubBranchNameBackgroundBrush}" BorderBrush="{DynamicResource GitHubHeaderSeparatorBrush}" BorderThickness="0 0 0 1"> |
| 71 | + <StackPanel Orientation="Horizontal" DockPanel.Dock="Left" > |
| 72 | + <TextBlock Foreground="{DynamicResource GitHubVsToolWindowText}" Margin="4"> |
| 73 | + <Run FontWeight="SemiBold" Text="{Binding Author.Login}" /> |
| 74 | + <Run Text="commented" /> |
| 75 | + </TextBlock> |
| 76 | + |
| 77 | + <ui:GitHubActionLink Content="{Binding CreatedAt, Converter={ui:DurationToStringConverter}}" |
| 78 | + Command="{Binding OpenOnGitHub}" |
| 79 | + Foreground="{DynamicResource GitHubVsToolWindowText}" |
| 80 | + VerticalAlignment="Center" |
| 81 | + Opacity="0.75" /> |
| 82 | + <Border Background="{DynamicResource VsBrush.InfoBackground}" |
| 83 | + BorderBrush="{DynamicResource VsBrush.AccentPale}" |
| 84 | + BorderThickness="1" |
| 85 | + CornerRadius="3" |
| 86 | + Padding="2 1" |
| 87 | + VerticalAlignment="Center" |
| 88 | + Visibility="{Binding IsPending, Converter={ui:BooleanToVisibilityConverter}, FallbackValue=Collapsed}"> |
| 89 | + <TextBlock FontSize="10" Text="{x:Static ghfvs:Resources.Pending}" /> |
| 90 | + </Border> |
| 91 | + </StackPanel> |
| 92 | + </Border> |
| 93 | + |
| 94 | + <markdig:MarkdownViewer Name="bodyMarkdown" Margin="8" Foreground="{DynamicResource VsBrush.WindowText}" Markdown="{Binding Body}"/> |
| 95 | + </StackPanel> |
| 96 | + </Border> |
| 97 | + </Grid> |
| 98 | + |
| 99 | + <!-- Displays edit view or a reply placeholder--> |
| 100 | + <Grid> |
| 101 | + <Grid.Style> |
| 102 | + <Style TargetType="FrameworkElement"> |
| 103 | + <Setter Property="Visibility" Value="Collapsed"/> |
| 104 | + <Style.Triggers> |
| 105 | + <DataTrigger Binding="{Binding EditState}" Value="Placeholder"> |
| 106 | + <Setter Property="Visibility" Value="Visible"/> |
| 107 | + </DataTrigger> |
| 108 | + <DataTrigger Binding="{Binding EditState}" Value="Editing"> |
| 109 | + <Setter Property="Visibility" Value="Visible"/> |
| 110 | + </DataTrigger> |
| 111 | + </Style.Triggers> |
| 112 | + </Style> |
| 113 | + </Grid.Style> |
| 114 | + |
| 115 | + <Grid.ColumnDefinitions> |
| 116 | + <ColumnDefinition Width="40" /> |
| 117 | + <ColumnDefinition Width="Auto"/> |
| 118 | + <ColumnDefinition Width="*"/> |
| 119 | + </Grid.ColumnDefinitions> |
| 120 | + |
| 121 | + <Grid.RowDefinitions> |
| 122 | + <RowDefinition Height="Auto"/> |
| 123 | + <RowDefinition Height="*"/> |
| 124 | + <RowDefinition Height="Auto"/> |
| 125 | + <RowDefinition Height="Auto"/> |
| 126 | + </Grid.RowDefinitions> |
| 127 | + |
| 128 | + <Separator Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="0" Margin="0 0 0 4" |
| 129 | + Background="{DynamicResource GitHubButtonBorderBrush}"/> |
| 130 | + |
| 131 | + <ui:PromptTextBox Name="body" |
| 132 | + Grid.Column="2" |
| 133 | + Grid.Row="1" |
| 134 | + AcceptsReturn="True" |
| 135 | + AcceptsTab="True" |
| 136 | + IsReadOnly="{Binding IsReadOnly}" |
| 137 | + Margin="4 0 4 4" |
| 138 | + Text="{Binding Body, UpdateSourceTrigger=PropertyChanged}" |
| 139 | + TextWrapping="Wrap" |
| 140 | + VerticalAlignment="Center" |
| 141 | + GotFocus="ReplyPlaceholder_GotFocus" |
| 142 | + Loaded="body_Loaded" |
| 143 | + SpellCheck.IsEnabled="True"> |
| 144 | + <ui:PromptTextBox.Style> |
| 145 | + <Style TargetType="ui:PromptTextBox" BasedOn="{StaticResource RoundedPromptTextBox}"> |
| 146 | + <Setter Property="Foreground" Value="{DynamicResource GitHubVsToolWindowText}" /> |
| 147 | + <Setter Property="Background" Value="{DynamicResource VsBrush.SearchBoxBackground}" /> |
| 148 | + <Setter Property="Height" Value="28"/> |
| 149 | + <Setter Property="PromptText" Value="Reply..."/> |
| 150 | + <Setter Property="BorderBrush" Value="{DynamicResource GitHubVsBrandedUIBorder}" /> |
| 151 | + |
| 152 | + <Style.Triggers> |
| 153 | + <DataTrigger Binding="{Binding EditState}" Value="Editing"> |
| 154 | + <Setter Property="MinHeight" Value="100"/> |
| 155 | + <Setter Property="PromptText" Value="Leave a comment"/> |
| 156 | + </DataTrigger> |
| 157 | + </Style.Triggers> |
| 158 | + |
| 159 | + <Style.Resources> |
| 160 | + <Style TargetType="TextBlock"> |
| 161 | + <Setter Property="Foreground" Value="{DynamicResource GitHubVsToolWindowText}" /> |
| 162 | + </Style> |
| 163 | + </Style.Resources> |
| 164 | + </Style> |
| 165 | + </ui:PromptTextBox.Style> |
| 166 | + </ui:PromptTextBox> |
| 167 | + |
| 168 | + <DockPanel Grid.Column="2" Grid.Row="2" |
| 169 | + Margin="0 4" |
| 170 | + HorizontalAlignment="Left" |
| 171 | + TextBlock.Foreground="Red"> |
| 172 | + <DockPanel.Style> |
| 173 | + <Style TargetType="FrameworkElement"> |
| 174 | + <Style.Triggers> |
| 175 | + <DataTrigger Binding="{Binding ErrorMessage}" Value="{x:Null}"> |
| 176 | + <Setter Property="Visibility" Value="Collapsed"/> |
| 177 | + </DataTrigger> |
| 178 | + </Style.Triggers> |
| 179 | + </Style> |
| 180 | + </DockPanel.Style> |
| 181 | + <ui:OcticonImage DockPanel.Dock="Left" Icon="alert" Margin="0 0 4 0"/> |
| 182 | + <TextBlock Text="{Binding ErrorMessage}" TextWrapping="Wrap"/> |
| 183 | + </DockPanel> |
| 184 | + |
| 185 | + <StackPanel Name="buttonPanel" |
| 186 | + Grid.Column="2" Grid.Row="3" |
| 187 | + Margin="4 8" |
| 188 | + HorizontalAlignment="Left" |
| 189 | + Orientation="Horizontal" |
| 190 | + IsVisibleChanged="buttonPanel_IsVisibleChanged"> |
| 191 | + <StackPanel.Style> |
| 192 | + <Style TargetType="FrameworkElement"> |
| 193 | + <Setter Property="Visibility" Value="Collapsed"/> |
| 194 | + <Style.Triggers> |
| 195 | + <DataTrigger Binding="{Binding EditState}" Value="Editing"> |
| 196 | + <Setter Property="Visibility" Value="Visible"/> |
| 197 | + </DataTrigger> |
| 198 | + </Style.Triggers> |
| 199 | + </Style> |
| 200 | + </StackPanel.Style> |
| 201 | + <Button Command="{Binding CommitEdit}" Content="{Binding CommitCaption}"/> |
| 202 | + </StackPanel> |
| 203 | + </Grid> |
| 204 | + </Grid> |
| 205 | +</UserControl> |
0 commit comments