~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/SearchAndReplace/Project/SearchOptions.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using ICSharpCode.Core;
 
6
 
 
7
namespace SearchAndReplace
 
8
{
 
9
        public enum SearchStrategyType {
 
10
                Normal,
 
11
                RegEx,
 
12
                Wildcard
 
13
        }
 
14
        
 
15
        public static class SearchOptions
 
16
        {
 
17
                const string searchPropertyKey = "SearchAndReplaceProperties";
 
18
                
 
19
                static Properties properties;
 
20
                
 
21
                public static Properties Properties {
 
22
                        get {
 
23
                                return properties;
 
24
                        }
 
25
                }
 
26
                static string findPattern    = "";
 
27
                static string replacePattern = "";
 
28
                
 
29
                #region Search & Replace properties
 
30
                public static string FindPattern {
 
31
                        get {
 
32
                                return findPattern;
 
33
                        }
 
34
                        set {
 
35
                                if (value != FindPattern) {
 
36
                                        findPattern = value;
 
37
                                        string[] oldPatterns = FindPatterns;
 
38
                                        string[] newPatterns = new string[oldPatterns.Length + 1];
 
39
                                        oldPatterns.CopyTo(newPatterns, 1);
 
40
                                        newPatterns[0] = value;
 
41
                                        FindPatterns = newPatterns;
 
42
                                }
 
43
                        }
 
44
                }
 
45
                
 
46
                public static string CurrentFindPattern {
 
47
                        get {
 
48
                                return findPattern;
 
49
                        }
 
50
                        set {
 
51
                                findPattern = value;
 
52
                        }
 
53
                }
 
54
                
 
55
                public static string[] FindPatterns {
 
56
                        get {
 
57
                                if (!properties.Contains("FindPatterns")) {
 
58
                                        return new string[] {};
 
59
                                }
 
60
                                return properties.Get("FindPatterns", "").Split('\xFF');
 
61
                        }
 
62
                        set {
 
63
                                properties.Set("FindPatterns", String.Join("\xFF", value));
 
64
                        }
 
65
                }
 
66
                
 
67
                public static string ReplacePattern {
 
68
                        get {
 
69
                                if (!properties.Contains("ReplacePatterns")) {
 
70
                                        return "";
 
71
                                }
 
72
                                return replacePattern;
 
73
                        }
 
74
                        set {
 
75
                                if (value != ReplacePattern) {
 
76
                                        string[] oldPatterns = ReplacePatterns;
 
77
                                        string[] newPatterns = new string[oldPatterns.Length + 1];
 
78
                                        oldPatterns.CopyTo(newPatterns, 1);
 
79
                                        newPatterns[0] = value;
 
80
                                        ReplacePatterns = newPatterns;
 
81
                                        replacePattern = value;
 
82
                                }
 
83
                        }
 
84
                }
 
85
                
 
86
                public static string[] ReplacePatterns {
 
87
                        get {
 
88
                                if (!properties.Contains("ReplacePatterns")) {
 
89
                                        return new string[] {};
 
90
                                }
 
91
                                
 
92
                                return properties.Get("ReplacePatterns", "").Split('\xFF');
 
93
                        }
 
94
                        set {
 
95
                                properties.Set("ReplacePatterns", String.Join("\xFF", value));
 
96
                        }
 
97
                }
 
98
                
 
99
                public static bool MatchCase {
 
100
                        get {
 
101
                                return properties.Get("MatchCase", false);
 
102
                        }
 
103
                        set {
 
104
                                properties.Set("MatchCase", value);
 
105
                        }
 
106
                }
 
107
                
 
108
                public static bool IncludeSubdirectories {
 
109
                        get {
 
110
                                return properties.Get("IncludeSubdirectories", false);
 
111
                        }
 
112
                        set {
 
113
                                properties.Set("IncludeSubdirectories", value);
 
114
                        }
 
115
                }
 
116
        
 
117
                public static bool MatchWholeWord {
 
118
                        get {
 
119
                                return properties.Get("MatchWholeWord", false);
 
120
                        }
 
121
                        set {
 
122
                                properties.Set("MatchWholeWord", value);
 
123
                        }
 
124
                }               
 
125
                
 
126
                public static string LookIn {
 
127
                        get {
 
128
                                return properties.Get("LookIn", @"C:\");
 
129
                        }
 
130
                        set {
 
131
                                properties.Set("LookIn", value);
 
132
                        }
 
133
                }
 
134
                
 
135
                public static string LookInFiletypes {
 
136
                        get {
 
137
                                return properties.Get("LookInFiletypes", "*.*");
 
138
                        }
 
139
                        set {
 
140
                                properties.Set("LookInFiletypes", value);
 
141
                        }
 
142
                }
 
143
                
 
144
                public static DocumentIteratorType DocumentIteratorType {
 
145
                        get {
 
146
                                return properties.Get("DocumentIteratorType", DocumentIteratorType.CurrentDocument);
 
147
                        }
 
148
                        set {
 
149
                                if (!Enum.IsDefined(typeof(DocumentIteratorType), value))
 
150
                                        throw new ArgumentException("invalid enum value");
 
151
                                properties.Set("DocumentIteratorType", value);
 
152
                        }
 
153
                }
 
154
                
 
155
                public static SearchStrategyType SearchStrategyType {
 
156
                        get {
 
157
                                return properties.Get("SearchStrategyType", SearchStrategyType.Normal);
 
158
                        }
 
159
                        set {
 
160
                                properties.Set("SearchStrategyType", value);
 
161
                        }
 
162
                }
 
163
                #endregion
 
164
                
 
165
                static SearchOptions()
 
166
                {
 
167
                        properties = PropertyService.Get(searchPropertyKey, new Properties());
 
168
                }
 
169
        }
 
170
}