8
8
// about your modifications. Your contributions are valued!
9
9
//
10
10
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND.
11
- using System ;
12
- using System . IO ;
13
11
using System . Threading . Tasks ;
14
12
using CodeIngestLib ;
15
13
using CSharp . Core . Extensions ;
@@ -22,69 +20,103 @@ namespace CodeIngest.Desktop;
22
20
public class MainViewModel : ViewModelBase
23
21
{
24
22
private readonly IDialogService m_dialogService ;
25
- private FolderTreeRoot m_root = new FolderTreeRoot ( new DirectoryInfo ( Environment . CurrentDirectory ) ) ;
23
+ private FolderTreeRoot m_root = new FolderTreeRoot ( Settings . Instance . RootFolder ) ;
26
24
27
- private bool m_isCSharp = true ;
28
- private bool m_isCppNoHeaders ;
29
- private bool m_isCppWithHeaders ;
30
- private bool m_includeMarkdown ;
31
- private bool m_excludeImports = true ;
32
- private bool m_useFullPaths ;
33
- private bool m_excludeComments = true ;
25
+ private bool m_isCSharp = Settings . Instance . IsCSharp ;
26
+ private bool m_isCppNoHeaders = Settings . Instance . IsCppNoHeaders ;
27
+ private bool m_isCppWithHeaders = Settings . Instance . IsCppWithHeaders ;
28
+ private bool m_includeMarkdown = Settings . Instance . IncludeMarkdown ;
29
+ private bool m_excludeImports = Settings . Instance . ExcludeImports ;
30
+ private bool m_useFullPaths = Settings . Instance . UseFullPaths ;
31
+ private bool m_excludeComments = Settings . Instance . ExcludeComments ;
34
32
35
33
public FolderTreeRoot Root
36
34
{
37
35
get => m_root ;
38
- set => SetField ( ref m_root , value ) ;
36
+ set
37
+ {
38
+ if ( SetField ( ref m_root , value ) )
39
+ Settings . Instance . RootFolder = value . Root . Clone ( ) ;
40
+ }
39
41
}
40
42
41
43
public bool IsCSharp
42
44
{
43
45
get => m_isCSharp ;
44
- set => SetField ( ref m_isCSharp , value ) ;
46
+ set
47
+ {
48
+ if ( SetField ( ref m_isCSharp , value ) )
49
+ Settings . Instance . IsCSharp = value ;
50
+ }
45
51
}
46
52
47
53
public bool IsCppNoHeaders
48
54
{
49
55
get => m_isCppNoHeaders ;
50
- set => SetField ( ref m_isCppNoHeaders , value ) ;
56
+ set
57
+ {
58
+ if ( SetField ( ref m_isCppNoHeaders , value ) )
59
+ Settings . Instance . IsCppNoHeaders = value ;
60
+ }
51
61
}
52
62
53
63
public bool IsCppWithHeaders
54
64
{
55
65
get => m_isCppWithHeaders ;
56
- set => SetField ( ref m_isCppWithHeaders , value ) ;
66
+ set
67
+ {
68
+ if ( SetField ( ref m_isCppWithHeaders , value ) )
69
+ Settings . Instance . IsCppWithHeaders = value ;
70
+ }
57
71
}
58
72
59
73
public bool ExcludeImports
60
74
{
61
75
get => m_excludeImports ;
62
- set => SetField ( ref m_excludeImports , value ) ;
76
+ set
77
+ {
78
+ if ( SetField ( ref m_excludeImports , value ) )
79
+ Settings . Instance . ExcludeImports = value ;
80
+ }
63
81
}
64
82
65
83
public bool ExcludeComments
66
84
{
67
85
get => m_excludeComments ;
68
- set => SetField ( ref m_excludeComments , value ) ;
86
+ set
87
+ {
88
+ if ( SetField ( ref m_excludeComments , value ) )
89
+ Settings . Instance . ExcludeComments = value ;
90
+ }
69
91
}
70
92
71
93
public bool IncludeMarkdown
72
94
{
73
95
get => m_includeMarkdown ;
74
- set => SetField ( ref m_includeMarkdown , value ) ;
96
+ set
97
+ {
98
+ if ( SetField ( ref m_includeMarkdown , value ) )
99
+ Settings . Instance . IncludeMarkdown = value ;
100
+ }
75
101
}
76
102
77
103
public bool UseFullPaths
78
104
{
79
105
get => m_useFullPaths ;
80
- set => SetField ( ref m_useFullPaths , value ) ;
106
+ set
107
+ {
108
+ if ( SetField ( ref m_useFullPaths , value ) )
109
+ Settings . Instance . UseFullPaths = value ;
110
+ }
81
111
}
82
112
83
113
public async Task SelectRoot ( )
84
114
{
85
115
var rootFolder = await m_dialogService . SelectFolderAsync ( "Select a folder to scan for code." ) ;
86
- if ( rootFolder != null )
87
- Root = new FolderTreeRoot ( rootFolder ) ;
116
+ if ( rootFolder == null )
117
+ return ;
118
+
119
+ Root = new FolderTreeRoot ( rootFolder ) ;
88
120
}
89
121
90
122
public MainViewModel ( IDialogService dialogService = null )
@@ -142,6 +174,6 @@ public async Task RunIngest()
142
174
return ;
143
175
}
144
176
145
- m_dialogService . ShowMessage ( "Code file generated successfully." , $@ "{ result . Value . FileCount : N0} files produced { result . Value . OutputBytes . ToSize ( ) } of output.") ;
177
+ m_dialogService . ShowMessage ( "Code file generated successfully." , $ "{ result . Value . FileCount : N0} files produced { result . Value . OutputBytes . ToSize ( ) } of output.") ;
146
178
}
147
179
}
0 commit comments