-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDFFSearchOptions.cs
143 lines (133 loc) · 5.26 KB
/
DFFSearchOptions.cs
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* Created by SharpDevelop.
* User: jgustafson
* Date: 3/23/2017
* Time: 5:48 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.IO;
using System.Windows.Forms;
//using System.Diagnostics; //System.Diagnostics.Debug.WriteLine etc
using System.Reflection; // provides MethodBase
using System.Diagnostics; // provides Tracing
namespace DeepFileFind
{
/// <summary>
/// Description of DFFSearchOptions.
/// </summary>
public class DFFSearchOptions
{
/// <summary>
/// MUST be UTC
/// </summary>
public DateTime modified_start_datetime_utc = DateTime.MinValue;
/// <summary>
/// MUST be UTC
/// </summary>
public DateTime modified_endbefore_datetime_utc = DateTime.MaxValue;
public bool modified_start_date_enable = false;
public bool modified_endbefore_date_enable = false;
public bool modified_start_time_enable = false;
public bool modified_endbefore_time_enable = false;
public ArrayList start_directoryinfos = null;
public ArrayList never_use_names = null;
private string _name_string = null;
public string name_string {
get {
return _name_string;
}
set {
var stackTrace = new StackTrace();
MethodBase method = stackTrace.GetFrame(1).GetMethod();
string methodName = method.Name;
string className = method.ReflectedType.Name;
if (value != null)
Debug.WriteLine("name_string=\""+value+"\" as set by "+className+"."+methodName);
else
Debug.WriteLine("name_string=null as set by "+className+"."+methodName);
_name_string = value;
}
}
public string content_string = null;
public bool recursive_enable = true;
public bool include_folders_as_results_enable = true;
public bool case_sensitive_enable = false;
public bool threading_enable = true;
public bool min_size_enable = false;
public bool max_size_enable = false;
public long min_size = 0;
public long max_size = long.MaxValue;
private System.Windows.Forms.TextBox statusTextBox = null; // private to be thread-safe. See SetStatus.
public bool follow_folder_symlinks_enable = false;
public bool search_inside_hidden_files_enable = false;
public bool follow_dot_folders_enable = true;
public bool follow_hidden_folders_enable = true;
public bool follow_system_folders_enable = false;
public bool follow_temporary_folders_enable = false;
public DFFSearchOptions()
{
start_directoryinfos = new ArrayList();
never_use_names = new ArrayList(); // ignore list (see also exclude_names; set by application while initializing each search)
//never_use_names.Add(".cache");
//never_use_names.Add("Trash");
}
public void DumpToDebug() {
Console.Error.WriteLine("Dumping options:");
foreach (string s in Dump()) {
Console.Error.WriteLine(s);
}
Console.Error.WriteLine("");
}
public ArrayList Dump() {
ArrayList results = new ArrayList();
//NOTE: these MUST match the values from MainFormLoad in order for all settings to save and load
results.Add("start_date_enable = "+(modified_start_date_enable?"true":"false"));
results.Add("start_time_enable = "+(modified_start_time_enable?"true":"false"));
results.Add("start_datetime_utc = "+modified_start_datetime_utc.ToUniversalTime().ToString(DFF.datetime_sortable_format_string));
results.Add("endbefore_date_enable = "+(modified_endbefore_date_enable?"true":"false"));
results.Add("endbefore_time_enable = "+(modified_endbefore_time_enable?"true":"false"));
results.Add("endbefore_datetime_utc = "+modified_endbefore_datetime_utc.ToUniversalTime().ToString(DFF.datetime_sortable_format_string));
results.Add("recursive_enable = "+(recursive_enable?"true":"false"));
results.Add("include_folders_as_results_enable = "+(include_folders_as_results_enable?"true":"false"));
results.Add("case_sensitive_enable = "+(case_sensitive_enable?"true":"false"));
results.Add("min_size_enable = "+(min_size_enable?"true":"false"));
results.Add("max_size_enable = "+(max_size_enable?"true":"false"));
results.Add("min_size = "+min_size.ToString());
results.Add("max_size = "+max_size.ToString());
string line = "start_directoryinfos = ";
foreach (DirectoryInfo di in start_directoryinfos) {
line += di.FullName+";";
}
results.Add(line);
results.Add("name_string = "+(name_string!=null?"\""+name_string+"\"":"null"));
results.Add("content_string = "+(content_string!=null?"\""+content_string+"\"":"null"));
return results;
}
private static void SetTextBoxText(TextBox box, string text) {
// - tried <https://www.codeproject.com/questions/1073539/control-richtextbox-accessed-from-a-thread-other-t>
if (box.InvokeRequired)
{
// System.Windows.Forms.MethodInvoker
box.Invoke((MethodInvoker)(() => box.Text = text));
}
else
{
box.Text = text;
}
}
public void SetStatus(string text) {
if (this.statusTextBox != null) {
SetTextBoxText(this.statusTextBox, text);
}
else {
Console.Error.WriteLine(text);
}
}
public void SetStatusTextBox(System.Windows.Forms.TextBox textbox) {
this.statusTextBox = textbox;
}
}
}