aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Search/ISearchStrategy.cs
blob: dd4942f33b0d07de2fd3f52a4881266f7643afe0 (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
// 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.Collections.Generic;
using System.Runtime.Serialization;

using Tango.Scripting.Editors.Document;

namespace Tango.Scripting.Editors.Search
{
	/// <summary>
	/// Basic interface for search algorithms.
	/// </summary>
	public interface ISearchStrategy : IEquatable<ISearchStrategy>
	{
		/// <summary>
		/// Finds all matches in the given ITextSource and the given range.
		/// </summary>
		/// <remarks>
		/// This method must be implemented thread-safe.
		/// All segments in the result must be within the given range, and they must be returned in order
		/// (e.g. if two results are returned, EndOffset of first result must be less than or equal StartOffset of second result).
		/// </remarks>
		IEnumerable<ISearchResult> FindAll(ITextSource document, int offset, int length);
		
		/// <summary>
		/// Finds the next match in the given ITextSource and the given range.
		/// </summary>
		/// <remarks>This method must be implemented thread-safe.</remarks>
		ISearchResult FindNext(ITextSource document, int offset, int length);
	}
	
	/// <summary>
	/// Represents a search result.
	/// </summary>
	public interface ISearchResult : ISegment
	{
		/// <summary>
		/// Replaces parts of the replacement string with parts from the match. (e.g. $1)
		/// </summary>
		string ReplaceWith(string replacement);
	}
	
	/// <summary>
	/// Defines supported search modes.
	/// </summary>
	public enum SearchMode
	{
		/// <summary>
		/// Standard search
		/// </summary>
		Normal,
		/// <summary>
		/// RegEx search
		/// </summary>
		RegEx,
		/// <summary>
		/// Wildcard search
		/// </summary>
		Wildcard
	}
	
	/// <inheritdoc/>
	public class SearchPatternException : Exception, ISerializable
	{
		/// <inheritdoc/>
		public SearchPatternException()
		{
		}
		
		/// <inheritdoc/>
		public SearchPatternException(string message) : base(message)
		{
		}
		
		/// <inheritdoc/>
		public SearchPatternException(string message, Exception innerException) : base(message, innerException)
		{
		}

		// This constructor is needed for serialization.
		/// <inheritdoc/>
		protected SearchPatternException(SerializationInfo info, StreamingContext context) : base(info, context)
		{
		}
	}
}
r> </Style.Triggers> </Style> </Grid.Style> </Grid> <Grid x:Name="grid" HorizontalAlignment="Right" MinWidth="300" RenderTransformOrigin="1,0" VerticalAlignment="Top" Margin="0 100 0 0"> <Grid.Style> <Style TargetType="Grid"> <Setter Property="RenderTransform"> <Setter.Value> <ScaleTransform ScaleY="1" ScaleX="0"></ScaleTransform> </Setter.Value> </Setter> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=IsEditViewOpen}" Value="False"> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="0" Duration="00:00:0.3"></DoubleAnimation> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> <DataTrigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:0.3"></DoubleAnimation> </Storyboard> </BeginStoryboard> </DataTrigger.ExitActions> </DataTrigger> </Style.Triggers> </Style> </Grid.Style> <Border Padding="10" CornerRadius="10 0 0 10" Background="White"> <Border.Effect> <DropShadowEffect/> </Border.Effect> <DockPanel LastChildFill="True"> <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" VerticalAlignment="Top"> <materialDesign:PackIcon x:Name="icon" VerticalAlignment="Center" Width="32" Height="32" Foreground="{StaticResource AccentColorBrush}" /> <TextBlock x:Name="txtTitle" Margin="10 0 0 0" Foreground="{StaticResource AccentColorBrush}" FontSize="16"></TextBlock> </StackPanel> <StackPanel DockPanel.Dock="Bottom"> <ItemsControl ItemsSource="{Binding ValidationErrors}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <materialDesign:PackIcon VerticalAlignment="Center" Kind="Exclamation" Foreground="Red" Width="16" Height="16"></materialDesign:PackIcon> <TextBlock VerticalAlignment="Center" Margin="5 0 0 0" Foreground="Red" Text="{Binding}"></TextBlock> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right"> <Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="{Binding DialogOKCommand}"> ACCEPT </Button> <Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{Binding DialogCancelCommand}"> CANCEL </Button> </StackPanel> </StackPanel> <ScrollViewer Margin="0 10 0 0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Padding="5"> <ContentPresenter x:Name="presenter"></ContentPresenter> </ScrollViewer> </DockPanel> </Border> <Thumb HorizontalAlignment="Left" Opacity="0" Width="5" VerticalAlignment="Stretch" Cursor="SizeWE" DragDelta="Thumb_DragDelta"></Thumb> </Grid> <Grid Background="#C9000000" Visibility="{Binding NotLoaded,Converter={StaticResource BoolToVisConverter}}"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 20 0 0"> <TextBlock TextAlignment="Center" FontSize="16" Foreground="Gainsboro"> <Run>The Database module is considered obsolete and will be removed in the future.</Run> <LineBreak/> <Run>Loading the module will require some time and memory.</Run> </TextBlock> <Button Height="50" Width="200" Margin="0 40 0 0" Command="{Binding LoadCommand}">LOAD</Button> <mahapps:ProgressRing Margin="0 20 0 0" IsActive="{Binding IsLoading}" /> </StackPanel> </Grid> </Grid> </UserControl>