aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml
blob: 37cd0b79393095731dfab7ec04d0e390d9de3473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<UserControl x:Class="Tango.MachineStudio.UI.Views.ReportIssueView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete"
             xmlns:integration="clr-namespace:Tango.Integration.Services;assembly=Tango.Integration"
             xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
             xmlns:vm="clr-namespace:Tango.MachineStudio.UI.ViewModels"
             xmlns:tfs="clr-namespace:Tango.TFS;assembly=Tango.TFS"
             xmlns:tfss="clr-namespace:Tango.MachineStudio.UI.TFS"
             xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views"
             mc:Ignorable="d" Width="530" Height="680" Background="White" d:DataContext="{d:DesignInstance Type=vm:ReportIssueViewVM, IsDesignTimeCreatable=False}">

    <UserControl.Resources>
        <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" />
        <tfss:TeamMembersProvider x:Key="TeamMembersProvider" />
        <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>

    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="90"/>
                <RowDefinition Height="377*"/>
                <RowDefinition Height="70"/>
            </Grid.RowDefinitions>

            <Grid>
                <StackPanel Orientation="Horizontal">
                    <Image Source="/Images/bug.png" Width="48" RenderOptions.BitmapScalingMode="Fant"></Image>
                    <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" FontSize="20">Report Issue</TextBlock>
                </StackPanel>
            </Grid>

            <Grid Grid.Row="1">
                <DockPanel>
                    <StackPanel DockPanel.Dock="Top">
                        <DockPanel>
                            <materialDesign:PackIcon Kind="Pencil" Width="24" Height="24" VerticalAlignment="Center" Margin="0 0 10 0" />
                            <TextBox materialDesign:HintAssist.Hint="Title" materialDesign:HintAssist.IsFloating="True" FontSize="16" Text="{Binding WorkItem.Title}"></TextBox>
                        </DockPanel>

                        <DockPanel Margin="0 10 0 0">
                            <materialDesign:PackIcon Kind="Account" Width="24" Height="24" VerticalAlignment="Center" Margin="0 0 10 0" />
                            <autoComplete:AutoCompleteTextBox Provider="{StaticResource TeamMembersProvider}" SelectedItem="{Binding WorkItem.AssignedTo,Mode=TwoWay}" DisplayMember="DisplayName" materialDesign:HintAssist.Hint="Assigned To" materialDesign:HintAssist.IsFloating="True"></autoComplete:AutoCompleteTextBox>
                        </DockPanel>

                        <DockPanel Margin="0 10 0 0">
                            <materialDesign:PackIcon Kind="Star" Width="24" Height="24" VerticalAlignment="Center" Margin="0 0 10 0" />
                            <ComboBox materialDesign:HintAssist.Hint="Area" materialDesign:HintAssist.IsFloating="True" ItemsSource="{Binding Project.Areas}" SelectedItem="{Binding WorkItem.Area}" DisplayMemberPath="Name"></ComboBox>
                        </DockPanel>

                        <DockPanel Margin="0 10 0 0">
                            <materialDesign:PackIcon Kind="CommentAlertOutline" Width="24" Height="24" VerticalAlignment="Center" Margin="0 0 10 0" />
                            <ComboBox materialDesign:HintAssist.Hint="Severity" materialDesign:HintAssist.IsFloating="True" ItemsSource="{Binding Source={x:Type tfs:Severity},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding WorkItem.Severity}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"></ComboBox>
                        </DockPanel>

                        <DockPanel Margin="0 20 0 0">
                            <materialDesign:PackIcon Kind="Tag" Width="24" Height="24" VerticalAlignment="Center" Margin="0 0 10 0" />
                            <TextBlock VerticalAlignment="Center"><Run>Tags</Run> <Run FontSize="10" Foreground="Gray">(highlight selected tags)</Run></TextBlock>
                        </DockPanel>
                        <ScrollViewer Margin="30 0 0 0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Height="120">
                            <ItemsControl ItemsSource="{Binding SelectedTags}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel IsItemsHost="True" Orientation="Horizontal" />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <ToggleButton Style="{StaticResource emptyToggleButton}" IsChecked="{Binding IsSelected}" Cursor="Hand">
                                            <Border CornerRadius="5" Margin="0 5 5 5" Padding="5" BorderThickness="1" BorderBrush="DimGray">
                                                <Border.Style>
                                                    <Style TargetType="Border">
                                                        <Setter Property="Background" Value="Silver"></Setter>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                                                                <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter>
                                                                <Setter Property="TextElement.Foreground" Value="White"></Setter>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Border.Style>
                                                <TextBlock Text="{Binding Data.Name}" FontSize="11"></TextBlock>
                                            </Border>
                                        </ToggleButton>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>
                    </StackPanel>

                    <Grid>
                        <DockPanel>
                            <DockPanel Margin="0 10 0 0" DockPanel.Dock="Top">
                                <materialDesign:PackIcon Kind="ChartTimeline" Width="24" Height="24" VerticalAlignment="Center" Margin="0 0 10 0" />
                                <TextBlock VerticalAlignment="Center">Steps To Reproduce</TextBlock>
                            </DockPanel>

                            <Grid Margin="30 0 0 0">
                                <TextBox Margin="0 5 0 0" Style="{x:Null}" BorderBrush="Silver" AcceptsReturn="True" TextWrapping="Wrap" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Text="{Binding WorkItem.StepsToReproduce}"></TextBox>
                            </Grid>
                        </DockPanel>
                    </Grid>
                </DockPanel>
            </Grid>

            <Grid Grid.Row="2">
                <Button HorizontalAlignment="Right" Height="40" Width="140" Command="{Binding OKCommand}" Background="#FF6262" BorderBrush="#FF6262" IsDefault="True">SUBMIT</Button>

                <ItemsControl ItemsSource="{Binding ValidationErrors}" HorizontalAlignment="Left" Margin="5" VerticalAlignment="Center" Visibility="Visible">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Foreground="#FF4C4C" Margin="0 2 0 0"><Run>*</Run> <Run Text="{Binding Path=*,Mode=OneWay}"></Run></TextBlock>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
