1
- using Rubberduck . Settings ;
1
+ using System ;
2
+ using Rubberduck . Settings ;
2
3
using Rubberduck . SmartIndenter ;
3
4
4
5
namespace Rubberduck . UI . Settings
@@ -7,22 +8,22 @@ public class IndenterSettingsViewModel : ViewModelBase, ISettingsViewModel
7
8
{
8
9
public IndenterSettingsViewModel ( Configuration config )
9
10
{
10
- AlignCommentsWithCode = config . UserSettings . IndenterSettings . AlignCommentsWithCode ;
11
- AlignContinuations = config . UserSettings . IndenterSettings . AlignContinuations ;
12
- AlignDimColumn = config . UserSettings . IndenterSettings . AlignDimColumn ;
13
- AlignDims = config . UserSettings . IndenterSettings . AlignDims ;
14
- EnableUndo = config . UserSettings . IndenterSettings . EnableUndo ;
15
- EndOfLineCommentColumnSpaceAlignment = config . UserSettings . IndenterSettings . EndOfLineCommentColumnSpaceAlignment ;
16
- EndOfLineCommentStyle = config . UserSettings . IndenterSettings . EndOfLineCommentStyle ;
17
- ForceCompilerDirectivesInColumn1 = config . UserSettings . IndenterSettings . ForceCompilerDirectivesInColumn1 ;
18
- ForceDebugStatementsInColumn1 = config . UserSettings . IndenterSettings . ForceDebugStatementsInColumn1 ;
19
- IgnoreOperatorsInContinuations = config . UserSettings . IndenterSettings . IgnoreOperatorsInContinuations ;
20
- IndentCase = config . UserSettings . IndenterSettings . IndentCase ;
21
- IndentCompilerDirectives = config . UserSettings . IndenterSettings . IndentCompilerDirectives ;
22
- IndentEntireProcedureBody = config . UserSettings . IndenterSettings . IndentEntireProcedureBody ;
23
- IndentFirstCommentBlock = config . UserSettings . IndenterSettings . IndentFirstCommentBlock ;
24
- IndentFirstDeclarationBlock = config . UserSettings . IndenterSettings . IndentFirstDeclarationBlock ;
25
- IndentSpaces = config . UserSettings . IndenterSettings . IndentSpaces ;
11
+ _alignCommentsWithCode = config . UserSettings . IndenterSettings . AlignCommentsWithCode ;
12
+ _alignContinuations = config . UserSettings . IndenterSettings . AlignContinuations ;
13
+ _alignDimColumn = config . UserSettings . IndenterSettings . AlignDimColumn ;
14
+ _alignDims = config . UserSettings . IndenterSettings . AlignDims ;
15
+ _enableUndo = config . UserSettings . IndenterSettings . EnableUndo ;
16
+ _endOfLineCommentColumnSpaceAlignment = config . UserSettings . IndenterSettings . EndOfLineCommentColumnSpaceAlignment ;
17
+ _endOfLineCommentStyle = config . UserSettings . IndenterSettings . EndOfLineCommentStyle ;
18
+ _forceCompilerDirectivesInColumn1 = config . UserSettings . IndenterSettings . ForceCompilerDirectivesInColumn1 ;
19
+ _forceDebugStatementsInColumn1 = config . UserSettings . IndenterSettings . ForceDebugStatementsInColumn1 ;
20
+ _ignoreOperatorsInContinuations = config . UserSettings . IndenterSettings . IgnoreOperatorsInContinuations ;
21
+ _indentCase = config . UserSettings . IndenterSettings . IndentCase ;
22
+ _indentCompilerDirectives = config . UserSettings . IndenterSettings . IndentCompilerDirectives ;
23
+ _indentEntireProcedureBody = config . UserSettings . IndenterSettings . IndentEntireProcedureBody ;
24
+ _indentFirstCommentBlock = config . UserSettings . IndenterSettings . IndentFirstCommentBlock ;
25
+ _indentFirstDeclarationBlock = config . UserSettings . IndenterSettings . IndentFirstDeclarationBlock ;
26
+ _indentSpaces = config . UserSettings . IndenterSettings . IndentSpaces ;
26
27
27
28
PropertyChanged += IndenterSettingsViewModel_PropertyChanged ;
28
29
}
@@ -262,14 +263,72 @@ public int IndentSpaces
262
263
}
263
264
264
265
// ReSharper disable once InconsistentNaming
265
- private const string _previewSampleCode = @"Sub Foo()
266
- ' Do something here
267
- ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ' comment here
268
- End Sub" ;
266
+ private const string _previewSampleCode =
267
+ @"' Example Procedure
268
+ Sub ExampleProc()
269
+
270
+ ' SMART INDENTER
271
+ '@ 2016 by Rubberduck VBA.
272
+
273
+ Dim iCount As Integer
274
+ Static sName As String
275
+
276
+ If YouWantMoreExamplesAndTools Then
277
+ ' Visit http://rubberduckvba.com/
278
+
279
+ Select Case X
280
+ Case ""A""
281
+ ' If you have any comments or suggestions, _
282
+ or find valid VBA code that isn't indented correctly,
283
+
284
+ #If VBA6 Then
285
+ MsgBox ""Contact contact@rubberduck-vba.com""
286
+ #End If
287
+
288
+ Case ""Continued strings and parameters can be"" _
289
+ & ""lined up for easier reading, optionally ignoring"" _
290
+ , ""any operatirs (&+, etc) at the start of the line.""
291
+
292
+ Debug.Print ""X<>1""
293
+ End Select 'Case X
294
+ End If 'More Tools?
295
+
296
+ End Sub
297
+ " ;
269
298
270
299
public string PreviewSampleCode
271
300
{
272
- get { return _previewSampleCode ; /* SmartIndenter.Indent(_indenterData); */ }
301
+ get
302
+ {
303
+ var indenter = new Indenter ( null , GetCurrentSettings ) ;
304
+
305
+ var lines = _previewSampleCode . Split ( new [ ] { Environment . NewLine } , StringSplitOptions . None ) ;
306
+ indenter . Indent ( lines , "TestModule" , false ) ;
307
+ return string . Join ( Environment . NewLine , lines ) ;
308
+ }
309
+ }
310
+
311
+ private IIndenterSettings GetCurrentSettings ( )
312
+ {
313
+ return new SmartIndenter . IndenterSettings
314
+ {
315
+ AlignCommentsWithCode = AlignCommentsWithCode ,
316
+ AlignContinuations = AlignContinuations ,
317
+ AlignDimColumn = AlignDimColumn ,
318
+ AlignDims = AlignDims ,
319
+ EnableUndo = EnableUndo ,
320
+ EndOfLineCommentColumnSpaceAlignment = EndOfLineCommentColumnSpaceAlignment ,
321
+ EndOfLineCommentStyle = EndOfLineCommentStyle ,
322
+ ForceCompilerDirectivesInColumn1 = ForceCompilerDirectivesInColumn1 ,
323
+ ForceDebugStatementsInColumn1 = ForceDebugStatementsInColumn1 ,
324
+ IgnoreOperatorsInContinuations = IgnoreOperatorsInContinuations ,
325
+ IndentCase = IndentCase ,
326
+ IndentCompilerDirectives = IndentCompilerDirectives ,
327
+ IndentEntireProcedureBody = IndentEntireProcedureBody ,
328
+ IndentFirstCommentBlock = IndentFirstCommentBlock ,
329
+ IndentFirstDeclarationBlock = IndentFirstDeclarationBlock ,
330
+ IndentSpaces = IndentSpaces
331
+ } ;
273
332
}
274
333
275
334
#endregion
0 commit comments