forked from sergiisyrovatchenko/SQLIndexManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsBox.cs
More file actions
150 lines (125 loc) · 5.54 KB
/
Copy pathSettingsBox.cs
File metadata and controls
150 lines (125 loc) · 5.54 KB
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
144
145
146
147
148
149
150
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace SQLIndexManager {
public partial class SettingsBox : XtraForm {
public SettingsBox() {
InitializeComponent();
UpdateControls(Settings.Options);
}
private void UpdateControls(Options o) {
boxThreshold.Value = new TrackBarRange(o.ReorganizeThreshold, o.RebuildThreshold);
boxMinIndexSize.Value = new TrackBarRange(o.MinIndexSize, o.PreDescribeSize);
boxMaxIndexSize.Value = o.MaxIndexSize;
boxOnline.Checked = o.Online;
boxSortInTempDb.Checked = o.SortInTempDb;
boxLobCompaction.Checked = o.LobCompaction;
boxMaxDod.Value = o.MaxDop;
boxStatsSamplePercent.Value = o.SampleStatsPercent;
boxConnectionTimeout.Value = o.ConnectionTimeout;
boxCommandTimeout.Value = o.CommandTimeout;
boxWaitAtLowPriority.Checked = o.WaitAtLowPriority;
boxMaxDuration.EditValue = o.MaxDuration;
boxAbortAfterWait.EditValue = o.AbortAfterWait;
boxDataCompression.EditValue = o.DataCompression;
boxFillFactor.EditValue = o.FillFactor;
boxScanHeap.Checked = o.ScanHeap;
boxScanClusteredIndex.Checked = o.ScanClusteredIndex;
boxScanNonClusteredIndex.Checked = o.ScanNonClusteredIndex;
boxScanClusteredColumnstore.Checked = o.ScanClusteredColumnstore;
boxScanNonClusteredColumnstore.Checked = o.ScanNonClusteredColumnstore;
boxScanMissingIndex.Checked = o.ScanMissingIndex;
boxScanStatistics.Checked = o.ScanStatistics;
boxIncludeSchemas.EditValue = string.Join(";", o.IncludeSchemas);
boxExcludeSchemas.EditValue = string.Join(";", o.ExcludeSchemas);
boxExcludeObject.EditValue = string.Join(";", o.ExcludeObject);
boxIgnorePermissions.Checked = o.IgnorePermissions;
boxIgnoreReadOnlyFL.Checked = o.IgnoreReadOnlyFL;
}
public Options GetSettings() {
return new Options {
ReorganizeThreshold = boxThreshold.Value.Minimum,
RebuildThreshold = boxThreshold.Value.Maximum,
MinIndexSize = boxMinIndexSize.Value.Minimum,
PreDescribeSize = boxMinIndexSize.Value.Maximum,
MaxIndexSize = boxMaxIndexSize.Value,
MaxDop = (int)boxMaxDod.Value,
Online = boxOnline.Checked,
SortInTempDb = boxSortInTempDb.Checked,
LobCompaction = boxLobCompaction.Checked,
SampleStatsPercent = (int)boxStatsSamplePercent.Value,
ConnectionTimeout = (int)boxConnectionTimeout.Value,
CommandTimeout = (int)boxCommandTimeout.Value,
WaitAtLowPriority = boxWaitAtLowPriority.Checked,
MaxDuration = (int)boxMaxDuration.Value,
AbortAfterWait = (string)boxAbortAfterWait.EditValue,
DataCompression = (string)boxDataCompression.EditValue,
FillFactor = (int)boxFillFactor.Value,
ScanHeap = boxScanHeap.Checked,
ScanClusteredIndex = boxScanClusteredIndex.Checked,
ScanNonClusteredIndex = boxScanNonClusteredIndex.Checked,
ScanClusteredColumnstore = boxScanClusteredColumnstore.Checked,
ScanNonClusteredColumnstore = boxScanNonClusteredColumnstore.Checked,
ScanMissingIndex = boxScanMissingIndex.Checked,
ScanStatistics = boxScanStatistics.Checked,
IncludeSchemas = new List<string> (boxIncludeSchemas.EditValue.ToString().Split(';')),
ExcludeSchemas = new List<string> (boxExcludeSchemas.EditValue.ToString().Split(';')),
ExcludeObject = new List<string> (boxExcludeObject.EditValue.ToString().Split(';')),
IgnorePermissions = boxIgnorePermissions.Checked,
IgnoreReadOnlyFL = boxIgnoreReadOnlyFL.Checked
};
}
#region Controls
private void ButtonRestoreClick(object sender, EventArgs e) {
UpdateControls(new Options());
}
private void IndexSizeValueChanged(object sender, EventArgs e) {
labelSize.Text = $@"Filter Size [ {boxMinIndexSize.Value.Minimum.FormatMbSize()} ... {boxMinIndexSize.Value.Maximum.FormatMbSize()} ... {boxMaxIndexSize.Value.FormatMbSize()} ]";
}
private void ThresholdValueChanged(object sender, EventArgs e) {
labelReorganize.Text = $@">= {boxThreshold.Value.Minimum}% AND < {boxThreshold.Value.Maximum }%";
labelRebuild.Text = $@">= {boxThreshold.Value.Maximum}%";
}
private void TrackBarEditValueChanged(object sender, EventArgs e) {
var obj = (RangeTrackBarControl)sender;
TrackBarRange val = obj.Value;
if (val.Minimum == val.Maximum) {
if (val.Minimum > 0)
val.Minimum -= 1;
else
val.Maximum += 1;
}
obj.Value = val;
}
private void IndexTypeCheckedChanged(object sender, EventArgs e) {
buttonOK.Enabled = (
boxScanHeap.Checked
|| boxScanClusteredIndex.Checked
|| boxScanNonClusteredIndex.Checked
|| boxScanClusteredColumnstore.Checked
|| boxScanNonClusteredColumnstore.Checked
|| boxScanMissingIndex.Checked
|| boxScanStatistics.Checked
);
}
private void TokenValidate(object sender, TokenEditValidateTokenEventArgs e) {
e.IsValid = true;
}
#endregion
#region Override Methods
protected override bool ProcessDialogKey(Keys keyData) {
if (keyData == Keys.Escape) {
DialogResult = DialogResult.Cancel;
return true;
}
if (keyData == Keys.Enter && buttonOK.Enabled) {
DialogResult = DialogResult.OK;
return true;
}
return base.ProcessDialogKey(keyData);
}
#endregion
}
}