an> /// The text is replaced character-by-character. /// Anchors keep their position inside the replaced text. /// Anchors after the replaced region will move accordingly if the replacement text has a different length than the replaced text. /// If the new text is shorter than the old text, anchors inside the old text that would end up behind the replacement text /// will be moved so that they point to the end of the replacement text. /// </summary> /// <remarks> /// On the OffsetChangeMap level, growing text is implemented by replacing the last character in the replaced text /// with itself and the additional text segment. A simple insertion of the additional text would have the undesired /// effect of moving anchors immediately after the replaced text into the replacement text if they used /// AnchorMovementStyle.BeforeInsertion. /// Shrinking text is implemented by removing the text segment that's too long; but in a special mode that /// causes anchors to always survive irrespective of their <see cref="TextAnchor.SurviveDeletion"/> setting. /// If the text keeps its old size, this is implemented as OffsetChangeMap.Empty. /// </remarks> CharacterReplace, /// <summary> /// Like 'Normal', but anchors with <see cref="TextAnchor.MovementType"/> = Default will stay in front of the /// insertion instead of being moved behind it. /// </summary> KeepAnchorBeforeInsertion } /// <summary> /// Describes a series of offset changes. /// </summary> [Serializable] [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification="It's a mapping old offsets -> new offsets")] public sealed class OffsetChangeMap : Collection<OffsetChangeMapEntry> { /// <summary> /// Immutable OffsetChangeMap that is empty. /// </summary> [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification="The Empty instance is immutable")] public static readonly OffsetChangeMap Empty = new OffsetChangeMap(Empty<OffsetChangeMapEntry>.Array, true); /// <summary> /// Creates a new OffsetChangeMap with a single element. /// </summary> /// <param name="entry">The entry.</param> /// <returns>Returns a frozen OffsetChangeMap with a single entry.</returns> public static OffsetChangeMap FromSingleElement(OffsetChangeMapEntry entry) { return new OffsetChangeMap(new OffsetChangeMapEntry[] { entry }, true); } bool isFrozen; /// <summary> /// Creates a new OffsetChangeMap instance. /// </summary> public OffsetChangeMap() { } internal OffsetChangeMap(int capacity) : base(new List<OffsetChangeMapEntry>(capacity)) { } private OffsetChangeMap(IList<OffsetChangeMapEntry> entries, bool isFrozen) : base(entries) { this.isFrozen = isFrozen; } /// <summary> /// Gets the new offset where the specified offset moves after this document change. /// </summary> public int GetNewOffset(int offset, AnchorMovementType movementType) { IList<OffsetChangeMapEntry> items = this.Items; int count = items.Count; for (int i = 0; i < count; i++) { offset = items[i].GetNewOffset(offset, movementType); } return offset; } /// <summary> /// Gets whether this OffsetChangeMap is a valid explanation for the specified document change. /// </summary> public bool IsValidForDocumentChange(int offset, int removalLength, int insertionLength) { int endOffset = offset + removalLength; foreach (OffsetChangeMapEntry entry in this) { // check that ChangeMapEntry is in valid range for this document change if (entry.Offset < offset || entry.Offset + entry.RemovalLength > endOffset) return false; endOffset += entry.InsertionLength - entry.RemovalLength; } // check that the total delta matches return endOffset == offset + insertionLength; } /// <summary> /// Calculates the inverted OffsetChangeMap (used for the undo operation). /// </summary> public OffsetChangeMap Invert() { if (this == Empty) return this; OffsetChangeMap newMap = new OffsetChangeMap(this.Count); for (int i = this.Count - 1; i >= 0; i--) { OffsetChangeMapEntry entry = this[i]; // swap InsertionLength and RemovalLength newMap.Add(new OffsetChangeMapEntry(entry.Offset, entry.InsertionLength, entry.RemovalLength)); } return newMap; } /// <inheritdoc/> protected override void ClearItems() { CheckFrozen(); base.ClearItems(); } /// <inheritdoc/> protected override void InsertItem(int index, OffsetChangeMapEntry item) { CheckFrozen(); base.InsertItem(index, item); } /// <inheritdoc/> protected override void RemoveItem(int index) { CheckFrozen(); base.RemoveItem(index); } /// <inheritdoc/> protected override void SetItem(int index, OffsetChangeMapEntry item) { CheckFrozen(); base.SetItem(index, item); } void CheckFrozen() { if (isFrozen) throw new InvalidOperationException("This instance is frozen and cannot be modified."); } /// <summary> /// Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe. /// </summary> public bool IsFrozen { get { return isFrozen; } } /// <summary> /// Freezes this instance. /// </summary> public void Freeze() { isFrozen = true; } } /// <summary> /// An entry in the OffsetChangeMap. /// This represents the offset of a document change (either insertion or removal, not both at once). /// </summary> [Serializable] public struct OffsetChangeMapEntry : IEquatable<OffsetChangeMapEntry> { readonly int offset; // MSB: DefaultAnchorMovementIsBeforeInsertion readonly uint insertionLengthWithMovementFlag; // MSB: RemovalNeverCausesAnchorDeletion; other 31 bits: RemovalLength readonly uint removalLengthWithDeletionFlag; /// <summary> /// The offset at which the change occurs. /// </summary> public int Offset { get { return offset; } } /// <summary> /// The number of characters inserted. /// Returns 0 if this entry represents a removal. /// </summary> public int InsertionLength { get { return (int)(insertionLengthWithMovementFlag & 0x7fffffff); } } /// <summary> /// The number of characters removed. /// Returns 0 if this entry represents an insertion. /// </summary> public int RemovalLength { get { return (int)(removalLengthWithDeletionFlag & 0x7fffffff); } } /// <summary> /// Gets whether the removal should not cause any anchor deletions. /// </summary> public bool RemovalNeverCausesAnchorDeletion { get { return (removalLengthWithDeletionFlag & 0x80000000) != 0; } } /// <summary> /// Gets whether default anchor movement causes the anchor to stay in front of the caret. /// </summary> public bool DefaultAnchorMovementIsBeforeInsertion { get { return (insertionLengthWithMovementFlag & 0x80000000) != 0; } } /// <summary> /// Gets the new offset where the specified offset moves after this document change. /// </summary> public int GetNewOffset(int oldOffset, AnchorMovementType movementType) { int insertionLength = this.InsertionLength; int removalLength = this.RemovalLength; if (!(removalLength == 0 && oldOffset == offset)) { // we're getting trouble (both if statements in here would apply) // if there's no removal and we insert at the offset // -> we'd need to disambiguate by movementType, which is handled after the if // offset is before start of change: no movement if (oldOffset <= offset) return oldOffset; // offset is after end of change: movement by normal delta if (oldOffset >= offset + removalLength) return oldOffset + insertionLength - removalLength; } // we reach this point if // a) the oldOffset is inside the deleted segment // b) there was no removal and we insert at the caret position if (movementType == AnchorMovementType.AfterInsertion) return offset + insertionLength; else if (movementType == AnchorMovementType.BeforeInsertion) return offset; else return this.DefaultAnchorMovementIsBeforeInsertion ? offset : offset + insertionLength; } /// <summary> /// Creates a new OffsetChangeMapEntry instance. /// </summary> public OffsetChangeMapEntry(int offset, int removalLength, int insertionLength) { ThrowUtil.CheckNotNegative(offset, "offset"); ThrowUtil.CheckNotNegative(removalLength, "removalLength"); ThrowUtil.CheckNotNegative(insertionLength, "insertionLength"); this.offset = offset; this.removalLengthWithDeletionFlag = (uint)removalLength; this.insertionLengthWithMovementFlag = (uint)insertionLength; } /// <summary> /// Creates a new OffsetChangeMapEntry instance. /// </summary> public OffsetChangeMapEntry(int offset, int removalLength, int insertionLength, bool removalNeverCausesAnchorDeletion, bool defaultAnchorMovementIsBeforeInsertion) : this(offset, removalLength, insertionLength) { if (removalNeverCausesAnchorDeletion) this.removalLengthWithDeletionFlag |= 0x80000000; if (defaultAnchorMovementIsBeforeInsertion) this.insertionLengthWithMovementFlag |= 0x80000000; } /// <inheritdoc/> public override int GetHashCode() { unchecked { return offset + 3559 * (int)insertionLengthWithMovementFlag + 3571 * (int)removalLengthWithDeletionFlag; } } /// <inheritdoc/> public override bool Equals(object obj) { return obj is OffsetChangeMapEntry && this.Equals((OffsetChangeMapEntry)obj); } /// <inheritdoc/> public bool Equals(OffsetChangeMapEntry other) { return offset == other.offset && insertionLengthWithMovementFlag == other.insertionLengthWithMovementFlag && removalLengthWithDeletionFlag == other.removalLengthWithDeletionFlag; } /// <summary> /// Tests the two entries for equality. /// </summary> public static bool operator ==(OffsetChangeMapEntry left, OffsetChangeMapEntry right) { return left.Equals(right); } /// <summary> /// Tests the two entries for inequality. /// </summary> public static bool operator !=(OffsetChangeMapEntry left, OffsetChangeMapEntry right) { return !left.Equals(right); } } }